All Examples
For each example, open a command shell, and run the setEnv script provided in the root directory of the WebLogic installation to set up your development environment.
This example demonstrates how to have the WebLogic Server invoke your custom classes when the server is started.
The class must implement the T3StartupDef interface, and be registered in the weblogic.properties file as a startup class. When the WebLogic Server is started, it invokes the setServices() method, and the startup() method on the startup class. Your startup class must implement both methods, and perform it's work in the startup() method. Your class should store a reference to the T3ServicesDef object when the setServices() method is invoked. The T3ServicesDef object may be used later by your startup class to access WebLogic services and facilities.
To compile the example, execute the following command in your development command shell:
$ javac -d %SERVER_CLASSES% StartupTest.javaAdd the following lines to your weblogic.properties file:
weblogic.system.startupClass.StartupTest=\ examples.t3client.StartupTest weblogic.system.startupArgs.StartupTest=logString=SERVER STARTEDMake sure that the SERVER_CLASSES directory is in the WebLogic Server's classpath, then start (or restart) the server. You should see the output:
StartupTest called with argument of SERVER STARTEDin the WebLogic log file or in the output to the command shell where you started the server.
Demonstrates how to have the WebLogic Server invoke your custom classes when the server is shut down.
Compile this class similarly to the StartupTest example using:
$ javac -d %SERVER_CLASSES% ShutdownTest.javaAdd the following lines to your weblogic.properties file:
weblogic.system.shutdownClass.ShutdownTest=examples.t3client.ShutdownTest weblogic.system.shutdownArgs.ShutdownTest=outfile=/temp/shutdownTest.logIn another command shell, start (or restart) the WebLogic Server.
You'll need to shut down the server 'gracefully' for the shutdown class to be invoked. One way is to start the WebLogic Console, connect to the server, and shut down the server from there. To start the WebLogic Console, see the Administrators Guide Running the WebLogic Console.
Creates a database ResultSet at startup and stores it in the system Workspace for later access by a client. This example uses the 'EMP' table in the database connection pool 'demoPool', in the demo Cloudscape database. To compile the example, first compile the T3Servlet and startup class (which are combined into one class) with:
$ javac -d %SERVER_CLASSES% StartupQuery.javathen register the StartupQuery class in the weblogic.properties file with:
weblogic.system.startupClass.doquery=examples.t3client.StartupQuery weblogic.system.startupArgs.doquery=\ query=select * from emp,\ db=jdbc:weblogic:pool:demoPoolThese properties are already provided for you, but you'll need to uncommented them. Now compile the client class with:
$ javac -d %CLIENT_CLASSES% StartupQueryClient.javaStart the WebLogic Server. The StartupQuery class will connect to the database, retrieve the details, and store them in a parameter set in a WebLogic workspace.
Run the client class with:
$ java examples.t3client.StartupQueryClient t3://localhost:7001 doqueryThe client first connects to the same StartupQuery class, this time as a T3Servlet, and invokes the execute() method. This method seeds the given ParamSet with the details from the workspace. The returned ParamSet is printed to the command shell.
Next, the client retrieves the same data, only this time by directly looking up the data in the workspace, and again prints it out to the command shell.
Shows the most basic task of a T3Client, making a connection to a WebLogic Server. Compile the client using:
$ javac -d %CLIENT_CLASSES% SimpleT3Client.javaTo run this example, supply a URL as the first argument of the form
scheme://WebLogicHost:Portwhere scheme is one of:
Here's an example:
$ java examples.t3client.SimpleT3Client t3s://localhost:7002Don't forget that by default, weblogic is set up to listen for secure connections on port 7002, and regular traffic on port 7001.
This example shows how to use three of WebLogic's facilities -- configuration, administration, and logging -- to get and store information about a T3Client's environment.
Compile this class in a development shell using:
$ javac -d %CLIENT_CLASSES% FacilitiesTest.javaStart (or restart) a WebLogic Server in another shell, and run the client in your development shell using:
$ java examples.t3client.FacilitiesTestThe client uses the default URL t3://localhost:7001 to connect to the WebLogic Server, unless you supply a command line argument to explicitly specify another URL.
This example shows how a client can be notified when it has been disconnected from the WebLogic Server.
To write a client that listens to disconnect events:
To compile this example, open a new command shell and set up your environment for developing by running the setEnv script in the WebLogic installation root directory. Change to this directory, and compile the TimeoutClass with:
$ javac -d %CLIENT_CLASSES% TimeoutClient.javaStart a WebLogic Server, and run the example from the command line with:
$ java examples.t3client.TimeoutClient WebLogicURLwhere WebLogicURL would be t3://localhost:7001 if you're running the server on the same machine as the client. The client will connect to the server, set the idle timeout to 1 minute, then sleep for up to 3 minutes. It will wake if the disconnectTimeout() method is called before the 3 minutes are up. It will then print out whether it received the disconnect callback or not.