1 7 package org.jboss.ejb3.dd; 8 9 import org.xml.sax.Attributes ; 10 import org.jboss.logging.Logger; 11 import org.jboss.xb.binding.UnmarshallingContext; 12 import org.jboss.xb.binding.ObjectModelFactory; 13 14 20 public class JBossDDObjectFactory implements ObjectModelFactory 21 { 22 private static final Logger log = Logger 23 .getLogger(JBossDDObjectFactory.class); 24 25 private EjbJarDD dd; 26 27 public JBossDDObjectFactory(EjbJarDD dd) 28 { 29 super(); 30 this.dd = dd; 31 } 32 33 36 public Object newRoot(Object root, UnmarshallingContext navigator, 37 String namespaceURI, String localName, Attributes attrs) 38 { 39 return dd; 40 } 41 42 public Object completeRoot(Object root, UnmarshallingContext ctx, 43 String uri, String name) 44 { 45 return root; 46 } 47 48 50 53 public Object newChild(EjbJarDD dd, UnmarshallingContext navigator, 54 String namespaceURI, String localName, Attributes attrs) 55 { 56 Object child = null; 57 58 if (localName.equals("enterprise-beans")) 59 { 60 child = dd.getEnterpriseBeans(); 61 } else if (localName.equals("loader-repository")) 62 { 63 child = new LoaderRepository(); 64 for (int i = 0 ; i < attrs.getLength() ;++i) 65 { 66 if (attrs.getLocalName(i).equals("loaderRepositoryClass")) 67 ((LoaderRepository)child).setLoaderRepositoryClass(attrs.getValue(i)); 68 } 69 } 70 71 return child; 72 } 73 74 77 public Object newChild(LoaderRepository repository, UnmarshallingContext navigator, 78 String namespaceURI, String localName, Attributes attrs) 79 { 80 Object child = null; 81 82 if (localName.equals("loader-repository-config")) 83 { 84 child = new LoaderRepositoryConfig(); 85 for (int i = 0 ; i < attrs.getLength() ;++i) 86 { 87 if (attrs.getLocalName(i).equals("configParserClass")) 88 ((LoaderRepositoryConfig)child).setConfigParserClass(attrs.getValue(i)); 89 } 90 } 91 92 return child; 93 } 94 95 98 public Object newChild(LoaderRepositoryConfig condig, UnmarshallingContext navigator, 99 String namespaceURI, String localName, Attributes attrs) 100 { 101 Object child = null; 102 103 return child; 104 } 105 106 109 public Object newChild(EnterpriseBeans ejbs, UnmarshallingContext navigator, 110 String namespaceURI, String localName, Attributes attrs) 111 { 112 Object child = null; 113 114 if (localName.equals("session")) 115 { 116 child = ejbs; 117 } else if (localName.equals("ejb-ref")) 118 { 119 child = new EjbRef(); 120 } else if (localName.equals("ejb-local-ref")) 121 { 122 child = new EjbLocalRef(); 123 } else if (localName.equals("resource-ref")) 124 { 125 child = new ResourceRef(); 126 } else if (localName.equals("call-by-value")) 127 { 128 ejbs.setCallByValue(true); 129 } else if (localName.equals("clustered")) 130 { 131 child = new ClusterConfig(); 132 } 133 134 return child; 135 } 136 137 140 public void addChild(EjbJarDD parent, LoaderRepository repository, 141 UnmarshallingContext navigator, String namespaceURI, String localName) 142 { 143 parent.setLoaderRepository(repository); 144 } 145 146 149 public void addChild(LoaderRepository parent, LoaderRepositoryConfig config, 150 UnmarshallingContext navigator, String namespaceURI, String localName) 151 { 152 parent.setLoaderRepositoryConfig(config); 153 } 154 155 158 public void addChild(EnterpriseBeans parent, EnterpriseBeans ejbs, 159 UnmarshallingContext navigator, String namespaceURI, String localName) 160 { 161 162 } 163 164 167 public void addChild(EnterpriseBeans parent, EjbRef ref, 168 UnmarshallingContext navigator, String namespaceURI, String localName) 169 { 170 parent.updateEjbRef(ref); 171 } 172 173 176 public void addChild(EnterpriseBeans parent, EjbLocalRef ref, 177 UnmarshallingContext navigator, String namespaceURI, String localName) 178 { 179 parent.updateEjbLocalRef(ref); 180 } 181 182 185 public void addChild(EnterpriseBeans parent, ResourceRef ref, 186 UnmarshallingContext navigator, String namespaceURI, String localName) 187 { 188 parent.updateResourceRef(ref); 189 } 190 191 194 public void addChild(EnterpriseBeans parent, ClusterConfig config, 195 UnmarshallingContext navigator, String namespaceURI, String localName) 196 { 197 parent.setClusterConfig(config); 198 } 199 200 203 public void setValue(EnterpriseBeans ejbs, UnmarshallingContext navigator, 204 String namespaceURI, String localName, String value) 205 { 206 if (localName.equals("ejb-name")) 207 { 208 ejbs.setCurrentEjbName(value); 209 } else if (localName.equals("jndi-name")) 210 { 211 ejbs.setJndiName(value); 212 } else if (localName.equals("local-jndi-name")) 213 { 214 ejbs.setLocalJndiName(value); 215 } else if (localName.equals("security-domain")) 216 { 217 ejbs.setSecurityDomain(value); 218 } else if (localName.equals("call-by-value")) 219 { 220 ejbs.setCallByValue(true); 221 } else if (localName.equals("run-as-principal")) 222 { 223 ejbs.setRunAsPrincipal(value); 224 } else if (localName.equals("aop-domain-name")) 225 { 226 ejbs.setAopDomainName(value); 227 } 228 } 229 230 233 public void setValue(ClusterConfig config, UnmarshallingContext navigator, 234 String namespaceURI, String localName, String value) 235 { 236 if (localName.equals("load-balance-policy")) 237 { 238 config.setLoadBalancePolicy(value); 239 } else if (localName.equals("partition-name")) 240 { 241 config.setPartition(value); 242 } 243 } 244 245 248 public void setValue(EjbRef ref, UnmarshallingContext navigator, 249 String namespaceURI, String localName, String value) 250 { 251 if (localName.equals("ejb-ref-name")) 252 { 253 ref.setEjbRefName(value); 254 } else if (localName.equals("jndi-name")) 255 { 256 ref.setJndiName(value); 257 } 258 } 259 260 263 public void setValue(EjbLocalRef ref, UnmarshallingContext navigator, 264 String namespaceURI, String localName, String value) 265 { 266 if (localName.equals("ejb-ref-name")) 267 { 268 ref.setEjbRefName(value); 269 } else if (localName.equals("jndi-name")) 270 { 271 ref.setJndiName(value); 272 } 273 } 274 275 278 public void setValue(ResourceRef ref, UnmarshallingContext navigator, 279 String namespaceURI, String localName, String value) 280 { 281 if (localName.equals("res-ref-name")) 282 { 283 ref.setResRefName(value); 284 } else if (localName.equals("jndi-name")) 285 { 286 ref.setJndiName(value); 287 } else if (localName.equals("resource-name")) 288 { 289 ref.setResourceName(value); 290 } 291 } 292 293 296 public void setValue(EjbJarDD dd, UnmarshallingContext navigator, 297 String namespaceURI, String localName, String value) 298 { 299 if (localName.equals("security-domain")) 300 { 301 dd.setSecurityDomain(value); 302 } 303 304 } 305 306 309 public void setValue(LoaderRepository repository, UnmarshallingContext navigator, 310 String namespaceURI, String localName, String value) 311 { 312 if (localName.equals("value")) 313 { 314 repository.setValue(value); 315 } else if (localName.equals("loader-repository")) 316 { 317 repository.setValue(value); 318 } 319 } 320 321 324 public void setValue(LoaderRepositoryConfig config, UnmarshallingContext navigator, 325 String namespaceURI, String localName, String value) 326 { 327 if (localName.equals("value")) 328 { 329 config.setValue(value); 330 } else if (localName.equals("loader-repository-config")) 331 { 332 config.setValue(value); 333 } 334 } 335 336 } 337 | Popular Tags |