com.infoengine.au
Class SocketAccess

java.lang.Object
  extended bycom.infoengine.au.SocketAccess

public class SocketAccess
extends Object

This class establishes a framework for listening on a TCP port for connection requests. When a connection request is received, it creates a thread to service the connection. The thread then reads Info*Engine request objects from the connection and passes them to a specified class for processing. The class that processes the requests can be defined as implementing the IeProcessor interface or the IeMultithreadedPrrocessor interface. If the class implements the IeProcessor interface, then a new instance is created and dispatched for each request received by the thread. If the class implements the IeMultithreadedProcessor interface, it is instantiated exactly once (when the thread receives the very first request), and reused thereafter.


Nested Class Summary
(package private)  class SocketAccess.SocketThread
           
 
Field Summary
private  int activeThreads
           
static int ADAPTER
           
static int ADMINISTRATIVE_SERVICE
           
protected static int count
           
private static String DEFAULT_SERVER_SOCKET_FACTORY
           
private static Class defaultTaskProcessorClass
           
private  long handledRequests
           
private static InetAddress localhostInetAddress
           
private  com.infoengine.log.LogWriter logWriter
           
private  long longestResponseTime
           
private  int maxThreadCount
           
private static InetAddress[] myClusterAddresses
           
private static String myClusterName
           
private static String myHostName
           
private static InetAddress[] myInetAddresses
           
private static Class procunitWebjectProcessorClass
           
private static String RESOURCE
           
private static Method SAKTaskVerifyByCertificate
           
private static Method SAKTaskVerifyUsername
           
private  int serverPort
           
private  String serviceName
           
private  int serviceType
           
private  long shortestResponseTime
           
private static Hashtable socketFactories
           
private  ServerSocket ss
           
static int TASK_PROCESSOR
           
private  Class taskProcessorClass
           
private  IeProcessor taskProcessorInstance
           
static int TEMPLATE_PROCESSOR
           
private  long totalResponseTime
           
static int WEBJECT_PROCESSOR
           
private  Class webjectProcessorClass
           
private  IeProcessor webjectProcessorInstance
           
private static Method webjectProcessorProcessTask
           
 
Constructor Summary
SocketAccess(Class webjectProcessorClass, Class taskProcessorClass, com.infoengine.log.LogWriter log, String serviceName)
          Constructs an instance that calls a specified classes to process each webject and task request received.
SocketAccess(Class webjectProcessorClass, com.infoengine.log.LogWriter log, String serviceName)
          Constructs an instance that calls a specified class to process each webject request received, and that calls the default task processor class to process each task request received.
SocketAccess(Class webjectProcessorClass, Properties props, com.infoengine.log.LogWriter log, String serviceName)
          Deprecated. Add the configuration properties to the System properties and use a constructor that does not take a properties object as a parameter.
 
Method Summary
private  long avgResponseTime()
           
private  void awaitNotification()
           
private  ServerSocket createServerSocket(String serviceName, int port)
           
private  void decrActive()
           
private  int getActive()
           
private  long getLongestResponseTime()
           
 int getPort()
           
private  long getRequests()
           
static ObjectDestination[] getServiceAddresses(String serviceName)
          Obtain the set of addresses and related attributes registered for a service.
 int getServiceType()
          Returns the type of service to which this instance provides access.
private  long getShortestResponseTime()
           
 Class getTaskProcessorClass()
          Returns the class used to execute tasks.
 Class getWebjectProcessorClass()
          Returns the class used to execute tasks.
private  void incrActive()
           
private  void incrRequests()
           
private  void incrResponseTime(long time)
           
private  void initialize(Class webjectProcessorClass, Class taskProcessorClass, com.infoengine.log.LogWriter log, String serviceName)
           
 void run()
          Begins listening for connection requests and creates a thread to accept and process each such request.
