com.cosylab.epics.caj
Class CAJChannel

java.lang.Object
  extended by gov.aps.jca.Channel
      extended by com.cosylab.epics.caj.CAJChannel
All Implemented Interfaces:
TransportClient

public class CAJChannel
extends gov.aps.jca.Channel
implements TransportClient

Implementation of CAJ JCA Channel.

Version:
$id$
Author:
Matej Sekoranja

Nested Class Summary
 
Nested classes/interfaces inherited from class gov.aps.jca.Channel
gov.aps.jca.Channel.ConnectionState
 
Field Summary
protected  int accessRights
          Channel access rights.
protected  ArrayList accessRightsListeners
          List of access rights listeners.
protected  boolean allowCreation
          Allow reconnection flag.
protected  boolean canceled
          Cancelation status.
protected  int channelID
          Client channel ID.
protected  ArrayList connectionListeners
          List of connection listeners.
protected  gov.aps.jca.Channel.ConnectionState connectionState
          Connection status.
protected  CAJContext context
          Context.
protected  int elementCount
          Data type element count.
protected  boolean lastReportedConnectionState
          Last reported connection status.
protected  Map monitors
          Map of channels (keys are CIDs).
protected  String name
          Channel name.
protected  ArrayFIFO owner
           
protected  int ownerIndex
           
protected  Object ownerLock
           
protected  short priority
          Process priority.
protected  int references
          Reference counting.
protected  Map responseRequests
          List of all channels pending requests.
protected  int searchTries
          Number of channel search tries.
protected  int sequenceNumberIO
          IO sequence number.
protected  int serverChannelID
          Server channel ID.
protected  boolean syncConnection
          Sync.
protected  CATransport transport
          Server transport.
protected  gov.aps.jca.dbr.DBRType type
          Channel data type.
 
Fields inherited from class gov.aps.jca.Channel
CLOSED, CONNECTED, DISCONNECTED, NEVER_CONNECTED, PRIORITY_ARCHIVE, PRIORITY_DEFAULT, PRIORITY_LINKS_DB, PRIORITY_MAX, PRIORITY_MIN, PRIORITY_OPI
 
Constructor Summary
protected CAJChannel(CAJContext context, int channelID, String name, gov.aps.jca.event.ConnectionListener listener, short priority)
          Constructor.
 
