bea.com | products | dev2dev | support | askBEA

Download Docs
Search

Programming Guide

RMI Access to the WebLogic JAM Gateway

A Remote Method Interface (RMI) configuration subsystem allows you to monitor and control the WebLogic JAM Gateway by a remote Java application. WebLogic JAM provides such administrative capabilities through the com.bea.jam.Admin utility. Using the features in the RMI subsystem, referred to as the JAM Deployed Configuration feature, you can develop your own custom administrative capabilities.

This section discusses the following topics:

- JAM Deployed Configuration Feature

- Sample JAM Administration Utility

JAM Deployed Configuration Feature

The JAM Deployed Configuration feature is comprised of several of RMI-based interfaces which are advertised in the JNDI tree of a WebLogic Server hosting the WebLogic JAM Gateway. These objects are constructed, at server boot time, based on the WebLogic JAM configuration information specified in the Administration Server of the WebLogic JAM domain. Information about the CRM, Links, and Services is maintained in the jamconfig.xml file. Update this file using the WebLogic Administration Console.

Note: For information about updating the jamconfig.xml file, refer to the BEA WebLogic JAM Configuration and Administration Guide.

The following objects are provided for remote gateway access:

- GatewayBootstrap

Primary access point to the Gateway(s) configured for a given WebLogic Server. This object allows access to Gateways without requiring knowledge of the Gateway name.

- DeployedGateway

This object provides access to all the remote functionality of the WebLogic JAM Gateway. It permits statistics to be gathered, starting/stopping the gateway, and returns information about deployed CRMs, Links, and services. If the Gateway name is known this object may be obtained directly from JNDI.

The following objects are obtained via the DeployedGateway object and provide additional information about the configuration and status of WebLogic JAM:

Object | Description
--- | ---
DeployedCRM | Provides a read-only copy of the CRM configuration being used by the Gateway.
DeployedLink | Provides read-only access to information about a CRM link.
DeployedService DeployedSession (object obtained using a DeployedService Object) | DeployedService contains information about a WebLogic JAM service. DeployedSession is a remote implementation of a WebLogic JAM session, which may be used to invoke the associated mainframe service. Note: While this capability may be useful to customers at times, it is strongly recommended that the EgenClient class be used for service invocation.
ActivityCounts | Provides count information for the respective Gateway/service. These counts reflect, for example, the number of requests processed by the Gateway, average response time, and number of failures.

These remote objects are arranged in a hierarchy within the WebLogic Server node as follows:

GatewayBootstrap Object

The GatewayBootstrap object is bound into the JNDI tree of each WebLogic Server hosting a WebLogic JAM Gateway. There is a single GatewayBootstrap object per WebLogic Server ("pinned" object) and its JNDI name, com.bea.jam.bootstrap, is the same on all server instances. This JNDI name is available via the named constant GatewayBootstrap.JNDI_NAME to eliminate literal hardcoding.

The following code listing demonstrates obtaining the GatewayBootstrap object from a WebLogic Server accessible via the URL t3://dynamo1:7001:

Listing D-1 Obtaining the GatewayBootstrap Object

>     Properties prop = new Properties();
>     prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>     	     weblogic.jndi.WLInitialContextFactory.class.getName());
>     prop.setProperty(Context.PROVIDER_URL, "t3://dynamo1:7001");
>     prop.setProperty(Context.SECURITY_PRINCIPAL, "UserId");
>     prop.setProperty(Context.SECURITY_CREDENTIALS, "Password");

>     Context ctx = new InitialContext(prop);
>     GatewayBootstrap gwBoot;
>     gwBoot = (GatewayBootstrap) ctx.lookup(GatewayBootstrap.JNDI_NAME);

This example obtains a JNDI Initial Context to the server in question and then looks up the GatewayBootstrap object using the predefined constant object name.

Following are the methods offered by the GatewayBootstrap object:

com.bea.jam.cluster.GatewayBootstrap

Implements java.rmi.Remote

