*/
private void doReact(SessCreateDestRequest req) throws RequestException {
AgentId destId = null;
// Verify if the destination exists
DestinationDesc desc = AdminTopic.lookupDest(req.getName(), req.getType());
if (desc == null) {
Destination dest = null;
if (DestinationConstants.isQueue(req.getType())) {
// Create a local queue.
dest = new Queue();
} else if (DestinationConstants.isTopic(req.getType())) {
// Create a local topic.
dest = new Topic();
} else {
throw new RequestException("Could not create destination, unknown type:" + req.getType());
}
dest.setName(req.getName());
dest.setAdminId(getId());
dest.setFreeWriting(true); // Setting free WRITE right on the destination
if (! DestinationConstants.isTemporary(req.getType()))
dest.setFreeReading(true); // Setting free READ right on the destination
destId = dest.getId();
try {
dest.deploy();
} catch (IOException exc) {
throw new RequestException("Could not create destination:" + exc.getMessage());
}
// Registers the newly created destination
AdminTopic.registerDest(destId, (req.getName() == null) ? destId.toString() : req.getName(),
req.getType());
if (DestinationConstants.isTemporary(req.getType())) {
// Registers the temporary destination in order to clean it at the end of the connection
activeCtx.addTemporaryDestination(destId);
}
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "UserAgent, new destination created: " + destId);
} else {
destId = desc.getId();
}
SessCreateDestReply reply = new SessCreateDestReply(req, destId.toString());
sendNot(getId(), new SyncReply(activeCtxId, reply));
}