...
USE BUILTIN(JSM_OPEN) TO_GET(#JSMSTS #JSMMSG)
USE BUILTIN(JSM_COMMAND) WITH_ARGS(SERVICE_LOAD(XYZSERVICE) TRACE(*YES)) TO_GET(#JSMSTS #JSMMSG)
USE BUILTIN(JSM_COMMAND) WITH_ARGS(SERVICE_UNLOAD) TO_GET(#JSMSTS #JSMMSG)
USE BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)
Sample XYZService code
| Code Block |
|---|
|
package com.lansa.jsm.userdefined ; |
...
...
...
...
...
public final class XYZService implements JSMService |
...
...
private JSMTrace m_trace = null ; |
...
private JSMResource m_serviceResource = null ; |
...
...
...
if ( !JSMManager.isLicenced ( this ) ) |
...
...
throw new IllegalArgumentException ( "Class is not licenced : " + this.getClass().getName() ) ; |
...
...
...
public final void service ( JSMContainer container ) |
...
...
m_trace = container.getServiceTrace () ; |
...
m_serviceResource = container.getServiceResource () ; |
...
...
public final JSMResponse command ( JSMCommand command ) throws JSMException |
...
...
...
...
...
...
m_trace.print ( command ) ; |
...
...
JSMResponse response = runCommand ( command ) ; |
...
...
...
m_trace.print ( command, response ) ; |
...
...
...
...
...
...
...
...
m_trace.print ( command, t ) ; |
...
...
return new JSMResponse ( t ) ; |
...
...
...
private final JSMResponse runCommand ( JSMCommand command ) throws Exception |
...
...
if ( command.equals ( JSMCommand.SERVICE_LOAD ) ) |
...
...
return commandLOAD ( command ) ; |
...
...
if ( command.equals ( JSMCommand.SERVICE_UNLOAD ) ) |
...
...
return commandUNLOAD ( command ) ; |
...
...
if ( command.equals ( "SEND" ) ) |
...
...
return commandSEND ( command ) ; |
...
...
return new JSMResponse ( JSMResponse.ERROR, m_serviceResource.getResource ( "message.003" ) + " " + command.getCommand () ) ; |
...
...
private final JSMResponse commandLOAD ( JSMCommand command ) throws Exception |
...
...
return new JSMResponse ( m_serviceResource.getResource ( "message.001" ) ) ; |
...
...
private final JSMResponse commandUNLOAD ( JSMCommand command ) throws Exception |
...
...
return new JSMResponse ( m_serviceResource.getResource ( "message.002" ) ) ; |
...
...
private final JSMResponse commandSEND ( JSMCommand command ) throws Exception |
...
...
return new JSMResponse ( "" ) ; |
...
...