Joram ${version}

org.objectweb.joram.mom.dest
Class DestinationImpl

java.lang.Object
  extended byorg.objectweb.joram.mom.dest.DestinationImpl
All Implemented Interfaces:
DestinationImplMBean, java.io.Serializable
Direct Known Subclasses:
QueueImpl, TopicImpl

public abstract class DestinationImpl
extends java.lang.Object
implements java.io.Serializable, DestinationImplMBean

The DestinationImpl class implements the common behaviour of MOM destinations.

See Also:
Serialized Form

Field Summary
static java.lang.String[] _rights
           
protected  java.util.Hashtable clients
          Table of the destination readers and writers.
 long creationDate
          date of creation.
protected  fr.dyade.aaa.agent.AgentId destId
          Identifier of the agent hosting the destination.
protected  fr.dyade.aaa.agent.AgentId dmqId
          Identifier of the dead message queue this destination must send its dead messages to, if any.
protected  boolean freeReading
          true if the READ access is granted to everybody.
protected  boolean freeWriting
          true if the WRITE access is granted to everybody.
protected  long nbMsgsDeliverSinceCreation
           
protected  long nbMsgsReceiveSinceCreation
           
protected  long nbMsgsSendToDMQSinceCreation
           
static int READ
          READ access value.
static int READWRITE
          READ and WRITE access value.
static int WRITE
          WRITE access value.
 
Constructor Summary
DestinationImpl(fr.dyade.aaa.agent.AgentId destId, fr.dyade.aaa.agent.AgentId adminId)
          Constructs a DestinationImpl.
 
Method Summary
 boolean canBeDeleted()
          Returns true if the destination might be deleted.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, ClientMessages not)
          Method implementing the reaction to a ClientMessages notification holding messages sent by a client.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, fr.dyade.aaa.agent.DeleteNot not)
          Method implementing the reaction to a DeleteNot notification requesting the deletion of the destination.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, Monit_FreeAccess not)
          Method implementing the reaction to a Monit_FreeAccess notification requesting the free access status of this destination.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, Monit_GetDMQSettings not)
          Method implementing the reaction to a Monit_GetDMQSettings notification requesting the destination's DMQ settings.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, Monit_GetReaders not)
          Method implementing the reaction to a Monit_GetReaders notification requesting the identifiers of the destination's readers.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, Monit_GetStat not)
          Method implementing the reaction to a Monit_GetStat notification requesting to get statistic of this destination.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, Monit_GetWriters not)
          Method implementing the reaction to a Monit_GetWriters notification requesting the identifiers of the destination's writers.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, SetDMQRequest not)
          Method implementing the reaction to a SetDMQRequest notification setting the dead message queue identifier for this destination.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, SetRightRequest not)
          Method implementing the reaction to a SetRightRequest notification requesting rights to be set for a user.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, SpecialAdminRequest not)
          Method implementing the reaction to a SpecialAdminRequest notification requesting the special administration of the destination.
protected  void doReact(fr.dyade.aaa.agent.AgentId from, fr.dyade.aaa.agent.UnknownAgent not)
          Method implementing the reaction to an UnknownAgent notification.
 java.lang.String getCreationDate()
          Returns this destination creation time through a String of the form: dow mon dd hh:mm:ss zzz yyyy.
 long getCreationTimeInMillis()
          Returns this destination creation time as a long.
 java.lang.String getDestinationId()
          Returns the unique identifier of the destination.
 java.lang.String getDMQId()
          Return the unique identifier of DMQ set for this destnation if any.
 long getNbMsgsDeliverSinceCreation()
          Returns the number of messages delivered since creation time of this destination.
 long getNbMsgsReceiveSinceCreation()
          Returns the number of messages received since creation time of this destination.
 long getNbMsgsSendToDMQSinceCreation()
          Returns the number of erroneous messages forwarded to the DMQ since creation time of this destination..
 java.lang.String getRight(java.lang.String userid)
          Returns a string representation of rights set on this destination for a particular user.
 java.lang.String[] getRights()
          Returns a string representation of the rights set on this destination.
protected  boolean isAdministrator(fr.dyade.aaa.agent.AgentId client)
          Checks the administering permission of a given client agent.
 boolean isFreeReading()
          Tests if this destination is free for reading.
 boolean isFreeWriting()
          Tests if this destination is free for writing.
protected  boolean isReader(fr.dyade.aaa.agent.AgentId client)
          Checks the reading permission of a given client agent.
protected  boolean isWriter(fr.dyade.aaa.agent.AgentId client)
          Checks the writing permission of a given client agent.
protected  void processSetRight(fr.dyade.aaa.agent.AgentId user, int right)
          set user right.
 void react(fr.dyade.aaa.agent.AgentId from, fr.dyade.aaa.agent.Notification not)
          Distributes the received notifications to the appropriate reactions.