private  void sendNotification()
           
 void setServiceType(int serviceType)
          Establishes the type of service to which this instance provides access.
 void setTaskProcessorClass(Class taskProcessorClass)
          Establishes the class used to execute tasks.
 void setWebjectProcessorClass(Class webjectProcessorClass)
          Establishes the class used to execute webjects.
static Throwable unwrap(Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVER_SOCKET_FACTORY

private static final String DEFAULT_SERVER_SOCKET_FACTORY
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

ADMINISTRATIVE_SERVICE

public static final int ADMINISTRATIVE_SERVICE
See Also:
Constant Field Values

TASK_PROCESSOR

public static final int TASK_PROCESSOR
See Also:
Constant Field Values

TEMPLATE_PROCESSOR

public static final int TEMPLATE_PROCESSOR
See Also:
Constant Field Values

WEBJECT_PROCESSOR

public static final int WEBJECT_PROCESSOR
See Also:
Constant Field Values

ADAPTER

public static final int ADAPTER
See Also:
Constant Field Values

count

protected static int count

logWriter

private com.infoengine.log.LogWriter logWriter

maxThreadCount

private int maxThreadCount

serverPort

private int serverPort

serviceName

private String serviceName

serviceType

private int serviceType

ss

private ServerSocket ss

taskProcessorClass

private Class taskProcessorClass

taskProcessorInstance

private IeProcessor taskProcessorInstance

webjectProcessorClass

private Class webjectProcessorClass

webjectProcessorInstance

private IeProcessor webjectProcessorInstance

activeThreads

private int activeThreads

handledRequests

private long handledRequests

longestResponseTime

private long longestResponseTime

shortestResponseTime

private long shortestResponseTime

totalResponseTime

private long totalResponseTime

localhostInetAddress

private static InetAddress localhostInetAddress

myClusterAddresses

private static InetAddress[] myClusterAddresses

myClusterName

private static String myClusterName

myHostName

private static String myHostName

myInetAddresses

private static InetAddress[] myInetAddresses

socketFactories

private static Hashtable socketFactories

defaultTaskProcessorClass

private static Class defaultTaskProcessorClass

procunitWebjectProcessorClass

private static Class procunitWebjectProcessorClass

SAKTaskVerifyByCertificate

private static Method SAKTaskVerifyByCertificate

SAKTaskVerifyUsername

private static Method SAKTaskVerifyUsername

webjectProcessorProcessTask

private static Method webjectProcessorProcessTask
Constructor Detail

SocketAccess

public SocketAccess(Class webjectProcessorClass,
                    com.infoengine.log.LogWriter log,
                    String serviceName)
             throws SocketAccessException
Constructs an instance that calls a specified class to process each webject request received, and that calls the default task processor class to process each task request received.

Parameters:
webjectProcessorClass - The class that will be called to process each webject request received. This class must implement either the com.infoengine.procunit.IeProcessor interface or the com.infoengine.procunit.IeMultithreadedProcessor interface.
log - The LogWriter to which messages related to the requests being processed will be written.
serviceName - The name of the service associated with this SocketAccess instance. This name selects configuration properties from the system properties.
Throws:
SocketAccessException - if a server socket can not be created successfully for listening for requests.

SocketAccess

public SocketAccess(Class webjectProcessorClass,
                    Class taskProcessorClass,
                    com.infoengine.log.LogWriter log,
                    String serviceName)
             throws SocketAccessException
Constructs an instance that calls a specified classes to process each webject and task request received.

Parameters:
webjectProcessorClass - The class that will be called to process each webject request received. This class must implement either the com.infoengine.procunit.IeProcessor interface or the com.infoengine.procunit.IeMultithreadedProcessor interface.
taskProcessorClass - The class that will be called to process each task request received. This class must implement either the com.infoengine.procunit.IeProcessor interface or the com.infoengine.procunit.IeMultithreadedProcessor interface.
log - The LogWriter to which messages related to the requests being processed will be written.
serviceName - The name of the service associated with this SocketAccess instance. This name selects configuration properties from the system properties.
Throws:
SocketAccessException - if a server socket can not be created successfully for listening for requests.

SocketAccess

public SocketAccess(Class webjectProcessorClass,
                    Properties props,
                    com.infoengine.log.LogWriter log,
                    String serviceName)
             throws SocketAccessException
Deprecated. Add the configuration properties to the System properties and use a constructor that does not take a properties object as a parameter.

Constructs an instance that calls a specified class to process each webject request received, and that calls the default task processor class to process each task request received.

Parameters:
webjectProcessorClass - The class that will be called to process each webject request received. This class must implement either the com.infoengine.procunit.IeProcessor interface or the com.infoengine.procunit.IeMultithreadedProcessor interface.
props - An object containing configuration properties.
log - The LogWriter to which messages related to the requests being processed will be written.
serviceName - The name of the service associated with this SocketAccess instance. This name selects configuration properties from the system properties.
Throws:
SocketAccessException - if a server socket can not be created successfully for listening for requests.
Method Detail

initialize

private void initialize(Class webjectProcessorClass,
                        Class taskProcessorClass,
                        com.infoengine.log.LogWriter log,
                        String serviceName)
                 throws SocketAccessException
Throws:
SocketAccessException

getServiceAddresses

public static ObjectDestination[] getServiceAddresses(String serviceName)
                                               throws SocketAccessException
Obtain the set of addresses and related attributes registered for a service.

Parameters:
serviceName - The name of the Info*Engine service for which to obtain network addresses.
Returns:
The set of service addresses and related attributes
Throws:
SocketAccessException - if network addresses can not be determined.

setServiceType

public void setServiceType(int serviceType)
Establishes the type of service to which this instance provides access.

Parameters:
serviceType - One of TEMPLATE_PROCESSOR, TASK_PROCESSOR, or WEBJECT_PROCESSOR. The default is WEBJECT_PROCESSOR.

getServiceType

public int getServiceType()
Returns the type of service to which this instance provides access.

Returns:
Type of service. One of TEMPLATE_PROCESSOR, TASK_PROCESSOR, or WEBJECT_PROCESSOR.

getPort

public int getPort()

setWebjectProcessorClass

public void setWebjectProcessorClass(Class webjectProcessorClass)
                              throws SocketAccessException
Establishes the class used to execute webjects.

Parameters:
webjectProcessorClass - The webject processor class.
Throws:
SocketAccessException - if the class can not be established as the webject processor class.

getWebjectProcessorClass

public Class getWebjectProcessorClass()
Returns the class used to execute tasks.

Returns:
The current task processor class.

setTaskProcessorClass

public void setTaskProcessorClass(Class taskProcessorClass)
                           throws SocketAccessException
Establishes the class used to execute tasks.

Parameters:
taskProcessorClass - The task processor class.
Throws:
SocketAccessException - if the class can not be established as the task processor class.

getTaskProcessorClass

public Class getTaskProcessorClass()
Returns the class used to execute tasks.

Returns:
The current task processor class.

awaitNotification

private void awaitNotification()
                        throws InterruptedException
Throws:
InterruptedException

sendNotification

private void sendNotification()
                       throws IllegalMonitorStateException
Throws:
IllegalMonitorStateException

createServerSocket

private ServerSocket createServerSocket(String serviceName,
                                        int port)
                                 throws Exception
Throws:
Exception

incrActive

private void incrActive()

getActive

private int getActive()

decrActive

private void decrActive()

incrRequests

private void incrRequests()

getRequests

private long getRequests()

incrResponseTime

private void incrResponseTime(long time)

avgResponseTime

private long avgResponseTime()

getShortestResponseTime

private long getShortestResponseTime()

getLongestResponseTime

private long getLongestResponseTime()

unwrap

public static Throwable unwrap(Throwable t)

run

public void run()
Begins listening for connection requests and creates a thread to accept and process each such request.