IBM Branch Transformation Toolkit Javadoc

com.ibm.dse.services.wosa
Class WOSADeviceService

java.lang.Object
  extended bycom.ibm.dse.base.DSENotifier
      extended bycom.ibm.dse.base.Service
          extended bycom.ibm.dse.services.wosa.WOSADeviceService
All Implemented Interfaces:
java.util.EventListener, Externalizable, java.io.Externalizable, Notifier, java.lang.Runnable, java.io.Serializable, WOSACmdListener, WOSADeviceServiceInterface, WOSADevListener

public class WOSADeviceService
extends Service
implements WOSADeviceServiceInterface, java.lang.Runnable, WOSACmdListener, WOSADevListener

The WOSADeviceService class is the WOSA Services base class. It interfaces with theWOSA/XFS (WOSA for short) via JNI and provides a subset of the WOSA asynchronous functions. The WOSA calls are issued in the caller thread and are directly mapped to the WOSA layer through JNI. A WOSA message is signalled by a waiting thread by using both the CBTF and JavaBeans event mechanism.

Notice: Some knowledge of the WOSA/XFS API is required in order to use this service.

See Also:
Service, Serialized Form

Field Summary
protected  WOSACmdListener aWOSACmdListener
           
protected  WOSADevListener aWOSADevListener
           
 java.lang.String COMPID
           
 java.lang.String logicalName
          Provides the WOSA service provider logical name
protected  java.lang.Thread messageThread
          The thread that waits for Windows/PM WOSA messages
 int timeout
          Provides the timeout in milliseconds for WOSA calls
 
Fields inherited from class com.ibm.dse.base.Service
externalizer
 
Fields inherited from class com.ibm.dse.base.DSENotifier
handlersList, name
 
Fields inherited from interface com.ibm.dse.services.wosa.WOSADeviceServiceInterface
JNI_BAD_INSTANCE, JNI_END_THREAD, JNI_UNKNOWN_INSTANCE, WFS_CLOSE_COMPLETE, WFS_DEREGISTER_COMPLETE, WFS_EXECUTE_COMPLETE, WFS_EXECUTE_EVENT, WFS_GETINFO_COMPLETE, WFS_INDEFINITE_WAIT, WFS_LOCK_COMPLETE, WFS_OPEN_COMPLETE, WFS_REGISTER_COMPLETE, WFS_SERVICE_EVENT, WFS_SUCCESS, WFS_SYSE_APP_DISCONNECT, WFS_SYSE_DEVICE_STATUS, WFS_SYSE_HARDWARE_ERROR, WFS_SYSE_UNDELIVERABLE_MSG, WFS_SYSE_VERSION_ERROR, WFS_SYSTEM_EVENT, WFS_TIMER_EVENT, WFS_UNLOCK_COMPLETE, WFS_USER_EVENT, WM_USER
 
Constructor Summary
WOSADeviceService()
          This constructor creates a WOSADeviceService object.
 
Method Summary
 void addWOSACmdListener(WOSACmdListener newListener)
          Adds a WOSA command listener.
 void addWOSADevListener(WOSADevListener newListener)
          Adds a WOSA device listener.
 WOSAResult cancelCmd()
          Cancels all outstanding requests.
 WOSAResult cancelCmd(int requestID)
          Cancels a request.
 int cleanup()
          Destroys the message thread.
 WOSAResult close()
          Closes the WOSA device.
 WOSAResult execute(WOSAMessageRequest cmd)
          Executes a WOSA service command.
protected  void fireHandleCmd(WOSACmdEvent event)
          Supports listener events.
protected  void fireHandleDevEvt(WOSADevEvent event)
          Supports listener events.
 java.lang.String getDeviceType()
          Returns the externalizable parameter deviceType.
 WOSAResult getInfo(WOSAMessageRequest info)
          Queries device information.
 java.lang.String getLogicalName()
          Returns the externalizable parameter logicalName.
 java.lang.String getSPMMaxVersion()
          Returns the externalizable parameter SPMMaxVersion.
 java.lang.String getSPMMinVersion()
          Returns the externalizable parameter SPMMinVersion.
 java.lang.String getTimeout()
          Returns the externalizable parameter timeout.
 java.lang.String getWosaTraceLevel()
          Returns the externalizable parameter wosaTraceLevel.
 void handleCmd(WOSACmdEvent ev)
          Handles a command event from a JavaBean event source and signals a CBTF event.
 void handleDevEvt(WOSADevEvent ev)
          Handles a device event from a JavaBean event source and signals a CBTF event.