protected  void sendToDMQ(ClientMessages deadMessages, fr.dyade.aaa.agent.AgentId dmqId)
          Sends dead messages to the appropriate dead message queue.
 void setFreeReading(boolean on)
          Sets the FreeReading attribute for this destination.
 void setFreeWriting(boolean on)
          Sets the FreeWriting attribute for this destination.
protected  java.lang.Object specialAdminProcess(SpecialAdminRequest not)
           
protected abstract  void specialProcess(fr.dyade.aaa.agent.Notification not)
          Abstract method to be implemented by subclasses for specifically processing notifications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.joram.mom.dest.DestinationImplMBean
toString
 

Field Detail

destId

protected fr.dyade.aaa.agent.AgentId destId
Identifier of the agent hosting the destination.


freeReading

protected boolean freeReading
true if the READ access is granted to everybody.


freeWriting

protected boolean freeWriting
true if the WRITE access is granted to everybody.


clients

protected java.util.Hashtable clients
Table of the destination readers and writers.


dmqId

protected fr.dyade.aaa.agent.AgentId dmqId
Identifier of the dead message queue this destination must send its dead messages to, if any.


READ

public static int READ
READ access value.


WRITE

public static int WRITE
WRITE access value.


READWRITE

public static int READWRITE
READ and WRITE access value.


creationDate

public long creationDate
date of creation.


nbMsgsReceiveSinceCreation

protected long nbMsgsReceiveSinceCreation

nbMsgsDeliverSinceCreation

protected long nbMsgsDeliverSinceCreation

nbMsgsSendToDMQSinceCreation

protected long nbMsgsSendToDMQSinceCreation

_rights

public static java.lang.String[] _rights
Constructor Detail

DestinationImpl

public DestinationImpl(fr.dyade.aaa.agent.AgentId destId,
                       fr.dyade.aaa.agent.AgentId adminId)
Constructs a DestinationImpl.

Parameters:
destId - Identifier of the agent hosting the destination.
adminId - Identifier of the administrator of the destination.
Method Detail

canBeDeleted

public boolean canBeDeleted()
Returns true if the destination might be deleted.


react

public void react(fr.dyade.aaa.agent.AgentId from,
                  fr.dyade.aaa.agent.Notification not)
           throws fr.dyade.aaa.agent.UnknownNotificationException
Distributes the received notifications to the appropriate reactions.

Throws:
fr.dyade.aaa.agent.UnknownNotificationException - If a received notification is unexpected by the destination.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       SetRightRequest not)
                throws AccessException
Method implementing the reaction to a SetRightRequest notification requesting rights to be set for a user.

Throws:
AccessException - If the requester is not the administrator.

processSetRight

protected void processSetRight(fr.dyade.aaa.agent.AgentId user,
                               int right)
                        throws RequestException
set user right.

Throws:
RequestException

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       SetDMQRequest not)
                throws AccessException
Method implementing the reaction to a SetDMQRequest notification setting the dead message queue identifier for this destination.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       Monit_GetReaders not)
                throws AccessException
Method implementing the reaction to a Monit_GetReaders notification requesting the identifiers of the destination's readers.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       Monit_GetWriters not)
                throws AccessException
Method implementing the reaction to a Monit_GetWriters notification requesting the identifiers of the destination's writers.

Throws:
AccessException - If the requester is not the administrator.

getRights

public java.lang.String[] getRights()
Returns a string representation of the rights set on this destination.

Specified by:
getRights in interface DestinationImplMBean
Returns:
the rights set on this destination.

getRight

public java.lang.String getRight(java.lang.String userid)
Returns a string representation of rights set on this destination for a particular user. The user is pointed out by its unique identifier.

Specified by:
getRight in interface DestinationImplMBean
Parameters:
userid - The user's unique identifier.
Returns:
the rights set on this destination.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       Monit_FreeAccess not)
                throws AccessException
Method implementing the reaction to a Monit_FreeAccess notification requesting the free access status of this destination.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       Monit_GetDMQSettings not)
                throws AccessException
Method implementing the reaction to a Monit_GetDMQSettings notification requesting the destination's DMQ settings.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       Monit_GetStat not)
                throws AccessException
Method implementing the reaction to a Monit_GetStat notification requesting to get statistic of this destination.

Throws:
AccessException - If the requester is not the administrator.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       ClientMessages not)
                throws AccessException
Method implementing the reaction to a ClientMessages notification holding messages sent by a client.

If the sender is not a writer on the destination the messages are sent to the DMQ and an exception is thrown. Otherwise, the processing of the received messages is performed in subclasses.

Throws:
AccessException - If the sender is not a WRITER on the destination.

doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       fr.dyade.aaa.agent.UnknownAgent not)
Method implementing the reaction to an UnknownAgent notification.

If the unknown agent is the DMQ, its identifier is set to null. If it is a client of the destination, it is removed. Specific processing is also done in subclasses.


doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       fr.dyade.aaa.agent.DeleteNot not)
Method implementing the reaction to a DeleteNot notification requesting the deletion of the destination.

The processing is done in subclasses if the sender is an administrator.


doReact

protected void doReact(fr.dyade.aaa.agent.AgentId from,
                       SpecialAdminRequest not)
Method implementing the reaction to a SpecialAdminRequest notification requesting the special administration of the destination.


specialAdminProcess

protected java.lang.Object specialAdminProcess(SpecialAdminRequest not)
                                        throws RequestException
Throws:
RequestException

isReader

protected boolean isReader(fr.dyade.aaa.agent.AgentId client)
Checks the reading permission of a given client agent.

Parameters:
client - AgentId of the client requesting a reading permission.

isWriter

protected boolean isWriter(fr.dyade.aaa.agent.AgentId client)
Checks the writing permission of a given client agent.

Parameters:
client - AgentId of the client requesting a writing permission.

isAdministrator

protected boolean isAdministrator(fr.dyade.aaa.agent.AgentId client)
Checks the administering permission of a given client agent.

Parameters:
client - AgentId of the client requesting an admin permission.

sendToDMQ

protected void sendToDMQ(ClientMessages deadMessages,
                         fr.dyade.aaa.agent.AgentId dmqId)
Sends dead messages to the appropriate dead message queue.

Parameters:
deadMessages - The dead messages.
dmqId - Identifier of the dead message queue to use, null if not provided.

specialProcess

protected abstract void specialProcess(fr.dyade.aaa.agent.Notification not)
Abstract method to be implemented by subclasses for specifically processing notifications.


getDestinationId

public java.lang.String getDestinationId()
Returns the unique identifier of the destination.

Specified by:
getDestinationId in interface DestinationImplMBean
Returns:
the unique identifier of the destination.

isFreeReading

public boolean isFreeReading()
Tests if this destination is free for reading.

Specified by:
isFreeReading in interface DestinationImplMBean
Returns:
true if anyone can receive messages from this destination; false otherwise.

setFreeReading

public void setFreeReading(boolean on)
Sets the FreeReading attribute for this destination.

Specified by:
setFreeReading in interface DestinationImplMBean
Parameters:
on - if true anyone can receive message from this destination.

isFreeWriting

public boolean isFreeWriting()
Tests if this destination is free for writing.

Specified by:
isFreeWriting in interface DestinationImplMBean
Returns:
true if anyone can send messages to this destination; false otherwise.

setFreeWriting

public void setFreeWriting(boolean on)
Sets the FreeWriting attribute for this destination.

Specified by:
setFreeWriting in interface DestinationImplMBean
Parameters:
on - if true anyone can send message to this destination.

getDMQId

public java.lang.String getDMQId()
Return the unique identifier of DMQ set for this destnation if any.

Specified by:
getDMQId in interface DestinationImplMBean
Returns:
the unique identifier of DMQ set for this destnation if any; null otherwise.

getCreationTimeInMillis

public long getCreationTimeInMillis()
Returns this destination creation time as a long.

Specified by:
getCreationTimeInMillis in interface DestinationImplMBean
Returns:
the destination creation time as UTC milliseconds from the epoch.

getCreationDate

public java.lang.String getCreationDate()
Returns this destination creation time through a String of the form: dow mon dd hh:mm:ss zzz yyyy.

Specified by:
getCreationDate in interface DestinationImplMBean
Returns:
the destination creation time.

getNbMsgsReceiveSinceCreation

public long getNbMsgsReceiveSinceCreation()
Returns the number of messages received since creation time of this destination.

Specified by:
getNbMsgsReceiveSinceCreation in interface DestinationImplMBean
Returns:
the number of messages received since creation time.

getNbMsgsDeliverSinceCreation

public long getNbMsgsDeliverSinceCreation()
Returns the number of messages delivered since creation time of this destination. It includes messages all delivered messages to a consumer, already acknowledged or not.

Specified by:
getNbMsgsDeliverSinceCreation in interface DestinationImplMBean
Returns:
the number of messages delivered since creation time.

getNbMsgsSendToDMQSinceCreation

public long getNbMsgsSendToDMQSinceCreation()
Returns the number of erroneous messages forwarded to the DMQ since creation time of this destination..

Specified by:
getNbMsgsSendToDMQSinceCreation in interface DestinationImplMBean
Returns:
the number of erroneous messages forwarded to the DMQ.

Joram ${version}

Copyright © 2005 Scalagent - All rights reserved