*/
private JmsDestination getDestination(JmsDestination destination,
boolean create)
throws InvalidDestinationException, JMSException {
final String name = destination.getName();
JmsDestination result;
JmsDestination existing = _destinations.getDestination(name);
if (existing == null) {
if (!create) {
throw new InvalidDestinationException(
"No destination with name=" + name + " exists");
}
// register the destination dynamically.
_destinations.createDestination(destination);
result = _destinations.getDestination(destination.getName());
} else {
// make sure the supplied destination has the same properties
// as the existing one
if (!destination.getClass().getName().equals(
existing.getClass().getName())) {
throw new InvalidDestinationException(
"Mismatched destination properties for destination"
+ " with name=" + name);
}
if (existing.getPersistent() != destination.getPersistent()) {
throw new InvalidDestinationException(
"Mismatched destination properties for destination"
+ " with name=" + name);
}
result = existing;