JAM Gateway bootstrap class is used to allow the creation and/or retrieval of Gateways on WebLogic Server nodes. This object is a singleton per WebLogic Server node and is registered in the JNDI tree as a local (i.e. REPLICATE_BINDINGS=false) object. It is created by the WebLogic JAM server startup task and remains available for the life of the server.

Methods

The following methods are available with the com.bea.jam.cluster.GatewayBootstrap object to retrieve Gateway information:

Method | Description
--- | ---
com.bea.jam.cluster.DeployedGateway getGateway(String gatewayName) | Returns a WebLogic JAM gateway existing on the local WebLogic Server node. Returns: a DeployedGateway remote object. If the gateway does not exist on the local node a null is returned. Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.DeployedGateway[] getGateways() | Returns an array of the WebLogic JAM Gateways existing on the local WebLogic Server node. Returns: an array of DeployedGateway remote objects. If no gateways exist on the local node an empty array is returned. Throws: RemoteException if a communication error is encountered.

Fields

  public static final JNDI_NAME

DeployedGateway Object

The DeployedGateway object is bound into the WebLogic JNDI tree using a name that is constructed of a literal prefix, DeployedGateway.JNDI_PREFIX, and suffixed by the name of the WebLogic JAM Gateway represented by the object. For example, the JNDI name of a WebLogic JAM Gateway named MyJAM would be:

>     DeployedGateway.JNDI_PREFIX+"MyJAM".

The DeployedGateway object for a WebLogic JAM Gateway may be obtained either from a GatewayBootstrap object or directly via a JNDI lookup.

The following code listing demonstrate three different ways of obtaining a DeployedGateway object named JAM1 from WebLogic Server t3://dynamo1:7001.

- Obtain the DeployedGateway using the GatewayBootstrap object retrieved by the sample code:

>     DeployedGateway gw = gwBoot.getGateway("JAM1");

- Obtain the DeployedGateway using the GatewayBootstrap object retrieved by the previous sample code. This example assumes JAM1 is the only gateway available and retrieves the remote object anonymously:

>     DeployedGateway gw = gwBoot.getGateways()[0];

- Obtain the DeployedGateway directly from the JNDI tree:

>     Properties prop = new Properties();
>     prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>          weblogic.jndi.WLInitialContextFactory.class.getName());
>     prop.setProperty(Context.PROVIDER_URL, "t3://dynamo1:7001");
>     prop.setProperty(Context.SECURITY_PRINCIPAL, "UserId");
>     prop.setProperty(Context.SECURITY_CREDENTIALS, "Password");

>     Context ctx = new InitialContext(prop);
>     DeployedGateway gw = (DeployedGateway) ctx.lookup(
>                           DeployedGateway.JNDI_PREFIX + "JAM1");

Following are the methods offered by the DeployedGateway object:

com.bea.jam.cluster.DeployedGateway

Implements java.rmi.Remote

This is the remote interface for the deployed gateway object. One DeployedGateway object exists for each configured WebLogic JAM Gateway. The DeployedGateway is placed in the JNDI tree under the name com.bea.jam.gateway. GatewayName where GatewayName is the configured name of the Gateway.

Methods

The following methods are available with the com.bea.jam.cluster.DeployedGateway object to retrieve Gateway information:

