Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
languagejava
package com.lansa.jsm.userdefined ;

...



import java.io.* ;

...


import java.net.* ;

...


import java.util.* ;

...



import com.lansa.jsm.* ;

...



public final class XYZService implements JSMService

...


{

...


    private JSMTrace m_trace = null ;

...


    private JSMResource m_serviceResource = null ;

...


    public XYZService ()

...


    {

...


        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

...


    {

...


        try

...


        {

...


            if ( m_trace != null )

...


            {

...


                m_trace.print ( command ) ;

...


            }

...



            JSMResponse response = runCommand ( command ) ;

...



            if ( m_trace != null )

...


            {

...


                m_trace.print ( command, response ) ;

...


            }

...


            return response ;

...


        }

...


        catch ( Throwable t )

...


        {

...


            if ( m_trace != null )

...


            {

...


                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 ( "" ) ;

...


    }

...


}