com.cosylab.epics.caj.cas
Class CAJServerContext

java.lang.Object
  extended by gov.aps.jca.cas.ServerContext
      extended by com.cosylab.epics.caj.cas.CAJServerContext
All Implemented Interfaces:
CAContext, LoggerProvider, gov.aps.jca.configuration.Configurable

public class CAJServerContext
extends gov.aps.jca.cas.ServerContext
implements CAContext, gov.aps.jca.configuration.Configurable

Implementation of CAJ JCA Context.

Version:
$id$
Author:
Matej Sekoranja

Field Summary
protected  CASAcceptor acceptor
          CAS acceptor (accepts CA virtual circuit).
protected  boolean autoBeaconAddressList
          Define whether or not the network interfaces should be discovered at runtime.
protected  String beaconAddressList
          A space-separated list of broadcast address which to send beacons.
protected  BeaconEmitter beaconEmitter
          Beacon emitter..
protected  float beaconPeriod
          Period in second between two beacon signals.
protected  int beaconPort
          Port number for the repeater to listen to.
protected  BroadcastTransport broadcastTransport
          Broadcast transport needed for channel searches.
protected  CachedByteBufferAllocator cachedBufferAllocator
          Cached byte buffer allocator.
static String CAJ_SINGLE_THREADED_MODEL
          String value of the JVM property key to turn on single threaded model.
protected  ArrayList contextExceptionListeners
          List of context exception listeners.
protected  ArrayList contextMessageListeners
          List of context message listeners.
protected  String ignoreAddressList
          A space-separated list of address from which to ignore name resolution requests.
protected  LeaderFollowersThreadPool leaderFollowersThreadPool
          Leader/followers thread pool.
protected  Logger logger
          Context logger.
protected  int maxArrayBytes
          Length in bytes of the maximum array size that may pass through CA.
protected  Reactor reactor
          Reactor.
protected  Object runLock
          Run lock.
protected  gov.aps.jca.cas.Server server
          Server.
protected  int serverPort
          Port number for the server to listen to.
protected  Timer timer
          Timer.
protected  CATransportRegistry transportRegistry
          CA transport (virtual circuit) registry.
static gov.aps.jca.Version VERSION
          Version.
 
Constructor Summary
CAJServerContext()
          Constructor.
 
Method Summary
 void addContextExceptionListener(gov.aps.jca.event.ContextExceptionListener l)
           
 void addContextMessageListener(gov.aps.jca.event.ContextMessageListener l)
           
protected  void checkState()
          Check context state and tries to establish necessary state.
 void configure(gov.aps.jca.configuration.Configuration configuration)
           
 void destroy()
           
 int generateChannelSID()
          Generate channel SID.
 String getBeaconAddressList()
          Get beacon address list.
 float getBeaconPeriod()
          Get beacon period (in seconds).
 int getBeaconPort()
          Get beacon port.
 int getBroadcastPort()
          Get broadcast port.
 BroadcastTransport getBroadcastTransport()
          Broadcast transport.
 CachedByteBufferAllocator getCachedBufferAllocator()
          Get cached byte allocator.
 gov.aps.jca.event.ContextExceptionListener[] getContextExceptionListeners()
           
 gov.aps.jca.event.ContextMessageListener[] getContextMessageListeners()
           
 String getIgnoreAddressList()
          Get ignore search address list.
 int getLastReceivedSequenceNumber(int seqNo)
          Set last UDP recived sequence number.
 LeaderFollowersThreadPool getLeaderFollowersThreadPool()
          Get LF thread pool.
 Logger getLogger()
          Get logger.
 int getMaxArrayBytes()
          Get max array payload size.
 Reactor getReactor()
          Get context reactor.
 gov.aps.jca.cas.Server getServer()
          Get server implementation.
 InetAddress getServerInetAddress()
          Get server newtwork (IP) address.
 int getServerPort()
          Get server port.
 Timer getTimer()
          Get timer.
 CATransportRegistry getTransportRegistry()
          Get CA transport (virtual circuit) registry.
 gov.aps.jca.Version getVersion()
          Get context version.
 void initialize(gov.aps.jca.cas.Server server)
          Set server and initialize.
protected  void initializeLogger()
          Initialize context logger.
 void invalidateLastReceivedSequence()
          Invalidate last (UDP) received sequence.
 boolean isAutoBeaconAddressList()
          Get beacon address list auto flag.
 boolean isDestroyed()
          Get destruction status.
 boolean isInitialized()
          Get initialization status.
protected  void loadConfiguration()
          Load configuration.
 void printInfo(PrintStream out)
           
 void removeContextExceptionListener(gov.aps.jca.event.ContextExceptionListener l)
           
 void removeContextMessageListener(gov.aps.jca.event.ContextMessageListener l)
           
 void run(int seconds)
          Run server (process events).
 void setLastReceivedSequenceNumber(int seqNo)
          Set last UDP recived sequence number.
 void setServerPort(int port)
          Set server port number.
 void shutdown()
           
 