Method | Description
--- | ---
boolean isEnabled() | Returns a value indicating if this WebLogic JAM Gateway is deployed and running. Throws: RemoteException if a communication error is encountered.
boolean isStarting() | Returns a value indicating if this WebLogic JAM Gateway is starting up. Throws: RemoteException if a communication error is encountered.
boolean isStopped() | Returns a value indicating if this WebLogic JAM Gateway is stopped. Throws: RemoteException if a communication error is encountered.
boolean isDeployed() | Returns a value indicating if this WebLogic JAM Gateway is deployed.
java.lang.String getName() | Retrieves the name of this Gateway. Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.DeployedCRM getCRM() | Retrieves information on the CRM used by this Gateway. Throws: RemoteException if a communication error is encountered.
void setStopWlsOnExit( boolean wlsStopOnExit) | Returns a boolean value indicating whether to terminate WebLogic Server if the WebLogic JAM Gateway shuts down. If set to true, WebLogic Server will terminate when the Gateway shuts down.
com.bea.jam.cluster.DeployedLink getLink(String linkName) | Retrieves a DeployedLink object representing the requested link on this Gateway. Parameter: linkName - The name of the link to retrieve. Throws: DeployedException if the linkName is invalid or does not exist on this Gateway. RemoteException if a communication error is encountered.
com.bea.jam.cluster.DeployedLink[] getLinks() | Retrieves an array of DeployedLink objects representing all the links defined on the CRM used by this Gateway. Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.DeployedService getService( String serviceName) | Retrieves a DeployedService stub for the named service object. Parameter: serviceName - The name of the service to retrieve. Throws: DeployedException if the serviceName is invalid or does not exist on this Gateway. RemoteException if a communication error is encountered.
void deploy( boolean deployed) | Marks this Gateway as being deployed or undeployed. If an enabled Gateway is undeployed it will be shut down. Parameter: deployed - true if the Gateway is deployed and false otherwise. Throws: RemoteException if a communication error is encountered.
void enableLink(String linkName) | Enables all services being offered by link linkName. Throws: DeployedException if the named link is unknown. RemoteException if a communication error is encountered.
void disableLink(String linkName) | Disables all services being offered by link linkName. Parameter: linkName - The name of the link to be undeployed. Throws: DeployedException if the named link is unknown. RemoteException if a communication error is encountered.
com.bea.jam.cluster.ActivityCounts getServiceActivity(String serviceName) | Gets the activity counts for this service. Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.ActivityCounts getLocalServiceActivity(String serviceName) | Gets the activity counts for this local service. Throws: RemoteException if a communication error is encountered.
void startup() | Starts this WebLogic JAM Gateway. If the Gateway is already running, this method simply returns. Throws: RemoteException if a communication error is encountered.
void shutdown() | Stops this WebLogic JAM Gateway. If the Gateway is already stopped, this method simply returns Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.ActivityCounts[] getGatewayActivity() | Gets the activity counts for all services offered by this Gateway. Throws: RemoteException if a communication error is encountered.

Fields

public static final JNDI_PREFIX

JNDI prefix used by all DeployedGateway objects.

DeployedCRM Object

The DeployedCRM object is obtained via the DeployedGateway.getCRM() method. This object is a read-only wrapper providing the information used to configure the CRM being used by this WebLogic JAM Gateway.

com.bea.jam.cluster.DeployedCRM

Implements java.io.Serializable

Methods

The following methods are available with the com.bea.jam.cluster.DeployedCRM object.

Method | Description
--- | ---
boolean isEnabled() | Determines if this CRM is enabled.
java.lang.String getName() | Retrieves the name of this CRM.
java.lang.String getListenAddress() | Retrieves the host NIC address where this CRM listens for connections.
int getListenPort() | Retrieves the host port where this CRM listens for connections.
java.lang.String getLU() | Retrieves the APPC Logical Unit used for this CRM.
java.lang.String getStackType() | Retrieves the type of stack used by this CRM for CICS/IMS communication.

DeployedLink Object

The DeployedLink object is obtained via the DeployedGateway.getLink() or DeployedGateway.getLinks() methods. It is a read-only wrapper providing information about a particular CRM mainframe link. Following are the methods offered by this object:

com.bea.jam.cluster.DeployedLink

Implements java.io.Serializable

This is the interface for the deployed link object. DeployedLink objects are created by their parent Gateways and are used to the services offered on each Gateway link.

Methods

The following methods are available with the com.bea.jam.cluster.DeployedLink object.

Method | Description
--- | ---
boolean isEnabled() | Determines if this link is enabled on any gateway on the local WLS node.
java.lang.String getName() | Retrieve the name of this link.

DeployedService Object

