Package org.objectweb.joram.mom.proxies
Class ClientContext
- java.lang.Object
-
- org.objectweb.joram.mom.proxies.ClientContext
-
- All Implemented Interfaces:
Encodable,Serializable
public final class ClientContext extends Object implements Serializable, Encodable
TheClientContextclass holds the data related to a connection context. Contexts are only reloaded during a broker restart to allow them to be cleaned up, they are then immediately deleted.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClientContext.ClientContextFactory(package private) static classClientContext.MultiReplyContext
-
Field Summary
Fields Modifier and Type Field Description private Vector<String>activeSubsVector of active subscriptions' names.private intcancelledRequestIdIdentifier of a cancelled "receive" request, set when a PTP listener has been unset.private Hashtable<Integer,ClientContext.MultiReplyContext>commitTableContexts waiting for the replies from some local agentsprivate static booleanDEBUGprivate Hashtable<AgentId,AgentId>deliveringQueuesIdentifiers of queues delivering messages.private booleanfirstprivate intidContext identifier.static Loggerloggerloggerprivate booleanmodifiedprivate ProxyAgentItfproxyAn handle to proxy Agentprivate AgentIdproxyIdThe proxy's agent identifierprivate Vector<AbstractJmsReply>repliesBufferPending replies waiting for the context to be activated.private static longserialVersionUIDdefine serialVersionUID for interoperabilityprivate booleanstartedtrueif the context is activated.private Vector<AgentId>tempDestinationsVector of temporary destinations.private Hashtable<Xid,XACnxPrepare>transactionsTablePrepared transactions objects waiting for commit.private StringtxName-
Fields inherited from interface fr.dyade.aaa.common.encoding.Encodable
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
-
-
Constructor Summary
Constructors Constructor Description ClientContext()ClientContext(AgentId proxyId, int id)Constructs aClientContextinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddDeliveringQueue(AgentId queueId)Adds, if not already, the identifier of a delivering queue.(package private) voidaddMultiReplyContext(int requestId, int asyncReplyCount)Some requests may require to wait for several SendReplyNot notifications before replying to the client.(package private) voidaddPendingDelivery(AbstractJmsReply reply)Adds a pending delivery.(package private) voidaddSubName(String subName)Adds an active subscription name.(package private) voidaddTemporaryDestination(AgentId destId)Adds a temporary destination identifier.(package private) voidcancelReceive(int cancelledRequestId)Cancels a "receive" request.(package private) voidclearPendingDeliveries()Clears the pending deliveries buffer.voiddecode(Decoder decoder)Decodes the content of this objectvoiddelete()voidencode(Encoder encoder)Encodes the content of this object(package private) List<String>getActiveSubList()(package private) Iterator<String>getActiveSubs()Returns the active subscriptions' names.(package private) intgetCancelledReceive()Returns the cancelled "receive" request identifier.(package private) Iterator<AgentId>getDeliveringQueues()Returns the identifiers of the delivering queues.(package private) Map<AgentId,AgentId>getDeliveringQueueTable()intgetEncodableClassId()Returns a unique class identifier.intgetEncodedSize()Returns the size of the byte array that results from the encoding of this object.(package private) intgetId()Returns the identifier of the context.(package private) Iterator<AbstractJmsReply>getPendingDeliveries()Returns the pending deliveries.AgentIdgetProxyId()(package private) List<AgentId>getTempDestinationList()(package private) Iterator<AgentId>getTempDestinations()static StringgetTransactionPrefix(AgentId proxyId)(package private) Hashtable<Xid,XACnxPrepare>getTransactionsTable()(package private) Iterator<Xid>getTxIds()Returns the identifiers of the prepared transactions.StringgetTxName()(package private) XACnxPreparegetTxPrepare(Object key)Returns and deletes a given transaction "prepare".(package private) booleanisActivated()Returnstrueif the context is activated.booleanisPrepared(Object key)static ClientContextload(String txName)(package private) voidregisterTxPrepare(Object key, XACnxPrepare prepare)Registers a given transaction "prepare".(package private) voidremoveSubName(String subName)Removes an active subscription name.(package private) voidremoveTemporaryDestination(AgentId destId)Removes a temporary destination identifier.voidsave()(package private) voidsetActivated(boolean started)Sets the activation status of the context.private voidsetModified()(package private) voidsetProxyAgent(ProxyAgentItf proxy)(package private) intsetReply(int requestId)Called by UserAgent when a SendReplyNot arrived.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
logger
public static final Logger logger
logger
-
DEBUG
private static final boolean DEBUG
-
id
private int id
Context identifier.
-
deliveringQueues
private Hashtable<AgentId,AgentId> deliveringQueues
Identifiers of queues delivering messages.
-
transactionsTable
private Hashtable<Xid,XACnxPrepare> transactionsTable
Prepared transactions objects waiting for commit.
-
started
private transient boolean started
trueif the context is activated.
-
cancelledRequestId
private transient int cancelledRequestId
Identifier of a cancelled "receive" request, set when a PTP listener has been unset.
-
repliesBuffer
private transient Vector<AbstractJmsReply> repliesBuffer
Pending replies waiting for the context to be activated.
-
commitTable
private transient Hashtable<Integer,ClientContext.MultiReplyContext> commitTable
Contexts waiting for the replies from some local agents
-
proxyId
private AgentId proxyId
The proxy's agent identifier
-
proxy
private transient ProxyAgentItf proxy
An handle to proxy Agent
-
txName
private transient String txName
-
modified
private transient boolean modified
-
first
private transient boolean first
-
-
Constructor Detail
-
ClientContext
ClientContext()
-
ClientContext
ClientContext(AgentId proxyId, int id)
Constructs aClientContextinstance.- Parameters:
proxyId- The proxy's agent identifier.id- Identifier of the context.
-
-
Method Detail
-
getId
int getId()
Returns the identifier of the context.
-
addTemporaryDestination
void addTemporaryDestination(AgentId destId)
Adds a temporary destination identifier.
-
removeTemporaryDestination
void removeTemporaryDestination(AgentId destId)
Removes a temporary destination identifier.
-
addDeliveringQueue
void addDeliveringQueue(AgentId queueId)
Adds, if not already, the identifier of a delivering queue.
-
getDeliveringQueues
Iterator<AgentId> getDeliveringQueues()
Returns the identifiers of the delivering queues.
-
setActivated
void setActivated(boolean started)
Sets the activation status of the context.
-
isActivated
boolean isActivated()
Returnstrueif the context is activated.
-
cancelReceive
void cancelReceive(int cancelledRequestId)
Cancels a "receive" request.
-
getCancelledReceive
int getCancelledReceive()
Returns the cancelled "receive" request identifier.
-
addSubName
void addSubName(String subName)
Adds an active subscription name.
-
removeSubName
void removeSubName(String subName)
Removes an active subscription name.
-
addPendingDelivery
void addPendingDelivery(AbstractJmsReply reply)
Adds a pending delivery.
-
getPendingDeliveries
Iterator<AbstractJmsReply> getPendingDeliveries()
Returns the pending deliveries.
-
clearPendingDeliveries
void clearPendingDeliveries()
Clears the pending deliveries buffer.
-
addMultiReplyContext
void addMultiReplyContext(int requestId, int asyncReplyCount)Some requests may require to wait for several SendReplyNot notifications before replying to the client.- Parameters:
requestId-asyncReplyCount-
-
getProxyId
public AgentId getProxyId()
-
setProxyAgent
void setProxyAgent(ProxyAgentItf proxy)
-
setModified
private final void setModified()
-
setReply
int setReply(int requestId)
Called by UserAgent when a SendReplyNot arrived.- Parameters:
requestId-- Returns:
- > 0 if there are still some pending replies, 0 if all the replies arrived (the context is removed) or if the context doesn't exist
-
registerTxPrepare
void registerTxPrepare(Object key, XACnxPrepare prepare) throws Exception
Registers a given transaction "prepare".- Throws:
Exception
-
getTxPrepare
XACnxPrepare getTxPrepare(Object key)
Returns and deletes a given transaction "prepare".
-
isPrepared
public boolean isPrepared(Object key)
- Parameters:
key- XID- Returns:
- true if prepared transation.
-
getEncodableClassId
public int getEncodableClassId()
Description copied from interface:EncodableReturns a unique class identifier.- Specified by:
getEncodableClassIdin interfaceEncodable- Returns:
- a unique class identifier
-
getEncodedSize
public int getEncodedSize() throws ExceptionDescription copied from interface:EncodableReturns the size of the byte array that results from the encoding of this object.- Specified by:
getEncodedSizein interfaceEncodable- Returns:
- the size of the encoded byte array
- Throws:
Exception- if an error occurs
-
encode
public void encode(Encoder encoder) throws Exception
Description copied from interface:EncodableEncodes the content of this object
-
decode
public void decode(Decoder decoder) throws Exception
Description copied from interface:EncodableDecodes the content of this object
-
getTxName
public final String getTxName()
-
load
public static final ClientContext load(String txName) throws Exception
- Throws:
Exception
-
save
public final void save()
-
delete
public void delete()
-
getTransactionsTable
Hashtable<Xid,XACnxPrepare> getTransactionsTable()
-
-