com.sap.conn.jco.server
Interface JCoServer


public interface JCoServer

JCo Server APIs. The JCoServer interface provides access to the public APIs in the JCo server implementation. Applications implementing server applications use the JCoServerFactory to create an instance of the JCoServer. Once the server instance is created, the application can customize and then start it. The connections will be opened asynchronously. JCoServer provides the following features:

JCo distribution provides example StepByStepServer.java covering the basic topics. StatefulServerExample.java covers the implementation of the stateful requests.

See Also:
JCoServerFactory.getServer(String)

Method Summary
 void addServerErrorListener(JCoServerErrorListener listener)
          Adds an error listener to the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.
 void addServerExceptionListener(JCoServerExceptionListener listener)
          Adds an exception listener to the list of listeners.
If a listener is added as listener during firing of an event, it wont be notified about the last event.
 void addServerStateChangedListener(JCoServerStateChangedListener listener)
          Adds a state changed listener to the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.
 JCoServerCallHandlerFactory getCallHandlerFactory()
           
 int getConnectionCount()
          returns the initial connection count for this server
 java.lang.String getGatewayHost()
          Returns the gateway host as defined by the server configuration.
 java.lang.String getGatewayService()
          Returns the gateway service (or port) as defined by the server configuration.
 JCoServerMonitor getMonitor()
           
 java.lang.String getMySncName()
          Returns the SNC name as defined by the server configuration.
 java.lang.String getProgramID()
          Returns the program id as defined by the server configuration.
 java.lang.String getProperty(java.lang.String key)
          Returns the value for a property defined by the server configuration.
 JCoRepository getRepository()
          Returns the default repository instance used by this server instance.
 JCoRepository getRepository(JCoServerContextInfo serverContext)
          Returns the repository instance used by this server instance for the specified request context.
 java.lang.String getRepositoryDestination()
          Returns the repository destination name for obtaining the default repository.
 java.lang.String getSAPRouterString()
          Returns the SAP-Router string as defined by the server configuration.
 JCoServerSecurityHandler getSecurityHandler()
           
 JCoServerThreadStarter getServerThreadStarter()
           
 java.lang.String getSncLibrary()
          Returns the path to the SNC library as defined by the server configuration.
 boolean getSncMode()
          Returns true if the server is configured to use SNC connection.
 int getSncQOP()
          Returns the QOP level of SNC as defined by the server configuration.
 JCoServerState getState()
          Returns the current state of the server instance.
 JCoThroughput getThroughput()
          Returns the throughput instance
 JCoServerTIDHandler getTIDHandler()
           
 JCoServerUnitIDHandler getUnitIDHandler()
          Returns the current unit ID handler.
 boolean isValid()
          Returns true if the corresponding server configuration was neither changed nor removed, false otherwise.
 void release()
          Releases all resources allocated by the server instance.
 void removeServerErrorListener(JCoServerErrorListener listener)
          Removes an error listener from the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.
 void removeServerExceptionListener(JCoServerExceptionListener listener)
          Removes an exception listener from the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.
 void removeServerStateChangedListener(JCoServerStateChangedListener listener)
          Removes a state changed listener from the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.
 void removeThroughput()
          Removes the throughput instance from the server.
 void setCallHandlerFactory(JCoServerCallHandlerFactory callHandlerFactory)
          Defines the call handler factory that will be used by the JCo runtime to get a handler instance if a remote call is invoked.
 void setConnectionCount(int count)
          Defines the count of the registered connections managed by this server instance.
 void setRepository(JCoDestination destination)
          Sets the destination instance which is used for obtaining the default repository for querying RFC meta data.
 void setRepository(JCoRepository repository)
          Sets the default repository instance which is being used for querying RFC meta data.
 void setRepository(java.lang.String sID, java.lang.String client, JCoDestination destination)
          Sets the repository destination instance for incoming RFC calls from the system with the system ID SID and - if defined - with the appropriate client.
 void setRepository(java.lang.String sID, java.lang.String client, JCoRepository repository)
          Sets the repository instance for incoming RFC calls from the system with the system ID SID and - if defined - with the appropriate client.
 void setSecurityHandler(JCoServerSecurityHandler securityManager)
          Defines the security handler for this server instance.
 void setServerThreadStarter(JCoServerThreadStarter starter)
          Defines the instance that will starts the server runnable instance.
 void setThroughput(JCoThroughput throughput)
          sets the throughput instance to measure the calls dispatched by this server The previously defined throughput instance will be overwritten.
 void setTIDHandler(JCoServerTIDHandler tidHandler)
          Allow to specify the TID handler.
 void setUnitIDHandler(JCoServerUnitIDHandler unitIDHandler)
          Allow to specify the unit ID handler.
 void start()
          Starts the server.
 void stop()
          Stops the server.
 

Method Detail

start

void start()
Starts the server. The server will open the specified number of connections.

See Also:
setConnectionCount(int)

stop

void stop()
Stops the server. All connections will be closed, cached requests will not be processed and aborted.

See Also:
setConnectionCount(int)

setConnectionCount

