protected void setupDestination() throws Exception { String destinationName = spec.getDestination(); if (spec.isUseJNDI()) { Context ctx; if (spec.getParsedJndiParams() == null) { ctx = new InitialContext(); } else { ctx = new InitialContext(spec.getParsedJndiParams()); } HornetQRALogger.LOGGER.debug("Using context " + ctx.getEnvironment() + " for " + spec); if (HornetQActivation.trace) { HornetQRALogger.LOGGER.trace("setupDestination(" + ctx + ")"); } String destinationTypeString = spec.getDestinationType(); if (destinationTypeString != null && !destinationTypeString.trim().equals("")) { HornetQRALogger.LOGGER.debug("Destination type defined as " + destinationTypeString); Class<?> destinationType; if (Topic.class.getName().equals(destinationTypeString)) { destinationType = Topic.class; isTopic = true; } else { destinationType = Queue.class; } HornetQRALogger.LOGGER.debug( "Retrieving " + destinationType.getName() + " \"" + destinationName + "\" from JNDI"); try { destination = (HornetQDestination) HornetQRaUtils.lookup(ctx, destinationName, destinationType); } catch (Exception e) { if (destinationName == null) { throw HornetQRABundle.BUNDLE.noDestinationName(); } String calculatedDestinationName = destinationName.substring(destinationName.lastIndexOf('/') + 1); HornetQRALogger.LOGGER.debug( "Unable to retrieve " + destinationName + " from JNDI. Creating a new " + destinationType.getName() + " named " + calculatedDestinationName + " to be used by the MDB."); // If there is no binding on naming, we will just create a new instance if (isTopic) { destination = (HornetQDestination) HornetQJMSClient.createTopic(calculatedDestinationName); } else { destination = (HornetQDestination) HornetQJMSClient.createQueue(calculatedDestinationName); } } } else { HornetQRALogger.LOGGER.debug( "Destination type not defined in MDB activation configuration."); HornetQRALogger.LOGGER.debug( "Retrieving " + Destination.class.getName() + " \"" + destinationName + "\" from JNDI"); destination = (HornetQDestination) HornetQRaUtils.lookup(ctx, destinationName, Destination.class); if (destination instanceof Topic) { isTopic = true; } } } else { HornetQRALogger.LOGGER.instantiatingDestination( spec.getDestinationType(), spec.getDestination()); if (Topic.class.getName().equals(spec.getDestinationType())) { destination = (HornetQDestination) HornetQJMSClient.createTopic(spec.getDestination()); isTopic = true; } else { destination = (HornetQDestination) HornetQJMSClient.createQueue(spec.getDestination()); } } }