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);
  }
 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();
 }