public abstract class Server extends Object implements ServerInterface
Agents and protocol servers are two types of Server. An agent is an
application that runs unattended and performs some operation, either
periodically or in response to an IfsEvent. A protocol server opens
a java.net.ServerSocket
, awaits connections from clients,
and performs operations dictated by a protocol specification in response
to client requests.
To create a server, you can write a concrete subclass of this Server class. An easier approach, however, is to subclass IfsServer, which provides default implementations for methods, and provides tools for easily writing a thread-safe event-driven or timer-driven application.
Modifier and Type | Field and Description |
---|---|
static int |
LEVEL_HIGH
Deprecated.
CM SDK 10g: Use IfsLogger for logging
|
static int |
LEVEL_LOW
Deprecated.
CM SDK 10g: Use IfsLogger for logging
|
static int |
LEVEL_MEDIUM
Deprecated.
CM SDK 10g: Use IfsLogger for logging
|
static int |
LEVEL_OFF
Deprecated.
CM SDK 10g: Use IfsLogger for logging
|
SERVERSTATUS_DISPOSED, SERVERSTATUS_RUNNING, SERVERSTATUS_STARTING, SERVERSTATUS_STOPPED, SERVERSTATUS_STOPPING, SERVERSTATUS_SUSPENDED, SERVERSTATUS_UNKNOWN
Constructor and Description |
---|
Server()
Constructs a Server.
|
Modifier and Type | Method and Description |
---|---|
protected LibrarySession |
acquireSession()
Acquires a LibrarySession from the session pool.
|
protected LibrarySessionPool |
constructLibrarySessionPool(int maxSessCount,
String serviceName,
String appName,
SystemUserCredential cred)
Constructs a LibrarySessionPool.
|
AttributeValue |
createServerState()
Creates a ServerState if it has not yet been created.
|
protected void |
deregister()
Deregisters this Server.
|
protected void |
disconnectSession()
Disconnects the Server's session.
|
AttributeValueTable |
getConfigurationOverridesTable()
Gets the configuration overrides specified for this Server.
|
AttributeValueTable |
getConfigurationTable()
Gets the effective configuration parameters for this Server,
representing the combination of the initial
Configuration and any overrides that have been applied.
|
Credential |
getCredential(String name)
Gets a Credential for the specified user.
|
int |
getDesiredStatus()
Gets the desired status of this Server.
|
String |
getIfsHome()
Gets the CM SDK home directory for this Server's node.
|
AttributeValueTable |
getInitialConfigurationTable()
Gets the initial configuration parameters for this Server as
an AttributeValueTable.
|
IfsLogger |
getLogger()
Gets the appropriate logger for this server.
|
protected IfsLogger |
getLoggerForLegacyLogging()
Gets the IfsLogger to use for legacy logging.
|
String |
getName()
Gets the name of this Server.
|
protected NodeInterface |
getNode()
Gets the Node that manages this Server.
|
String |
getNodeName()
Gets the name of the node for this Server.
|
String |
getOracleHome()
Deprecated.
9.3.4.0: no longer a property that the Node makes available
|
ParameterTable |
getParameterTable()
Gets the configuration parameters for this Server as
an immutable ParameterTable.
|
int |
getPriority()
Gets the priority of this Server.
|
AttributeValue[] |
getProperties()
Gets the values for all dynamic properties for this Server.
|
AttributeValue |
getProperty(String name)
Gets the value of the specified dynamic property for this Server.
|
String |
getServerConfigurationName()
Gets the server configuration name of this Server.
|
ServerState |
getServerState(LibrarySession session)
Gets the ServerState for this Server.
|
AttributeValue |
getServerStateValue()
Gets the ServerState value.
|
String |
getServerType()
Gets the type of this Server.
|
String |
getServiceName()
Gets the name of the default service for this Server.
|
protected LibrarySession |
getSession()
Gets the session for this Server.
|
AttributeValueTable |
getStateTable()
Gets the runtime state table.
|
int |
getStatus()
Gets the status of this Server.
|
SystemUserCredential |
getSystemUserCredential()
Gets a System user credential.
|
void |
handleServerConfigurationOverrideRequest(ServerState ss)
Handle ServerConfiguration overrides that have been posted.
|
protected void |
handleServerStateEvent(String eventKey)
Handle a ServerState event.
|
void |
initialize()
Initializes this Server.
|
void |
initialize(String name,
NodeInterface node,
LibrarySessionPool sessionPool,
AttributeValueTable initialConfig,
AttributeValueTable overrides)
Initializes this Server (managed by Node).
|
void |
initialize(String name,
String serviceName,
String schemaPassword,
ParameterTable parameterTable)
Initializes this Server (standalone).
|
boolean |
isAgent()
Gets whether this Server is an agent.
|
protected boolean |
isDisposed()
Gets whether this Server has been disposed.
|
boolean |
isInitialized()
Gets whether this Server has been initialized and not disposed.
|
boolean |
isLogged(int level)
Deprecated.
: Use IfsLogger for logging
|
void |
log(int level,
String message)
Deprecated.
: Use IfsLogger for logging
|
void |
log(int level,
String message,
Throwable throwable)
Deprecated.
: Use IfsLogger for logging
|
void |
log(int level,
Throwable throwable)
Deprecated.
: Use IfsLogger for logging
|
protected void |
releaseSession()
Releases the Server's session back to the session pool.
|
protected void |
releaseSession(LibrarySession session)
Releases the specified session (that was previously acquired)
back to the pool.
|
protected void |
setDesiredStatus(int status)
Sets the desired status of this Server.
|
protected void |
setDesiredStatus(int status,
boolean force)
Sets the desired status of this Server.
|
void |
setPriority(int priority)
Sets the priority of this Server.
|
void |
setSessionTimeoutPrevented(boolean prevented)
Sets an indication as to whether or not sessions used by the Server
should be prevented from timing out on long-running operations.
|
protected void |
setStateProperty(AttributeValue av)
Called when a dynamic (State) property of this Server is set or changed.
|
protected void |
setStatus(int status)
Sets the status of this Server.
|
void |
startStandalone(String name,
ParameterTable pt)
Starts the server when run in standalone mode with the server
properties specified as a ParameterTable.
|
void |
startStandalone(String name,
String[] args)
Starts the server when run via a static main in standalone mode.
|
boolean |
supportsPriority()
Gets whether this Server supports set/get priority.
|
boolean |
supportsSuspendResume()
Gets whether this Server supports suspend/resume.
|
static String |
toStatusLabel(int status)
Gets a localized label for the specified status of a Server, using a
default Localizer.
|
static String |
toStatusLabel(int status,
LibrarySessionInterface session)
Gets a localized label for the specified status of a Server, using the
specified session's Localizer.
|
static String |
toStatusLabel(int serverStatus,
Localizer localizer)
Gets a localized label for the specified status of a Server, using the
specified Localizer.
|
protected void |
verifyNotDisposed()
Verifies this Server has not been disposed.
|
protected void |
verifyNotDisposed(int rethrowCode)
Verifies this Server has not been disposed, and re-throws an IfsException
of the specified code.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dispose, isPropertyReadonly, restart, resume, setProperty, start, stop, suspend
public static final int LEVEL_OFF
public static final int LEVEL_LOW
public static final int LEVEL_MEDIUM
public static final int LEVEL_HIGH
public Server() throws IfsException
Subclasses should provide a zero-argument constructor.
IfsException
- if the operation failspublic void startStandalone(String name, String[] args) throws IfsException
name
- the name of the Serverargs
- the arguments supplied to the static mainException
- if the operation failsIfsException
public void startStandalone(String name, ParameterTable pt) throws IfsException
name
- the name of the Serverpt
- the server propertiesIfsException
- if the operation failspublic void initialize() throws Exception
This method is called when the Server is first loaded. This method is typically implemented by each Server implementation.
Exception
- if the operation failspublic void initialize(String name, NodeInterface node, LibrarySessionPool sessionPool, AttributeValueTable initialConfig, AttributeValueTable overrides) throws IfsException
This method is called by Node in setting up Servers to be started.
name
- the name of the Servernode
- the managing Node contextsessionPool
- the LibrarySession pool to use for session factoryinitialConfig
- the initial Server configuration parametersoverrides
- the Server configuration parameter overridesIfsException
- if the operation failspublic void initialize(String name, String serviceName, String schemaPassword, ParameterTable parameterTable) throws IfsException
This method should be called when starting a Server outside the domain administration framework. For such a standalone Server, call this method immediately after the Server is constructed.
name
- the name of the ServerserviceName
- the name of the default service used
by this Server; this service must be
already startedschemaPassword
- the schema passwordparameterTable
- the Server configuration parametersIfsException
- (IFS-45201) if the operation failspublic AttributeValue getServerStateValue() throws IfsException
IfsException
- if the operation failspublic AttributeValue createServerState() throws IfsException
IfsException
- if the operation failspublic ServerState getServerState(LibrarySession session) throws IfsException
IfsException
- if the operation failspublic String getName() throws IfsException
getName
in interface ServerInterface
IfsException
- (IFS-45160) if the operation failspublic String getServerConfigurationName() throws IfsException
getServerConfigurationName
in interface ServerInterface
IfsException
- (IFS-45179) if the operation failspublic String getServiceName() throws IfsException
getServiceName
in interface ServerInterface
IfsException
- if the operation failspublic String getServerType() throws IfsException
Returns the fully-qualified classname of this Server.
getServerType
in interface ServerInterface
IfsException
- (IFS-45177) if the operation failspublic boolean isAgent() throws IfsException
Returns false by default.
isAgent
in interface ServerInterface
IfsException
- (IFS-45178) if the operation failspublic int getStatus()
getStatus
in interface ServerInterface
public int getDesiredStatus()
public boolean supportsSuspendResume() throws IfsException
If false, then suspend
and resume
will result in stop and start instead.
supportsSuspendResume
in interface ServerInterface
IfsException
- if the operation failspublic boolean supportsPriority() throws IfsException
If false, then setPriority
and getPriority
will throw an exception.
supportsPriority
in interface ServerInterface
IfsException
- if the operation failspublic boolean isInitialized() throws IfsException
IfsException
- if the operation failspublic ParameterTable getParameterTable() throws IfsException
These configuration parameters are provided by the Node in loading the Server, and are immutable.
IfsException
- if the operation failspublic AttributeValueTable getInitialConfigurationTable() throws IfsException
The configuration parameters are provided by the Node in loading the Server, and are not subsequently updated.
IfsException
- if the operation failspublic AttributeValueTable getConfigurationTable() throws IfsException
The configuration parameters are provided by the Node in loading the Server, and are updated whenever a Configuration Override is applied to the active Server.
IfsException
- if the operation failspublic AttributeValueTable getConfigurationOverridesTable() throws IfsException
The configuration overrides are provided by the Node in loading the Server, and are updated whenever a Configuration Override is applied to the active Server.
IfsException
- if the operation failspublic AttributeValueTable getStateTable() throws IfsException
IfsException
- if the operation failsprotected NodeInterface getNode() throws IfsException
IfsException
- if the operation failspublic String getNodeName() throws IfsException
IfsException
- if the operation failspublic String getOracleHome() throws IfsException
The Oracle home directory is specified by the Server's
IFS.SERVER.OracleHome
parameter.
IfsException
- (IFS-45208) if the operation failspublic String getIfsHome() throws IfsException
The CM SDK home directory is specified by the node's
IFS.NODE.IfsHome
parameter.
(For standalone Servers, the CM SDK home directory
is specified by the server's parameter named
IFS.NODE.IfsHome
.)
IfsException
- (IFS-45207) if the operation failspublic IfsLogger getLogger()
Typically overridden by subclasses to return the IfsLogger associatged with the specific server.
protected LibrarySession acquireSession() throws IfsException
IfsException
- if the operation failsprotected LibrarySession getSession()
protected void releaseSession() throws IfsException
IfsException
- if the operation failsprotected void releaseSession(LibrarySession session) throws IfsException
session
- the sessionIfsException
- if the operation failsprotected void disconnectSession() throws IfsException
If there is no Server session, no action is taken. Any exception that occurs in disconnecting the session is consumed.
IfsException
- if the operation failspublic void setSessionTimeoutPrevented(boolean prevented) throws IfsException
If set to true, then all new LibrarySessions created as a result of
getSession
or acquireSession
calls will
not incur session timeouts due to long-running operations.
If this option is changed after obtaining a session, the current session
is not changed.
It is best to invoke this method during initialize
so that all sessions created subsequently have the desired behavior
with respect to session timeouts.
prevented
- true if session timeouts are to be prevented.IfsException
- if the operation failspublic SystemUserCredential getSystemUserCredential() throws IfsException
IfsException
- if the operation failsprotected LibrarySessionPool constructLibrarySessionPool(int maxSessCount, String serviceName, String appName, SystemUserCredential cred) throws IfsException
maxSessCount
- the maximum number of sessions that can
be constructed by this poolserviceName
- the service nameappName
- the application name (for DB connection metadata)cred
- the system user credentialsIfsException
- if the operation failspublic Credential getCredential(String name) throws IfsException
A TokenCredential is returned. In this way, this Server can obtain a valid Credential for any CM SDK user without that user's password.
The generated TokenCredential is valid for one use or 600 seconds, whichever comes first.
name
- the user nameIfsException
- (IFS-45206) if the operation failspublic AttributeValue getProperty(String name) throws IfsException
getProperty
in interface ServerInterface
name
- the property nameIfsException
- (IFS-45172) if the operation failspublic AttributeValue[] getProperties() throws IfsException
getProperties
in interface ServerInterface
IfsException
- (IFS-45173) if the operation failsprotected void setStateProperty(AttributeValue av) throws IfsException
av
- the property (name and value assumed to be set)IfsException
- if the operation failsprotected void handleServerStateEvent(String eventKey) throws IfsException
eventKey
- the ServerState event keyIfsException
- if the operation failspublic void handleServerConfigurationOverrideRequest(ServerState ss) throws IfsException
ss
- the ServerState instanceIfsException
- if the operation failsprotected void setDesiredStatus(int status) throws IfsException
status
- the new statusIfsException
- if the operation failsprotected void setDesiredStatus(int status, boolean force) throws IfsException
status
- the new statusforce
- if true, set the desired status regardless of
the current statusIfsException
- if the operation failsprotected void setStatus(int status) throws IfsException
status
- the new statusIfsException
- if the operation failsprotected void deregister() throws IfsException
This method called after the Server is disposed, so that it can notify its managing Node (if any) that it is disposed.
IfsException
- (IFS-45205) if the operation failspublic int getPriority() throws IfsException
getPriority
in interface ServerInterface
IfsException
- if the operation failspublic void setPriority(int priority) throws IfsException
setPriority
in interface ServerInterface
priority
- the priorityIfsException
- if the operation failspublic static String toStatusLabel(int status) throws IfsException
Equivalent to toStatusLabel(status, null)
.
status
- the statusIfsException
- if the operation failspublic static String toStatusLabel(int status, LibrarySessionInterface session) throws IfsException
Equivalent to toStatusLabel(status, session.getLocalizer())
.
status
- the statussession
- the sessionIfsException
- if the operation failspublic static String toStatusLabel(int serverStatus, Localizer localizer) throws IfsException
If localizer
is null, this method is equivalent to
toStatusLabel(status, new Localizer())
.
serverStatus
- the statuslocalizer
- the LocalizerIfsException
- if the operation failsprotected boolean isDisposed() throws IfsException
IfsException
- if this Server has been disposedprotected final void verifyNotDisposed() throws IfsException
The getStatus
method is called to check
the status of this Server.
Invoking methods on a disposed Server (other than
getStatus
, getName
and
deregister
) is illegal and should throw
an exception. Call this method to perform that check.
IfsException
- (IFS-45203) if this Server has been disposedprotected final void verifyNotDisposed(int rethrowCode) throws IfsException
IfsException
- if this Server has been disposedprotected IfsLogger getLoggerForLegacyLogging()
public void log(int level, String message)
level
- the minimum logging level for the messagemessage
- the messagepublic void log(int level, Throwable throwable)
level
- the minimum logging level for the messagethrowable
- the throwablepublic void log(int level, String message, Throwable throwable)
level
- the minimum logging level for the messagemessage
- the messagethrowable
- the throwablepublic boolean isLogged(int level)
log
with the specified logging
level would cause a message to be logged.level
- the logging levelCopyright © 2023. All rights reserved.