geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/naming/src/test/org/apache/geronimo/naming/java ContextBuilderTest.java
Date Tue, 09 Mar 2004 18:03:11 GMT
djencks     2004/03/09 10:03:11

  Modified:    modules/naming maven.xml project.xml
               modules/naming/src/java/org/apache/geronimo/naming/deployment
                        ENCHelper.java
               modules/naming/src/java/org/apache/geronimo/naming/java
                        ComponentContextBuilder.java ReadOnlyContext.java
               modules/naming/src/schema geronimo-naming.xsd
               modules/naming/src/test/org/apache/geronimo/naming/java
                        ContextBuilderTest.java
  Added:       modules/naming/src/java/org/apache/geronimo/naming/deployment
                        ENCConfigBuilder.java LocalRefDConfigBean.java
                        RefAdapter.java RemoteRefDConfigBean.java
               modules/naming/src/java/org/apache/geronimo/naming/jmx
                        JMXObjectFactory.java JMXRefAddr.java
                        JMXReferenceFactory.java
  Removed:     modules/naming/src/java/org/apache/geronimo/naming/deployment
                        EJBLocalRefDConfigBean.java EJBRefDConfigBean.java
                        MessageDestinationRefDConfigBean.java
                        ResourceEnvRefDConfigBean.java
                        ResourceRefDConfigBean.java
               modules/naming/src/java/org/apache/geronimo/naming/proxy
                        CFContainer.java EJBContainer.java
                        ExternalProxy.java ProxyFactory.java
                        ProxyManager.java
  Log:
  Remove proxy idea, introduce geronimo-specific References
  
  Revision  Changes    Path
  1.2       +3 -3      incubator-geronimo/modules/naming/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/naming/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml	14 Feb 2004 16:55:28 -0000	1.1
  +++ maven.xml	9 Mar 2004 18:03:11 -0000	1.2
  @@ -5,13 +5,13 @@
   <project default="default"
       xmlns:xmlbeans="geronimo:xmlbeans">
   
  -    <preGoal name="java:compile">
  +    <!--preGoal name="java:compile">
           <xmlbeans:schema2java
               sourcedir="${basedir}/src"
               sourceschema="schema/geronimo-naming.xsd"
               xmlconfigs="${basedir}/src/schema/xmlconfig.xml"
               targetdir="${basedir}/target/xmlbeans"
               cataloglocation="${basedir}/../../specs/schema/src/catalog/resolver-catalog.xml"/>
  -    </preGoal>
  +    </preGoal-->
   
   </project>
  
  
  
  1.7       +22 -1     incubator-geronimo/modules/naming/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/naming/project.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- project.xml	19 Feb 2004 09:00:28 -0000	1.6
  +++ project.xml	9 Mar 2004 18:03:11 -0000	1.7
  @@ -72,6 +72,27 @@
               <artifactId>geronimo-spec-jta</artifactId>
               <version>${pom.currentVersion}</version>
           </dependency>
  +
  +        <dependency>
  +            <groupId>cglib</groupId>
  +            <artifactId>cglib-full</artifactId>
  +            <version>2.0-RC2</version>
  +            <url>http://cglib.sf.net/</url>
  +        </dependency>
  +
  +        <dependency>
  +            <groupId>commons-logging</groupId>
  +            <artifactId>commons-logging</artifactId>
  +            <version>1.0.3</version>
  +            <url>http://jakarta.apache.org/commons/logging/</url>
  +        </dependency>
  +
  +        <dependency>
  +            <groupId>mx4j</groupId>
  +            <artifactId>mx4j</artifactId>
  +            <version>SNAPSHOT</version>
  +        </dependency>
  +
       </dependencies>
   
       <build>
  
  
  
  1.4       +185 -141  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCHelper.java
  
  Index: ENCHelper.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ENCHelper.java	25 Feb 2004 09:57:57 -0000	1.3
  +++ ENCHelper.java	9 Mar 2004 18:03:11 -0000	1.4
  @@ -22,13 +22,9 @@
   
   import javax.enterprise.deploy.model.DDBean;
   import javax.enterprise.deploy.spi.DConfigBean;
  +import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
   import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
   
  -import org.apache.geronimo.xbeans.geronimo.GerEjbLocalRefType;
  -import org.apache.geronimo.xbeans.geronimo.GerEjbRefType;
  -import org.apache.geronimo.xbeans.geronimo.GerMessageDestinationRefType;
  -import org.apache.geronimo.xbeans.geronimo.GerResourceEnvRefType;
  -import org.apache.geronimo.xbeans.geronimo.GerResourceRefType;
   import org.apache.xmlbeans.SchemaTypeLoader;
   import org.apache.xmlbeans.XmlBeans;
   
  @@ -38,194 +34,222 @@
    * @version $Revision$ $Date$
    */
   public class ENCHelper {
  -    static final SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.typeLoaderUnion(new SchemaTypeLoader[] {
  +    static final SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.typeLoaderUnion(new SchemaTypeLoader[]{
           XmlBeans.typeLoaderForClassLoader(org.apache.geronimo.xbeans.j2ee.String.class.getClassLoader()),
  -        XmlBeans.typeLoaderForClassLoader(GerEjbRefType.class.getClassLoader())
       });
   
   
  -    public static final String[] ENC_XPATHS = {
  -        "ejb-ref",
  -        "ejb-local-ref",
  -        "message-destination-ref",
  -        "resource-env-ref",
  -        "resource-ref",
  +    public static final String[][] ENC_XPATHS = {
  +        {"ejb-ref"},
  +        {"ejb-local-ref"},
  +        {"message-destination-ref"},
  +        {"resource-env-ref"},
  +        {"resource-ref"},
  +    };
  +
  +    public static final String[][] NAME_XPATHS = {
  +        {"ejb-ref-name"},
  +        {"ejb-ref-name"},
  +        {"message-destination-ref-name"},
  +        {"resource-env-ref-name"},
  +        {"res-ref-name"}
       };
   
       private final DDBean ddBean;
   
       private final XmlEnvRefs envRefs;
   
  -    private EJBRefDConfigBean[] ejbRefs;
  +    private final String[] xpaths;
  +    private final String[] namePaths;
   
  -    private EJBLocalRefDConfigBean[] ejbLocalRefs;
  -    private MessageDestinationRefDConfigBean[] messageDestinationRefs;
  -    private ResourceEnvRefDConfigBean[] resourceEnvRefs;
  -    private ResourceRefDConfigBean[] resourceRefs;
  +    private LocalRefDConfigBean[] ejbRefs;
   
  -    public ENCHelper(DDBean ddBean, XmlEnvRefs envRefs) {
  +    private LocalRefDConfigBean[] ejbLocalRefs;
  +    private LocalRefDConfigBean[] messageDestinationRefs;
  +    private LocalRefDConfigBean[] resourceEnvRefs;
  +    private LocalRefDConfigBean[] resourceRefs;
  +
  +    public ENCHelper(DDBean ddBean, XmlEnvRefs envRefs, String[] xpaths, String[] namePaths) {
           this.ddBean = ddBean;
           this.envRefs = envRefs;
  -        DDBean[] ddEjbRefs = ddBean.getChildBean(ENC_XPATHS[0]);
  +        this.xpaths = xpaths;
  +        this.namePaths = namePaths;
  +        DDBean[] ddEjbRefs = ddBean.getChildBean(xpaths[0]);
           if (ddEjbRefs == null) {
               ddEjbRefs = new DDBean[0];
           }
  -        ejbRefs = new EJBRefDConfigBean[ddEjbRefs.length];
  -        GerEjbRefType[] xmlEjbRefs = envRefs.getEjbRefs();
  +        ejbRefs = new RemoteRefDConfigBean[ddEjbRefs.length];
  +        RefAdapter[] xmlEjbRefs = envRefs.getEjbRefs();
           Map ejbRefMap = new HashMap();
           for (int i = 0; i < xmlEjbRefs.length; i++) {
  -            GerEjbRefType xmlEjbRef = xmlEjbRefs[i];
  -            ejbRefMap.put(xmlEjbRef.getEjbRefName().getStringValue(), xmlEjbRef.getUri());
  +            RefAdapter refAdapter = xmlEjbRefs[i];
  +            ejbRefMap.put(refAdapter.getRefName(), refAdapter);
               envRefs.removeEjbRef(0);
           }
           for (int i = 0; i < ddEjbRefs.length; i++) {
  -            DDBean ddEjbRef = ddEjbRefs[i];
  -            String name = ddEjbRef.getText("ejb-ref-name")[0];
  -            GerEjbRefType xmlEjbRef = envRefs.addNewEjbRef();
  -            xmlEjbRef.addNewEjbRefName().setStringValue(name);
  -            if (ejbRefMap.get(name) != null) {
  -                xmlEjbRef.setUri((String)ejbRefMap.get(name));
  +            DDBean ddRef = ddEjbRefs[i];
  +            String name = ddRef.getText(namePaths[0])[0];
  +            RefAdapter refAdapter;
  +            if (ejbRefMap.get(name) == null) {
  +                refAdapter = envRefs.addNewEjbRef();
  +                refAdapter.setRefName(name);
  +            } else {
  +                refAdapter = (RefAdapter) ejbRefMap.get(name);
  +                envRefs.setEjbRef(i, refAdapter);
               }
  -            ejbRefs[i] = new EJBRefDConfigBean(ddEjbRef,  xmlEjbRef);
  +            ejbRefs[i] = new RemoteRefDConfigBean(ddRef, refAdapter, namePaths[0]);
           }
   
  -        DDBean[] ddEjbLocalRefs = ddBean.getChildBean(ENC_XPATHS[1]);
  +        DDBean[] ddEjbLocalRefs = ddBean.getChildBean(xpaths[1]);
           if (ddEjbLocalRefs == null) {
               ddEjbLocalRefs = new DDBean[0];
           }
  -        ejbLocalRefs = new EJBLocalRefDConfigBean[ddEjbLocalRefs.length];
  -        GerEjbLocalRefType[] xmlEjbLocalRefs = envRefs.getEjbLocalRefs();
  -        Map EjbLocalRefMap = new HashMap();
  +        ejbLocalRefs = new LocalRefDConfigBean[ddEjbLocalRefs.length];
  +        RefAdapter[] xmlEjbLocalRefs = envRefs.getEjbLocalRefs();
  +        Map ejbLocalRefMap = new HashMap();
           for (int i = 0; i < xmlEjbLocalRefs.length; i++) {
  -            GerEjbLocalRefType xmlEjbLocalRef = xmlEjbLocalRefs[i];
  -            EjbLocalRefMap.put(xmlEjbLocalRef.getEjbRefName().getStringValue(), xmlEjbLocalRef.getUri());
  +            RefAdapter refAdapter = xmlEjbLocalRefs[i];
  +            ejbLocalRefMap.put(refAdapter.getRefName(), refAdapter);
               envRefs.removeEjbLocalRef(0);
           }
           for (int i = 0; i < ddEjbLocalRefs.length; i++) {
  -            DDBean ddEjbLocalRef = ddEjbLocalRefs[i];
  -            String name = ddEjbLocalRef.getText("ejb-ref-name")[0];
  -            GerEjbLocalRefType xmlEjbLocalRef = envRefs.addNewEjbLocalRef();
  -            xmlEjbLocalRef.addNewEjbRefName().setStringValue(name);
  -            if (EjbLocalRefMap.get(name) != null) {
  -                xmlEjbLocalRef.setUri((String)EjbLocalRefMap.get(name));
  +            DDBean ddRef = ddEjbLocalRefs[i];
  +            String name = ddRef.getText(namePaths[1])[0];
  +            RefAdapter refAdapter;
  +            if (ejbLocalRefMap.get(name) == null) {
  +                refAdapter = envRefs.addNewEjbLocalRef();
  +                refAdapter.setRefName(name);
  +            } else {
  +                refAdapter = (RefAdapter) ejbLocalRefMap.get(name);
  +                envRefs.setEjbLocalRef(i, refAdapter);
               }
  -            ejbLocalRefs[i] = new EJBLocalRefDConfigBean(ddEjbLocalRef,  xmlEjbLocalRef);
  +            ejbLocalRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[1]);
           }
   
  -        DDBean[] ddMessageDestinationRefs = ddBean.getChildBean(ENC_XPATHS[2]);
  +        DDBean[] ddMessageDestinationRefs = ddBean.getChildBean(xpaths[2]);
           if (ddMessageDestinationRefs == null) {
               ddMessageDestinationRefs = new DDBean[0];
           }
  -        messageDestinationRefs = new MessageDestinationRefDConfigBean[ddMessageDestinationRefs.length];
  -        GerMessageDestinationRefType[] xmlMessageDestinationRefs = envRefs.getMessageDestinationRefs();
  -        Map MessageDestinationRefMap = new HashMap();
  +        messageDestinationRefs = new LocalRefDConfigBean[ddMessageDestinationRefs.length];
  +        RefAdapter[] xmlMessageDestinationRefs = envRefs.getMessageDestinationRefs();
  +        Map messageDestinationRefMap = new HashMap();
           for (int i = 0; i < xmlMessageDestinationRefs.length; i++) {
  -            GerMessageDestinationRefType xmlMessageDestinationRef = xmlMessageDestinationRefs[i];
  -            MessageDestinationRefMap.put(xmlMessageDestinationRef.getMessageDestinationRefName().getStringValue(), xmlMessageDestinationRef.getUri());
  +            RefAdapter refAdapter = xmlMessageDestinationRefs[i];
  +            messageDestinationRefMap.put(refAdapter.getRefName(), refAdapter);
               envRefs.removeMessageDestinationRef(0);
           }
           for (int i = 0; i < ddMessageDestinationRefs.length; i++) {
  -            DDBean ddMessageDestinationRef = ddMessageDestinationRefs[i];
  -            String name = ddMessageDestinationRef.getText("message-destination-ref-name")[0];
  -            GerMessageDestinationRefType xmlMessageDestinationRef = envRefs.addNewMessageDestinationRef();
  -            xmlMessageDestinationRef.addNewMessageDestinationRefName().setStringValue(name);
  -            if (MessageDestinationRefMap.get(name) != null) {
  -                xmlMessageDestinationRef.setUri((String)MessageDestinationRefMap.get(name));
  +            DDBean ddRef = ddMessageDestinationRefs[i];
  +            String name = ddRef.getText(namePaths[2])[0];
  +            RefAdapter refAdapter;
  +            if (messageDestinationRefMap.get(name) == null) {
  +                refAdapter = envRefs.addNewMessageDestinationRef();
  +                refAdapter.setRefName(name);
  +            } else {
  +                refAdapter = (RefAdapter) messageDestinationRefMap.get(name);
  +                envRefs.setMessageDestinationRef(i, refAdapter);
               }
  -            messageDestinationRefs[i] = new MessageDestinationRefDConfigBean(ddMessageDestinationRef,  xmlMessageDestinationRef);
  -         }
  +            //??? local or remote
  +            messageDestinationRefs[i] = new RemoteRefDConfigBean(ddRef, refAdapter, namePaths[2]);
  +        }
   
  -        DDBean[] ddResourceEnvRefs = ddBean.getChildBean(ENC_XPATHS[3]);
  +        DDBean[] ddResourceEnvRefs = ddBean.getChildBean(xpaths[3]);
           if (ddResourceEnvRefs == null) {
               ddResourceEnvRefs = new DDBean[0];
           }
  -        resourceEnvRefs = new ResourceEnvRefDConfigBean[ddResourceEnvRefs.length];
  -        GerResourceEnvRefType[] xmlResourceEnvRefs = envRefs.getResourceEnvRefs();
  -        Map ResourceEnvRefMap = new HashMap();
  +        resourceEnvRefs = new LocalRefDConfigBean[ddResourceEnvRefs.length];
  +        RefAdapter[] xmlResourceEnvRefs = envRefs.getResourceEnvRefs();
  +        Map resourceEnvRefMap = new HashMap();
           for (int i = 0; i < xmlResourceEnvRefs.length; i++) {
  -            GerResourceEnvRefType xmlResourceEnvRef = xmlResourceEnvRefs[i];
  -            ResourceEnvRefMap.put(xmlResourceEnvRef.getResourceEnvRefName().getStringValue(), xmlResourceEnvRef.getUri());
  +            RefAdapter refAdapter = xmlResourceEnvRefs[i];
  +            resourceEnvRefMap.put(refAdapter.getRefName(), refAdapter);
               envRefs.removeResourceEnvRef(0);
           }
           for (int i = 0; i < ddResourceEnvRefs.length; i++) {
  -            DDBean ddResourceEnvRef = ddResourceEnvRefs[i];
  -            String name = ddResourceEnvRef.getText("resource-env-ref-name")[0];
  -            GerResourceEnvRefType xmlResourceEnvRef = envRefs.addNewResourceEnvRef();
  -            xmlResourceEnvRef.addNewResourceEnvRefName().setStringValue(name);
  -            if (ResourceEnvRefMap.get(name) != null) {
  -                xmlResourceEnvRef.setUri((String)ResourceEnvRefMap.get(name));
  +            DDBean ddRef = ddResourceEnvRefs[i];
  +            String name = ddRef.getText(namePaths[3])[0];
  +            RefAdapter refAdapter;
  +            if (resourceEnvRefMap.get(name) == null) {
  +                refAdapter = envRefs.addNewResourceEnvRef();
  +                refAdapter.setRefName(name);
  +            } else {
  +                refAdapter = (RefAdapter) resourceEnvRefMap.get(name);
  +                envRefs.setResourceEnvRef(i, refAdapter);
               }
  -            resourceEnvRefs[i] = new ResourceEnvRefDConfigBean(ddResourceEnvRef,  xmlResourceEnvRef);
  +            resourceEnvRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[3]);
           }
   
  -        DDBean[] ddResourceRefs = ddBean.getChildBean(ENC_XPATHS[4]);
  +        DDBean[] ddResourceRefs = ddBean.getChildBean(xpaths[4]);
           if (ddResourceRefs == null) {
               ddResourceRefs = new DDBean[0];
           }
  -        resourceRefs = new ResourceRefDConfigBean[ddResourceRefs.length];
  -        GerResourceRefType[] xmlResourceRefs = envRefs.getResourceRefs();
  -        Map ResourceRefMap = new HashMap();
  +        resourceRefs = new LocalRefDConfigBean[ddResourceRefs.length];
  +        RefAdapter[] xmlResourceRefs = envRefs.getResourceRefs();
  +        Map resourceRefMap = new HashMap();
           for (int i = 0; i < xmlResourceRefs.length; i++) {
  -            GerResourceRefType xmlResourceRef = xmlResourceRefs[i];
  -            ResourceRefMap.put(xmlResourceRef.getResRefName().getStringValue(), xmlResourceRef.getUri());
  +            RefAdapter refAdapter = xmlResourceRefs[i];
  +            resourceRefMap.put(refAdapter.getRefName(), refAdapter);
               envRefs.removeResourceRef(0);
           }
           for (int i = 0; i < ddResourceRefs.length; i++) {
  -            DDBean ddResourceRef = ddResourceRefs[i];
  -            String name = ddResourceRef.getText("res-ref-name")[0];
  -            GerResourceRefType xmlResourceRef = envRefs.addNewResourceRef();
  -            xmlResourceRef.addNewResRefName().setStringValue(name);
  -            if (ResourceRefMap.get(name) != null) {
  -                xmlResourceRef.setUri((String)ResourceRefMap.get(name));
  +            DDBean ddRef = ddResourceRefs[i];
  +            String name = ddRef.getText(namePaths[4])[0];
  +            RefAdapter refAdapter;
  +            if (resourceRefMap.get(name) == null) {
  +                refAdapter = envRefs.addNewResourceRef();
  +                refAdapter.setRefName(name);
  +            } else {
  +                refAdapter = (RefAdapter) resourceRefMap.get(name);
  +                envRefs.setResourceRef(i, refAdapter);
               }
  -            resourceRefs[i] = new ResourceRefDConfigBean(ddResourceRef,  xmlResourceRef);
  +            resourceRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[4]);
           }
   
       }
   
       public DConfigBean getDConfigBean(DDBean ddBean) throws ConfigurationException {
           String xpath = ddBean.getXpath();
  -        if (xpath.equals(ENC_XPATHS[0])) {
  -            String name = ddBean.getText("ejb-ref-name")[0];
  +        if (xpath.equals(xpaths[0])) {
  +            String name = ddBean.getText(namePaths[0])[0];
               for (int i = 0; i < ejbRefs.length; i++) {
  -                EJBRefDConfigBean ejbRef = ejbRefs[i];
  -                if (ejbRef.getEjbRefName().equals(name)) {
  +                LocalRefDConfigBean ejbRef = ejbRefs[i];
  +                if (ejbRef.getRefName().equals(name)) {
                       return ejbRef;
                   }
               }
               throw new ConfigurationException("no such ejb-ref-name" + name);
  -        } else if (xpath.equals(ENC_XPATHS[1])) {
  -            String name = ddBean.getText("ejb-ref-name")[0];
  +        } else if (xpath.equals(xpaths[1])) {
  +            String name = ddBean.getText(namePaths[1])[0];
               for (int i = 0; i < ejbLocalRefs.length; i++) {
  -                EJBLocalRefDConfigBean ejbLocalRef = ejbLocalRefs[i];
  -                if (ejbLocalRef.getEjbRefName().equals(name)) {
  +                LocalRefDConfigBean ejbLocalRef = ejbLocalRefs[i];
  +                if (ejbLocalRef.getRefName().equals(name)) {
                       return ejbLocalRef;
                   }
               }
               throw new ConfigurationException("no such ejb-ref-name" + name);
  -        } else if (xpath.equals(ENC_XPATHS[2])) {
  -            String name = ddBean.getText("message-destination-ref-name")[0];
  +        } else if (xpath.equals(xpaths[2])) {
  +            String name = ddBean.getText(namePaths[2])[0];
               for (int i = 0; i < messageDestinationRefs.length; i++) {
  -                MessageDestinationRefDConfigBean messageDestinationRef = messageDestinationRefs[i];
  -                if (messageDestinationRef.getMessageDestinationRefName().equals(name)) {
  +                LocalRefDConfigBean messageDestinationRef = messageDestinationRefs[i];
  +                if (messageDestinationRef.getRefName().equals(name)) {
                       return messageDestinationRef;
                   }
               }
               throw new ConfigurationException("no such ejb-ref-name" + name);
  -        } else if (xpath.equals(ENC_XPATHS[3])) {
  -            String name = ddBean.getText("resource-env-ref-name")[0];
  +        } else if (xpath.equals(xpaths[3])) {
  +            String name = ddBean.getText(namePaths[3])[0];
               for (int i = 0; i < resourceEnvRefs.length; i++) {
  -                ResourceEnvRefDConfigBean resourceEnvRef = resourceEnvRefs[i];
  -                if (resourceEnvRef.getResourceEnvRefName().equals(name)) {
  +                LocalRefDConfigBean resourceEnvRef = resourceEnvRefs[i];
  +                if (resourceEnvRef.getRefName().equals(name)) {
                       return resourceEnvRef;
                   }
               }
               throw new ConfigurationException("no such ejb-ref-name" + name);
  -        } else if (xpath.equals(ENC_XPATHS[4])) {
  -            String name = ddBean.getText("res-ref-name")[0];
  +        } else if (xpath.equals(xpaths[4])) {
  +            String name = ddBean.getText(namePaths[4])[0];
               for (int i = 0; i < resourceRefs.length; i++) {
  -                ResourceRefDConfigBean resourceRef = resourceRefs[i];
  -                if (resourceRef.getResourceRefName().equals(name)) {
  +                LocalRefDConfigBean resourceRef = resourceRefs[i];
  +                if (resourceRef.getRefName().equals(name)) {
                       return resourceRef;
                   }
               }
  @@ -234,54 +258,74 @@
               throw new ConfigurationException("Unrecognized XPath: " + ddBean.getXpath());
           }
       }
  -  /*
  -    public void removeDConfigBean(DConfigBean dcBean) throws BeanNotFoundException {
  -        DDBean ddBean = dcBean.getDDBean();
  -        String xpath = ddBean.getXpath();
  -        String name = ddBean.getText();
   
  -        if (xpath.endsWith("ejb-ref/ejb-ref-name")) {
  -            if (ejbRefs.remove(name) == null) {
  -                throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  -            }
  -        } else if (xpath.endsWith("ejb-local-ref/ejb-ref-name")) {
  -            if (ejbLocalRefs.remove(name) == null) {
  -                throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  -            }
  -        } else if (xpath.endsWith("service-ref/service-ref-name")) {
  -            if (serviceRefs.remove(name) == null) {
  -                throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  -            }
  -        } else if (xpath.endsWith("resource-ref/res-ref-name")) {
  -            if (resourceRefs.remove(name) == null) {
  -                throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  -            }
  -        } else {
  -            throw new BeanNotFoundException("Unrecognized XPath: " + xpath);
  -        }
  -    }
  +      public void removeDConfigBean(DConfigBean dcBean) throws BeanNotFoundException {
  +          DDBean ddBean = dcBean.getDDBean();
  +          String xpath = ddBean.getXpath();
  +          String name = ddBean.getText();
  +    /*
  +          if (xpath.endsWith("ejb-ref/ejb-ref-name")) {
  +              if (ejbRefs.remove(name) == null) {
  +                  throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  +              }
  +          } else if (xpath.endsWith("ejb-local-ref/ejb-ref-name")) {
  +              if (ejbLocalRefs.remove(name) == null) {
  +                  throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  +              }
  +          } else if (xpath.endsWith("service-ref/service-ref-name")) {
  +              if (serviceRefs.remove(name) == null) {
  +                  throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  +              }
  +          } else if (xpath.endsWith("resource-ref/res-ref-name")) {
  +              if (resourceRefs.remove(name) == null) {
  +                  throw new BeanNotFoundException("No DConfigBean found with name: " + name);
  +              }
  +          } else {
  +              throw new BeanNotFoundException("Unrecognized XPath: " + xpath);
  +          }
  +          */
  +      }
   
  -     */
   
       public interface XmlEnvRefs {
  -        GerEjbRefType[] getEjbRefs();
  -        GerEjbRefType addNewEjbRef();
  +        RefAdapter[] getEjbRefs();
  +
  +        RefAdapter addNewEjbRef();
  +
  +        void setEjbRef(int i, RefAdapter refAdapter);
  +
           void removeEjbRef(int i);
   
  -        GerEjbLocalRefType[] getEjbLocalRefs();
  -        GerEjbLocalRefType addNewEjbLocalRef();
  +        RefAdapter[] getEjbLocalRefs();
  +
  +        RefAdapter addNewEjbLocalRef();
  +
  +        void setEjbLocalRef(int i, RefAdapter refAdapter);
  +
           void removeEjbLocalRef(int i);
   
  -        GerMessageDestinationRefType[] getMessageDestinationRefs();
  -        GerMessageDestinationRefType addNewMessageDestinationRef();
  +        RefAdapter[] getMessageDestinationRefs();
  +
  +        RefAdapter addNewMessageDestinationRef();
  +
  +        void setMessageDestinationRef(int i, RefAdapter refAdapter);
  +
           void removeMessageDestinationRef(int i);
   
  -        GerResourceEnvRefType[] getResourceEnvRefs();
  -        GerResourceEnvRefType addNewResourceEnvRef();
  +        RefAdapter[] getResourceEnvRefs();
  +
  +        RefAdapter addNewResourceEnvRef();
  +
  +        void setResourceEnvRef(int i, RefAdapter refAdapter);
  +
           void removeResourceEnvRef(int i);
   
  -        GerResourceRefType[] getResourceRefs();
  -        GerResourceRefType addNewResourceRef();
  +        RefAdapter[] getResourceRefs();
  +
  +        RefAdapter addNewResourceRef();
  +
  +        void setResourceRef(int i, RefAdapter refAdapter);
  +
           void removeResourceRef(int i);
   
       }
  
  
  
  1.1                  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
  
  Index: ENCConfigBuilder.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.naming.deployment;
  
  import java.util.Map;
  
  import javax.naming.NamingException;
  
  import org.apache.geronimo.xbeans.j2ee.EnvEntryType;
  import org.apache.geronimo.xbeans.j2ee.ResourceRefType;
  import org.apache.geronimo.deployment.DeploymentException;
  import org.apache.geronimo.naming.java.ComponentContextBuilder;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/03/09 18:03:11 $
   *
   * */
  public class ENCConfigBuilder {
  
      public static void addEnvEntries(EnvEntryType[] envEntries, ComponentContextBuilder builder) throws DeploymentException {
          for (int i = 0; i < envEntries.length; i++) {
              EnvEntryType envEntry = envEntries[i];
              String name = envEntry.getEnvEntryName().getStringValue();
              String type = envEntry.getEnvEntryType().getStringValue();
              String text = envEntry.getEnvEntryValue().getStringValue();
              try {
                  builder.addEnvEntry(name, type, text);
              } catch (NumberFormatException e) {
                  throw new DeploymentException("Invalid env-entry value for name: " + name, e);
              } catch (NamingException e) {
                  throw new DeploymentException("Invalid env-entry definition for name: " + name, e);
              }
          }
  
      }
  
      public static void addResourceRefs(ResourceRefType[] resourceRefs, ClassLoader cl, Map refAdapterMap, ComponentContextBuilder builder) throws DeploymentException {
          for (int i = 0; i < resourceRefs.length; i++) {
              ResourceRefType resourceRef = resourceRefs[i];
              String name = resourceRef.getResRefName().getStringValue();
              String type = resourceRef.getResType().getStringValue();
              Class iface = null;
              try {
                  iface = cl.loadClass(type);
              } catch (ClassNotFoundException e) {
                  throw new DeploymentException("could not load class " + type, e);
              }
              RefAdapter refAdapter = (RefAdapter) refAdapterMap.get(name);
              try {
                  builder.addResourceRef(name, iface, refAdapter);
              } catch (NamingException e) {
                  throw new DeploymentException("Invalid env-entry definition for name: " + name, e);
              }
          }
  
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/deployment/LocalRefDConfigBean.java
  
  Index: LocalRefDConfigBean.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.naming.deployment;
  
  import javax.enterprise.deploy.model.DDBean;
  
  import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
  import org.apache.xmlbeans.SchemaTypeLoader;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/03/09 18:03:11 $
   */
  public class LocalRefDConfigBean extends DConfigBeanSupport {
  
      protected final RefAdapter ref;
  
      public LocalRefDConfigBean(DDBean ddBean, RefAdapter ref, String namePath) {
          super(ddBean, ref.getXmlObject());
          this.ref = ref;
          assert ddBean.getChildBean(namePath)[0].equals(getRefName());
      }
  
      String getRefName() {
          return ref.getRefName();
      }
  
      public String getExternalUri() {
          return ref.getExternalUri();
      }
  
      public void setExternalUri(String targetURI) {
          ref.setExternalUri(targetURI);
      }
  
  
      public String getKernelName() {
          return ref.getKernelName();
      }
  
      public void setKernelName(String kernelName) {
          ref.setKernelName(kernelName);
      }
  
      public String getTargetName() {
          return ref.getTargetName();
      }
  
      public void setTargetName(String targetName) {
          ref.setTargetName(targetName);
      }
  
      protected SchemaTypeLoader getSchemaTypeLoader() {
          return ENCHelper.SCHEMA_TYPE_LOADER;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/deployment/RefAdapter.java
  
  Index: RefAdapter.java
  ===================================================================
  package org.apache.geronimo.naming.deployment;
  
  import org.apache.xmlbeans.XmlObject;
  
  /**
   * adapting wrapper for different xml objects generated for different schema incusions.
   *
   * @version $Revision: 1.1 $ $Date: 2004/03/09 18:03:11 $
   *
   * */
  public interface RefAdapter {
      XmlObject getXmlObject();
      void setXmlObject(XmlObject xmlObject);
  
      String getRefName();
      void setRefName(String name);
      String getServerName();
      void setServerName(String serverName);
      String getKernelName();
      void setKernelName(String kernelName);
      String getTargetName();
      void setTargetName(String targetName);
      String getExternalUri();
      void setExternalUri(String externalURI);
  }
  
  
  
  1.1                  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/deployment/RemoteRefDConfigBean.java
  
  Index: RemoteRefDConfigBean.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.naming.deployment;
  
  import javax.enterprise.deploy.model.DDBean;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/03/09 18:03:11 $
   *
   * */
  public class RemoteRefDConfigBean extends LocalRefDConfigBean {
  
      public RemoteRefDConfigBean(DDBean ddBean, RefAdapter ref, String namePath) {
          super (ddBean, ref, namePath);
      }
  
      public String getServerName() {
          return ref.getServerName();
      }
  
      public void setServerName(String serverName) {
          ref.setServerName(serverName);
      }
  }
  
  
  
  1.6       +41 -2     incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java
  
  Index: ComponentContextBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ComponentContextBuilder.java	25 Feb 2004 09:57:57 -0000	1.5
  +++ ComponentContextBuilder.java	9 Mar 2004 18:03:11 -0000	1.6
  @@ -17,9 +17,17 @@
   
   package org.apache.geronimo.naming.java;
   
  +import java.net.MalformedURLException;
  +import java.net.URL;
  +
  +import javax.management.MalformedObjectNameException;
   import javax.naming.NamingException;
  +import javax.naming.Reference;
   import javax.transaction.UserTransaction;
   
  +import org.apache.geronimo.naming.deployment.RefAdapter;
  +import org.apache.geronimo.naming.jmx.JMXReferenceFactory;
  +
   /**
    *
    *
  @@ -27,9 +35,11 @@
    */
   public class ComponentContextBuilder {
       private static final String ENV = "env/";
  +    private final JMXReferenceFactory referenceFactory;
       private final ReadOnlyContext context;
   
  -    public ComponentContextBuilder() {
  +    public ComponentContextBuilder(JMXReferenceFactory referenceFactory) {
  +        this.referenceFactory = referenceFactory;
           this.context = new ReadOnlyContext();
       }
   
  @@ -45,6 +55,7 @@
           context.internalBind("UserTransaction", userTransaction);
       }
   
  +
       public void addEnvEntry(String name, String type, String text) throws NamingException, NumberFormatException {
           if (context.isFrozen()) {
               throw new IllegalStateException("Context has been frozen");
  @@ -75,6 +86,34 @@
               throw new IllegalArgumentException("Invalid class for env-entry " + name + ", " + type);
           }
           context.internalBind(ENV + name, value);
  +    }
  +
  +    public void addResourceRef(String name, Class iface, RefAdapter refAdapter) throws NamingException {
  +        if (iface == URL.class) {
  +            try {
  +                context.internalBind(ENV + name, new URL(refAdapter.getExternalUri()));
  +            } catch (MalformedURLException e) {
  +                throw (NamingException) new NamingException("Could not convert " + refAdapter + " to URL").initCause(e);
  +            }
  +        } else {
  +            Reference ref = null;
  +            try {
  +                ref = referenceFactory.buildConnectionFactoryReference(refAdapter, iface);
  +            } catch (MalformedObjectNameException e) {
  +                throw (NamingException) new NamingException("invalid object name").initCause(e);
  +            }
  +            context.internalBind(ENV + name, ref);
  +        }
  +    }
  +
  +    public void addResourceEnvRef(String name, Class iface, RefAdapter refAdapter) throws NamingException {
  +        Reference ref = null;
  +        try {
  +            ref = referenceFactory.buildAdminObjectReference(refAdapter, iface);
  +        } catch (MalformedObjectNameException e) {
  +            throw (NamingException) new NamingException("invalid object name").initCause(e);
  +        }
  +        context.internalBind(ENV + name, ref);
       }
   
       // todo methods for other references
  
  
  
  1.6       +11 -1     incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java
  
  Index: ReadOnlyContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ReadOnlyContext.java	25 Feb 2004 09:57:57 -0000	1.5
  +++ ReadOnlyContext.java	9 Mar 2004 18:03:11 -0000	1.6
  @@ -36,6 +36,7 @@
   import javax.naming.NamingException;
   import javax.naming.NotContextException;
   import javax.naming.OperationNotSupportedException;
  +import javax.naming.Reference;
   import javax.naming.spi.NamingManager;
   
   /**
  @@ -198,6 +199,15 @@
           if (result instanceof LinkRef) {
               LinkRef ref = (LinkRef) result;
               result = lookup(ref.getLinkName());
  +        }
  +        if (result instanceof Reference) {
  +            try {
  +                result = NamingManager.getObjectInstance(result, null, null, this.env);
  +            } catch (NamingException e) {
  +                throw e;
  +            } catch (Exception e) {
  +                throw (NamingException)new NamingException("could not look up : " + name).initCause(e);
  +            }
           }
           if (result instanceof ReadOnlyContext) {
               result = new ReadOnlyContext((ReadOnlyContext) result, env);
  
  
  
  1.1                  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java
  
  Index: JMXObjectFactory.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.naming.jmx;
  
  import java.util.Hashtable;
  
  import javax.naming.Context;
  import javax.naming.Name;
  import javax.naming.RefAddr;
  import javax.naming.Reference;
  import javax.naming.spi.ObjectFactory;
  
  import org.apache.geronimo.kernel.Kernel;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/03/09 18:03:11 $
   *
   * */
  public class JMXObjectFactory implements ObjectFactory {
  
      public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                                      Hashtable environment) throws Exception {
          if (obj instanceof Reference) {
              Reference ref = (Reference) obj;
              RefAddr refAddr = ref.get(0);
              if (!(refAddr instanceof JMXRefAddr)) {
                  throw new IllegalStateException("Invalid ref addr in a Connectionfactory ref: " + refAddr);
              }
              JMXRefAddr jmxRefAddr = (JMXRefAddr)refAddr;
              Kernel kernel;
              if (jmxRefAddr.getKernelName() == null) {
                  kernel = Kernel.getSingleKernel();
              } else {
                  kernel = Kernel.getKernel(jmxRefAddr.getKernelName());
              }
              Object proxy = kernel.invoke(jmxRefAddr.getTargetName(), "getProxy");
              if (!jmxRefAddr.getInterface().isAssignableFrom(proxy.getClass())) {
                  throw new IllegalStateException("Proxy does not implement expected interface " + jmxRefAddr.getInterface());
              }
              return proxy;
          }
          return null;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java
  
  Index: JMXRefAddr.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.naming.jmx;
  
  import java.net.URI;
  import java.net.URISyntaxException;
  
  import javax.naming.RefAddr;
  import javax.management.ObjectName;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/03/09 18:03:11 $
   *
   * */
  public class JMXRefAddr extends RefAddr {
  
      private final static String TYPE = "org.apache.geronimo.naming.jmx.RefType";
  
      private final String serverName;
      private final String kernelName;
      private final ObjectName targetName;
      private final static String SCHEME = "geronimo";
      private final Class iface;
  
      public JMXRefAddr(String serverName, String kernelName, ObjectName targetname, Class iface) {
          super(TYPE);
          this.serverName = serverName;
          this.kernelName = kernelName;
          this.targetName = targetname;
          this.iface = iface;
      }
  
      public String getServerName() {
          return serverName;
      }
  
      public String getKernelName() {
          return kernelName;
      }
  
      public ObjectName getTargetName() {
          return targetName;
      }
  
      public Class getInterface() {
          return iface;
      }
  
      public Object getContent() {
          try {
              return new URI(SCHEME, kernelName, targetName.toString(), null);
          } catch (URISyntaxException e) {
              throw (IllegalStateException)new IllegalStateException("invalid jmx ref addr").initCause(e);
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXReferenceFactory.java
  
  Index: JMXReferenceFactory.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.naming.jmx;
  
  import javax.management.MalformedObjectNameException;
  import javax.management.ObjectName;
  import javax.naming.Reference;
  
  import org.apache.geronimo.naming.deployment.RefAdapter;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/03/09 18:03:11 $
   *
   * */
  public class JMXReferenceFactory {
  
      public static final String BASE_MANAGED_CONNECTION_FACTORY_NAME = "geronimo.management:J2eeType=ManagedConnectionFactory,name=";
      public static final String BASE_ADMIN_OBJECT_NAME = "geronimo.management:service=AdminObject,name=";
  
      public JMXReferenceFactory() {
      }
  
      public Reference buildConnectionFactoryReference(RefAdapter refAdapter, Class iface) throws MalformedObjectNameException {
          Reference ref = new Reference(null, JMXObjectFactory.class.getName(), null);
          ref.add(new JMXRefAddr(refAdapter.getServerName(), refAdapter.getKernelName(), ObjectName.getInstance(BASE_MANAGED_CONNECTION_FACTORY_NAME + refAdapter.getTargetName()), iface));
          return ref;
      }
  
      public Reference buildAdminObjectReference(RefAdapter refAdapter, Class iface) throws MalformedObjectNameException {
          Reference ref = new Reference(null, JMXObjectFactory.class.getName(), null);
          ref.add(new JMXRefAddr(refAdapter.getServerName(), refAdapter.getKernelName(), ObjectName.getInstance(BASE_ADMIN_OBJECT_NAME + refAdapter.getTargetName()), iface));
          return ref;
      }
  
      //TODO remotable references should check for externalURI and use a LinkRef if present.
  }
  
  
  
  1.3       +45 -43    incubator-geronimo/modules/naming/src/schema/geronimo-naming.xsd
  
  Index: geronimo-naming.xsd
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/naming/src/schema/geronimo-naming.xsd,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- geronimo-naming.xsd	14 Feb 2004 01:50:15 -0000	1.2
  +++ geronimo-naming.xsd	9 Mar 2004 18:03:11 -0000	1.3
  @@ -1,12 +1,21 @@
   <?xml version="1.0" encoding="UTF-8"?>
  -<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
  -    xmlns:ger="http://geronimo.apache.org/xml/ns/j2ee"
  -    targetNamespace="http://geronimo.apache.org/xml/ns/j2ee"
  +<xsd:schema
       xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified"
       attributeFormDefault="unqualified"
       version="1.0">
  +
  +    <xsd:annotation>
  +        <xsd:documentation>
  +            <![CDATA[
  +            Partial schema containing common naming elements which can be included in other schemas.
  +            This schema does not define a targetNamespace and so all definitions from this
  +            schema instance will end up in the targetNamespace of the including document.
  +            ]]>
  +        </xsd:documentation>
  +    </xsd:annotation>
  +
       <xsd:import namespace="http://java.sun.com/xml/ns/j2ee" schemaLocation="j2ee_1_4.xsd"/>
   
       <xsd:group name="jndiEnvironmentRefsGroup">
  @@ -20,65 +29,58 @@
           </xsd:annotation>
           <xsd:sequence>
               <!--xsd:element name="env-entry"
  -                type="ger:env-entryType"
  +                type="env-entryType"
                   minOccurs="0" maxOccurs="unbounded"/-->
               <xsd:element name="ejb-ref"
  -                type="ger:ejb-refType"
  +                type="remote-refType"
                   minOccurs="0" maxOccurs="unbounded"/>
               <xsd:element name="ejb-local-ref"
  -                type="ger:ejb-local-refType"
  +                type="local-refType"
                   minOccurs="0" maxOccurs="unbounded"/>
               <!-- leave web services out until I know what they do -->
  -            <!--xsd:group ref="ger:service-refGroup"/-->
  +            <!--xsd:group ref="service-refGroup"/-->
               <xsd:element name="resource-ref"
  -                type="ger:resource-refType"
  +                type="local-refType"
                   minOccurs="0" maxOccurs="unbounded"/>
               <xsd:element name="resource-env-ref"
  -                type="ger:resource-env-refType"
  +                type="local-refType"
                   minOccurs="0" maxOccurs="unbounded"/>
               <xsd:element name="message-destination-ref"
  -                type="ger:message-destination-refType"
  +                type="remote-refType"
                   minOccurs="0" maxOccurs="unbounded"/>
           </xsd:sequence>
       </xsd:group>
   
  -    <xsd:complexType name="ejb-refType">
  -        <xsd:sequence>
  -            <xsd:element name="ejb-ref-name" type="j2ee:ejb-ref-nameType"/>
  -            <xsd:element name="uri" type="xsd:string"/>
  -        </xsd:sequence>
  -    </xsd:complexType>
  -
  -    <!-- has exactly same content as ejb-refType, might not be needed -->
  -    <xsd:complexType name="ejb-local-refType">
  -        <xsd:sequence>
  -            <xsd:element name="ejb-ref-name" type="j2ee:ejb-ref-nameType"/>
  -            <xsd:element name="uri" type="xsd:string"/>
  -        </xsd:sequence>
  -    </xsd:complexType>
  -
  -    <xsd:complexType name="message-destination-refType">
  -        <xsd:sequence>
  -            <xsd:element name="message-destination-ref-name"
  -                type="j2ee:jndi-nameType"/>
  -            <xsd:element name="uri" type="xsd:string"/>
  -        </xsd:sequence>
  -    </xsd:complexType>
  -
  -    <xsd:complexType name="resource-env-refType">
  +    <xsd:complexType name="remote-refType">
           <xsd:sequence>
  -            <xsd:element name="resource-env-ref-name"
  -                type="j2ee:jndi-nameType"/>
  -            <xsd:element name="uri" type="xsd:string"/>
  +            <xsd:element name="ref-name" type="xsd:string"/>
  +            <xsd:choice>
  +                <xsd:sequence>
  +                    <xsd:element name="server" type="xsd:string" minOccurs="0"/>
  +                    <xsd:element name="kernel-name" type="xsd:string" minOccurs="0"/>
  +                    <xsd:element name="target-name" type="xsd:string"/>
  +                </xsd:sequence>
  +                <xsd:element name="external-uri" type="xsd:string"/>
  +            </xsd:choice>
           </xsd:sequence>
       </xsd:complexType>
   
  -    <xsd:complexType name="resource-refType">
  -        <xsd:sequence>
  -            <xsd:element name="res-ref-name"
  -                type="j2ee:jndi-nameType"/>
  -            <xsd:element name="uri" type="xsd:string"/>
  -        </xsd:sequence>
  +    <xsd:complexType name="local-refType">
  +        <xsd:complexContent>
  +            <xsd:restriction base="remote-refType">
  +                <xsd:sequence>
  +                    <xsd:element name="ref-name" type="xsd:string"/>
  +                    <xsd:choice>
  +                        <xsd:sequence>
  +                            <xsd:element name="server" type="xsd:string" minOccurs="0" maxOccurs="0"/>
  +                            <xsd:element name="kernel-name" type="xsd:string" minOccurs="0"/>
  +                            <xsd:element name="target-name" type="xsd:string"/>
  +                        </xsd:sequence>
  +                        <xsd:element name="external-uri" type="xsd:string"/>
  +                    </xsd:choice>
  +                </xsd:sequence>
  +            </xsd:restriction>
  +        </xsd:complexContent>
       </xsd:complexType>
   
   </xsd:schema>
  
  
  
  1.3       +109 -10   incubator-geronimo/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java
  
  Index: ContextBuilderTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContextBuilderTest.java	25 Feb 2004 09:57:57 -0000	1.2
  +++ ContextBuilderTest.java	9 Mar 2004 18:03:11 -0000	1.3
  @@ -17,14 +17,25 @@
   
   package org.apache.geronimo.naming.java;
   
  -import java.util.Set;
  -import java.util.HashSet;
  +import java.util.ArrayList;
   import java.util.Arrays;
  -import javax.naming.NamingException;
  -import javax.naming.NamingEnumeration;
  +import java.util.HashSet;
  +import java.util.List;
  +import java.util.Set;
  +
  +import javax.management.ObjectName;
   import javax.naming.NameClassPair;
  +import javax.naming.NamingEnumeration;
  +import javax.naming.NamingException;
   
   import junit.framework.TestCase;
  +import org.apache.geronimo.gbean.GBeanInfo;
  +import org.apache.geronimo.gbean.GBeanInfoFactory;
  +import org.apache.geronimo.gbean.jmx.GBeanMBean;
  +import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.naming.deployment.RefAdapter;
  +import org.apache.geronimo.naming.jmx.JMXReferenceFactory;
  +import org.apache.xmlbeans.XmlObject;
   
   /**
    *
  @@ -34,6 +45,8 @@
   public class ContextBuilderTest extends TestCase {
       private ComponentContextBuilder builder;
   
  +    private List proxy;
  +
       public void testFreeze() {
           ReadOnlyContext context = builder.getContext();
           assertTrue(context.isFrozen());
  @@ -58,8 +71,8 @@
       public void testEnvEntries() throws Exception {
           String stringVal = "Hello World";
           Character charVal = new Character('H');
  -        Byte byteVal = new Byte((byte)12);
  -        Short shortVal = new Short((short)12345);
  +        Byte byteVal = new Byte((byte) 12);
  +        Short shortVal = new Short((short) 12345);
           Integer intVal = new Integer(12345678);
           Long longVal = new Long(1234567890123456L);
           Float floatVal = new Float(123.456);
  @@ -77,11 +90,11 @@
   
           ReadOnlyContext context = builder.getContext();
           Set actual = new HashSet();
  -        for (NamingEnumeration e = context.listBindings("env");e.hasMore();) {
  +        for (NamingEnumeration e = context.listBindings("env"); e.hasMore();) {
               NameClassPair pair = (NameClassPair) e.next();
               actual.add(pair.getName());
           }
  -        Set expected = new HashSet(Arrays.asList(new String[] {"string", "char", "byte", "short", "int", "long", "float", "double", "boolean"}));
  +        Set expected = new HashSet(Arrays.asList(new String[]{"string", "char", "byte", "short", "int", "long", "float", "double", "boolean"}));
           assertEquals(expected, actual);
           assertEquals(stringVal, context.lookup("env/string"));
           assertEquals(charVal, context.lookup("env/char"));
  @@ -94,8 +107,94 @@
           assertEquals(booleanVal, context.lookup("env/boolean"));
       }
   
  +    public void testResourceEnv() throws Exception {
  +        proxy = new ArrayList();
  +        builder.addResourceEnvRef("resourceenvref", List.class, new RefAdapter() {
  +            public XmlObject getXmlObject() {
  +                return null;
  +            }
  +
  +            public void setXmlObject(XmlObject xmlObject) {
  +            }
  +
  +            public String getRefName() {
  +                return "resourceenvref";
  +            }
  +
  +            public void setRefName(String name) {
  +            }
  +
  +            public String getServerName() {
  +                return null;
  +            }
  +
  +            public void setServerName(String serverName) {
  +            }
  +
  +            public String getKernelName() {
  +                return "test.kernel";
  +            }
  +
  +            public void setKernelName(String kernelName) {
  +            }
  +
  +            public String getTargetName() {
  +                return "testAdminObject";
  +            }
  +
  +            public void setTargetName(String targetName) {
  +            }
  +
  +            public String getExternalUri() {
  +                return null;
  +            }
  +
  +            public void setExternalUri(String externalURI) {
  +            }
  +
  +        });
  +        ReadOnlyContext roc = builder.getContext();
  +        Kernel kernel = new Kernel("test.kernel", "test.domain");
  +        kernel.boot();
  +        try {
  +            assertEquals(kernel, Kernel.getKernel("test.kernel"));
  +            ObjectName proxyFactoryName = ObjectName.getInstance(JMXReferenceFactory.BASE_ADMIN_OBJECT_NAME + "testAdminObject");
  +            GBeanMBean gbean = new GBeanMBean(getGbeanInfo());
  +            gbean.setAttribute("Content", proxy);
  +            kernel.loadGBean(proxyFactoryName, gbean);
  +            kernel.startGBean(proxyFactoryName);
  +            Object o = roc.lookup("env/resourceenvref");
  +            assertEquals(proxy, o);
  +        } finally {
  +            kernel.shutdown();
  +        }
  +    }
  +
       protected void setUp() throws Exception {
           super.setUp();
  -        builder = new ComponentContextBuilder();
  +        JMXReferenceFactory referenceFactory = new JMXReferenceFactory();
  +        builder = new ComponentContextBuilder(referenceFactory);
  +    }
  +
  +    public static class TestProxyFactory {
  +
  +        private Object proxy;
  +
  +        public TestProxyFactory(Object proxy) {
  +            this.proxy = proxy;
  +        }
  +
  +        public Object getProxy() {
  +            return proxy;
  +        }
  +
  +    }
  +
  +    public GBeanInfo getGbeanInfo() {
  +        GBeanInfoFactory infoFactory = new GBeanInfoFactory(TestProxyFactory.class);
  +        infoFactory.addAttribute("Content", true);
  +        infoFactory.addOperation("getProxy");
  +        infoFactory.setConstructor(new String[] {"Content"}, new Class[] {Object.class});
  +        return infoFactory.getBeanInfo();
       }
   }
  
  
  

Mime
View raw message