// Retrieving an existing destination:
if (destName != null && ! destName.equals("") && destinationsTable.containsKey(destName)) {
destDesc = (DestinationDesc) destinationsTable.get(destName);
if (! DestinationConstants.compatible(destDesc.getType(), type)) {
throw new RequestException("Destination type not compliant");
}
strbuf.append("Request [").append(requestClassName)
.append("], processed by AdminTopic on server [").append(serverId)
.append("], successful [true]: destination [")
.append(destName).append("] has been retrieved");
} else {
// Instantiating the destination class.
Destination dest = null;
try {
dest = (Destination) Class.forName(className).newInstance();
dest.setName(destName);
dest.setAdminId(adminId);
dest.setProperties(properties, true);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR,
"Could not instantiate Destination class [" + className + "]: ", exc);
if (exc instanceof ClassCastException)
throw new RequestException("Class [" + className + "] is not a Destination class.");
throw new RequestException("Could not instantiate Destination class [" + className + "]: " + exc);
}
byte destType = dest.getType();
if (! DestinationConstants.compatible(destType, type)) {
throw new RequestException("Requested destination type is not compliant with destination classname");
}
if (destName == null || destName.equals(""))
destName = dest.getAgentId();
destDesc = new DestinationDesc(dest.getId(), destName, destType);
try {
dest.deploy();
destinationsTable.put(destName, destDesc);
strbuf.append("Request [").append(requestClassName)
.append("], processed by AdminTopic on server [").append(serverId)
.append("], successful [true]: ").append(className).append(" [")
.append(dest.getAgentId()).append("] has been created and deployed");
} catch (Exception exc) {
if (logger.isLoggable(BasicLevel.ERROR))
logger.log(BasicLevel.ERROR, "xxx", exc);
throw new RequestException("Error while deploying Destination [" + className + "]: " + exc);
}
}
return destDesc;
}