com.adventnet.tl1
Class TL1ServerSession

java.lang.Object
  extended by com.adventnet.tl1.TL1ServerSession

public class TL1ServerSession
extends java.lang.Object

This class is used for running TL1 Agent. Users should implement their transport provider mechanism for communication between the TL1Agent and the TL1 Manager.

 Example Usage :
      TL1API api = new TL1API();
      TL1ServerSession server = new TL1ServerSession(api);
      ....
      server.addTL1Client(com.adventnet.tl1.TL1Client_Implementation);
      TcpServerTransportImpl serverTransportImpl = new TcpServerTransportImpl();
      server.setTL1ServerTransportProvider(serverTransportImpl);
      Hashtable parameters = new Hashtable();
      parameters.put("PORT","9999");
      server.open(parameters);
      server.start();
 


Field Summary
(package private)  TL1API api
           
(package private)  TL1Client client
           
(package private)  java.util.Hashtable parameters
           
(package private)  com.adventnet.tl1.transport.ProtocolOptions serverProtocolOptions
           
(package private)  boolean serverStarted
           
(package private)  com.adventnet.tl1.transport.TL1ServerTransportProvider serverTransportProvider
           
(package private)  TL1Session sess
           
(package private)  java.lang.Object sessionClassifier
           
(package private)  java.util.Vector sessionV
           
 
Constructor Summary
TL1ServerSession()
          Default constructor that initilises the TCP ServerSocket.
TL1ServerSession(int port)
          Constructor, that initiates the server socket on the given port.
TL1ServerSession(TL1API tl1api)
          Constructor with TL1API argument.
 
Method Summary
 void addTL1Client(TL1Client client)
          Set the TL1Client object with the given value.
 void addTL1Session(TL1Session session)
          This method should be invoked from TL1ServerTransportProvider implementation for registering client sessions.
 void close()
          Closes all the client sessions and server session.
 TL1Session getAgentSession()
          Get the TL1Session.
 int getServerPort()
          To get the port on which the server is running.
 java.lang.Object getSessionClassifier()
          This method is used to get the Object value of session classifier set using setSessionClassifier(..) of this class.
 java.util.Vector getSessionList()
          Get the List of TL1 Sessions managed under this TL1API instance.
 TL1Client getTL1Client()
          Get the TL1Client object.
 com.adventnet.tl1.transport.TL1ServerTransportProvider getTL1ServerTransportProvider()
          This method returns the TL1ServerTransportProvider object associated with this TL1ServerSession.
 boolean isActive()
          To check for Server connection.
 void open()
          Open method that calls the start() method to start the server session.
 void open(java.util.Hashtable params)
          This method will invoke the TL1ServerTransportProvider open method.
 void setServerPort(int port)
          To set the server port with the given value.
 void setSessionClassifier(java.lang.Object obj)
          This method is used for storing some application specific details.
 void setTL1Client(TL1Client client)
          Deprecated. Since AdventNetTL1 API 2.0. Use addTL1Client(..)
 void setTL1ServerTransportProvider(com.adventnet.tl1.transport.TL1ServerTransportProvider tl1ServerTransportProvider)
          To set the TL1ServerTransportProvider implementation with the given value.
 void start()
          This method will invoke the TL1ServerTransportProvider start method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

api

TL1API api

sess

TL1Session sess

client

TL1Client client

serverStarted

boolean serverStarted

serverProtocolOptions

com.adventnet.tl1.transport.ProtocolOptions serverProtocolOptions

serverTransportProvider

com.adventnet.tl1.transport.TL1ServerTransportProvider serverTransportProvider

sessionV

java.util.Vector sessionV

sessionClassifier

java.lang.Object sessionClassifier

parameters

java.util.Hashtable parameters
Constructor Detail

TL1ServerSession

public TL1ServerSession()
                 throws java.lang.Exception
Default constructor that initilises the TCP ServerSocket.