The DeployedService object represents a WebLogic JAM outbound service currently being offered by a CRM mainframe region link. The DeployedService object may be obtained via the DeployedGateway.getService() method. It may also be obtained directly via a JNDI lookup using a literal prefix and the name of the service as a key. The following code listing demonstrates obtaining the DeployedService object for an outbound service named NewEmployee.

>     Properties prop = new Properties();
>     prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>         weblogic.jndi.WLInitialContextFactory.class.getName());
>     prop.setProperty(Context.PROVIDER_URL, "t3://dynamo1:7001");
>     prop.setProperty(Context.SECURITY_PRINCIPAL, "UserId");
>     prop.setProperty(Context.SECURITY_CREDENTIALS, "Password");

>     Context ctx = new InitialContext(prop);
>     DeployedService svc = (DeployedService) ctx.lookup(
>                     DeployedService.JNDI_PREFIX + "NewEmployee");

Following are the methods offered by the DeployedService object:

com.bea.jam.cluster.DeployedService

Implements java.rmi.Remote

This is the remote interface for the deployed service object. There is one service object defined on each WebLogic Server node for each unique service name. The service object is responsible for the following:

- maintaining information on the local Gateways and links offering the service

- load balancing between the Gateways on a single WebLogic Server

Methods

The following methods are available with the com.bea.jam.cluster.DeployedService object.

Method | Description
--- | ---
boolean isEnabled() | Determines if this service is enabled on any link serviced by a Gateway on the local WebLogic Server node. Throws: RemoteException if a communication error is encountered.
void deploy(boolean deployed) | Sets the deployment state of this service. If the service is undeployed while it is enabled it will be disabled as part of the undeployment. Parameter: deployed - Pass as true if the service is deployed and false otherwise. Throws: RemoteException if a communication error is encountered.
java.lang.String getName() | Retrieves the name of this service. Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.DeployedGateway[] getGateways() | Retrieves an array of the local Gateways offering this service. Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.DeployedLink[] getLinks(String gatewayName) | Retrieves an array of links offering this service for the specified gateway. Parameter: gatewayName - The name of the Gateway for which links are to be returned. If this parameter is passed as null, all links offering the service on the local WebLogic Server node will be returned. Throws: RemoteException if a communication error is encountered.
com.bea.jam.cluster.DeployedSession getSession() | Returns a session object that may be used to invoke this service on the mainframe via the WebLogic JAM Gateway. Throws: RemoteException if a communication error is encountered.

Fields

public static final JNDI_PREFIX

JNDI prefix used by all replicated DeployedService objects.

ActivityCounts Object

The ActivityCounts object contains a number of long integer fields representing various statistics for a WebLogic JAM service. This object may be obtained for a particular service via the DeployedService.getServiceActivity() or DeployedGateway.getLocalServiceActivity() methods. In addition, the ActivityCount objects for all services offered by a Gateway may be obtained via the DeployedGateway. getGatewayActivity() method.

Following are the data fields available from the ActivityCounts object:

com.bea.jam.cluster.ActivityCounts

Implements java.io.Serializable

Statistics container. Holds a set of activity counts.

Constructors

public ActivityCounts()

Fields

  public m_requests

  The number of requests that have reached the gateway. This may be larger than the sum of successes and failures if some requests are still being processed.

  public m_successes

  The number of requests that have successfully been processed to completion by the gateway. Application level failures may be reported as gateway successes.

  public m_failures

  The total number of failures of any kind.

  public m_timeouts

  The number of requests that have timed out.

  public m_lateReplies

  The number of requests that timed out and then received a response. These will also be included in m_timeouts.

  public m_timedRequestCount

  The number of requests accounted for in the m_totalResponseTime field.

  public m_totalResponseTime

  The sum of the response times for all the requests that have reached the network.

  public m_minResponseTime

  The shortest response time registered during this Gateway session.

  public m_maxResponseTime

  The longest response time registered during this Gateway session.

DeployedSession Object

The DeployedSession object may be obtained via a DeployedService remote object. It represents a WebLogic JAM session which may be used to invoke the associated service on the mainframe. Following are the methods offered by this object:

