Package org.jcsp.lang
Class AltingConnectionClientImpl<T>
- java.lang.Object
-
- org.jcsp.lang.Guard
-
- org.jcsp.lang.AltingConnectionClient<T>
-
- org.jcsp.lang.AltingConnectionClientImpl<T>
-
- All Implemented Interfaces:
ConnectionClient<T>
- Direct Known Subclasses:
NetAltingConnectionClient,SharedAltingConnectionClient
public class AltingConnectionClientImpl<T> extends AltingConnectionClient<T>
This class does not need to be used by standard JCSP users. It is exposed so that the connection mechanism can be extended for custom connections.
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelOutputbackToClientprivate static intCLIENT_STATE_CLOSEDprivate static intCLIENT_STATE_MADE_REQprivate static intCLIENT_STATE_OPENprivate intcurrentClientStateprivate AltingChannelInput<ConnectionMessage<T>>fromServerprivate ConnectionClientMessagemsgprivate ConnectionClientOpenMessagemsgOpenprivate ChannelOutputopenToServerprivate ChannelOutputreqToServer
-
Constructor Summary
Constructors Modifier Constructor Description protectedAltingConnectionClientImpl(AltingChannelInput fromServer, ChannelOutput openToServer, ChannelOutput reqToServer, ChannelOutput backToClient)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclaim()This claims a lock on the client.booleanisOpen()Returns whether the server has kept its end of the Connection open.protected voidrelease()This releases a lock on the client.Treply()Receives some data back from the server afterrequest(Object)has been called.voidrequest(T data)Sends some data over the connection to server once the connection has been opened.-
Methods inherited from class org.jcsp.lang.AltingConnectionClient
disable, enable, getAltingChannel, pending, setAltingChannel
-
-
-
-
Field Detail
-
currentClientState
private int currentClientState
-
CLIENT_STATE_CLOSED
private static final int CLIENT_STATE_CLOSED
- See Also:
- Constant Field Values
-
CLIENT_STATE_MADE_REQ
private static final int CLIENT_STATE_MADE_REQ
- See Also:
- Constant Field Values
-
CLIENT_STATE_OPEN
private static final int CLIENT_STATE_OPEN
- See Also:
- Constant Field Values
-
fromServer
private AltingChannelInput<ConnectionMessage<T>> fromServer
-
openToServer
private ChannelOutput openToServer
-
reqToServer
private ChannelOutput reqToServer
-
backToClient
private ChannelOutput backToClient
-
msg
private ConnectionClientMessage msg
-
msgOpen
private ConnectionClientOpenMessage msgOpen
-
-
Constructor Detail
-
AltingConnectionClientImpl
protected AltingConnectionClientImpl(AltingChannelInput fromServer, ChannelOutput openToServer, ChannelOutput reqToServer, ChannelOutput backToClient)
Constructs a new instance. This constructor must be called by a subclass which is responsible for creating the channels used by the connection and must pass them into this constructor.
-
-
Method Detail
-
request
public void request(T data) throws java.lang.IllegalStateException
Sends some data over the connection to server once the connection has been opened.- Parameters:
data- theObjectto send to the server.- Throws:
java.lang.IllegalStateException- if the method is called when it is not meant to be.
-
reply
public T reply() throws java.lang.IllegalStateException
Receives some data back from the server afterrequest(Object)has been called.- Returns:
- the
Objectsent from the server. - Throws:
java.lang.IllegalStateException- if the method is called when it is not meant to be.
-
isOpen
public boolean isOpen() throws java.lang.IllegalStateExceptionReturns whether the server has kept its end of the Connection open. This should only be called after a call toreply()and before any other Connection method is called.- Returns:
trueiff the server has kept the connection open.- Throws:
java.lang.IllegalStateException
-
claim
protected void claim()
This claims a lock on the client. This implementation does nothing as instances of this class are only meant to be used with One2?Connection objects.
-
release
protected void release()
This releases a lock on the client. This implementation does nothing as instances of this class are only meant to be used with One2?Connection objects.
-
-