org.objectweb.joram.mom.dest
Class DestinationImpl

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

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

The DestinationImpl class implements the common behaviour of MOM destinations.

See Also:
Serialized Form

Field Summary
protected  AgentId adminId
          Identifier of the destination's administrator.
protected  java.util.Hashtable clients
          Table of the destination readers and writers.
protected  AgentId destId
          Identifier of the agent hosting the destination.
protected  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.
static int READ
          READ access value.
static int READWRITE
          READ and WRITE access value.
static int WRITE
          WRITE access value.
 
Constructor Summary
DestinationImpl(AgentId destId, AgentId adminId)
          Constructs a DestinationImpl.
 
Method Summary
 boolean canBeDeleted()
          Returns true if the destination might be deleted.
protected  void doReact(AgentId from, ClientMessages not)
          Method implementing the reaction to a ClientMessages notification holding messages sent by a client.
protected  void doReact(AgentId from, DeleteNot not)
          Method implementing the reaction to a DeleteNot notification requesting the deletion of the destination.
protected  void doReact(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(AgentId from, Monit_GetDMQSettings not)
          Method implementing the reaction to a Monit_GetDMQSettings notification requesting the destination's DMQ settings.
protected  void doReact(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(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(AgentId from, SetDMQRequest not)
          Method implementing the reaction to a SetDMQRequest notification setting the dead message queue identifier for this destination.
protected  void doReact(AgentId from, SetRightRequest not)
          Method implementing the reaction to a SetRightRequest notification requesting rights to be set for a user.
protected  void doReact(AgentId from, SpecialAdminRequest not)
          Method implementing the reaction to a SpecialAdminRequest notification requesting the special administration of the destination.
protected  void doReact(AgentId from, UnknownAgent not)
          Method implementing the reaction to an UnknownAgent notification.
protected  boolean isAdministrator(AgentId client)
          Checks the administering permission of a given client agent.
protected  boolean isReader(AgentId client)
          Checks the reading permission of a given client agent.
protected  boolean isWriter(AgentId client)
          Checks the writing permission of a given client agent.
protected  void processSetRight(AgentId user, int right)
          set user right.
 void react(AgentId from, Notification not)
          Distributes the received notifications to the appropriate reactions.
protected  void sendToDMQ(ClientMessages deadMessages, AgentId dmqId)
          Sends dead messages to the appropriate dead message queue.
protected  java.lang.Object specialAdminProcess(SpecialAdminRequest not)
           
protected abstract  void specialProcess(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
 

Field Detail

adminId

protected AgentId adminId
Identifier of the destination's administrator.


destId

protected 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 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.

Constructor Detail

DestinationImpl

public DestinationImpl(AgentId destId,
                       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(AgentId from,
                  Notification not)
           throws UnknownNotificationException
Distributes the received notifications to the appropriate reactions.

Throws:
UnknownNotificationException - If a received notification is unexpected by the destination.

doReact

protected void doReact(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(AgentId user,
                               int right)
                        throws RequestException
set user right.

Throws:
RequestException

doReact

protected void doReact(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(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(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.

doReact

protected void doReact(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(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(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(AgentId from,
                       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(AgentId from,
                       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(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(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(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(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,
                         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(Notification not)
Abstract method to be implemented by subclasses for specifically processing notifications.



Copyright ? 2004 Scalagent - All rights reserved