All Examples  

package examples.t3client

Class Index

about this package

This package demonstrates some of the fundamental interfaces that you use to write applications on the WebLogic Server. Some of these examples demonstrate how to write server-side functionality, and some demonstrate how to write client-side functionality.

how to use this package

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.

Server-side Java examples:

See examples.t3client.StartupTest

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 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%
Add the following lines to your file:
  weblogic.system.startupArgs.StartupTest=logString=SERVER STARTED
Make 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 STARTED
in the WebLogic log file or in the output to the command shell where you started the server.

See examples.t3client.ShutdownTest

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%
Add the following lines to your file:
In 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.

See examples.t3client.StartupQuery

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%
then register the StartupQuery class in the file with:
    query=select * from emp,\

These properties are already provided for you, but you'll need to uncommented them. Now compile the client class with:
 $ javac -d %CLIENT_CLASSES%
Start 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 doquery
The 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.

Client-side Java examples:

See examples.t3client.SimpleT3Client

Shows the most basic task of a T3Client, making a connection to a WebLogic Server. Compile the client using:

 $  javac -d %CLIENT_CLASSES%
To run this example, supply a URL as the first argument of the form
where scheme is one of:
Standard WebLogic t3 protocol
WebLogic t3 protocol using Secure Sockets Layer(SSL)
HTTP tunneling
HTTP tunneling using SSL

Here's an example:

 $  java examples.t3client.SimpleT3Client t3s://localhost:7002
Don't forget that by default, weblogic is set up to listen for secure connections on port 7002, and regular traffic on port 7001.

See examples.t3clientFacilitiesTest

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%
Start (or restart) a WebLogic Server in another shell, and run the client in your development shell using:
 $  java examples.t3client.FacilitiesTest
The 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.

See examples.t3client.TimeoutClient

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%
Start a WebLogic Server, and run the example from the command line with:
 $  java examples.t3client.TimeoutClient WebLogicURL
where 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.

there's more . . .

The T3Client spans many of the WebLogic APIs. You can start with the Developers Guide, Writing a T3Client application, which introduces the T3Client and discusses many of the features that are common to all T3Client applications, no matter the service API. Then check out the Developer Guides for EJB, JDBC, HTTP Servlets, etc., for more service-related details.