Package gov.aps.jca
Class Context
- java.lang.Object
-
- gov.aps.jca.Context
-
- Direct Known Subclasses:
CAJContext
public abstract class Context extends 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
Constructors Constructor Description Context()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddContextExceptionListener(ContextExceptionListener l)Add a ContextExceptionListener to this context.abstract voidaddContextMessageListener(ContextMessageListener l)Add a ContextMessageListener to this context.abstract voidattachCurrentThread()Attach the calling thread to the list of threads allowed to access this context and all its channels.ChannelcreateChannel(String name)Create a new Channel using this context to access a process variable.ChannelcreateChannel(String name, short priority)Create a new Channel using this context to access a process variable.ChannelcreateChannel(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 ChannelcreateChannel(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.abstract voiddestroy()Clear all ressources attached to this Contextvoiddispose()abstract voidflushIO()Flush outstanding IO request to the servers.abstract Channel[]getChannels()Get all channels of this context.abstract ContextExceptionListener[]getContextExceptionListeners()abstract ContextMessageListener[]getContextMessageListeners()abstract VersiongetVersion()voidinitialize()abstract voidpendEvent(double time)Process all pending events.abstract voidpendIO(double timeout)Process all pending IO operations.abstract voidpoll()Flush the send buffer and process any outstanding CA background activity.voidprintInfo()Prints detailed information about the Context to the standard output stream.voidprintInfo(PrintStream out)Prints detailed information about the Context to the specified output stream.abstract voidremoveContextExceptionListener(ContextExceptionListener l)Removes a ContextExceptionListener from this context.abstract voidremoveContextMessageListener(ContextMessageListener l)Removes a ContextMessageListener from this context.abstract booleantestIO()Tests if all synchronous (ie not specifying listeners) get and channel creation requests are completed.
-
-
-
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 IllegalStateException
- Returns:
- an array containing all ContextMessageListeners attached to this context.
- Throws:
IllegalStateException- if the context has been destroyed.
-
addContextMessageListener
public abstract void addContextMessageListener(ContextMessageListener l) throws CAException, IllegalStateException
Add a ContextMessageListener to this context.- Parameters:
l- the listener to add- Throws:
IllegalStateException- if the context has been destroyed.CAException
-
removeContextMessageListener
public abstract void removeContextMessageListener(ContextMessageListener l) throws CAException, IllegalStateException
Removes a ContextMessageListener from this context.- Parameters:
l- the listener to remove- Throws:
IllegalStateException- if the context has been destroyed.CAException
-
getContextExceptionListeners
public abstract ContextExceptionListener[] getContextExceptionListeners() throws IllegalStateException
- Returns:
- an array containing all ContextExceptionListeners attached to this context.
- Throws:
IllegalStateException- if the context has been destroyed.
-
addContextExceptionListener
public abstract void addContextExceptionListener(ContextExceptionListener l) throws CAException, IllegalStateException
Add a ContextExceptionListener to this context.- Parameters:
l- the listener to add- Throws:
IllegalStateException- if the context has been destroyed.CAException
-
removeContextExceptionListener
public abstract void removeContextExceptionListener(ContextExceptionListener l) throws CAException, IllegalStateException
Removes a ContextExceptionListener from this context.- Parameters:
l- the listener to remove- Throws:
IllegalStateException- if the context has been destroyed.CAException
-
destroy
public abstract void destroy() throws CAException, IllegalStateExceptionClear all ressources attached to this Context- Throws:
IllegalStateException- if the context has been destroyed.CAException
-
createChannel
public Channel createChannel(String name) throws CAException, IllegalArgumentException, 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.IllegalArgumentException- is thrown if the channel's name is null or empty.IllegalStateException- if the context has been destroyed.
-
createChannel
public Channel createChannel(String name, short priority) throws CAException, IllegalArgumentException, 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.IllegalArgumentException- is thrown if the channel's name is null or empty.IllegalStateException- if the context has been destroyed.
-
createChannel
public Channel createChannel(String name, ConnectionListener l) throws CAException, 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.IllegalStateException- if the context has been destroyed.
-
createChannel
public abstract Channel createChannel(String name, ConnectionListener l, short priority) throws CAException, 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.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, IllegalStateExceptionProcess 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.IllegalStateException- if the context has been destroyed.
-
testIO
public abstract boolean testIO() throws CAException, IllegalStateExceptionTests 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 IOsIllegalStateException- if the context has been destroyed.
-
pendEvent
public abstract void pendEvent(double time) throws CAException, IllegalStateExceptionProcess all pending events.- Parameters:
time- the time during which the Context will process events.- Throws:
CAException- if a Channel Access error occured while pending eventsIllegalStateException- if the context has been destroyed.
-
poll
public abstract void poll() throws CAException, IllegalStateExceptionFlush the send buffer and process any outstanding CA background activity.- Throws:
CAException- if a Channel Access error occured while testing IOsIllegalStateException- if the context has been destroyed.
-
flushIO
public abstract void flushIO() throws CAException, IllegalStateExceptionFlush outstanding IO request to the servers.- Throws:
CAException- if a Channel Access error occured while flushing IOsIllegalStateException- if the context has been destroyed.
-
attachCurrentThread
public abstract void attachCurrentThread() throws CAException, IllegalStateExceptionAttach the calling thread to the list of threads allowed to access this context and all its channels.- Throws:
IllegalStateException- if the context has been destroyed. or if the context doesn't support multiple threads.CAException
-
printInfo
public void printInfo() throws IllegalStateExceptionPrints detailed information about the Context to the standard output stream.- Throws:
IllegalStateException- if the context has been destroyed.
-
printInfo
public void printInfo(PrintStream out) throws IllegalStateException
Prints detailed information about the Context to the specified output stream.- Parameters:
out- the output stream.- Throws:
IllegalStateException- if the context has been destroyed.
-
dispose
public void dispose()
-
-