com.bea.jam.cluster.DeployedSession

Implements java.rmi.Remote

This is the remote interface for the deployed session object. This object wraps a jcrmSession object allowing remote access via the DeployedService object. This object is not bound into the JNDI tree and is not clusterable. A DeployedSession object is obtained by calling the DeployedService.getSession() method.

See Also

DeployedService

Methods

The following methods are available with the com.bea.jam.cluster.DeployedSession object.

Method | Description
--- | ---
void setUser(T3User user) | Sets the userid and password on the remote session object. This method is preferred over setUserid and setPassword as it encrypts the credential data. Parameter: user - A weblogic.common.T3User object containing the userid and password to be used for this WebLogic JAM session. Throws: RemoteException if a communication error is encountered.
void setUserid(String u) | Sets the userid to be used by the WebLogic JAM session. This method will transmit the userid in clear text assuming that the remote session object is not co-located. Setting user information via the setUser method is preferred for security reasons. Parameter: u - The userid to be used for the JAM session. Throws: RemoteException if a communication error is encountered. See Also: setUser(T3User user)
void setPassword(String p) | Sets the password to be used by the WebLogic JAM session. This method will transmit the password in clear text assuming that the remote session object is not co-located. Setting user information via the setUser method is preferred for security reasons. Throws: RemoteException if a communication error is encountered. See Also: setUser(T3User user)
void dispatch() | Dispatches the WebLogic JAM service request to the mainframe. Throws: RemoteException in the event of a communication error. If an SNA error is encountered while communicating with the mainframe an snaException will be nested in the RemoteException.
java.lang.String getServiceName() | Returns the name of the service this session was established to invoke. Throws: RemoteException if a communication error is encountered.
byte[] getDataBuffer() | Retrieves the data buffer returned by a successful service invocation. Throws: RemoteException if a communication error is encountered.
boolean setDataBuffer(byte[] buffer) | Sets the data buffer to be used as input the the mainframe service. This method must be called prior to dispatching the service request. Parameter: buffer - A byte array containing the buffer to be used as input to the mainframe service. Returns: A boolean value indicating if the buffer was successfully set. Throws: RemoteException if a communication error is encountered.
byte[] runService(T3User user, byte[] buffer) | Sets the user/password and data buffer, dispatches the service call and returns the response buffer. This method may be used to reduce the network round trips in running a remote service. Parameter: user - A weblogic.common.T3User object containing the userid and password to be used for this WebLogic JAM session. buffer - A byte array containing the buffer to be used as input to the mainframe service. Returns: A byte array containing the buffer returned by the mainframe service. Throws: RemoteException in the event of a communication error. If an SNA error is encountered while communicating with the mainframe an snaException will be nested in the RemoteException.
void close() | Closes this session object and returns it to the WebLogic JAM session pool. This method should be called after dispatching a service and retrieving the resulting data buffer to free up resources and allow the session to be allocated to other users. Throws: RemoteException if a communication error is encountered.

Sample JAM Administration Utility

The following code presents a simple command line Java application which uses some of the RMI interfaces to control/monitor a JAM Gateway. This utility requires the weblogic.jar and jam.jar files to be listed in the CLASSPATH at runtime. For example, assuming that this utility was contained in a JAR file named jamadmin.jar, the following command line could be used to invoke the program:

>     set CLASSPATH=$WL_HOME/lib/weblogic.jar;$JAM_HOME/lib/jam.jar;jamadmin.jar
>     java com.bea.jam.Admin stop MyGateway MyUser MyPassword t3://MyServer:7001

This code is offered as a sample application, which may be modified by the customer to meet their needs. The program, as presented here, is also delivered in the jam.jar file.

Listing 7-2

>     /*
>             Sample command line administration utility for JAM 5.x

>                     Copyright (c) 2002, BEA Systems, Inc.
>                             All Rights Reserved
>     */

>     package com.bea.jam;

