com.SoftWoehr.JTOpenContrib.connectionmgr
Class Mgr

java.lang.Object
  |
  +--com.SoftWoehr.JTOpenContrib.connectionmgr.Mgr

public class Mgr
extends java.lang.Object

Simple manager for multiple shared AS400 connections. Clients of class ServiceClient make a request for a server and service. The server is an AS400. The service is one of the services AS400.FILE etc. A service record is returned, which is resubmitted by the client to relinquish the service. The AS400 connection is a public data member of that service record. The Mgr instance can also indicate to the ServiceClient that its connection is about to become invalid by calling the client's interface function ServiceClient.relinquish() The URL for the service request is of the form:

 mgr:serverName/SERVICE 
e.g., mgr:ANAS400/FILE A Mgr maintains one com.ibm.as400.access.AS400 object for each server. If you wish to have multiple instances of server objects, instance multiple Mgr's.


Inner Class Summary
 class Mgr.InvalidServiceRecordException
          Thrown if an invalid service record is returned by a client to the call freeService().
 class Mgr.Locator
          Class used to parse the requests made for service.
 class Mgr.UnknownProtocolException
          This exception is thrown if the "url" submitted for a service request is unrecognized.
 class Mgr.UnknownServiceException
          This is thrown if a request is made for an unknown or unsupported service.
 
Constructor Summary
Mgr()
          Creates new Mgr
 
Method Summary
 ServiceRecord createServiceRecord(java.lang.String serverName, int service, com.ibm.as400.access.AS400 as400, ServiceClient client)
          Create a new service record
 void freeService(ServiceRecord sr)
          A ServiceClient uses this function to inform the Mgr that the service which was obtained is no longer needed by the client.
 com.ibm.as400.access.AS400 getServer(java.lang.String serverName, java.lang.String hashName)
          Find a server if we have already created it.
 ServiceRecord getService(java.lang.String representation, ServiceClient client)
          This function accepts a URL-like request from a ServiceClient for a com.ibm.as400.access.AS400 service on a server.
 java.lang.String intToServiceName(int service)
          Return a string representing an AS400 service from its integer value.
static void main(java.lang.String[] argv)
          Test Mgr.
 java.lang.String serversToString()
          Return a string listing the servers active
 java.lang.String serviceRecordsToString()
          Return a string illustrating all current service records.
 java.lang.String toProtocol(java.lang.String representation)
          Extract protocol portion of the representation of a service request.
 java.lang.String toServerName(java.lang.String representation)
          Extract server portion of the representation of a service request.
 int toService(java.lang.String representation)
          Extract service portion of the representation of a service request and convert it to an AS400 service number.
 java.lang.String toServiceName(java.lang.String representation)
          Extract service portion of the representation of a service request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mgr

public Mgr()
Creates new Mgr
Method Detail

getServer

public com.ibm.as400.access.AS400 getServer(java.lang.String serverName,
                                            java.lang.String hashName)
Find a server if we have already created it. Create it if not already present.

createServiceRecord

public ServiceRecord createServiceRecord(java.lang.String serverName,
                                         int service,
                                         com.ibm.as400.access.AS400 as400,
                                         ServiceClient client)
                                  throws Mgr.UnknownServiceException
Create a new service record

getService

public ServiceRecord getService(java.lang.String representation,
                                ServiceClient client)
                         throws Mgr.UnknownServiceException,
                                Mgr.UnknownProtocolException
This function accepts a URL-like request from a ServiceClient for a com.ibm.as400.access.AS400 service on a server. A service record is returned which contains the reference to the server. The service record is passed back to Mgr when the ServiceClient is done with the service.
Parameters:
representation - A string of the form mgr:server/service where server is the name of the desired server and service is one of the service names for the AS400 object, e.g., FILE PRINT etc.
client - The client must implement the interface ServiceClient.
Returns:
A ServiceRecord which can be examined to obtain reference to the AS400 instance being represented. This record is passed back to the Mgr in the functifreeService when the client is done with the service
Throws:
Mgr.UnknownServiceException - If the name of the service is not recoqnized.
Mgr.UnknownProtocolException - If the "protocol" portion of the URL is not mgr.

freeService

public void freeService(ServiceRecord sr)
                 throws Mgr.InvalidServiceRecordException
A ServiceClient uses this function to inform the Mgr that the service which was obtained is no longer needed by the client.
Parameters:
sr - The ServiceRecord obtained by a call to Mgr.getService()
Throws:
Mgr.InvalidServiceRecordException - If the service record isn't valid.

toProtocol

public java.lang.String toProtocol(java.lang.String representation)
Extract protocol portion of the representation of a service request.
Parameters:
representation -  
Returns:
 

toServerName

public java.lang.String toServerName(java.lang.String representation)
                              throws Mgr.UnknownProtocolException
Extract server portion of the representation of a service request.
Parameters:
representation -  
Returns:
 
Throws:
Mgr.UnknownProtocolException -  

toServiceName

public java.lang.String toServiceName(java.lang.String representation)
                               throws Mgr.UnknownProtocolException
Extract service portion of the representation of a service request.
Parameters:
representation -  
Returns:
 
Throws:
Mgr.UnknownProtocolException -  

toService

public int toService(java.lang.String representation)
              throws Mgr.UnknownProtocolException
Extract service portion of the representation of a service request and convert it to an AS400 service number.
Parameters:
representation -  
Returns:
 
Throws:
Mgr.UnknownProtocolException -  

intToServiceName

public java.lang.String intToServiceName(int service)
Return a string representing an AS400 service from its integer value.
Parameters:
service - Integer representing an AS400 service constant.
Returns:
The string name of the service represented by the int.

serviceRecordsToString

public java.lang.String serviceRecordsToString()
Return a string illustrating all current service records.
Returns:
A string of the form server,service\n ... repeated for as many service records as exist.

serversToString

public java.lang.String serversToString()
Return a string listing the servers active

main

public static void main(java.lang.String[] argv)
Test Mgr.
Parameters:
argv - Not used.