1 16 17 package org.apache.ws.jaxme.generator.ino.api4j; 18 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import org.apache.ws.jaxme.generator.sg.ObjectSG; 23 import org.apache.ws.jaxme.generator.sg.SchemaSG; 24 import org.apache.ws.jaxme.generator.sg.SchemaSGChain; 25 import org.apache.ws.jaxme.generator.sg.TypeSG; 26 import org.apache.ws.jaxme.generator.sg.impl.SchemaSGChainImpl; 27 import org.apache.ws.jaxme.impl.JAXBContextImpl; 28 import org.apache.ws.jaxme.pm.ino.api4j.TaminoAPI4JPm; 29 import org.w3c.dom.Document ; 30 import org.w3c.dom.Element ; 31 import org.w3c.dom.Node ; 32 import org.xml.sax.SAXException ; 33 34 37 public class TaminoAPI4JSchemaSG extends SchemaSGChainImpl { 38 private final TaminoAPI4JSG baseSG; 39 40 public TaminoAPI4JSchemaSG(SchemaSGChain pChain, TaminoAPI4JSG pBaseSG) { 41 super(pChain); 42 baseSG = pBaseSG; 43 } 44 45 protected TaminoAPI4JSG getBaseSG() { 46 return baseSG; 47 } 48 49 private Element createProperty(Element pParent, String pName, String pValue) { 50 Element element = pParent.getOwnerDocument().createElementNS(JAXBContextImpl.CONFIGURATION_URI, "Property"); 51 pParent.appendChild(element); 52 element.setAttributeNS(null, "name", pName); 53 element.setAttributeNS(null, "value", pValue); 54 return element; 55 } 56 57 public Document getConfigFile(SchemaSG pController, String pPackageName, 58 List pContextList) throws SAXException { 59 final String uri = JAXBContextImpl.CONFIGURATION_URI; 60 final Document doc = super.getConfigFile(pController, pPackageName, pContextList); 61 final Element root = doc.getDocumentElement(); 62 final Iterator iter = pContextList.iterator(); 63 TaminoAPI4JSG.RaDetails details = baseSG.getRaDetails(); 64 for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) { 65 if (node.getNodeType() == Node.ELEMENT_NODE 66 && JAXBContextImpl.CONFIGURATION_URI.equals(node.getNamespaceURI()) 67 && "Manager".equals(node.getLocalName())) { 68 Element manager = (Element ) node; 69 final ObjectSG objectSG = (ObjectSG) iter.next(); 70 final TypeSG typeSG = objectSG.getTypeSG(); 71 if (typeSG.isComplex()) { 72 manager.setAttributeNS(uri, "pmClass", TaminoAPI4JPm.class.getName()); 73 } 74 75 if (details != null) { 76 String collection = details.getCollection(); 77 if (collection != null && collection.length() > 0) { 78 createProperty(manager, "collection", collection); 79 } 80 String jndiRef = details.getJndiReference(); 81 if (jndiRef != null && jndiRef.length() > 0) { 82 createProperty(manager, "jndiReference", jndiRef); 83 } 84 } 85 } 86 } 87 if (iter.hasNext()) { 88 throw new IllegalStateException ("More managers expected than found"); 89 } 90 return doc; 91 } 92 } 93 | Popular Tags |