protected  void initDefaults()
          Initializes internal and externalizable variables.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes the service.
 WOSAResult lock()
          Locks the device for exclusive access.
 WOSAResult open()
          Opens a WOSA device.
 void removeWOSACmdListener(WOSACmdListener newListener)
          Removes a WOSA command listener.
 void removeWOSADevListener(WOSADevListener newListener)
          Removes a WOSA device listener.
 void run()
          Provides the WOSA message loop.
 void setDeviceType(java.lang.String n)
          Sets the externalizable parameter deviceType.
 void setLogicalName(java.lang.String ln)
          Sets the externalizable parameter logicalName.
 void setSPMMaxVersion(java.lang.String mv)
          Sets the externalizable parameter SPMMaxVersion.
 void setSPMMinVersion(java.lang.String mv)
          Sets the externalizable parameter SPMMinVersion.
 void setTimeout(java.lang.String t)
          Sets the externalizable parameter timeout.
 void setWosaTraceLevel(java.lang.String l)
          Sets the externalizable parameter wosaTraceLevel.
 int startup()
          Provides instance control and native code binding.
 java.lang.String toString()
          Returns a visual representation of the WOSADeviceService service.
protected  void trace(java.lang.String s)
          Sends a string to the toolkit trace facility.
 WOSAResult unlock()
          Unlocks access to the device.
 
Methods inherited from class com.ibm.dse.base.Service
externalizer, getExternalizer, getTagName, readExternal, readExternal, readObject, removeExternal, setExternalizer, terminate, toStrings, toTags, writeExternal, writeExternal
 
Methods inherited from class com.ibm.dse.base.DSENotifier
addHandler, getHandlersList, getName, removeHandler, setName, signalEvent, signalEvent, signalEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.dse.base.Externalizable
getName, setName
 

Field Detail

timeout

public int timeout
Provides the timeout in milliseconds for WOSA calls


logicalName

public java.lang.String logicalName
Provides the WOSA service provider logical name


messageThread

protected java.lang.Thread messageThread
The thread that waits for Windows/PM WOSA messages


aWOSACmdListener

protected transient WOSACmdListener aWOSACmdListener

aWOSADevListener

protected transient WOSADevListener aWOSADevListener

COMPID

public java.lang.String COMPID
Constructor Detail

WOSADeviceService

public WOSADeviceService()
This constructor creates a WOSADeviceService object.

Method Detail

addWOSACmdListener

public void addWOSACmdListener(WOSACmdListener newListener)
Adds a WOSA command listener.

Parameters:
newListener - WOSACmdListener

addWOSADevListener

public void addWOSADevListener(WOSADevListener newListener)
Adds a WOSA device listener.

Parameters:
newListener - WOSADevListener

cancelCmd

public WOSAResult cancelCmd()
Cancels all outstanding requests. Calls WFSCancelAsyncRequest with 0 as the request ID.

Specified by:
cancelCmd in interface WOSADeviceServiceInterface
Returns:
WOSAResult

cancelCmd

public WOSAResult cancelCmd(int requestID)
Cancels a request. Calls the native WOSA/XFS function WFSCancelAsyncRequest.

Specified by:
cancelCmd in interface WOSADeviceServiceInterface
Parameters:
requestID - the requestID of a previous uncompleted request
Returns:
WOSAResult

cleanup

public int cleanup()
Destroys the message thread. If this is the last WOSA service being deallocated, it calls the WOSA function WFSCleanUp.

Specified by:
cleanup in interface WOSADeviceServiceInterface
Returns:
int

close

public WOSAResult close()
Closes the WOSA device. Calls the native WOSA functions WFSAsyncDeregister and WFSAsyncClose.

Specified by:
close in interface WOSADeviceServiceInterface
Returns:
WOSAResult

execute

public WOSAResult execute(WOSAMessageRequest cmd)
Executes a WOSA service command. Calls the native WOSA function WFSAsyncExecute.

Specified by:
execute in interface WOSADeviceServiceInterface
Parameters:
cmd - command request object, service dependant
Returns:
WOSAResult

fireHandleCmd

protected void fireHandleCmd(WOSACmdEvent event)
Supports listener events.

Parameters:
event - WOSACmdEvent

fireHandleDevEvt

protected void fireHandleDevEvt(WOSADevEvent event)
Supports listener events.

Parameters:
event - WOSADevEvent

getDeviceType

public java.lang.String getDeviceType()
Returns the externalizable parameter deviceType.

Returns:
String

getInfo

