org.epics.pvmanager.jca
Class JCAChannelHandler

java.lang.Object
  extended by org.epics.pvmanager.ChannelHandler<gov.aps.jca.event.MonitorEvent>
      extended by org.epics.pvmanager.jca.JCAChannelHandler

public class JCAChannelHandler
extends ChannelHandler<gov.aps.jca.event.MonitorEvent>

A ChannelHandler for the JCADataSource.

NOTE: this class is extensible as per Bastian request so that DESY can hook a different type factory. This is a temporary measure until the problem is solved in better, more general way, so that data sources can work only with data source specific types, while allowing conversions to normalized type through operators. The contract of this class is, therefore, expected to change.

Related changes are marked so that they are not accidentally removed in the meantime, and can be intentionally removed when a better solution is implemented.

Author:
carcassi

Field Summary
protected  Class<?> cacheType
           
protected  gov.aps.jca.dbr.DBR metadata
           
protected  gov.aps.jca.event.MonitorListener monitorListener
           
protected  TypeFactory vTypeFactory
           
 
Constructor Summary
JCAChannelHandler(String channelName, gov.aps.jca.Context context, int monitorMask)
           
 
Method Summary
 void addMonitor(Collector<?> collector, ValueCache<?> cache, ExceptionHandler handler)
          Used by the data source to add a read request on the channel managed by this handler.
 void connect(ExceptionHandler handler)
          Used by the handler to open the connection.
 void disconnect(ExceptionHandler handler)
          Used by the handler to close the connection.
 boolean isConnected()
          Returns true if it is connected.
protected  void setup(gov.aps.jca.Channel channel)
           
 boolean updateCache(gov.aps.jca.event.MonitorEvent event, ValueCache<?> cache)
          Used by the handler to forward values.
 void write(Object newValue, ChannelWriteCallback callback)
          Implements a write operation.
 
Methods inherited from class org.epics.pvmanager.ChannelHandler
addWriter, getChannelName, getReadUsageCounter, getUsageCounter, getWriteUsageCounter, processValue, removeMonitor, removeWrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheType

protected volatile Class<?> cacheType

vTypeFactory

protected volatile TypeFactory vTypeFactory

metadata

protected gov.aps.jca.dbr.DBR metadata

monitorListener

protected final gov.aps.jca.event.MonitorListener monitorListener
Constructor Detail

JCAChannelHandler

public JCAChannelHandler(String channelName,
                         gov.aps.jca.Context context,
                         int monitorMask)
Method Detail

addMonitor

public void addMonitor(Collector<?> collector,
                       ValueCache<?> cache,
                       ExceptionHandler handler)
Description copied from class: ChannelHandler
Used by the data source to add a read request on the channel managed by this handler.

Overrides:
addMonitor in class ChannelHandler<gov.aps.jca.event.MonitorEvent>
Parameters:
collector - collector to be notified at each update
cache - cache to contain the new value
handler - to be notified in case of errors

connect

public void connect(ExceptionHandler handler)
Description copied from class: ChannelHandler
Used by the handler to open the connection. This is called whenever the first read or write request is made.

Specified by:
connect in class ChannelHandler<gov.aps.jca.event.MonitorEvent>
Parameters:
handler - to be notified in case of errors

setup

protected void setup(gov.aps.jca.Channel channel)
              throws gov.aps.jca.CAException
Throws:
gov.aps.jca.CAException

disconnect

public void disconnect(ExceptionHandler handler)
Description copied from class: ChannelHandler
Used by the handler to close the connection. This is called whenever the last reader or writer is de-registered.

Specified by:
disconnect in class ChannelHandler<gov.aps.jca.event.MonitorEvent>
Parameters:
handler - to be notified in case of errors

write

public void write(Object newValue,
                  ChannelWriteCallback callback)
Description copied from class: ChannelHandler
Implements a write operation. Write the newValues to the channel and call the callback when done.

Specified by:
write in class ChannelHandler<gov.aps.jca.event.MonitorEvent>
Parameters:
newValue - new value to be written
callback - called when done or on error

updateCache

public boolean updateCache(gov.aps.jca.event.MonitorEvent event,
                           ValueCache<?> cache)
Description copied from class: ChannelHandler
Used by the handler to forward values. Extracts the value form the payload and stores it in the cache.

Specified by:
updateCache in class ChannelHandler<gov.aps.jca.event.MonitorEvent>
Parameters:
event - the payload
cache - the cache where to store the new value
Returns:
true if a new value was stored

isConnected

public boolean isConnected()
Description copied from class: ChannelHandler
Returns true if it is connected.

Specified by:
isConnected in class ChannelHandler<gov.aps.jca.event.MonitorEvent>
Returns:
true if underlying channel is connected


Copyright © 2011. All Rights Reserved.