1 17 18 package org.apache.geronimo.connector.deployment.dconfigbean; 19 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import javax.enterprise.deploy.model.DDBean ; 23 import javax.enterprise.deploy.model.DDBeanRoot ; 24 import javax.enterprise.deploy.spi.DConfigBean ; 25 import javax.enterprise.deploy.spi.exceptions.ConfigurationException ; 26 27 import org.apache.geronimo.deployment.plugin.DConfigBeanRootSupport; 28 import org.apache.geronimo.xbeans.geronimo.GerConnectionDefinitionType; 29 import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; 30 import org.apache.xmlbeans.SchemaTypeLoader; 31 import org.apache.xmlbeans.XmlException; 32 33 39 public class ResourceAdapter_1_0DConfigRoot extends DConfigBeanRootSupport { 40 41 private static String [] XPATHS = { 42 "connector/resourceadapter" 43 }; 44 45 private ConnectionDefinitionDConfigBean connectionDefinitionDConfigBean; 46 47 public ResourceAdapter_1_0DConfigRoot(DDBeanRoot ddBean) { 48 super(ddBean, GerConnectorDocument.Factory.newInstance()); 49 GerConnectionDefinitionType connectionDefinition = getConnectorDocument().addNewConnector().addNewResourceadapter().addNewOutboundResourceadapter().addNewConnectionDefinition(); 50 replaceConnectionDefinitionDConfigBean(connectionDefinition); 51 } 52 53 private void replaceConnectionDefinitionDConfigBean(GerConnectionDefinitionType connectionDefinition) { 54 DDBean ddBean = getDDBean(); 55 DDBean childDDBean = ddBean.getChildBean(getXpaths()[0])[0]; 56 connectionDefinitionDConfigBean = new ConnectionDefinitionDConfigBean(childDDBean, connectionDefinition); 57 } 58 59 GerConnectorDocument getConnectorDocument() { 60 return (GerConnectorDocument) getXmlObject(); 61 } 62 63 public String [] getXpaths() { 64 return XPATHS; 65 } 66 67 public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException { 68 if (getXpaths()[0].equals(bean.getXpath())) { 69 return connectionDefinitionDConfigBean; 70 } 71 return null; 72 } 73 74 public void fromXML(InputStream inputStream) throws XmlException, IOException { 75 super.fromXML(inputStream); 76 replaceConnectionDefinitionDConfigBean(getConnectorDocument().getConnector().getResourceadapterArray()[0].getOutboundResourceadapter().getConnectionDefinitionArray(0)); 78 } 79 80 protected SchemaTypeLoader getSchemaTypeLoader() { 81 return ResourceAdapterDConfigRoot.SCHEMA_TYPE_LOADER; 82 } 83 } 84 | Popular Tags |