>     import java.util.Properties;
>     import javax.naming.Context;
>     import javax.naming.InitialContext;
>     import javax.naming.NamingException;

>     import com.bea.jam.cluster.ActivityCounts;
>     import com.bea.jam.cluster.GatewayBootstrap;
>     import com.bea.jam.cluster.DeployedCRM;
>     import com.bea.jam.cluster.DeployedGateway;

>         /**
>       * This is a simple command line administration utility for the
>       * JAM Gateway.  The supported commands, start/stop/status, allow
>       * for starting/stopping the gateway as well as reporting of
>       * minimal statistics.
>       *
>       * @version JAM 5.1 (Kiwi)
>       */
>     public class Admin
>     {
>         public static void main(String[] args) throws Exception
>         {
>             if (args.length < 1)
>             {
>                 Usage();
>                 return;
>             }

>             processArgs(args);
>             String func = args[0];
>             if ("start".equalsIgnoreCase(func))
>             {
>                 startGateway();
>                 return;
>             }

>             if ("stop".equalsIgnoreCase(func))
>             {
>                 stopGateway();
>                 return;
>             }

>             if ("status".equalsIgnoreCase(func))
>             {
>                 statusGateway();
>                 return;
>             }

>      System.out.println();
>      System.out.println("*** Unknown function " + func + " - aborting");
>      Usage();
>     }

>             /**
>              *  Start the JAM Gateway.  If the gateway is not currently
>              *  deployed we deploy it first so that the startup will not
>             *  be ignored.
>             */
>         private static void startGateway() throws Exception
>         {
>             System.out.println("Connecting to host " + url);
>             Context ctx = getContext(url, user, psw);
>             try
>             {
>                 DeployedGateway gw = getGateway(ctx, name);
>                 if (!gw.isDeployed())
>                     gw.deploy(true);

>                 gw.startup();
>             }
>             finally
>             {
>                 ctx.close();
>             }
>         }

>             /**
>              * Stop the JAM Gateway.
>              */
>         private static void stopGateway() throws Exception
>         {
>             System.out.println("Connecting to host " + url);
>             Context ctx = getContext(url, user, psw);
>             try
>             {
>                 DeployedGateway gw = getGateway(ctx, name);
>                 gw.shutdown();
>             }
>             finally
>             {
>                 ctx.close();
>             }
>         }

>             /**
>              *  Obtain and display some status information from the
>              *  JAM Gateway.  The status of the gateway, enabled or
>              *  disabled, is displayed.  If the gateway is enabled
>              *  current activity counts are calculated and displayed.
>              */
>         private static void statusGateway() throws Exception
>         {
>             System.out.println("Connecting to host " + url);
>             Context ctx = getContext(url, user, psw);
>             try
>             {
>                 DeployedGateway gw = getGateway(ctx, name);
>                 boolean enabled = gw.isEnabled();
>                 System.out.println();
>                 System.out.println("Gateway " + gw.getName() + " is "
>                             + (enabled ? "enabled." : "disabled."));
>                 if (enabled)
>                 {
>                     ActivityCounts[] cnts = gw.getGatewayActivity();
>                     ActivityCounts tot = new ActivityCounts();
>                     for (int i = 0; i < cnts.length; ++i)
>                     {
>                         tot.m_successes += cnts[i].m_successes;
>                         tot.m_failures += cnts[i].m_failures;
>                         tot.m_timeouts += cnts[i].m_timeouts;
>                     }

>                 System.out.println();
>                 System.out.println("Gateway statistics:");
>                 System.out.println("    Successes: " + tot.m_successes);
>                 System.out.println("   Failures: " + tot.m_failures);
>                 System.out.println("     Timeouts: " + tot.m_timeouts);
>                 }
>             }
>             finally
>             {
>                 ctx.close();
>             }
>         }

>             /**
>            *  Obtain a JNDI Context for the requested (or defaulted)
>            *  WebLogic Server.  If a user ID and password are provided
>            *  they are passed to the InitialContext for authentication.
>            *
>            *  @param  url     The URL of the WebLogic Server hosting the
>            *                  JAM Gateway.
>            *  @param  user    The user ID to be passed to WebLogic.  May
>            *                  be null if none.
>            *  @param  psw     The password to be passed to WebLogic.  May
>            *                  be null if none.
>            *  @return JNDI Initial Context for the passed URL.
>            *  @throws NamingException if JNDI Context creation fails.
>            */
>     private static Context getContext(String url, String user, String psw)
>                                     throws NamingException
>         {
>             Properties prop = new Properties();
>             prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>                   weblogic.jndi.WLInitialContextFactory.class.getName());
>             prop.setProperty(Context.PROVIDER_URL, url);
>             if (null != user)
>                 prop.setProperty(Context.SECURITY_PRINCIPAL, user);

>             if (null != psw)
>                 prop.setProperty(Context.SECURITY_CREDENTIALS, psw);

>             return(new InitialContext(prop));
>         }

