if (destination == null) { throw new InvalidDestinationException("No such destination: " + jmsDestination); }
   public ProducerDelegate createProducerDelegate(Destination jmsDestination)         throws JMSException   {      if (closed)      {         throw new IllegalStateException("Session is closed");      }                  // look-up destination      DestinationManagerImpl dm = serverPeer.getDestinationManager();      Distributor destination = null;           if (jmsDestination != null)      {         destination = dm.getCoreDestination(jmsDestination);      }           log.debug("got producer's destination: " + destination);      // create the dynamic proxy that implements ProducerDelegate      Serializable oid = serverPeer.getProducerAdvisor().getName();      String stackName = "ProducerStack";      AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);      // TODO why do I need to the advisor to create the interceptor stack?      Interceptor[] interceptors = stack.createInterceptors(serverPeer.getProducerAdvisor(), null);      // TODO: The ConnectionFactoryDelegate and ConnectionDelegate share the same locator (TCP/IP connection?). Performance?      JMSInvocationHandler h = new JMSInvocationHandler(interceptors);      String producerID = generateProducerID();      SimpleMetaData metadata = new SimpleMetaData();      // TODO: The ConnectionFactoryDelegate and ConnectionDelegate share the same locator (TCP/IP connection?). Performance?      metadata.addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, oid, PayloadKey.AS_IS);      metadata.addMetaData(RemotingClientInterceptor.REMOTING,            RemotingClientInterceptor.INVOKER_LOCATOR,                           serverPeer.getLocator(),                           PayloadKey.AS_IS);      metadata.addMetaData(RemotingClientInterceptor.REMOTING,            RemotingClientInterceptor.SUBSYSTEM,                           "JMS",                           PayloadKey.AS_IS);      // TODO: Is this really necessary? Can't I just use the producerID?      metadata.addMetaData(JMSAdvisor.JMS, JMSAdvisor.CONNECTION_ID, connectionEndpoint.getConnectionID(), PayloadKey.AS_IS);      metadata.addMetaData(JMSAdvisor.JMS, JMSAdvisor.SESSION_ID, sessionID, PayloadKey.AS_IS);      metadata.addMetaData(JMSAdvisor.JMS, JMSAdvisor.PRODUCER_ID, producerID, PayloadKey.AS_IS);            h.getMetaData().mergeIn(metadata);      // TODO      ClassLoader loader = getClass().getClassLoader();      Class[] interfaces = new Class[] { ProducerDelegate.class };      ProducerDelegate delegate = (ProducerDelegate)Proxy.newProxyInstance(loader, interfaces, h);      // create the corresponding "server-side" ProducerDelegate and register it with this      // SessionDelegate instance      ServerProducerDelegate spd =            new ServerProducerDelegate(producerID, jmsDestination, this);      putProducerDelegate(producerID, spd);      log.debug("created producer delegate (producerID=" + producerID + ")");      return delegate;   }