Class SessionFactoryHelper

java.lang.Object
com.zeroc.Glacier2.SessionFactoryHelper

public class SessionFactoryHelper extends Object
A helper class for using Glacier2 with GUI applications. Applications should create a session factory for each Glacier2 router to which the application will connect. To connect with the Glacier2 router, call connect(). The callback object is notified of the various life cycle events. Once the session is torn down for whatever reason, the application can use the session factory to create another connection.
  • Constructor Details

    • SessionFactoryHelper

      public SessionFactoryHelper(SessionCallback callback) throws InitializationException
      Creates a SessionFactory object.
      Parameters:
      callback - The callback object for notifications.
      Throws:
      InitializationException - If a failure occurred while initializing the communicator.
    • SessionFactoryHelper

      public SessionFactoryHelper(InitializationData initData, SessionCallback callback) throws InitializationException
      Creates a SessionFactory object.
      Parameters:
      initData - The initialization data to use when creating the communicator.
      callback - The callback object for notifications.
      Throws:
      InitializationException - If a failure occurred while initializing the communicator.
    • SessionFactoryHelper

      public SessionFactoryHelper(Properties properties, SessionCallback callback) throws InitializationException
      Creates a SessionFactory object.
      Parameters:
      properties - The properties to use when creating the communicator.
      callback - The callback object for notifications.
      Throws:
      InitializationException - If a failure occurred while initializing the communicator.
  • Method Details

    • setRouterIdentity

      public void setRouterIdentity(Identity identity)
      Set the router object identity.
      Parameters:
      identity - The Glacier2 router's identity.
    • getRouterIdentity

      public Identity getRouterIdentity()
      Returns the object identity of the Glacier2 router.
      Returns:
      The Glacier2 router's identity.
    • setRouterHost

      public void setRouterHost(String hostname)
      Sets the host on which the Glacier2 router runs.
      Parameters:
      hostname - The host name (or IP address) of the router host.
    • getRouterHost

      public String getRouterHost()
      Returns the host on which the Glacier2 router runs.
      Returns:
      The Glacier2 router host.
    • setSecure

      @Deprecated public void setSecure(boolean secure)
      Deprecated.
      deprecated, use SessionFactoryHelper.setProtocol instead
      Sets whether to connect with the Glacier2 router securely.
      Parameters:
      secure - If true, the client connects to the router via SSL; otherwise, the client connects via TCP.
    • getSecure

      @Deprecated public boolean getSecure()
      Deprecated.
      deprecated, use SessionFactoryHelper.getProtocol instead
      Returns whether the session factory will establish a secure connection to the Glacier2 router.
      Returns:
      The secure flag.
    • setProtocol

      public void setProtocol(String protocol)
      Sets the protocol that will be used by the session factory to establish the connection.
      Parameters:
      protocol - The communication protocol.
    • getProtocol

      public String getProtocol()
      Returns the protocol that will be used by the session factory to establish the connection.
      Returns:
      The protocol.
    • setTimeout

      public void setTimeout(int timeoutMillisecs)
      Sets the connect and connection timeout for the Glacier2 router.
      Parameters:
      timeoutMillisecs - The timeout in milliseconds. A zero or negative timeout value indicates that the router proxy has no associated timeout.
    • getTimeout

      public int getTimeout()
      Returns the connect and connection timeout associated with the Glacier2 router.
      Returns:
      The timeout.
    • setPort

      public void setPort(int port)
      Sets the Glacier2 router port to connect to.
      Parameters:
      port - The port. If 0, then the default port (4063 for TCP or 4064 for SSL) is used.
    • getPort

      public int getPort()
      Returns the Glacier2 router port to connect to.
      Returns:
      The port.
    • getInitializationData

      public InitializationData getInitializationData()
      Returns the initialization data used to initialize the communicator.
      Returns:
      The initialization data.
    • setConnectContext

      public void setConnectContext(Map<String,String> context)
      Sets the request context to use while establishing a connection to the Glacier2 router.
      Parameters:
      context - The request context.
    • setUseCallbacks

      public void setUseCallbacks(boolean useCallbacks)
      Determines whether the session should create an object adapter that the client can use for receiving callbacks.
      Parameters:
      useCallbacks - True if the session should create an object adapter.
    • getUseCallbacks

      public boolean getUseCallbacks()
      Indicates whether a newly-created session will also create an object adapter that the client can use for receiving callbacks.
      Returns:
      True if the session will create an object adapter.
    • connect

      public SessionHelper connect()
      Connects to the Glacier2 router using the associated SSL credentials. Once the connection is established, SessionCallback.connected(com.zeroc.Glacier2.SessionHelper) is called on the callback object; upon failure, SessionCallback.connectFailed(com.zeroc.Glacier2.SessionHelper, java.lang.Throwable) is called with the exception.
      Returns:
      The connected session.
    • connect

      public SessionHelper connect(String username, String password)
      Connect the Glacier2 session using user name and password credentials. Once the connection is established, SessionCallback.connected(com.zeroc.Glacier2.SessionHelper) is called on the callback object; upon failure, SessionCallback.connectFailed(com.zeroc.Glacier2.SessionHelper, java.lang.Throwable) is called with the exception.
      Parameters:
      username - The user name.
      password - The password.
      Returns:
      The connected session.