Throws:
java.lang.Exception - in case the TL1ServerSession fails to initialise.

TL1ServerSession

public TL1ServerSession(int port)
                 throws java.lang.Exception
Constructor, that initiates the server socket on the given port.

Parameters:
port - port number where the server socket is to be started.
Throws:
java.lang.Exception - in case the TL1ServerSession fails to initialise.

TL1ServerSession

public TL1ServerSession(TL1API tl1api)
Constructor with TL1API argument.

Parameters:
tl1api - TL1API instance.
Method Detail

getSessionList

public java.util.Vector getSessionList()
Get the List of TL1 Sessions managed under this TL1API instance.

Returns:
vector of sessions.

getAgentSession

public TL1Session getAgentSession()
Get the TL1Session.

Returns:
TL1Session.
See Also:
TL1Session

setServerPort

public void setServerPort(int port)
To set the server port with the given value.

Parameters:
port - port number where the server should run.

getServerPort

public int getServerPort()
To get the port on which the server is running.

Returns:
port number as an integer.

setTL1Client

public void setTL1Client(TL1Client client)
Deprecated. Since AdventNetTL1 API 2.0. Use addTL1Client(..)

See Also:
addTL1Client(com.adventnet.tl1.TL1Client)

getTL1Client

public TL1Client getTL1Client()
Get the TL1Client object.

Returns:
TL1Client object.
See Also:
TL1Client

isActive

public boolean isActive()
To check for Server connection. i.e. to check if server session is alive or not.

Returns:
boolean value. true if server is active or else returns false.

open

public void open()
          throws java.lang.Exception
Open method that calls the start() method to start the server session.

Throws:
java.lang.Exception

addTL1Client

public void addTL1Client(TL1Client client)
Set the TL1Client object with the given value.

Parameters:
client - TL1Client instance to set.
See Also:
TL1Client

setTL1ServerTransportProvider

public void setTL1ServerTransportProvider(com.adventnet.tl1.transport.TL1ServerTransportProvider tl1ServerTransportProvider)
To set the TL1ServerTransportProvider implementation with the given value.

Parameters:
tl1ServerTransportProvider - TL1ServerTransportProvider implementation to set.

getTL1ServerTransportProvider

public com.adventnet.tl1.transport.TL1ServerTransportProvider getTL1ServerTransportProvider()
This method returns the TL1ServerTransportProvider object associated with this TL1ServerSession.

Returns:
Returns TL1ServerTransportProvider object instance.

setSessionClassifier

public void setSessionClassifier(java.lang.Object obj)
This method is used for storing some application specific details. This value is not used by the APIs and it is just set in all the client sessions(TL1Session) which are updated in addTL1Session(..) method. User can get the classifier value set in the client session from the callback implementation(TL1Client) using session.getSessionClassifier(), where session is an instance of TL1Session.

Parameters:
obj - Object instance.

getSessionClassifier

public java.lang.Object getSessionClassifier()
This method is used to get the Object value of session classifier set using setSessionClassifier(..) of this class.

Returns:
Returns an Object instance.

open

public void open(java.util.Hashtable params)
          throws java.lang.Exception
This method will invoke the TL1ServerTransportProvider open method.

Parameters:
params - Hashtable containing keys and value pairs that are used for opening the session.
Throws:
java.lang.Exception - if an error occurs while initializing/opening the session.

start

public void start()
           throws java.lang.Exception
This method will invoke the TL1ServerTransportProvider start method.

Throws:
java.lang.Exception - if an error occurs while opening the client session.

addTL1Session

public void addTL1Session(TL1Session session)
This method should be invoked from TL1ServerTransportProvider implementation for registering client sessions. For example in case of TCP : serverSocket.accept() will return a Socket. For each and every socket, a new TL1Session has to be created and registered here.

Parameters:
session - TL1Session instance.

close

public void close()
Closes all the client sessions and server session.

Throws:
java.lang.Exception - will be thrown in case of an error.