1 22 package org.jboss.resource.deployment; 23 24 import org.jboss.logging.Logger; 25 import org.jboss.resource.metadata.ConfigPropertyMetaData; 26 import org.jboss.resource.metadata.JBossRAMetaData; 27 import org.jboss.xb.binding.ObjectModelFactory; 28 import org.jboss.xb.binding.UnmarshallingContext; 29 import org.xml.sax.Attributes ; 30 31 37 public class JBossRAObjectModelFactory implements ObjectModelFactory 38 { 39 40 private boolean trace; 41 42 private Logger log = Logger.getLogger(JBossRAObjectModelFactory.class); 43 44 public Object completeRoot(Object root, UnmarshallingContext arg1, String arg2, String arg3) 45 { 46 return root; 47 } 48 49 public Object newRoot(Object root, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes atts) 50 { 51 52 if(localName == null || !localName.equals("jboss-ra")) 53 { 54 throw new IllegalArgumentException ("Error invalid root element for jboss-ra.xml" + localName); 55 56 } 57 58 JBossRAMetaData ramd = new JBossRAMetaData(); 59 return ramd; 60 } 61 62 public Object newChild(JBossRAMetaData ramd, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs) 63 { 64 65 if(localName.equals("ra-config-property")) 66 { 67 ConfigPropertyMetaData cpmd = new ConfigPropertyMetaData(); 68 ramd.addProperty(cpmd); 69 return cpmd; 70 71 } 72 else 73 { 74 return null; 75 76 } 77 78 } 79 80 public void setValue(ConfigPropertyMetaData cpmd, UnmarshallingContext navigator, String namespaceURI, String localName, String value) 81 { 82 if (trace) 83 log.trace("config property setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value); 84 85 else if (localName.equals("ra-config-property-name")) 86 cpmd.setName(value); 87 else if (localName.equals("ra-config-property-type")) 88 cpmd.setType(value); 89 else if (localName.equals("ra-config-property-value")) 90 cpmd.setValue(value); 91 else 92 throw new IllegalArgumentException ("Unknown config property setValue: nuri=" + namespaceURI + " localName=" + localName + " value=" + value); 93 } 94 95 96 } 97 | Popular Tags |