Server class

The Server Java class is intended to encapsulate the Java system connection within the Agentry Server.

Syntax

public class Server extends AgentryJavaBackEndManagedObject

Members

All members of Server, including inherited members.

Constructors
Modifier and Type Constructor Description
public Server() Constructs a new Server object.
Methods
Modifier and Type Method Description
public ComplexTableSession createComplexTableSession(String, SessionData, User) Factory method that creates a new ComplexTableSession object.
public DataTableSession createDataTableSession(String, SessionData, User) Factory method that creates a new DataTableSession object.
public final FetchSession createFetchSession(String, Server, SessionData, User) Deprecated. Use createFetchSession(String, SessionData, User) (i.e. remove the Server argument). This method is no longer supported; override createFetchSession(String, SessionData, User) instead.
public FetchSession createFetchSession(String, SessionData, User) Factory method that creates a new FetchSession object.
public final FetchSession createPushSession(String, Server, SessionData) Deprecated. Use createPushSession(String, SessionData) (i.e. remove the Server argument). This method is no longer supported; override createPushSession(String, SessionData) instead.
public PushSession createPushSession(String, SessionData) Factory method that creates a new PushSession object for a push session that is not tied to a specific user.
public final FetchSession createPushUserSession(String, Server, SessionData, User) Deprecated. Use createPushUserSession(String, SessionData, User) (i.e. remove the Server argument). This method is no longer supported; override createPushUserSession(String, SessionData, User) instead.
public PushUserSession createPushUserSession(String, SessionData, User) Factory method that creates a new PushUserSession object for a push session.
public final ServiceEventSession createServiceEventSession(String, Server, SessionData) Deprecated. Use createServiceEventSession(String, SessionData) (i.e. remove the Server argument). This method is no longer supported; override createServiceEventSession(String, SessionData) instead.
public ServiceEventSession createServiceEventSession(String, SessionData) Factory method that creates a new ServiceEventSession object.
public final FetchSession createTransactionSession(String, Server, SessionData, User) Deprecated. Use createTransactionSession(String, SessionData, User) (i.e. remove the Server argument). This method is no longer supported; override createTransactionSession(String, SessionData, User) instead.
public TransactionSession createTransactionSession(String, SessionData, User) Factory method that creates a new TransactionSession object.
public final User createUser(String, int) Deprecated. Use createUser(String) instead. This method is no longer supported; override createUser(String) instead.
public User createUser(String) Factory method that creates a new User object.
public final void debug(String) Writes a debug message to the Agentry Server's Java System Connection log file.
public final String decryptPassword(String) Decodes a password that has been encoded via Agentry's quickPW utility.
public File findConfigurationFile(String) Locates a configuration file in the Agentry application's deployment returns a.
public static final String getImplementationVersion() Retrieves the implementation version of the AJAPI release that this Server class is from.
public static Server getInstance() Return the singleton instance of this class.
public static final String getSpecificationVersion() Retrieves the specification version of the AJAPI that this Server implements.
public String getTimeZone() This is called by the Agentry server to find out what time zone is being used by whatever remote server this implementation is communicating with.
public LoginEnumeration login(String, String, SessionData) Deprecated. Override login(User, String, SessionData) instead. This method is called when a user initially connects to the Agentry Server from a client application and that server's system connection's enableAuthentication option is set to true in the Agentry.ini file.
public void login(User, String, SessionData) This method authenticates a client user against the Java System Connection.
public LoginEnumeration loginBlocked(String, StringBuffer) Deprecated. Override loginBlocked(User, String, StringBuffer, SessionData) instead. This method is called by the Agentry Server when authentication of a client user is blocked, either because this class returned a blocked login from the login(String, String, SessionData) or loginPreviousUser(String, String, SessionData) methods, or because another system connection blocked the login.
public void loginBlocked(User, StringBuffer, SessionData) Deprecated. Override loginBlocked(User, String, StringBuffer, SessionData) instead. This method is called by the Agentry Server when authentication of a client user is blocked, either because this class threw LoginBlockedException from the login, loginPreviousUser, or loginFailed methods, or because another system connection blocked the login.
public void loginBlocked(User, String, StringBuffer, SessionData) This method is called by the Agentry Server when authentication of a client user is blocked, either because this class threw LoginBlockedException from the login, loginPreviousUser, or loginFailed methods, or because another system connection blocked the login.
public LoginEnumeration loginFailed(String, StringBuffer) Deprecated. Override loginFailed(User, String, LoginFailureReason, StringBuffer, SessionData) instead. This method is called by the Agentry Server when authentication of a client user fails, either because this class returned a failed login from the login or loginPreviousUser methods, or because another system connection failed the login.
public void loginFailed(User, String, LoginFailureReason, StringBuffer, SessionData) This method is called by the Agentry Server when authentication of a client user fails, either because this class threw PasswordInvalidException from the login or loginPreviousUser methods, or because another system connection reported a login failure.
public LoginEnumeration loginPreviousUser(String, String, SessionData) Deprecated. Override loginPreviousUser(User, String, SessionData) instead. This method is called when a user has previously logged into Agentry successfully, and is now logging in again due to having been disconnected.
public void loginPreviousUser(User, String, SessionData) This method is called when a user has previously logged into Agentry successfully, and is now logging in again due to having been disconnected.
final void setDebugEnabled(boolean) Deprecated. This is only here because the Agentry server will call it. Setter method called by the Agentry server to enable/disable debugging.
public void shutdown() This method is called by the Agentry Server when the Java system connection is being shut down.
public void startup() This method is called by the Agentry Server when the Java system connection starts up and creates an instance of this class; it is called immediately after the class is constructed.

Usage

The bulk of the methods within this class are factory methods for various other object types. If the designer overrides one of the classes constructed by these factory methods, a subclass of the Server class must also be created. This implementation must override the appropriate factory methods to construct objects of the appropriate type.

In addition to these factory methods, there are also methods related to login and logout, server startup and shutdown, and debugging. By default, these methods perform no application-related processing; they merely print a message to the debug log indicating that these events have or are about to occur. If additional processing is required for an application, these methods should be overridden in a subclass of the Server class.

When an Agentry Server with a Java System Connection is started, the server will construct a singleton instance of the Server class or a subclass of it, as specified by the serverClass setting in the Java system connection section of the Agentry.ini file. This Server object will persist until the Agentry Server is shutdown. If the designer has implemented an extension of the Server class, this new class must be named in the serverClass option in the Agentry.ini file in the section containing the configuration options for the Java Interface system connection.

Note, the constructor is public even though this class is a singleton. This is mainly for legacy reasons: the Agentry.ini file names a subclass of this class instead of naming a factory class, and we kept it that way rather than changing it to take a factory class name to maintain compatibility with AJAPI version 4 (since the server supports both versions of the AJAPI).

As such, in this version of the AJAPI, this class is not a strict singleton, although it should be treated as such. Applications should not try to create another instance of it, although it is acceptable (since it is hard to avoid) to do so in unit tests.

Eventually, this class will likely become a true singleton and the Agentry server will adopt the factory pattern to instantiate it, so you may wish to do so now in unit tests using a factory similar to:

public class ServerFactory
{
       private static class LazyHolder
       {
               private static final Server _instance = new Server();
       }

       public static Server getServerInstance()
       {
               return LazyHolder._instance;
       }
}

(Note, this example follows the "Initialization on Demand Holder" pattern; see this article on Wikipedia for information on how/why it works.)