Methods inherited from class gov.aps.jca.cas.ServerContext
dispose, printInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final gov.aps.jca.Version VERSION
Version.


CAJ_SINGLE_THREADED_MODEL

public static final String CAJ_SINGLE_THREADED_MODEL
String value of the JVM property key to turn on single threaded model.

See Also:
Constant Field Values

logger

protected Logger logger
Context logger.


beaconAddressList

protected String beaconAddressList
A space-separated list of broadcast address which to send beacons. Each address must be of the form: ip.number:port or host.name:port


ignoreAddressList

protected String ignoreAddressList
A space-separated list of address from which to ignore name resolution requests. Each address must be of the form: ip.number:port or host.name:port


autoBeaconAddressList

protected boolean autoBeaconAddressList
Define whether or not the network interfaces should be discovered at runtime.


beaconPeriod

protected float beaconPeriod
Period in second between two beacon signals.


beaconPort

protected int beaconPort
Port number for the repeater to listen to.


serverPort

protected int serverPort
Port number for the server to listen to.


maxArrayBytes

protected int maxArrayBytes
Length in bytes of the maximum array size that may pass through CA.


contextMessageListeners

protected ArrayList contextMessageListeners
List of context message listeners.


contextExceptionListeners

protected ArrayList contextExceptionListeners
List of context exception listeners.


timer

protected Timer timer
Timer.


reactor

protected Reactor reactor
Reactor.


leaderFollowersThreadPool

protected LeaderFollowersThreadPool leaderFollowersThreadPool
Leader/followers thread pool.


broadcastTransport

protected BroadcastTransport broadcastTransport
Broadcast transport needed for channel searches.


beaconEmitter

protected BeaconEmitter beaconEmitter
Beacon emitter..


acceptor

protected CASAcceptor acceptor
CAS acceptor (accepts CA virtual circuit).


transportRegistry

protected CATransportRegistry transportRegistry
CA transport (virtual circuit) registry. This registry contains all active transports - connections to CA servers.


cachedBufferAllocator

protected CachedByteBufferAllocator cachedBufferAllocator
Cached byte buffer allocator. Used by transports which as send buffers.


server

protected gov.aps.jca.cas.Server server
Server.


runLock

protected Object runLock
Run lock.

Constructor Detail

CAJServerContext

public CAJServerContext()
Constructor.

Method Detail

getVersion

public gov.aps.jca.Version getVersion()
Get context version.

Specified by:
getVersion in class gov.aps.jca.cas.ServerContext
Returns:
context version.
See Also:
Context.getVersion()

initializeLogger

protected void initializeLogger()
Initialize context logger.


loadConfiguration

protected void loadConfiguration()
Load configuration.


configure

public void configure(gov.aps.jca.configuration.Configuration configuration)
               throws gov.aps.jca.configuration.ConfigurationException
Specified by:
configure in interface gov.aps.jca.configuration.Configurable
Throws:
gov.aps.jca.configuration.ConfigurationException
See Also:
Configurable.configure(gov.aps.jca.configuration.Configuration)

getContextMessageListeners

public gov.aps.jca.event.ContextMessageListener[] getContextMessageListeners()
                                                                      throws IllegalStateException
Specified by:
getContextMessageListeners in class gov.aps.jca.cas.ServerContext
Returns:
array of context message listeners.
Throws:
IllegalStateException
See Also:
Context.getContextMessageListeners()

addContextMessageListener

public void addContextMessageListener(gov.aps.jca.event.ContextMessageListener l)
                               throws gov.aps.jca.CAException,
                                      IllegalStateException
Specified by:
addContextMessageListener in class gov.aps.jca.cas.ServerContext
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Context.addContextMessageListener(gov.aps.jca.event.ContextMessageListener)

removeContextMessageListener

public void removeContextMessageListener(gov.aps.jca.event.ContextMessageListener l)
                                  throws gov.aps.jca.CAException,
                                         IllegalStateException
Specified by:
removeContextMessageListener in class gov.aps.jca.cas.ServerContext
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Context.removeContextMessageListener(gov.aps.jca.event.ContextMessageListener)

getContextExceptionListeners

public gov.aps.jca.event.ContextExceptionListener[] getContextExceptionListeners()
                                                                          throws IllegalStateException
Specified by:
getContextExceptionListeners in class gov.aps.jca.cas.ServerContext
Throws:
IllegalStateException
See Also:
Context.getContextExceptionListeners()

addContextExceptionListener

public void addContextExceptionListener(gov.aps.jca.event.ContextExceptionListener l)
                                 throws gov.aps.jca.CAException,
                                        IllegalStateException
Specified by:
addContextExceptionListener in class gov.aps.jca.cas.ServerContext
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Context.addContextExceptionListener(gov.aps.jca.event.ContextExceptionListener)

removeContextExceptionListener

public void removeContextExceptionListener(gov.aps.jca.event.ContextExceptionListener l)
                                    throws gov.aps.jca.CAException,
                                           IllegalStateException
