public abstract class Destination extends Agent implements DestinationMBean
Destination
class implements the common behavior of
MOM destinations.Modifier and Type | Field and Description |
---|---|
static String[] |
_rights |
private AgentId |
adminId
Identifier of the destination's administrator.
|
protected Hashtable |
clients
Table of the destination readers and writers.
|
long |
creationDate
date of creation.
|
private boolean |
deletable
true if the destination successfully processed a deletion
request. |
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. |
private List<MessageInterceptor> |
interceptors |
private List<Properties> |
interceptorsProp
the interceptors list.
|
static org.objectweb.util.monolog.api.Logger |
logger |
protected long |
nbMsgsDeliverSinceCreation |
protected long |
nbMsgsSentToDMQSinceCreation |
private long |
period
period to run task at regular interval: cleaning, load-balancing, etc.
|
static int |
READ
READ access value.
|
static int |
READWRITE
READ and WRITE access value.
|
(package private) StringBuffer |
strbuf
Transient
StringBuffer used to build message, this buffer
is created during agent initialization, then reused during the destination
life. |
protected WakeUpTask |
task |
static String |
WAKEUP_PERIOD |
static int |
WRITE
WRITE access value.
|
agentProfiling, emptyString, fixed, logmon
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
Modifier | Constructor and Description |
---|---|
|
Destination()
Empty constructor for newInstance().
|
protected |
Destination(String name,
boolean fixed,
int stamp)
Constructor with parameters for fixing the destination and specifying its
identifier.
|
Modifier and Type | Method and Description |
---|---|
private void |
addInterceptor(String agentId,
String agentName,
Properties prop) |
void |
agentFinalize(boolean lastTime)
Finalizes the agent before it is garbaged.
|
protected void |
agentInitialize(boolean firstTime)
Gives this agent an opportunity to initialize after having been deployed,
and each time it is loaded into memory.
|
private boolean |
canBeDeleted()
Returns
true if the destination might be deleted. |
protected void |
clientMessages(AgentId from,
ClientMessages not)
Method implementing the reaction to a
ClientMessages
notification holding messages sent by a client. |
void |
decode(Decoder decoder)
Decodes the object.
|
void |
delete()
Permits this agent to destroy itself.
|
protected void |
deleteNot(AgentId from,
DeleteNot not)
Method implementing the reaction to a
DeleteNot
notification requesting the deletion of the destination. |
protected abstract void |
doClientMessages(AgentId from,
ClientMessages not,
boolean throwsExceptionOnFullDest) |
protected abstract void |
doDeleteNot(DeleteNot not) |
protected abstract void |
doRightRequest(AgentId user,
int right)
This method is needed for right revocation.
|
private void |
doSetPeriod(long period) |
protected abstract void |
doUnknownAgent(UnknownAgent not) |
void |
encode(Encoder encoder)
Encodes the object.
|
protected abstract void |
finalize(boolean lastTime)
Finalizes the destination before it is garbaged.
|
protected void |
forward(AgentId to,
Notification not) |
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.
|
String |
getDestinationId()
Returns the unique identifier of the destination.
|
AgentId |
getDMQAgentId() |
String |
getDMQId()
Return the unique identifier of DMQ set for this destination if any.
|
int |
getEncodedSize()
Returns the size of the encoded object.
|
protected Hashtable |
getJMXStatistics(String names)
Returns values of all valid JMX attributes about the destination.
|
String |
getMBeanName() |
long |
getNbMsgsDeliverSinceCreation()
Returns the number of messages delivered since creation time of this
destination.
|
abstract long |
getNbMsgsReceiveSinceCreation()
Returns the number of messages received since creation time of this
destination.
|
long |
getNbMsgsSentToDMQSinceCreation()
Returns the number of erroneous messages forwarded to the DMQ since
creation time of this destination..
|
long |
getPeriod()
Returns the period value of this destination, -1 if not set.
|
String |
getRight(String userid)
Returns a string representation of rights set on this destination for a
particular user.
|
String[] |
getRights()
Returns a string representation of the rights set on this destination.
|
protected void |
getRights(AgentId from,
GetRightsRequestNot not)
Method implementing the reaction to a
GetRightsRequest
notification requesting the rights about this destination. |
(package private) abstract Properties |
getStats() |
abstract byte |
getType()
Returns the type of this destination: Queue or Topic.
|
protected void |
handleAdminRequestNot(AgentId from,
FwdAdminRequestNot not) |
protected void |
handleDeniedMessage(String msgId,
AgentId replyTo)
Method used to do specific actions when a message is denied because of a
lack of rights.
|
protected abstract void |
initialize(boolean firstTime)
Initializes the destination.
|
protected boolean |
interceptorsAvailable() |
protected boolean |
isAdministrator(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 |
isLocal(AgentId id) |
protected boolean |
isReader(AgentId client)
Checks the reading permission of a given client agent.
|
protected boolean |
isValidJMXAttribute(String attrName)
This method allows to exclude some JMX attribute of getJMXStatistics method.
|
protected boolean |
isWriter(AgentId client)
Checks the writing permission of a given client agent.
|
protected void |
postProcess(ClientMessages msgs)
This method is needed to add processing after the standard handling.
|
protected ClientMessages |
preProcess(AgentId from,
ClientMessages msgs)
This method is needed to add processing before the standard handling.
|
protected void |
processAdminCommand(AdminCommandRequest request,
AgentId replyTo,
String requestMsgId)
Proccess an admin command.
|
protected Message |
processInterceptors(Message msg)
Interceptors process
|
protected void |
processSetRight(AgentId user,
int right)
set user right.
|
protected Properties |
processStartHandler(Properties prop)
Start the acquisition queue/topic handler.
|
protected Properties |
processStopHandler(Properties prop)
Stop the acquisition queue/topic handler.
|
void |
react(AgentId from,
Notification not)
Distributes the received notifications to the appropriate reactions.
|
private void |
readObject(ObjectInputStream in) |
private void |
removeInterceptor(String classNames) |
private void |
replaceInterceptor(String agentId,
String agentName,
Properties prop) |
protected void |
replyToTopic(AdminReply reply,
AgentId replyTo,
String requestMsgId,
String replyMsgId) |
protected void |
requestGroupNot(AgentId from,
RequestGroupNot not) |
void |
setAdminId(AgentId adminId)
Sets the administrator of the destination.
|
void |
setFreeReading(boolean on)
Sets the
FreeReading attribute for this destination. |
void |
setFreeWriting(boolean on)
Sets the
FreeWriting attribute for this destination. |
void |
setPeriod(long period)
Sets or unsets the period for this destination.
|
void |
setProperties(Properties prop,
boolean firstTime)
Sets the configuration of a
Destination . |
protected void |
setRight(SetRight request,
AgentId replyTo,
String requestMsgId,
String replyMsgId)
Method implementing the reaction to a
SetRightRequest
notification requesting rights to be set for a user. |
protected void |
unknownAgent(AgentId from,
UnknownAgent not)
Method implementing the reaction to an
UnknownAgent
notification. |
abstract void |
wakeUpNot(WakeUpNot not) |
private void |
writeObject(ObjectOutputStream out) |
agentSave, delete, delete, deploy, deploy, getAgentId, getCommitTime, getEncodableClassId, getId, getLogTopic, getName, getReactNb, getReactTime, hasName, isAgentProfiling, isDeployed, isFixed, isUpdated, needToBeCommited, resetCommitTime, resetReactTime, resetTimer, save, sendTo, sendTo, sendTo, setAgentProfiling, setName, setNoSave, setSave, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName, toString
getAgentId, getCommitTime, getReactNb, getReactTime, isAgentProfiling, isFixed, resetCommitTime, resetReactTime, resetTimer, setAgentProfiling
public static org.objectweb.util.monolog.api.Logger logger
public static final String WAKEUP_PERIOD
private boolean deletable
true
if the destination successfully processed a deletion
request.private long period
private AgentId adminId
protected transient WakeUpTask task
private List<Properties> interceptorsProp
private transient List<MessageInterceptor> interceptors
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 Hashtable clients
public static int READ
public static int WRITE
public static int READWRITE
protected AgentId dmqId
transient StringBuffer strbuf
StringBuffer
used to build message, this buffer
is created during agent initialization, then reused during the destination
life.public long creationDate
protected long nbMsgsDeliverSinceCreation
protected long nbMsgsSentToDMQSinceCreation
public static String[] _rights
public Destination()
protected Destination(String name, boolean fixed, int stamp)
public abstract byte getType()
DestinationConstants.TOPIC_TYPE
,
DestinationConstants.QUEUE_TYPE
protected void agentInitialize(boolean firstTime) throws Exception
agentInitialize
in class Agent
firstTime
- true when first called by the factoryException
- unspecialized exceptionprotected abstract void initialize(boolean firstTime) throws Exception
firstTime
- true when first called by the factoryException
public void agentFinalize(boolean lastTime)
agentFinalize
in class Agent
lastime
- true if the destination is deletedprotected abstract void finalize(boolean lastTime)
lastime
- true if the destination is deletedpublic String getMBeanName()
abstract Properties getStats()
public void react(AgentId from, Notification not) throws Exception
private void doSetPeriod(long period)
public final void setAdminId(AgentId adminId)
adminId
- Identifier of the administrator of the destination.public void setProperties(Properties prop, boolean firstTime) throws Exception
Destination
. Be careful, this is
done a first time before Agent.deploy()
, so the agent is serialized and
initialized afterwards.prop
- The initial set of properties.Exception
protected boolean isLocal(AgentId id)
private final boolean canBeDeleted()
true
if the destination might be deleted.public long getPeriod()
getPeriod
in interface DestinationMBean
public void setPeriod(long period)
setPeriod
in interface DestinationMBean
period
- The period value to be set or -1 for unsetting previous
value (ignore 0).public abstract void wakeUpNot(WakeUpNot not)
protected void setRight(SetRight request, AgentId replyTo, String requestMsgId, String replyMsgId)
SetRightRequest
notification requesting rights to be set for a user.not
- The notification describing the security modifications.protected abstract void doRightRequest(AgentId user, int right)
user
- The user about right modification.right
- The right modification.protected void processSetRight(AgentId user, int right) throws RequestException
RequestException
protected void getRights(AgentId from, GetRightsRequestNot not) throws AccessException
GetRightsRequest
notification requesting the rights about this destination.AccessException
- If the requester is not the administrator.public String[] getRights()
getRights
in interface DestinationMBean
public String getRight(String userid)
getRight
in interface DestinationMBean
userid
- The user's unique identifier.protected boolean isValidJMXAttribute(String attrName)
attrName
- name of attribute to test.protected final Hashtable getJMXStatistics(String names)
names
- A comma separated list of requested JMX attribute names.protected void clientMessages(AgentId from, ClientMessages not) throws AccessException
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.
AccessException
- If the sender is not a WRITER on the
destination.protected void handleDeniedMessage(String msgId, AgentId replyTo)
protected void unknownAgent(AgentId from, UnknownAgent not)
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.
protected void deleteNot(AgentId from, DeleteNot not)
DeleteNot
notification requesting the deletion of the destination.
The processing is done in subclasses if the sender is an administrator.
protected void requestGroupNot(AgentId from, RequestGroupNot not)
protected boolean isReader(AgentId client)
client
- AgentId of the client requesting a reading permission.protected boolean isWriter(AgentId client)
client
- AgentId of the client requesting a writing permission.protected boolean isAdministrator(AgentId client)
client
- AgentId of the client requesting an admin permission.protected abstract void doClientMessages(AgentId from, ClientMessages not, boolean throwsExceptionOnFullDest) throws AccessException
AccessException
protected abstract void doUnknownAgent(UnknownAgent not)
protected abstract void doDeleteNot(DeleteNot not)
public void delete()
Agent
delete
in interface AgentMBean
delete
in interface DestinationMBean
delete
in class Agent
protected ClientMessages preProcess(AgentId from, ClientMessages msgs)
Queue
and Topic
.
The incoming messages can be modified or deleted during the processing.from
- The sender of the messagemsgs
- The incoming messages.protected void postProcess(ClientMessages msgs)
Queue
and Topic
.
The incoming messages can be modified or deleted during the processing.from
- The sender of the messagemsgs
- The incoming messages.private void writeObject(ObjectOutputStream out) throws IOException
IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final String getDestinationId()
getDestinationId
in interface DestinationMBean
public boolean isFreeReading()
isFreeReading
in interface DestinationMBean
public void setFreeReading(boolean on)
FreeReading
attribute for this destination.setFreeReading
in interface DestinationMBean
on
- if true anyone can receive message from this destination.public boolean isFreeWriting()
isFreeWriting
in interface DestinationMBean
public void setFreeWriting(boolean on)
FreeWriting
attribute for this destination.setFreeWriting
in interface DestinationMBean
on
- if true anyone can send message to this destination.public String getDMQId()
getDMQId
in interface DestinationMBean
public AgentId getDMQAgentId()
public long getCreationTimeInMillis()
getCreationTimeInMillis
in interface DestinationMBean
public String getCreationDate()
String
of
the form: dow mon dd hh:mm:ss zzz yyyy
.getCreationDate
in interface DestinationMBean
public abstract long getNbMsgsReceiveSinceCreation()
getNbMsgsReceiveSinceCreation
in interface DestinationMBean
public long getNbMsgsDeliverSinceCreation()
getNbMsgsDeliverSinceCreation
in interface DestinationMBean
public long getNbMsgsSentToDMQSinceCreation()
getNbMsgsSentToDMQSinceCreation
in interface DestinationMBean
protected void replyToTopic(AdminReply reply, AgentId replyTo, String requestMsgId, String replyMsgId)
protected final void forward(AgentId to, Notification not)
protected void handleAdminRequestNot(AgentId from, FwdAdminRequestNot not)
from
- not
- protected void processAdminCommand(AdminCommandRequest request, AgentId replyTo, String requestMsgId)
request
- The administration request.replyTo
- The destination to reply.requestMsgId
- The JMS message id needed to reply.protected Properties processStartHandler(Properties prop) throws Exception
prop
- properties for start if needed (can be null)Exception
protected Properties processStopHandler(Properties prop) throws Exception
prop
- properties for start if needed (can be null)Exception
protected Message processInterceptors(Message msg)
msg
- the messageprotected boolean interceptorsAvailable()
private void addInterceptor(String agentId, String agentName, Properties prop) throws Exception
Exception
private void removeInterceptor(String classNames) throws Exception
Exception
private void replaceInterceptor(String agentId, String agentName, Properties prop) throws Exception
Exception
public int getEncodedSize() throws Exception
Agent
getEncodedSize
in interface Encodable
getEncodedSize
in class Agent
Exception
- if an error occurspublic void encode(Encoder encoder) throws Exception
Agent
Copyright © 2016 ScalAgent D.T.. All Rights Reserved.