gov.aps.jca
Class Context

java.lang.Object
  extended by gov.aps.jca.Context
Direct Known Subclasses:
JNIContext

public abstract class Context
extends java.lang.Object

The class representing a CA Context. A Context controls all IO operations and the circuits thru which Channels will be created and connected. Since CA 3.14 an application can create more than one context, thus ehancing IO control and Channels managment. Context are created thru the JCALibrary factory class.

See Also:
JCALibrary

Constructor Summary
Context()
           
 
Method Summary
abstract  void addContextExceptionListener(ContextExceptionListener l)
          Add a ContextExceptionListener to this context.
abstract  void addContextMessageListener(ContextMessageListener l)
          Add a ContextMessageListener to this context.
abstract  void attachCurrentThread()
          Attach the calling thread to the list of threads allowed to access this context and all its channels.
 Channel createChannel(java.lang.String name)
          Create a new Channel using this context to access a process variable.
 Channel createChannel(java.lang.String name, ConnectionListener l)
          Create a new Channel using this context to access a process variable with a ConnectionListener to receive ConnectionEvent from the newly created Channel.
abstract  Channel createChannel(java.lang.String name, ConnectionListener l, short priority)
          Create a new Channel using this context to access a process variable with a ConnectionListener to receive ConnectionEvent from the newly created Channel.
 Channel createChannel(java.lang.String name, short priority)
          Create a new Channel using this context to access a process variable.
abstract  void destroy()
          Clear all ressources attached to this Context
 void dispose()
           
abstract  void flushIO()
          Flush outstanding IO request to the servers.
abstract  Channel[] getChannels()
          Get all channels of this context.
abstract  ContextExceptionListener[] getContextExceptionListeners()
           
abstract  ContextMessageListener[] getContextMessageListeners()
           
abstract  Version getVersion()
           
 void initialize()
           
abstract  void pendEvent(double time)
          Process all pending events.
abstract  void pendIO(double timeout)
          Process all pending IO operations.
abstract  void poll()
          Flush the send buffer and process any outstanding CA background activity.
 void printInfo()
          Prints detailed information about the Context to the standard output stream.
 void printInfo(java.io.PrintStream out)
          Prints detailed information about the Context to the specified output stream.
abstract  void removeContextExceptionListener(ContextExceptionListener l)
          Removes a ContextExceptionListener from this context.
abstract  void removeContextMessageListener(ContextMessageListener l)
          Removes a ContextMessageListener from this context.
abstract  boolean testIO()
          Tests if all synchronous (ie not specifying listeners) get and channel creation requests are completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Context

public Context()
Method Detail

getVersion

public abstract Version getVersion()
Returns:
version of the context implementation.

initialize

public void initialize()
                throws CAException
Throws:
CAException

getContextMessageListeners

public abstract ContextMessageListener[] getContextMessageListeners()
                                                             throws java.lang.IllegalStateException
Returns:
an array containing all ContextMessageListeners attached to this context.
Throws:
java.lang.IllegalStateException - if the context has been destroyed.

addContextMessageListener

public abstract void addContextMessageListener(ContextMessageListener l)
                                        throws CAException,
                                               java.lang.IllegalStateException
Add a ContextMessageListener to this context.

Parameters:
l - the listener to add
Throws:
java.lang.IllegalStateException - if the context has been destroyed.
CAException

removeContextMessageListener

public abstract void removeContextMessageListener(ContextMessageListener l)
                                           throws CAException,
                                                  java.lang.IllegalStateException
Removes a ContextMessageListener from this context.

Parameters:
l - the listener to remove
Throws:
java.lang.IllegalStateException - if the context has been destroyed.
CAException

getContextExceptionListeners

public abstract ContextExceptionListener[] getContextExceptionListeners()
                                                                 throws java.lang.IllegalStateException
Returns:
an array containing all ContextExceptionListeners attached to this context.
Throws:
java.lang.IllegalStateException - if the context has been destroyed.

addContextExceptionListener

public abstract void addContextExceptionListener(ContextExceptionListener l)
                                          throws CAException,
                                                 java.lang.IllegalStateException
Add a ContextExceptionListener to this context.

Parameters:
l - the listener to add
Throws:
java.lang.IllegalStateException - if the context has been destroyed.
CAException

removeContextExceptionListener

public abstract void removeContextExceptionListener(ContextExceptionListener l)
                                             throws CAException,
                                                    java.lang.IllegalStateException
Removes a ContextExceptionListener from this context.

Parameters:
l - the listener to remove
Throws:
java.lang.IllegalStateException - if the context has been destroyed.
CAException

destroy

public abstract void destroy()
                      throws CAException,
                             java.lang.IllegalStateException
Clear all ressources attached to this Context

Throws:
java.lang.IllegalStateException - if the context has been destroyed.
CAException