Specified by:
removeContextExceptionListener in class gov.aps.jca.cas.ServerContext
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
Context.removeContextExceptionListener(gov.aps.jca.event.ContextExceptionListener)

checkState

protected void checkState()
                   throws gov.aps.jca.CAException,
                          IllegalStateException
Check context state and tries to establish necessary state.

Throws:
gov.aps.jca.CAException
IllegalStateException

initialize

public void initialize(gov.aps.jca.cas.Server server)
                throws gov.aps.jca.CAException,
                       IllegalStateException
Set server and initialize.

Specified by:
initialize in class gov.aps.jca.cas.ServerContext
Throws:
gov.aps.jca.CAException
IllegalStateException
See Also:
ServerContext.initialize(gov.aps.jca.cas.Server)

run

public void run(int seconds)
         throws gov.aps.jca.CAException,
                IllegalStateException
Run server (process events).

Specified by:
run in class gov.aps.jca.cas.ServerContext
Parameters:
seconds - time in seconds the server will process events (method will block), if 0 the method would block until destory() is called.
Throws:
IllegalStateException - if server is already destroyed.
gov.aps.jca.CAException

shutdown

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

destroy

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

printInfo

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

isInitialized

public boolean isInitialized()
Get initialization status.

Returns:
initialization status.

isDestroyed

public boolean isDestroyed()
Get destruction status.

Returns:
destruction status.

getBeaconAddressList

public String getBeaconAddressList()
Get beacon address list.

Returns:
beacon address list.

isAutoBeaconAddressList

public boolean isAutoBeaconAddressList()
Get beacon address list auto flag.

Returns:
beacon address list auto flag.

getBeaconPeriod

public float getBeaconPeriod()
Get beacon period (in seconds).

Returns:
beacon period (in seconds).

getLogger

public Logger getLogger()
Get logger.

Specified by:
getLogger in interface LoggerProvider
Returns:
logger.

getMaxArrayBytes

public int getMaxArrayBytes()
Get max array payload size.

Returns:
max array payload size.

getBeaconPort

public int getBeaconPort()
Get beacon port.

Returns:
beacon port.

getServerPort

public int getServerPort()
Get server port.

Specified by:
getServerPort in interface CAContext
Returns:
server port.

setServerPort

public void setServerPort(int port)
Set server port number.

Parameters:
port - new server port number.

getBroadcastPort

public int getBroadcastPort()
Get broadcast port.

Specified by:
getBroadcastPort in interface CAContext
Returns:
broadcast port.

getIgnoreAddressList

public String getIgnoreAddressList()
Get ignore search address list.

Returns:
ignore search addrresr list.

getServerInetAddress

public InetAddress getServerInetAddress()
Get server newtwork (IP) address.

Returns:
server network (IP) address, null if not bounded.

getReactor

public Reactor getReactor()
Get context reactor.

Specified by:
getReactor in interface CAContext
Returns:
context reactor.

getBroadcastTransport

public BroadcastTransport getBroadcastTransport()
Broadcast transport.

Specified by:
getBroadcastTransport in interface CAContext
Returns:
broadcast transport.

getTransportRegistry

public CATransportRegistry getTransportRegistry()
Get CA transport (virtual circuit) registry.

Specified by:
getTransportRegistry in interface CAContext
Returns:
CA transport (virtual circuit) registry.

getTimer

public Timer getTimer()
Get timer.

Specified by:
getTimer in interface CAContext
Returns:
timer.

getCachedBufferAllocator

public CachedByteBufferAllocator getCachedBufferAllocator()
Get cached byte allocator.

Specified by:
getCachedBufferAllocator in interface CAContext
Returns:
cached byte allocator.

getLeaderFollowersThreadPool

public LeaderFollowersThreadPool getLeaderFollowersThreadPool()
Get LF thread pool.

Specified by:
getLeaderFollowersThreadPool in interface CAContext
Returns:
LF thread pool, can be null if disabled.

getServer

public gov.aps.jca.cas.Server getServer()
Get server implementation.

Returns:
server implementation.

generateChannelSID

public int generateChannelSID()
Generate channel SID.

Returns:
channel SID.

setLastReceivedSequenceNumber

public final void setLastReceivedSequenceNumber(int seqNo)
Set last UDP recived sequence number.

Parameters:
seqNo - last UDP recived sequence number.

getLastReceivedSequenceNumber

public final int getLastReceivedSequenceNumber(int seqNo)
Set last UDP recived sequence number.

Parameters:
seqNo - last UDP recived sequence number.

invalidateLastReceivedSequence

public final void invalidateLastReceivedSequence()
Description copied from interface: CAContext
Invalidate last (UDP) received sequence.

Specified by:
invalidateLastReceivedSequence in interface CAContext
See Also:
CAContext.invalidateLastReceivedSequence()


Copyright © 2004-2013 Cosylab. All Rights Reserved.