public WOSAResult getInfo(WOSAMessageRequest info)
Queries device information. Calls the native WOSA function WFSAsyncGetInfo.

Specified by:
getInfo in interface WOSADeviceServiceInterface
Parameters:
info - WOSAMessageRequest - information request object, service dependant.
Returns:
WOSAResult

getLogicalName

public java.lang.String getLogicalName()
Returns the externalizable parameter logicalName.

Returns:
String

getSPMMaxVersion

public java.lang.String getSPMMaxVersion()
Returns the externalizable parameter SPMMaxVersion.

Returns:
String

getSPMMinVersion

public java.lang.String getSPMMinVersion()
Returns the externalizable parameter SPMMinVersion.

Returns:
String

getTimeout

public java.lang.String getTimeout()
Returns the externalizable parameter timeout..

Returns:
String

getWosaTraceLevel

public java.lang.String getWosaTraceLevel()
Returns the externalizable parameter wosaTraceLevel.

Returns:
String

handleCmd

public void handleCmd(WOSACmdEvent ev)
Handles a command event from a JavaBean event source and signals a CBTF event.

Specified by:
handleCmd in interface WOSACmdListener
Parameters:
ev - WOSACmdEvent

handleDevEvt

public void handleDevEvt(WOSADevEvent ev)
Handles a device event from a JavaBean event source and signals a CBTF event.

Specified by:
handleDevEvt in interface WOSADevListener
Parameters:
ev - WOSADevEvent

initDefaults

protected void initDefaults()
Initializes internal and externalizable variables.


initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException
Initializes the service.

Specified by:
initializeFrom in interface Externalizable
Overrides:
initializeFrom in class Service
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException - thrown when an IO exception happens

lock

public WOSAResult lock()
Locks the device for exclusive access. Calls the WOSA native function WFSAsyncLock.

Specified by:
lock in interface WOSADeviceServiceInterface
Returns:
WOSAResult

open

public WOSAResult open()
Opens a WOSA device. Calls the WOSA native functions WFSCreateAppHandle, WFSAsyncOpen and WFSAsyncRegister.

Specified by:
open in interface WOSADeviceServiceInterface
Returns:
WOSAResult

removeWOSACmdListener

public void removeWOSACmdListener(WOSACmdListener newListener)
Removes a WOSA command listener.

Parameters:
newListener - WOSACmdListener

removeWOSADevListener

public void removeWOSADevListener(WOSADevListener newListener)
Removes a WOSA device listener.

Parameters:
newListener - WOSADevListener

run

public void run()
Provides the WOSA message loop. Runs in a separate thread.

Specified by:
run in interface java.lang.Runnable

setDeviceType

public void setDeviceType(java.lang.String n)
Sets the externalizable parameter deviceType.

Parameters:
n - String

setLogicalName

public void setLogicalName(java.lang.String ln)
Sets the externalizable parameter logicalName.

Parameters:
ln - String

setSPMMaxVersion

public void setSPMMaxVersion(java.lang.String mv)
Sets the externalizable parameter SPMMaxVersion.

Parameters:
mv - String

setSPMMinVersion

public void setSPMMinVersion(java.lang.String mv)
Sets the externalizable parameter SPMMinVersion.

Parameters:
mv - String

setTimeout

public void setTimeout(java.lang.String t)
                throws java.lang.NumberFormatException
Sets the externalizable parameter timeout.

Parameters:
t - String
Throws:
java.lang.NumberFormatException

setWosaTraceLevel

public void setWosaTraceLevel(java.lang.String l)
                       throws java.lang.NumberFormatException
Sets the externalizable parameter wosaTraceLevel.

Parameters:
l - String
Throws:
java.lang.NumberFormatException

startup

public int startup()
            throws DSEDLLNotFoundException
Provides instance control and native code binding. If it is the first WOSA service instance. It performs the WOSA startup by calling the WOSA native function WFSStartUp.

Specified by:
startup in interface WOSADeviceServiceInterface
Returns:
int
Throws:
DSEDLLNotFoundException - thrown when the DLL with the native code cannot be loaded

toString

public java.lang.String toString()
Returns a visual representation of the WOSADeviceService service.

Overrides:
toString in class Service
Returns:
java.lang.String

trace

protected void trace(java.lang.String s)
Sends a string to the toolkit trace facility.

Parameters:
s - String

unlock

public WOSAResult unlock()
Unlocks access to the device. Calls the WOSA native function WFSAsyncUnlock.

Specified by:
unlock in interface WOSADeviceServiceInterface
Returns:
com.ibm.dse.services.wosa.WOSAResult

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005