void setConnectionCount(int count)
Defines the count of the registered connections managed by this server instance. This API has to be invoked before the start of the server and may be invoke at runtime. The valid value range is [1..100]. Note: in most scenarios 2 connections are enough for the servers serves business calls and 1 connection for the servers used for technical/administrative purposes.


getConnectionCount

int getConnectionCount()
returns the initial connection count for this server

Returns:
connection count

release

void release()
Releases all resources allocated by the server instance. This method can be only used after all server worker threads are stopped.

Throws:
JCoRuntimeException - in case some workers are still running

getRepository

JCoRepository getRepository()
Returns the default repository instance used by this server instance.

Returns:
server's default repository

getRepository

JCoRepository getRepository(JCoServerContextInfo serverContext)
Returns the repository instance used by this server instance for the specified request context.

Parameters:
serverContext - request context
Returns:
server's repository
Since:
JCo 3.0.5

setRepository

void setRepository(JCoDestination destination)
Sets the destination instance which is used for obtaining the default repository for querying RFC meta data. A previously defined default repository that has been set by calling setRepository(JCoRepository) will be overwritten by this method.

Parameters:
destination - a destination being used for obtaining the default repository
Since:
JCo 3.0.11

setRepository

void setRepository(JCoRepository repository)
Sets the default repository instance which is being used for querying RFC meta data. A previously defined repository destination that has been set by calling setRepository(JCoDestination) will be overwritten by this method.

Parameters:
repository - either a custom repository or a repository connected to an ABAP server

setRepository

void setRepository(java.lang.String sID,
                   java.lang.String client,
                   JCoDestination destination)
                   throws JCoRuntimeException
Sets the repository destination instance for incoming RFC calls from the system with the system ID SID and - if defined - with the appropriate client. If the client is not relevant it may be null. If no matching SID and client combination is defined, the repository for the specified SID only will be used. If also no SID is defined, the current default repository will be used for processing the appropriate RFC call.
An already defined corresponding repository rule that has been set before by calling setRepository(String, String, JCoRepository) will be overwritten by this method.

Parameters:
sID - system ID of the SAP ABAP System containing exactly 3-letters
client - null or the client containing exactly 3 digits
destination - destination instance to be used for obtaining a repository if sID and client are matching
Throws:
JCoRuntimeException - is thrown if sID or client is illegal.
Since:
JCo 3.0.11

setRepository

void setRepository(java.lang.String sID,
                   java.lang.String client,
                   JCoRepository repository)
                   throws JCoRuntimeException
Sets the repository instance for incoming RFC calls from the system with the system ID SID and - if defined - with the appropriate client. If the client is not relevant it may be null. If no matching SID and client combination is defined, the repository for the specified SID only will be used. If also no SID is defined, the current default repository will be used for processing the appropriate RFC call.
An already defined corresponding repository destination rule that has been set before by calling setRepository(String, String, JCoDestination) will be overwritten by this method.

Parameters:
sID - system ID of the SAP ABAP System containing exactly 3-letters
client - null or the client containing exactly 3 digits
repository - repository instance to be used if sID and client are matching
Throws:
JCoRuntimeException - is thrown if sID or client is illegal.
Since:
JCo 3.0.5

getGatewayHost

java.lang.String getGatewayHost()
Returns the gateway host as defined by the server configuration.

Returns:
gateway host as string

getGatewayService

java.lang.String getGatewayService()
Returns the gateway service (or port) as defined by the server configuration.

Returns:
gateway service as string

getSAPRouterString

java.lang.String getSAPRouterString()
Returns the SAP-Router string as defined by the server configuration. The router string will be used to locate the gateway. The router string contains one or more routers with the follow format /H/[/S/][/P/]

Returns:
SAP router string

getProgramID

java.lang.String getProgramID()
Returns the program id as defined by the server configuration.

Returns:
program id as string

getSncMode

boolean getSncMode()
Returns true if the server is configured to use SNC connection.

Returns:
true if SNC is on

getMySncName

java.lang.String getMySncName()
Returns the SNC name as defined by the server configuration.

Returns:
SNC name as string

getSncQOP

int getSncQOP()
Returns the QOP level of SNC as defined by the server configuration.

Returns:
QOP level of SNC as number

getSncLibrary

java.lang.String getSncLibrary()
Returns the path to the SNC library as defined by the server configuration.

Returns:
path to the SNC library as string

getProperty

java.lang.String getProperty(java.lang.String key)
Returns the value for a property defined by the server configuration.

Returns:
value for the specified property

getRepositoryDestination

java.lang.String getRepositoryDestination()
Returns the repository destination name for obtaining the default repository.

Returns:
the specified default repository destination name

setCallHandlerFactory

void setCallHandlerFactory(JCoServerCallHandlerFactory callHandlerFactory)
Defines the call handler factory that will be used by the JCo runtime to get a handler instance if a remote call is invoked. Factory for the call handlers is required. Until a factory is defined the server instance cannot be started. callHandlerFactory has to be an instance of JCoServerRequestHandlerFactory or JCoServerFunctionHandlerFactory. Otherwise an JCoRuntimeException will be thrown.

