1 22 package org.jboss.test.messagedriven.mock; 23 24 import java.util.Properties ; 25 26 import javax.naming.Context ; 27 import javax.naming.NamingException ; 28 29 import org.jboss.jms.jndi.JMSProviderAdapter; 30 import org.w3c.dom.Document ; 31 import org.w3c.dom.Element ; 32 import org.w3c.dom.Node ; 33 import org.w3c.dom.NodeList ; 34 35 41 public class JmsMockProviderAdapter implements JMSProviderAdapter, JmsMockObject 42 { 43 private static final String DEFAULT_URL = "org/jboss/test/messagedriven/mock/mock-provider-adapter.xml"; 44 45 private String name; 46 private String factoryRef; 47 private String queueFactoryRef; 48 private String topicFactoryRef; 49 50 51 public String getFactoryRef() 53 { 54 return this.factoryRef; 55 } 56 57 public Context getInitialContext() throws NamingException 58 { 59 return null; 60 61 } 62 63 public String getName() 64 { 65 return this.name; 66 } 67 68 public Properties getProperties() 69 { 70 return null; 72 } 73 74 public String getQueueFactoryRef() 75 { 76 return this.queueFactoryRef; 78 } 79 80 public String getTopicFactoryRef() 81 { 82 return this.topicFactoryRef; 84 } 85 86 public void setFactoryRef(String newFactoryRef) 87 { 88 this.factoryRef = newFactoryRef; 89 90 } 91 92 public void setName(String name) 93 { 94 this.name = name; 95 } 96 97 public void setProperties(Properties properties) 98 { 99 101 } 102 103 public void setQueueFactoryRef(String newQueueFactoryRef) 104 { 105 this.queueFactoryRef = newQueueFactoryRef; 106 107 } 108 109 public void setTopicFactoryRef(String newTopicFactoryRef) 110 { 111 this.topicFactoryRef = newTopicFactoryRef; 112 } 113 114 public void load(final String xml) 115 { 116 117 Document doc = JmsMockObjectHelper.getDocument(xml); 118 119 final NodeList nl = doc.getDocumentElement().getChildNodes(); 120 121 for(int i = 0; i < nl.getLength(); i++){ 122 123 Node node = (Node )nl.item(i); 124 125 if(node.getNodeType() == Node.ELEMENT_NODE){ 126 127 Element elem = (Element )node; 128 String nodeName = elem.getNodeName(); 129 130 NodeList childNodes = elem.getChildNodes(); 131 132 for(int j = 0; j < childNodes.getLength(); j++){ 133 134 Node child = (Node )childNodes.item(j); 135 if(child.getNodeType() == Node.TEXT_NODE){ 136 138 } 139 } 140 141 } 142 143 } 144 145 } 146 147 public void load(Element xml) 148 { 149 150 } 151 152 public void load() 153 { 154 155 load(DEFAULT_URL); 156 157 } 158 159 public static void main(String [] args) 160 { 161 JmsMockProviderAdapter a = new JmsMockProviderAdapter(); 162 a.load(); 163 164 } 165 166 private void setValue(String name, String value){ 167 168 if(name.equals("name")){ 169 setName(value); 170 171 }else if(name.equals("factoryRef")){ 172 173 setFactoryRef(value); 174 175 }else if(name.equals("queueFactoryRef")){ 176 177 setQueueFactoryRef(value); 178 179 }else if(name.equals("topicFactoryRef")){ 180 181 setTopicFactoryRef(value); 182 } 183 184 } 185 186 187 } 188 | Popular Tags |