cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping JcoServer in another class.

Former Member
0 Kudos

I am a beginner.I am starting the  JCoServer when application server is started in Java .It works.This is for the Outbound process.For some other process,I need to stop the server.I want to stop the server in another class.There I am creating an instance of JcoServer class and setting it as stop.I need to ask ,whether the server  I am trying to stop now would stop the same Jcoserver instance that I  had stared previously in another class?

JCoIDocServer server = (JCoIDocServer) SIALJCOServerManager.getServer("IDOC_SERVER_Q47");

server.stop();

server.getState());;

Accepted Solutions (0)

Answers (2)

Answers (2)

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Shefali,

as I don't know what class SIALJCOServerManager is, I can only give a general answer:

With SAP's current implementation, JCoServerFactory.getServer(String serverName) and JCoIDoc.getServer(String serverName) will return the same object instance for the same given serverName, if the SAP Java IDoc Class Library has been initialized before the call (i.e. some JIDocLib API has already been invoked). The returned object instance then always implements the JCoIDocServer interface which is an extension of the JCoServer interface and therefore also a potential upcast of JCoServer to JCoIDocServer works then. But it is not guaranteed that such an upcast from JCoServer to JCoIDocServer for objects returned from JCoServerFactory.getServer(String serverName) will also work with future implementations of the JCo or the JIDocLib.

If you always work with the JIDocLib, I recommend to only use the API JCoIDoc.getServer(String serverName) for getting the JCoIDocServer instance, thus avoiding unsafe upcast operations. Besides, the JCoServer interface would be sufficient for only stopping the server or getting its state in your example.

Best regard,
Stefan

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Shefali,

assuming that you also started the server for IDOC_SERVER_Q47 and SIALJCOServerManager is wrapping the JCoServerFactory or JCoIDoc.getServer(), the the code above will stop the server and server,getState() will return STOPPED when invoked late enough, before it will be STOPPING.

Not necessary to mention that it needs to happen in the same Java process, I guess ...

Best regards,

Markus