org.epics.pvmanager
Class ChannelHandler

java.lang.Object
  extended by org.epics.pvmanager.ChannelHandler
Direct Known Subclasses:
MultiplexedChannelHandler

public abstract class ChannelHandler
extends java.lang.Object

Manages the connection for each channel of a data source.

Author:
carcassi

Constructor Summary
ChannelHandler(java.lang.String channelName)
          Creates a new channel handler.
 
Method Summary
protected abstract  void addMonitor(ChannelHandlerReadSubscription subscription)
          Used by the data source to add a read request on the channel managed by this handler.
protected abstract  void addWriter(WriteCache<?> cache, ExceptionHandler handler)
          Used by the data source to prepare the channel managed by this handler for write.
 java.lang.String getChannelName()
          Returns the name of the channel.
 java.util.Map<java.lang.String,java.lang.Object> getProperties()
          Returns extra information about the channel, typically useful for debugging.
abstract  int getReadUsageCounter()
          Returns how many read PVs are open on this channel.
abstract  int getUsageCounter()
          Returns how many read or write PVs are open on this channel.
abstract  int getWriteUsageCounter()
          Returns how many write PVs are open on this channel.
abstract  boolean isConnected()
          Returns true if it is connected.
protected abstract  void removeMonitor(Collector<?> collector)
          Used by the data source to remove a read request.
protected abstract  void removeWrite(WriteCache<?> cache, ExceptionHandler exceptionHandler)
          Used by the data source to conclude writes to the channel managed by this handler.
protected abstract  void write(java.lang.Object newValue, ChannelWriteCallback callback)
          Implements a write operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelHandler

public ChannelHandler(java.lang.String channelName)
Creates a new channel handler.

Parameters:
channelName - the name of the channel this handler will be responsible of
Method Detail

getProperties

public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Returns extra information about the channel, typically useful for debugging.

Returns:
a property map

getChannelName

public java.lang.String getChannelName()
Returns the name of the channel.

Returns:
the channel name; can't be null

getUsageCounter

public abstract int getUsageCounter()
Returns how many read or write PVs are open on this channel.

Returns:
the number of open read/writes

getReadUsageCounter

public abstract int getReadUsageCounter()
Returns how many read PVs are open on this channel.

Returns:
the number of open reads

getWriteUsageCounter

public abstract int getWriteUsageCounter()
Returns how many write PVs are open on this channel.

Returns:
the number of open writes

addMonitor

protected abstract void addMonitor(ChannelHandlerReadSubscription subscription)
Used by the data source to add a read request on the channel managed by this handler.

Parameters:
subscription - the data required for a subscription

removeMonitor

protected abstract void removeMonitor(Collector<?> collector)
Used by the data source to remove a read request.

Parameters:
collector - the collector that does not need to be notified anymore

addWriter

protected abstract void addWriter(WriteCache<?> cache,
                                  ExceptionHandler handler)
Used by the data source to prepare the channel managed by this handler for write.

Parameters:
handler - to be notified in case of errors

removeWrite

protected abstract void removeWrite(WriteCache<?> cache,
                                    ExceptionHandler exceptionHandler)
Used by the data source to conclude writes to the channel managed by this handler.

Parameters:
exceptionHandler - to be notified in case of errors

write

protected abstract void write(java.lang.Object newValue,
                              ChannelWriteCallback callback)
Implements a write operation. Write the newValues to the channel and call the callback when done.

Parameters:
newValue - new value to be written
callback - called when done or on error

isConnected

public abstract boolean isConnected()
Returns true if it is connected.

Returns:
true if underlying channel is connected