Parameters:
callHandlerFactory - to be use by the server
See Also:
DefaultServerHandlerFactory

getCallHandlerFactory

JCoServerCallHandlerFactory getCallHandlerFactory()
Returns:
reference to the factory for call handlers set for this server instance

setTIDHandler

void setTIDHandler(JCoServerTIDHandler tidHandler)
Allow to specify the TID handler. The calls sent in "background task" (tRFC) are identified by a unique TID. To ensure the proper TID handling and to separate the TID handling from the application logic, the method handling with TIDs are gathered together in the JCoServerTIDHandler. Each the application dispatching the tRFC calls, has to provide an implementation for the JCoServerTIDHandler interface.

Parameters:
tidHandler - instance implementation the TID handling

getTIDHandler

JCoServerTIDHandler getTIDHandler()
Returns:
the current TID handler or null

setUnitIDHandler

void setUnitIDHandler(JCoServerUnitIDHandler unitIDHandler)
Allow to specify the unit ID handler. The calls sent by the ABAP server in background unit contains an unique ID. The treatment of the unit IDs is similar to the TID handling. To insure, that the application aware of differences in the TID and unit ID handling, unit ID handling is defined by the additional interface JCoServerUnitIDHandler.

Parameters:
unitIDHandler -

getUnitIDHandler

JCoServerUnitIDHandler getUnitIDHandler()
Returns the current unit ID handler.

Returns:
the unit ID handler or null

setSecurityHandler

void setSecurityHandler(JCoServerSecurityHandler securityManager)
Defines the security handler for this server instance. Security handler will be invoked by the JCo runtime to check the permissions of the user initiated the remote call.
Note:once the security handler is set it is not possible to change it due to security reasons. The only way to change the implementation of the security handler is to create/start an other server instance.


getSecurityHandler

JCoServerSecurityHandler getSecurityHandler()
Returns:
the reference to the security handler set for this server instance

setServerThreadStarter

void setServerThreadStarter(JCoServerThreadStarter starter)
Defines the instance that will starts the server runnable instance. In some environments the starting new threads by Thread.start() is permitted and may be done using special APIs only. In this case the application may provide its own implementation to start the server threads.

Parameters:
starter - instance that starts new server worker threads

getServerThreadStarter

JCoServerThreadStarter getServerThreadStarter()
Returns:
reference to the JCoServerThreadStarter, if defined, or null

addServerErrorListener

void addServerErrorListener(JCoServerErrorListener listener)
Adds an error listener to the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.

Parameters:
listener - the listener to add
See Also:
removeServerErrorListener(com.sap.conn.jco.server.JCoServerErrorListener)

addServerExceptionListener

void addServerExceptionListener(JCoServerExceptionListener listener)
Adds an exception listener to the list of listeners.
If a listener is added as listener during firing of an event, it wont be notified about the last event.

Parameters:
listener - the listener to add
See Also:
removeServerExceptionListener(com.sap.conn.jco.server.JCoServerExceptionListener)

addServerStateChangedListener

void addServerStateChangedListener(JCoServerStateChangedListener listener)
Adds a state changed listener to the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.

Parameters:
listener - the listener to add
See Also:
removeServerStateChangedListener(com.sap.conn.jco.server.JCoServerStateChangedListener)

removeServerErrorListener

void removeServerErrorListener(JCoServerErrorListener listener)
Removes an error listener from the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.

Parameters:
listener - the listener to remove
See Also:
addServerErrorListener(com.sap.conn.jco.server.JCoServerErrorListener)

removeServerExceptionListener

void removeServerExceptionListener(JCoServerExceptionListener listener)
Removes an exception listener from the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.

Parameters:
listener - the listener to remove
See Also:
addServerExceptionListener(com.sap.conn.jco.server.JCoServerExceptionListener)

removeServerStateChangedListener

void removeServerStateChangedListener(JCoServerStateChangedListener listener)
Removes a state changed listener from the list of listeners.
If a listener is removed from the list of listeners during firing of an event, it will be notified about the last event.

Parameters:
listener - the listener to remove
See Also:
addServerStateChangedListener(com.sap.conn.jco.server.JCoServerStateChangedListener)

setThroughput

void setThroughput(JCoThroughput throughput)
sets the throughput instance to measure the calls dispatched by this server The previously defined throughput instance will be overwritten.

Parameters:
throughput -

getThroughput

JCoThroughput getThroughput()
Returns the throughput instance

Returns:
the throughput instance

removeThroughput

void removeThroughput()
Removes the throughput instance from the server. The measuring will be deactivated.


getMonitor

JCoServerMonitor getMonitor()
Returns:
the monitor instance for this server

getState

JCoServerState getState()
Returns the current state of the server instance.

Returns:
state as JCoServer.State

isValid

boolean isValid()
Returns true if the corresponding server configuration was neither changed nor removed, false otherwise.

Returns:
true if server configuration was neither changed nor removed
Since:
JCo 3.0.7


Copyright © 2008-2014 SAP AG. All Rights Reserved.