Method Summary
 void acquire()
          Increment reference.
 void addAccessRightsListener(gov.aps.jca.event.AccessRightsListener l)
           
 void addAndSetListOwnership(ArrayFIFO newOwner, int index)
           
 void addConnectionListener(gov.aps.jca.event.ConnectionListener l)
           
 void addConnectionListenerAndFireIfConnected(gov.aps.jca.event.ConnectionListener l)
           
 gov.aps.jca.Monitor addMonitor(gov.aps.jca.dbr.DBRType type, int count, int mask, gov.aps.jca.event.MonitorListener l)
           
 void cancel()
          Called when connecton completed (successfully or not).
 void connectionCompleted(int sid, short typeCode, int elementCount)
          Called when channel crated succeeded on the server.
 void createChannel(CATransport transport, int sid, short typeCode, int elementCount)
          Create a channel, i.e.
 void createChannelFailed()
          Create channel failed.
 void destroy()
           
 void destroy(boolean force)
           
 void destroyChannel(boolean force)
          Actual destory method, to be called CAJContext.
 void disconnect(boolean initiateSearch)
          Disconnected notification.
 boolean generateSearchRequestMessage(Transport transport, ByteBuffer buffer)
          Send search message.
 gov.aps.jca.dbr.DBR get(gov.aps.jca.dbr.DBR preallocatedDBR, gov.aps.jca.dbr.DBRType type, int count)
           
 gov.aps.jca.dbr.DBR get(gov.aps.jca.dbr.DBRType type, int count)
           
 void get(gov.aps.jca.dbr.DBRType type, int count, gov.aps.jca.event.GetListener l)
           
 gov.aps.jca.event.AccessRightsListener[] getAccessRightsListeners()
           
 int getChannelID()
          Get client channel ID.
 gov.aps.jca.event.ConnectionListener[] getConnectionListeners()
           
 gov.aps.jca.Channel.ConnectionState getConnectionState()
           
 gov.aps.jca.Context getContext()
           
 int getElementCount()
           
 gov.aps.jca.dbr.DBRType getFieldType()
           
 String getHostName()
          NOTE: synchronization guarantees that transport is non-null and state == CONNECTED.
 String getName()
           
 int getOwnerIndex()
           
 short getPriority()
          Get process priority.
 boolean getReadAccess()
           
 int getSearchTries()
          Get number of search tried for this channel.
 int getServerChannelID()
          Get SID.
 CATransport getTransport()
          Get transport used by this channel.
 boolean getWriteAccess()
           
 void initiateSearch()
          Initiate search (connect) procedure.
 void printInfo(PrintStream out)
           
 void put(byte[] value)
           
 void put(byte[] value, gov.aps.jca.event.PutListener l)
           
 void put(gov.aps.jca.dbr.DBRType type, int count, Object value)
          Put value.
 void put(gov.aps.jca.dbr.DBRType type, int count, Object value, gov.aps.jca.event.PutListener l)
          Put value.
 void put(double[] value)
           
 void put(double[] value, gov.aps.jca.event.PutListener l)
           
 void put(float[] value)
           
 void put(float[] value, gov.aps.jca.event.PutListener l)
           
 void put(int[] value)
           
 void put(int[] value, gov.aps.jca.event.PutListener l)
           
 void put(short[] value)
           
 void put(short[] value, gov.aps.jca.event.PutListener l)
           
 void put(String[] value)
           
 void put(String[] value, gov.aps.jca.event.PutListener l)
           
 void putACKS(gov.aps.jca.dbr.Severity severity)
           
 void putACKS(gov.aps.jca.dbr.Severity severity, gov.aps.jca.event.PutListener l)
           
 void putACKT(boolean value)
           
 void putACKT(boolean value, gov.aps.jca.event.PutListener l)
           
 void registerResponseRequest(ResponseRequest responseRequest)
          Register a response request.
 void removeAccessRightsListener(gov.aps.jca.event.AccessRightsListener l)
           
 void removeAndUnsetListOwnership()
           
 void removeConnectionListener(gov.aps.jca.event.ConnectionListener l)
           
 void setAccessRights(int accessRights)
          Set access rights.
 void timeout()
           
 String toString()
           
 void transportChanged()
          Notification of network change (server restarted).
 void transportClosed()
          Notification of forcefully closed transport.
 void transportResponsive(Transport transport)
          Notification of responsive transport (e.g.
 void transportUnresponsive()
          Notification of unresponsive transport (e.g.
 void unregisterResponseRequest(ResponseRequest responseRequest)
           
 void unsetListOwnership()
           
 
Methods inherited from class gov.aps.jca.Channel
addMonitor, addMonitor, addMonitor, checkMonitorSize, dispose, get, get, get, get, printInfo, put, put, put, put, put, put, put, put, put, put, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

channelID

protected int channelID
Client channel ID.


context

protected CAJContext context
Context.


name

protected String name
Channel name.


accessRights

protected int accessRights
Channel access rights.


priority

protected short priority
Process priority.


lastReportedConnectionState

protected boolean lastReportedConnectionState
Last reported connection status.


connectionState

protected gov.aps.jca.Channel.ConnectionState connectionState
Connection status.


type

protected gov.aps.jca.dbr.DBRType type
Channel data type.


elementCount

protected int elementCount
Data type element count.


connectionListeners

protected ArrayList connectionListeners
List of connection listeners.


accessRightsListeners

protected ArrayList accessRightsListeners
List of access rights listeners.


syncConnection

protected boolean syncConnection
Sync. connection (i.e. w/ callback) flag.


sequenceNumberIO

protected int sequenceNumberIO
IO sequence number.


monitors

protected Map monitors
Map of channels (keys are CIDs). Lazy initialization used, since not all channel will have monitors.


responseRequests

protected Map responseRequests
List of all channels pending requests.


searchTries

protected int searchTries
Number of channel search tries.


allowCreation

protected boolean allowCreation
Allow reconnection flag.


references

protected int references
Reference counting.


transport

protected CATransport transport
Server transport.


serverChannelID

protected int serverChannelID
Server channel ID.


canceled

protected volatile boolean canceled
Cancelation status.


ownerLock

protected Object ownerLock

owner

protected ArrayFIFO owner

ownerIndex

protected int ownerIndex
Constructor Detail

CAJChannel

protected CAJChannel(CAJContext context,
                     int channelID,
                     String name,
                     gov.aps.jca.event.ConnectionListener listener,
                     short priority)
              throws gov.aps.jca.CAException
Constructor.

Parameters:
context -
name -
listener -
Throws:
gov.aps.jca.CAException
Method Detail

createChannel

public void createChannel(CATransport transport,
                          int sid,
                          short typeCode,
                          int elementCount)
Create a channel, i.e. submit create channel request to the server. This method is called after seatch is complete. sid, typeCode, elementCount might not be valid, this depends on protocol revision.

Parameters:
transport -
sid -
typeCode -
elementCount -

cancel

public void cancel()
Called when connecton completed (successfully or not).

See Also:
ResponseRequest.cancel()

timeout

public void timeout()
See Also:
ResponseRequest.timeout()

createChannelFailed

public void createChannelFailed()
Create channel failed.


connectionCompleted

public void connectionCompleted(int sid,
                                short typeCode,
                                int elementCount)
                         throws IllegalStateException
Called when channel crated succeeded on the server. sid might not be valid, this depends on protocol revision.

Parameters:
sid -
typeCode -
elementCount -
Throws:
IllegalStateException

destroy

public void destroy()
             throws gov.aps.jca.CAException,
                    IllegalStateException
Specified by:
destroy in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.destroy()

destroy

public void destroy(boolean force)
             throws gov.aps.jca.CAException,
                    IllegalStateException
Parameters:
force - force destruction regardless of reference count
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.destroy()

acquire

public void acquire()
Increment reference.


destroyChannel

public void destroyChannel(boolean force)
                    throws gov.aps.jca.CAException,
                           IllegalStateException,
                           IOException
Actual destory method, to be called CAJContext.

Parameters:
force - force destruction regardless of reference count
Throws:
gov.aps.jca.CAException
IllegalStateException
IOException

disconnect

public void disconnect(boolean initiateSearch)
Disconnected notification.

Parameters:
initiateSearch - flag to indicate if searching (connect) procedure should be initiated

initiateSearch

public void initiateSearch()
Initiate search (connect) procedure.


generateSearchRequestMessage

public boolean generateSearchRequestMessage(Transport transport,
                                            ByteBuffer buffer)
Send search message.

Returns:
success status.

transportClosed

public void transportClosed()
Description copied from interface: TransportClient
Notification of forcefully closed transport.

Specified by:
transportClosed in interface TransportClient
See Also:
TransportClient.transportClosed()

transportChanged

public void transportChanged()
Description copied from interface: TransportClient
Notification of network change (server restarted).

Specified by:
transportChanged in interface TransportClient
See Also:
TransportClient.transportChanged()

transportResponsive

public void transportResponsive(Transport transport)
Description copied from interface: TransportClient
Notification of responsive transport (e.g. heartbeat detected again), called to discard transportUnresponsive notification.

Specified by:
transportResponsive in interface TransportClient
Parameters:
transport - responsive transport.
See Also:
TransportClient.transportResponsive(com.cosylab.epics.caj.impl.Transport)

transportUnresponsive

public void transportUnresponsive()
Description copied from interface: TransportClient
Notification of unresponsive transport (e.g. no heartbeat detected) .

Specified by:
transportUnresponsive in interface TransportClient
See Also:
TransportClient.transportUnresponsive()

getConnectionListeners

public gov.aps.jca.event.ConnectionListener[] getConnectionListeners()
                                                              throws IllegalStateException
Specified by:
getConnectionListeners in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getConnectionListeners()

addConnectionListener

public void addConnectionListener(gov.aps.jca.event.ConnectionListener l)
                           throws gov.aps.jca.CAException,
                                  IllegalStateException
Specified by:
addConnectionListener in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.addConnectionListener(gov.aps.jca.event.ConnectionListener)

addConnectionListenerAndFireIfConnected

public void addConnectionListenerAndFireIfConnected(gov.aps.jca.event.ConnectionListener l)
                                             throws gov.aps.jca.CAException,
                                                    IllegalStateException
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.addConnectionListener(gov.aps.jca.event.ConnectionListener)

removeConnectionListener

public void removeConnectionListener(gov.aps.jca.event.ConnectionListener l)
                              throws gov.aps.jca.CAException,
                                     IllegalStateException
Specified by:
removeConnectionListener in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.removeConnectionListener(gov.aps.jca.event.ConnectionListener)

getAccessRightsListeners

public gov.aps.jca.event.AccessRightsListener[] getAccessRightsListeners()
                                                                  throws IllegalStateException
Specified by:
getAccessRightsListeners in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getAccessRightsListeners()

addAccessRightsListener

public void addAccessRightsListener(gov.aps.jca.event.AccessRightsListener l)
                             throws gov.aps.jca.CAException,
                                    IllegalStateException
Specified by:
addAccessRightsListener in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.addAccessRightsListener(gov.aps.jca.event.AccessRightsListener)

removeAccessRightsListener

public void removeAccessRightsListener(gov.aps.jca.event.AccessRightsListener l)
                                throws gov.aps.jca.CAException,
                                       IllegalStateException
Specified by:
removeAccessRightsListener in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.removeAccessRightsListener(gov.aps.jca.event.AccessRightsListener)

setAccessRights

public void setAccessRights(int accessRights)
Set access rights.

Parameters:
accessRights - access rights to set

getName

public String getName()
               throws IllegalStateException
Specified by:
getName in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getName()

getFieldType

public gov.aps.jca.dbr.DBRType getFieldType()
                                     throws IllegalStateException
Specified by:
getFieldType in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getFieldType()

getElementCount

public int getElementCount()
                    throws IllegalStateException
Specified by:
getElementCount in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getElementCount()

getConnectionState

public gov.aps.jca.Channel.ConnectionState getConnectionState()
                                                       throws IllegalStateException
Specified by:
getConnectionState in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getConnectionState()

getHostName

public String getHostName()
                   throws IllegalStateException
NOTE: synchronization guarantees that transport is non-null and state == CONNECTED.

Specified by:
getHostName in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getHostName()

getReadAccess

public boolean getReadAccess()
                      throws IllegalStateException
Specified by:
getReadAccess in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getReadAccess()

getWriteAccess

public boolean getWriteAccess()
                       throws IllegalStateException
Specified by:
getWriteAccess in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getWriteAccess()

put

public void put(byte[] value)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(byte[])

put

public void put(byte[] value,
                gov.aps.jca.event.PutListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(byte[], gov.aps.jca.event.PutListener)

put

public void put(short[] value)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(short[])

put

public void put(short[] value,
                gov.aps.jca.event.PutListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(short[], gov.aps.jca.event.PutListener)

put

public void put(int[] value)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(int[])

put

public void put(int[] value,
                gov.aps.jca.event.PutListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(int[], gov.aps.jca.event.PutListener)

put

public void put(float[] value)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(float[])

put

public void put(float[] value,
                gov.aps.jca.event.PutListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(float[], gov.aps.jca.event.PutListener)

put

public void put(double[] value)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(double[])

put

public void put(double[] value,
                gov.aps.jca.event.PutListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(double[], gov.aps.jca.event.PutListener)

put

public void put(String[] value)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(java.lang.String[])

put

public void put(String[] value,
                gov.aps.jca.event.PutListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
put in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.put(java.lang.String[], gov.aps.jca.event.PutListener)

putACKS

public void putACKS(gov.aps.jca.dbr.Severity severity,
                    gov.aps.jca.event.PutListener l)
             throws gov.aps.jca.CAException,
                    IllegalStateException
Specified by:
putACKS in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.putACKS(gov.aps.jca.dbr.Severity, gov.aps.jca.event.PutListener)

putACKS

public void putACKS(gov.aps.jca.dbr.Severity severity)
             throws gov.aps.jca.CAException,
                    IllegalStateException
Specified by:
putACKS in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.putACKS(gov.aps.jca.dbr.Severity)

putACKT

public void putACKT(boolean value,
                    gov.aps.jca.event.PutListener l)
             throws gov.aps.jca.CAException,
                    IllegalStateException
Specified by:
putACKT in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.putACKT(boolean, gov.aps.jca.event.PutListener)

putACKT

public void putACKT(boolean value)
             throws gov.aps.jca.CAException,
                    IllegalStateException
Specified by:
putACKT in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.putACKT(boolean)

get

public gov.aps.jca.dbr.DBR get(gov.aps.jca.dbr.DBRType type,
                               int count)
                        throws gov.aps.jca.CAException,
                               IllegalStateException
Specified by:
get in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.get(gov.aps.jca.dbr.DBRType, int)

get

public gov.aps.jca.dbr.DBR get(gov.aps.jca.dbr.DBR preallocatedDBR,
                               gov.aps.jca.dbr.DBRType type,
                               int count)
                        throws gov.aps.jca.CAException,
                               IllegalStateException
Throws:
gov.aps.jca.CAException
IllegalStateException

get

public void get(gov.aps.jca.dbr.DBRType type,
                int count,
                gov.aps.jca.event.GetListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Specified by:
get in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.get(gov.aps.jca.dbr.DBRType, int, gov.aps.jca.event.GetListener)

put

public void put(gov.aps.jca.dbr.DBRType type,
                int count,
                Object value)
         throws gov.aps.jca.CAException,
                IllegalStateException
Put value.

Parameters:
type -
count -
value -
Throws:
gov.aps.jca.CAException
IllegalStateException

put

public void put(gov.aps.jca.dbr.DBRType type,
                int count,
                Object value,
                gov.aps.jca.event.PutListener l)
         throws gov.aps.jca.CAException,
                IllegalStateException
Put value.

Parameters:
type -
count -
value -
l -
Throws:
gov.aps.jca.CAException
IllegalStateException

addMonitor

public gov.aps.jca.Monitor addMonitor(gov.aps.jca.dbr.DBRType type,
                                      int count,
                                      int mask,
                                      gov.aps.jca.event.MonitorListener l)
                               throws gov.aps.jca.CAException,
                                      IllegalStateException
Specified by:
addMonitor in class gov.aps.jca.Channel
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Channel.addMonitor(gov.aps.jca.dbr.DBRType, int, int, gov.aps.jca.event.MonitorListener)

getChannelID

public int getChannelID()
Get client channel ID.

Returns:
client channel ID.

getContext

public gov.aps.jca.Context getContext()
                               throws IllegalStateException
Specified by:
getContext in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.getContext()

printInfo

public void printInfo(PrintStream out)
               throws IllegalStateException
Overrides:
printInfo in class gov.aps.jca.Channel
Throws:
IllegalStateException
See Also:
Channel.printInfo(java.io.PrintStream)

getTransport

public CATransport getTransport()
Get transport used by this channel.

Returns:
transport used by this channel.

getServerChannelID

public int getServerChannelID()
Get SID.

Returns:
SID.

registerResponseRequest

public void registerResponseRequest(ResponseRequest responseRequest)
Register a response request.

Parameters:
responseRequest - response request to register.

unregisterResponseRequest

public void unregisterResponseRequest(ResponseRequest responseRequest)

getSearchTries

public int getSearchTries()
Get number of search tried for this channel.

Returns:
number of search tried for this channel.

getPriority

public short getPriority()
Get process priority.

Returns:
process priority.

unsetListOwnership

public void unsetListOwnership()

addAndSetListOwnership

public void addAndSetListOwnership(ArrayFIFO newOwner,
                                   int index)

removeAndUnsetListOwnership

public void removeAndUnsetListOwnership()

getOwnerIndex

public final int getOwnerIndex()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2013 Cosylab. All Rights Reserved.