1 package org.objectweb.jtests.providers.admin; 2 3 import org.objectweb.jtests.jms.admin.Admin; 4 import javax.naming.*; 5 import com.ashnasoft.jms.client.admin.*; 6 import com.ashnasoft.jms.client.*; 7 import javax.jms.Queue ; 8 import javax.jms.Topic ; 9 import java.util.Properties ; 10 11 public class AshnaMQAdmin implements Admin { 12 13 private String name = "AshnaMQ"; 14 private InitialContext ictx = null; 15 private ASAdministrator admin = null; 16 17 public AshnaMQAdmin() { 18 try { 19 Properties props = new Properties (); 20 props.setProperty("java.naming.factory.initial", "com.ashnasoft.jms.client.jndi.InitialContextFactoryImpl"); 21 props.setProperty("java.naming.factory.host", "localhost"); 22 props.setProperty("java.naming.provider.url", "jndi:Ashna://localhost:9090"); 23 props.setProperty("java.naming.security.principal","admin"); 24 props.setProperty("java.naming.security.credentials","admin"); 25 ictx = new InitialContext (props); 26 admin = new ASAdministrator("localhost", 9090, "admin", "admin", false); 27 } catch (Exception e) { 28 e.printStackTrace(); 29 System.exit(1); 30 } 31 } 32 33 public String getName() { 34 return name; 35 } 36 37 public InitialContext createInitialContext() throws NamingException { 38 return ictx; 39 } 40 41 public void createQueueConnectionFactory(String qcfName) { 42 try { 43 ASQueueConnectionFactory qcf = new ASQueueConnectionFactory("localhost", 9090, false); 44 ictx.rebind(qcfName, qcf); 45 } 46 catch (Exception e) { 47 e.printStackTrace(); 48 } 49 } 50 51 public void createTopicConnectionFactory(String tcfName) { 52 try { 53 ASTopicConnectionFactory tcf = new ASTopicConnectionFactory("localhost", 9090, false); 54 ictx.rebind(tcfName, tcf); 55 } 56 catch (Exception e) { 57 e.printStackTrace(); 58 } 59 } 60 61 public void createQueue(String queueName) { 62 try { 63 admin.createQueue(queueName); 64 } 65 catch (Exception e) { 66 e.printStackTrace(); 67 } 68 } 69 70 public void createTopic(String topicName) { 71 try { 72 admin.createTopic(topicName); 73 } 74 catch (Exception e) { 75 e.printStackTrace(); 76 } 77 } 78 79 public void deleteQueue(String queueName) { 80 try { 81 admin.removeQueue(queueName); 82 } 83 catch (Exception e) { 84 e.printStackTrace(); 85 } 86 } 87 88 public void deleteTopic(String topicName) { 89 try { 90 admin.removeTopic(topicName); 91 } 92 catch (Exception e) { 93 e.printStackTrace(); 94 } 95 } 96 97 public void deleteTopicConnectionFactory(String tcfName) { 98 try { 99 ictx.unbind(tcfName); 100 } 101 catch (Exception e) { 102 e.printStackTrace(); 103 } 104 } 105 106 public void deleteQueueConnectionFactory(String qcfName) { 107 try { 108 ictx.unbind(qcfName); 109 } 110 catch (Exception e) { 111 e.printStackTrace(); 112 } 113 } 114 } 115 | Popular Tags |