createChannel

public Channel createChannel(java.lang.String name)
                      throws CAException,
                             java.lang.IllegalArgumentException,
                             java.lang.IllegalStateException
Create a new Channel using this context to access a process variable.

Parameters:
name - the process variable to connect to.
Returns:
the new Channel.
Throws:
CAException - is thrown if a Channel Access error occured while creating the channel.
java.lang.IllegalArgumentException - is thrown if the channel's name is null or empty.
java.lang.IllegalStateException - if the context has been destroyed.

createChannel

public Channel createChannel(java.lang.String name,
                             short priority)
                      throws CAException,
                             java.lang.IllegalArgumentException,
                             java.lang.IllegalStateException
Create a new Channel using this context to access a process variable.

Parameters:
name - the process variable to connect to.
priority - channel process priority
Returns:
the new Channel.
Throws:
CAException - is thrown if a Channel Access error occured while creating the channel.
java.lang.IllegalArgumentException - is thrown if the channel's name is null or empty.
java.lang.IllegalStateException - if the context has been destroyed.

createChannel

public Channel createChannel(java.lang.String name,
                             ConnectionListener l)
                      throws CAException,
                             java.lang.IllegalStateException
Create a new Channel using this context to access a process variable with a ConnectionListener to receive ConnectionEvent from the newly created Channel.

Parameters:
name - the process variable to connect to.
l - the ConnectionListener.
priority - channel process priority
Returns:
the new Channel.
Throws:
CAException - is thrown if a Channel Access error occured while creating the channel.
java.lang.IllegalStateException - if the context has been destroyed.

createChannel

public abstract Channel createChannel(java.lang.String name,
                                      ConnectionListener l,
                                      short priority)
                               throws CAException,
                                      java.lang.IllegalStateException
Create a new Channel using this context to access a process variable with a ConnectionListener to receive ConnectionEvent from the newly created Channel.

Parameters:
name - the process variable to connect to.
l - the ConnectionListener.
Returns:
the new Channel.
Throws:
CAException - is thrown if a Channel Access error occured while creating the channel.
java.lang.IllegalStateException - if the context has been destroyed.

getChannels

public abstract Channel[] getChannels()
Get all channels of this context.

Returns:
array of channels of this context.

pendIO

public abstract void pendIO(double timeout)
                     throws TimeoutException,
                            CAException,
                            java.lang.IllegalStateException
Process all pending IO operations.

Parameters:
timeout - the timeout limit.
Throws:
TimeoutException - if all the IO couldn't be processed.
CAException - if a Channel Exception error occured while processing IOs.
java.lang.IllegalStateException - if the context has been destroyed.

testIO

public abstract boolean testIO()
                        throws CAException,
                               java.lang.IllegalStateException
Tests if all synchronous (ie not specifying listeners) get and channel creation requests are completed. It will only test request and channel created after the last pendIO() call.

Returns:
true if all pending IO request have been processed. False otherwise.
Throws:
CAException - if a Channel Access error occured while testing IOs
java.lang.IllegalStateException - if the context has been destroyed.

pendEvent

public abstract void pendEvent(double time)
                        throws CAException,
                               java.lang.IllegalStateException
Process all pending events.

Parameters:
time - the time during which the Context will process events.
Throws:
CAException - if a Channel Access error occured while pending events
java.lang.IllegalStateException - if the context has been destroyed.

poll

public abstract void poll()
                   throws CAException,
                          java.lang.IllegalStateException
Flush the send buffer and process any outstanding CA background activity.

Throws:
CAException - if a Channel Access error occured while testing IOs
java.lang.IllegalStateException - if the context has been destroyed.

flushIO

public abstract void flushIO()
                      throws CAException,
                             java.lang.IllegalStateException
Flush outstanding IO request to the servers.

Throws:
CAException - if a Channel Access error occured while flushing IOs
java.lang.IllegalStateException - if the context has been destroyed.

attachCurrentThread

public abstract void attachCurrentThread()
                                  throws CAException,
                                         java.lang.IllegalStateException
Attach the calling thread to the list of threads allowed to access this context and all its channels.

Throws:
java.lang.IllegalStateException - if the context has been destroyed. or if the context doesn't support multiple threads.
CAException

printInfo

public void printInfo()
               throws java.lang.IllegalStateException
Prints detailed information about the Context to the standard output stream.

Throws:
java.lang.IllegalStateException - if the context has been destroyed.

printInfo

public void printInfo(java.io.PrintStream out)
               throws java.lang.IllegalStateException
Prints detailed information about the Context to the specified output stream.

Parameters:
out - the output stream.
Throws:
java.lang.IllegalStateException - if the context has been destroyed.

dispose

public void dispose()


Copyright © 2004-2006 Cosylab. All Rights Reserved.