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(),