List of usage examples for javax.management.j2ee ManagementHome create
Management create() throws CreateException, RemoteException;
From source file:org.firstopen.singularity.util.JMSUtil.java
public static Queue createTopic(String topicName) throws InfrastructureException { Queue queue = null;//w ww . ja v a 2 s .c o m InitialContext jndiContext = null; try { queue = (Queue) jndiContext.lookup("topic/" + topicName); } catch (Exception e) { /* * try to create the queue */ try { jndiContext = JNDIUtil.getInitialContext(); ManagementHome mejbHome = (ManagementHome) jndiContext.lookup("ejb/mgmt/MEJB"); Management mejb = mejbHome.create(); ObjectName objectName = new ObjectName("jboss.mq:service=DestinationManager"); mejb.invoke(objectName, "createTopic", new Object[] { topicName, "topic/" + topicName }, new String[] { String.class.getName(), String.class.getName() }); queue = queueExists(topicName); } catch (Exception e1) { log.error("unable to create queue/" + topicName, e1); throw new InfrastructureException(); } } return queue; }
From source file:org.firstopen.singularity.util.JMSUtil.java
public static Queue createQueue(String queueName) throws InfrastructureException { Queue queue = null;/* w ww . j a v a 2 s.c o m*/ InitialContext jndiContext = null; try { queue = queueExists(queueName); } catch (Exception e) { /* * try to create the queue */ try { jndiContext = JNDIUtil.getInitialContext(); ManagementHome mejbHome = (ManagementHome) jndiContext.lookup("ejb/mgmt/MEJB"); Management mejb = mejbHome.create(); ObjectName objectName = new ObjectName("jboss.mq:service=DestinationManager"); mejb.invoke(objectName, "createQueue", new Object[] { queueName, "queue/" + queueName }, new String[] { String.class.getName(), String.class.getName() }); queue = queueExists(queueName); } catch (Exception e1) { log.error("unable to create queue/" + queueName, e1); throw new InfrastructureException(); } } return queue; }
From source file:org.firstopen.singularity.util.JMSUtil.java
public static String listMessageCounter(String queueName) throws Exception { InitialContext jndiContext = JNDIUtil.getInitialContext(); ManagementHome mejbHome = (ManagementHome) jndiContext.lookup("ejb/mgmt/MEJB"); Management mejb = mejbHome.create(); ObjectName objectName = new ObjectName("jboss.mq.destination:service=Queue,id=" + queueName); return (String) mejb.invoke(objectName, "listMessageCounter", new Object[] {}, new String[] {}); }
From source file:org.firstopen.singularity.util.JMSUtil.java
public static void terminateQueue(String queueName) throws InfrastructureException { InitialContext jndiContext;/*w w w . j a v a 2 s. c o m*/ try { jndiContext = JNDIUtil.getInitialContext(); ManagementHome mejbHome = (ManagementHome) jndiContext.lookup("ejb/mgmt/MEJB"); Management mejb = mejbHome.create(); ObjectName objectName = new ObjectName("jboss.mq.destination:service=Queue,id=" + queueName); objectName = new ObjectName("jboss.mq:service=DestinationManager"); mejb.invoke(objectName, "destroyQueue", new Object[] { queueName }, new String[] { String.class.getName() }); } catch (Exception e) { log.error("Unable Terminate Queue: " + queueName, e); throw new InfrastructureException("Unable Terminate Queue: " + queueName); } }
From source file:org.firstopen.singularity.util.JMSUtil.java
public static void terminateTopic(String topicName) throws InfrastructureException { InitialContext jndiContext;//w w w . ja v a2 s . com try { jndiContext = JNDIUtil.getInitialContext(); ManagementHome mejbHome = (ManagementHome) jndiContext.lookup("ejb/mgmt/MEJB"); Management mejb = mejbHome.create(); ObjectName objectName = new ObjectName("jboss.mq.destination:service=Queue,id=" + topicName); // mejb.invoke(objectName, "stop", new Object[]{}, new String[]{}); objectName = new ObjectName("jboss.mq:service=DestinationManager"); mejb.invoke(objectName, "destroyTopic", new Object[] { topicName }, new String[] { String.class.getName() }); } catch (Exception e) { log.error("Unable Terminate Topic: " + topicName, e); throw new InfrastructureException("Unable Terminate Topic: " + topicName); } }