>             /**
>              *  Examine command line arguments and save passed information
>            *  for use by functional methods.
>            */
>     private static void processArgs(String[] args)
>     {
>             System.out.println();
>             if (args.length > 1)
>             {
>                 name = args[1];
>                 System.out.print("Gateway(" + name + ") ");
>             }

>             if (args.length > 2)
>             {
>                 user = args[2];
>                 System.out.print("User(" + user + ") ");
>             }

>             if (args.length > 3)
>             {
>                 psw = args[3];
>                 System.out.print("Password(**secret**) ");
>             }

>             if (args.length > 4)
>                 url = args[4];

>             System.out.println("URL(" + url + ")");
>          }

>             /**
>              *  Obtain a remote gateway object using the passed JNDI
>              *  Context.
>              *
>              *  @param  ctx     The JNDI Context to be used in obtaining
>              *                  the remote gateway object.
>              *  @param  name    The name of the gateway to retrieve.  May
>              *                  be passed as null to obtain the first
>              *                  gateway defined for the server.
>              *  @return Returns a DeployedGateway object representing the
>              *          requested gateway.
>              *  @throws Exception if an error is encountered.
>              */
>     private static DeployedGateway getGateway(Context ctx, String name)
>                                     throws Exception
>         {
>             if (null == name)
>             {
>                 GatewayBootstrap boot = (GatewayBootstrap) ctx.lookup(
>                                                     GatewayBootstrap.JNDI_NAME);
>                 DeployedGateway[] gw = boot.getGateways();
>                 if (gw.length > 0)
>                     return(gw[0]);

>                 throw new Exception("There are no JAM gateways defined
>                 on this server");
>             }

>             return((DeployedGateway) ctx.lookup(DeployedGateway.JNDI_PREFIX + name));
>         }

>             /**
>              *  Display program usage information.
>              */
>         private static void Usage()
>         {
>             System.out.println();
>             System.out.println("Usage: com.bea.jam.Admin <function> ");
>             System.out.println("[<name> <user> <password>] [<URL>]");
>             System.out.println("function:   The function to perform.  Supported functions ");
>             System.out.println("            are start, stop, status.");
>             System.out.println("            start:  Start the JAM Gateway");
>             System.out.println("            stop:   Stop the JAM Gateway");
>             System.out.println("            status: Report the JAM Gateway status");
>             System.out.println();
>             System.out.println("name:       The name of the JAM Gateway for the requested ");
>             System.out.println("            function.  Default is the 1st gateway defined ");
>             System.out.println("            on the selected WebLogic Server.");
>             System.out.println();
>             System.out.println("user:       The user ID used to authenicate with WebLogic.");
>             System.out.println();
>             System.out.println("password:   The psw used to authenicate with WebLogic.");
>             System.out.println();
>             System.out.println("URL:        The URL for the WLS Server hosting the JAM ");
>             System.out.println("             Gateway.  The default is t3://localhost:7001.");
>             System.out.println();
>         }

>     private static String name = null;
>     private static String user = null;
>     private static String psw = null;
>     private static String url = "t3://localhost:7001";
>     }