FileDocCategorySizeDatePackage
DestinationManagerJMSDestinationFactory.javaAPI DocJBoss 4.2.13131Fri Jul 13 20:53:54 BST 2007org.jboss.ejb3.jms

DestinationManagerJMSDestinationFactory

public class DestinationManagerJMSDestinationFactory extends JMSDestinationFactory
Use DestinationManager for creation of destinations. JBoss AS 4.2
author
Carlo de Wolf
version
$Revision: $

Fields Summary
Constructors Summary
Methods Summary
public voidcreateDestination(java.lang.Class type, java.lang.String jndiSuffix)

      String methodName;
      String destinationContext;
      if (type == Topic.class)
      {
         destinationContext = "topic";
         methodName = "createTopic";
      }
      else if (type == Queue.class)
      {
         destinationContext = "queue";
         methodName = "createQueue";
      }
      else
      {
         // type was not a Topic or Queue, bad user
         throw new IllegalArgumentException
                 ("Expected javax.jms.Queue or javax.jms.Topic: " + type);
      }
      
      ObjectName destinationManagerName = new ObjectName("jboss.mq:service=DestinationManager");
      
      KernelAbstraction kernel = KernelAbstractionFactory.getInstance();
      // invoke the server to create the destination
      Object result = kernel.invoke(destinationManagerName,
              methodName,
              new Object[]{jndiSuffix},
              new String[]{"java.lang.String"});
      
      InitialContext jndiContext = InitialContextFactory.getInitialContext();
      String binding = destinationContext + "/" + jndiSuffix;
      try
      {
         jndiContext.lookup(binding);
      }
      catch (NamingException e)
      {
         jndiContext.rebind(binding, result);
      }