1 package org.objectweb.jtests.providers.admin; 2 3 import org.objectweb.jtests.jms.admin.Admin; 4 5 import javax.naming.*; 6 import fr.dyade.aaa.joram.admin.AdminItf; 7 import fr.dyade.aaa.joram.admin.AdminImpl; 8 import javax.jms.*; 9 import java.util.*; 10 import java.io.*; 11 12 public class JoramAdmin implements Admin 13 { 14 private String name = "JORAM"; 15 InitialContext ictx = null; 16 AdminItf admin; 17 18 public JoramAdmin() 19 { 20 try { 21 Properties props = new Properties(); 22 props.setProperty("java.naming.factory.initial", 23 "fr.dyade.aaa.jndi2.client.NamingContextFactory"); 24 props.setProperty("java.naming.factory.host", "localhost"); 25 props.setProperty("java.naming.provider.url", "http://localhost:16400"); 26 27 ictx = new InitialContext (props); 28 admin = new AdminImpl(); 29 admin.connect("root", "root", 100); 30 31 admin.createUser("anonymous", "anonymous", 0); 32 } 33 catch (Exception e) { 34 e.printStackTrace(); 35 } 36 } 37 38 39 public String getName() 40 { 41 return name; 42 } 43 44 public InitialContext createInitialContext() throws NamingException 45 { 46 return ictx; 47 } 48 49 public void createConnectionFactory(String name) 50 { 51 try { 52 ConnectionFactory cf = admin.createConnectionFactory(); 53 ictx.rebind(name, cf); 54 } 55 catch (Exception e) { 56 e.printStackTrace(); 57 } 58 } 59 60 public void createQueueConnectionFactory(String name) 61 { 62 try { 63 QueueConnectionFactory cf = admin.createQueueConnectionFactory(); 64 ictx.rebind(name, cf); 65 } 66 catch (Exception e) { 67 e.printStackTrace(); 68 } 69 } 70 71 public void createTopicConnectionFactory(String name) 72 { 73 try { 74 TopicConnectionFactory cf = admin.createTopicConnectionFactory(); 75 ictx.rebind(name, cf); 76 } 77 catch (Exception e) { 78 e.printStackTrace(); 79 } 80 } 81 82 public void createQueue(String name) 83 { 84 try { 85 Queue queue = admin.createQueue(0); 86 ictx.rebind(name, queue); 87 admin.setFreeWriting(queue); 88 admin.setFreeReading(queue); 89 } 90 catch (Exception e) { 91 e.printStackTrace(); 92 } 93 } 94 95 public void createTopic(String name) 96 { 97 try { 98 Topic topic = admin.createTopic(0); 99 ictx.rebind(name, topic); 100 admin.setFreeWriting(topic); 101 admin.setFreeReading(topic); 102 } 103 catch (Exception e) { 104 e.printStackTrace(); 105 } 106 } 107 108 public void deleteQueue(String name) 109 { 110 try { 111 Queue queue = (Queue) ictx.lookup(name); 112 admin.deleteDestination(queue); 113 ictx.unbind(name); 114 } 115 catch (Exception e) { 116 e.printStackTrace(); 117 } 118 } 119 120 public void deleteTopic(String name) 121 { 122 try { 123 Topic topic = (Topic) ictx.lookup(name); 124 admin.deleteDestination(topic); 125 ictx.unbind(name); 126 } 127 catch (Exception e) { 128 e.printStackTrace(); 129 } 130 } 131 132 public void deleteConnectionFactory(String name) 133 { 134 try { 135 ictx.unbind(name); 136 } 137 catch (Exception e) { 138 e.printStackTrace(); 139 } 140 } 141 142 public void deleteTopicConnectionFactory(String name) 143 { 144 try { 145 ictx.unbind(name); 146 } 147 catch (Exception e) { 148 e.printStackTrace(); 149 } 150 } 151 152 public void deleteQueueConnectionFactory(String name) 153 { 154 try { 155 ictx.unbind(name); 156 } 157 catch (Exception e) { 158 e.printStackTrace(); 159 } 160 } 161 } 162 | Popular Tags |