public void attach(
      JmsConnectionSource source, PhysicalConnectionTarget target, ChannelConnection connection)
      throws Fabric3Exception {
    URI serviceUri = source.getUri();
    ClassLoader sourceClassLoader = source.getClassLoader();

    JmsBindingMetadata metadata = source.getMetadata();

    ResolvedObjects objects = resolveAdministeredObjects(source);

    ContainerConfiguration configuration = new ContainerConfiguration();
    ConnectionFactory connectionFactory = objects.getRequestFactory();
    javax.jms.Destination destination = objects.getRequestDestination();
    EventStream stream = connection.getEventStream();
    EventStreamListener listener =
        new EventStreamListener(sourceClassLoader, stream.getHeadHandler(), monitor);
    configuration.setDestinationType(metadata.getDestination().geType());
    configuration.setDestination(destination);
    configuration.setFactory(connectionFactory);
    configuration.setMessageListener(listener);
    configuration.setUri(serviceUri);
    configuration.setSessionType(source.getSessionType());
    populateConfiguration(configuration, metadata);
    if (containerManager.isRegistered(serviceUri)) {
      // the wire has changed and it is being re-provisioned
      containerManager.unregister(serviceUri);
    }
    AdaptiveMessageContainer container = containerFactory.create(configuration);
    containerManager.register(container);
  }
 public void testParse() throws Exception {
   String uri =
       "jms:destination?jndiConnectionFactoryName=factory&deliveryMode=nonpersistent&selector=select";
   JmsBindingMetadata metadata = JmsLoaderHelper.parseUri(uri);
   assertEquals("destination", metadata.getDestination().getName());
   assertEquals("factory", metadata.getConnectionFactory().getName());
   assertEquals("select", metadata.getUriMessageSelection().getSelector());
   assertEquals(DeliveryMode.NON_PERSISTENT, metadata.getUriHeaders().getDeliveryMode());
 }
 private ResolvedObjects resolveAdministeredObjects(JmsConnectionSource source)
     throws Fabric3Exception {
   JmsBindingMetadata metadata = source.getMetadata();
   ConnectionFactoryDefinition connectionFactory = metadata.getConnectionFactory();
   ConnectionFactory requestConnectionFactory = resolver.resolve(connectionFactory);
   Destination requestDestinationDefinition = metadata.getDestination();
   javax.jms.Destination requestDestination =
       resolver.resolve(requestDestinationDefinition, requestConnectionFactory);
   return new ResolvedObjects(requestConnectionFactory, requestDestination);
 }
 private void populateConfiguration(
     ContainerConfiguration configuration, JmsBindingMetadata metadata) {
   CacheLevel cacheLevel = metadata.getCacheLevel();
   if (CONNECTION == cacheLevel) {
     configuration.setCacheLevel(CACHE_CONNECTION);
   } else if (ADMINISTERED_OBJECTS == cacheLevel) {
     configuration.setCacheLevel(CACHE_ADMINISTERED_OBJECTS);
   } else {
     configuration.setCacheLevel(CACHE_NONE);
   }
   configuration.setIdleLimit(metadata.getIdleLimit());
   configuration.setMaxMessagesToProcess(metadata.getMaxMessagesToProcess());
   configuration.setMaxReceivers(metadata.getMaxReceivers());
   configuration.setMinReceivers(metadata.getMinReceivers());
   configuration.setReceiveTimeout(metadata.getReceiveTimeout());
   configuration.setSubscriptionId(metadata.getSubscriptionId());
   configuration.setDurable(metadata.isDurable());
   //        configuration.setDeliveryMode();
   //        configuration.setExceptionListener();
   //        configuration.setLocalDelivery();
 }