geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 55764 - in geronimo/trunk/modules: assembly/src/plan client-builder/src/java/org/apache/geronimo/client/builder client-builder/src/test/org/apache/geronimo/client/builder connector/src/java/org/apache/geronimo/connector connector/src/java/org/apache/geronimo/connector/deployment connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean connector/src/java/org/apache/geronimo/connector/outbound connector/src/java/org/apache/geronimo/connector/outbound/transactionlog connector/src/schema connector/src/test-data/connector_1_5 connector/src/test-data/data connector/src/test/org/apache/geronimo/connector connector/src/test/org/apache/geronimo/connector/deployment connector/src/test/org/apache/geronimo/connector/outbound derby-connector j2ee-schema/src/java/org/apache/geronimo/schema j2ee-schema/src/test-data/geronimo j2ee/src/java/org/apache/geronimo/j2ee/deployment j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames j2ee/src/test/org/apache/geronimo/j2ee/deployment jetty/src/java/org/apache/geronimo/jetty/deployment jetty/src/test/org/apache/geronimo/jetty/deployment mail/src/java/org/apache/geronimo/mail mail/src/test/org/apache/geronimo/mail naming/src/java/org/apache/geronimo/naming naming/src/java/org/apache/geronimo/naming/deployment naming/src/java/org/apache/geronimo/naming/java naming/src/java/org/apache/geronimo/naming/jmx naming/src/schema naming/src/test/org/apache/geronimo/naming/java timer/src/java/org/apache/geronimo/timer/jdbc
Date Thu, 28 Oct 2004 01:51:14 GMT
Author: djencks
Date: Wed Oct 27 18:51:13 2004
New Revision: 55764

Added:
   geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/AppClientBuilderTest.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java
      - copied, changed from rev 55502, geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBRefContext.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ResourceReferenceBuilder.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/J2eeContext.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/J2eeContextImpl.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/NameFactory.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/GBeanResourceEnvironmentBuilder.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ResourceEnvironmentBuilder.java
Removed:
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBRefContext.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/ReferenceFactory.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXReferenceFactory.java
Modified:
   geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml
   geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml
   geronimo/trunk/modules/assembly/src/plan/system-jms-plan.xml
   geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
   geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ActivationSpecInfo.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/JCAConnectionFactoryImpl.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigBean.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigRoot.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapter_1_0DConfigRoot.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
   geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd
   geronimo/trunk/modules/connector/src/test-data/connector_1_5/geronimo-ra.xml
   geronimo/trunk/modules/connector/src/test-data/data/external-application-plan.xml
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java
   geronimo/trunk/modules/derby-connector/geronimo-derby-connector.iml
   geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
   geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-post.xml
   geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-pre.xml
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EJBRefContextTest.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java
   geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
   geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java
   geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCHelper.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/LocalRefDConfigBean.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/RemoteRefDConfigBean.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java
   geronimo/trunk/modules/naming/src/schema/geronimo-naming.xsd
   geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java
   geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java
Log:
GERONIMO-371, 393, 372. Refactor jsr-77 naming and restructure specification of ref names to parallel jsr-77

Modified: geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml	(original)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml	Wed Oct 27 18:51:13 2004
@@ -92,13 +92,14 @@
         <attribute name="j2eeServer" type="javax.management.ObjectName">geronimo.server:j2eeType=J2EEServer,name=geronimo</attribute>
         <attribute name="transactionContextManagerObjectName" type="javax.management.ObjectName">geronimo.server:type=TransactionContextManager</attribute>
         <attribute name="connectionTrackerObjectName" type="javax.management.ObjectName">geronimo.server:type=ConnectionTracker</attribute>
-        <attribute name="transactionalTimerObjectName" type="javax.management.ObjectName">geronimo.server:type=ThreadPooledTimer,name=JDBCTransactionalThreadPooledTimer</attribute>
-        <attribute name="nonTransactionalTimerObjectName" type="javax.management.ObjectName">geronimo.server:type=ThreadPooledTimer,name=JDBCNonTransactionalThreadPooledTimer</attribute>
+        <attribute name="transactionalTimerObjectName" type="javax.management.ObjectName">geronimo.server:type=ThreadPooledTimer,name=TransactionalThreadPooledTimer</attribute>
+        <attribute name="nonTransactionalTimerObjectName" type="javax.management.ObjectName">geronimo.server:type=ThreadPooledTimer,name=NonTransactionalThreadPooledTimer</attribute>
         <reference name="Repository">*:role=Repository,*</reference>
         <reference name="EJBConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=EJB,config=org/apache/geronimo/J2EEDeployer</reference>
         <reference name="EJBReferenceBuilder">geronimo.deployer:role=ModuleBuilder,type=EJB,config=org/apache/geronimo/J2EEDeployer</reference>
         <reference name="WebConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=Web,config=org/apache/geronimo/J2EEDeployer</reference>
         <reference name="ConnectorConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/J2EEDeployer</reference>
+        <reference name="ResourceReferenceBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/J2EEDeployer</reference>
         <reference name="AppClientConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=AppClient,config=org/apache/geronimo/J2EEDeployer</reference>
     </gbean>
 
@@ -106,14 +107,18 @@
 
     <gbean name="geronimo.deployer:role=ModuleBuilder,type=EJB,config=org/apache/geronimo/J2EEDeployer" class="org.openejb.deployment.OpenEJBModuleBuilder"/>
 
+    <gbean name="geronimo.deployer:role=ClientEJBReferenceBuilder,config=org/apache/geronimo/J2EEDeployer" class="org.openejb.deployment.RemoteEJBReferenceBuilder"/>
+
     <gbean name="geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/J2EEDeployer" class="org.apache.geronimo.connector.deployment.ConnectorModuleBuilder"/>
 
     <gbean name="geronimo.deployer:role=ModuleBuilder,type=AppClient,config=org/apache/geronimo/J2EEDeployer" class="org.apache.geronimo.client.builder.AppClientModuleBuilder">
         <attribute name="transactionContextManagerObjectName" type="javax.management.ObjectName">geronimo.client:type=TransactionContextManager</attribute>
         <attribute name="connectionTrackerObjectName" type="javax.management.ObjectName">geronimo.client:type=ConnectionTracker</attribute>
+        <reference name="EJBReferenceBuilder">geronimo.deployer:role=ClientEJBReferenceBuilder,config=org/apache/geronimo/J2EEDeployer</reference>
         <reference name="ConnectorModuleBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/J2EEDeployer</reference>
+        <reference name="ResourceReferenceBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/J2EEDeployer</reference>
         <reference name="Store">geronimo.deployment:role=ConfigurationStore,type=Local</reference>
         <reference name="Repository">*:role=Repository,*</reference>
     </gbean>
 
-</configuration>
\ No newline at end of file
+</configuration>

Modified: geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml	(original)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-server-plan.xml	Wed Oct 27 18:51:13 2004
@@ -146,7 +146,7 @@
     <gbean name="geronimo.server:type=ConnectionTracker" class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator">
     </gbean>
 
-    <gbean name="geronimo.server:type=WorkManager,name=DefaultWorkManager" class="org.apache.geronimo.connector.work.GeronimoWorkManager">
+    <gbean name="geronimo.server:J2EEServer=geronimo,j2eeType=JCAWorkManager,name=DefaultWorkManager" class="org.apache.geronimo.connector.work.GeronimoWorkManager">
         <attribute name="syncMaximumPoolSize" type="int">10</attribute>
         <attribute name="startMaximumPoolSize" type="int">10</attribute>
         <attribute name="scheduledMaximumPoolSize" type="int">10</attribute>
@@ -252,6 +252,7 @@
         <reference name="EJBReferenceBuilder">geronimo.deployer:role=ModuleBuilder,type=EJB,config=org/apache/geronimo/Server</reference>
         <reference name="WebConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=Web,config=org/apache/geronimo/Server</reference>
         <reference name="ConnectorConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/Server</reference>
+        <reference name="ResourceReferenceBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/Server</reference>
         <reference name="AppClientConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=AppClient,config=org/apache/geronimo/Server</reference>
     </gbean>
 
@@ -259,12 +260,16 @@
 
     <gbean name="geronimo.deployer:role=ModuleBuilder,type=EJB,config=org/apache/geronimo/Server" class="org.openejb.deployment.OpenEJBModuleBuilder"/>
 
+    <gbean name="geronimo.deployer:role=ClientEJBReferenceBuilder,config=org/apache/geronimo/Server" class="org.openejb.deployment.RemoteEJBReferenceBuilder"/>
+
     <gbean name="geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/Server" class="org.apache.geronimo.connector.deployment.ConnectorModuleBuilder"/>
 
     <gbean name="geronimo.deployer:role=ModuleBuilder,type=AppClient,config=org/apache/geronimo/Server" class="org.apache.geronimo.client.builder.AppClientModuleBuilder">
         <attribute name="transactionContextManagerObjectName" type="javax.management.ObjectName">geronimo.client:type=TransactionContextManager</attribute>
         <attribute name="connectionTrackerObjectName" type="javax.management.ObjectName">geronimo.client:type=ConnectionTracker</attribute>
+        <reference name="EJBReferenceBuilder">geronimo.deployer:role=ClientEJBReferenceBuilder,config=org/apache/geronimo/Server</reference>
         <reference name="ConnectorModuleBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/Server</reference>
+        <reference name="ResourceReferenceBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/Server</reference>
         <reference name="Store">*:role=ConfigurationStore,type=Local</reference>
         <reference name="Repository">*:role=Repository,*</reference>
     </gbean>

Modified: geronimo/trunk/modules/assembly/src/plan/system-jms-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/system-jms-plan.xml	(original)
+++ geronimo/trunk/modules/assembly/src/plan/system-jms-plan.xml	Wed Oct 27 18:51:13 2004
@@ -22,52 +22,52 @@
     version="1.5"
     configId="org/apache/geronimo/SystemJMS"
     parentId="org/apache/geronimo/ActiveMQServer">
-  <resourceadapter>
-    <resourceadapter-instance>
-      <resourceadapter-name>ActiveMQ RA</resourceadapter-name>
-      <config-property-setting name="ServerUrl">tcp://localhost:61616</config-property-setting>
-      <config-property-setting name="UserName">geronimo</config-property-setting>
-      <config-property-setting name="Password">geronimo</config-property-setting>
-      <workmanager-name>DefaultWorkManager</workmanager-name>
-    </resourceadapter-instance>
-    <outbound-resourceadapter>
-      <connection-definition>
-        <connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-interface>
-        <connectiondefinition-instance>
-          <name>DefaultActiveMQConnectionFactory</name>
-          <implemented-interface>javax.jms.QueueConnectionFactory</implemented-interface>
-          <implemented-interface>javax.jms.TopicConnectionFactory</implemented-interface>
-          <connectionmanager>
-            <xa-transaction>
-              <transaction-caching/>
-            </xa-transaction>
-            <single-pool>
-              <max-size>10</max-size>
-              <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
-              <match-one/>
-            </single-pool>
-          </connectionmanager>
-          <global-jndi-name>jms/ConnectionFactoryLocalTx</global-jndi-name>
-          <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
-        </connectiondefinition-instance>
-      </connection-definition>
-    </outbound-resourceadapter>
+    <resourceadapter>
+        <resourceadapter-instance>
+            <resourceadapter-name>ActiveMQ RA</resourceadapter-name>
+            <config-property-setting name="ServerUrl">tcp://localhost:61616</config-property-setting>
+            <config-property-setting name="UserName">geronimo</config-property-setting>
+            <config-property-setting name="Password">geronimo</config-property-setting>
+            <workmanager-name>DefaultWorkManager</workmanager-name>
+        </resourceadapter-instance>
+        <outbound-resourceadapter>
+            <connection-definition>
+                <connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-interface>
+                <connectiondefinition-instance>
+                    <name>DefaultActiveMQConnectionFactory</name>
+                    <implemented-interface>javax.jms.QueueConnectionFactory</implemented-interface>
+                    <implemented-interface>javax.jms.TopicConnectionFactory</implemented-interface>
+                    <connectionmanager>
+                        <xa-transaction>
+                            <transaction-caching/>
+                        </xa-transaction>
+                        <single-pool>
+                            <max-size>10</max-size>
+                            <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
+                            <match-one/>
+                        </single-pool>
+                    </connectionmanager>
+                    <global-jndi-name>jms/ConnectionFactoryLocalTx</global-jndi-name>
+                    <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+                </connectiondefinition-instance>
+            </connection-definition>
+        </outbound-resourceadapter>
+    </resourceadapter>
     <adminobject>
-      <adminobject-interface>javax.jms.Queue</adminobject-interface>
-      <adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</adminobject-class>
-      <adminobject-instance>
-        <message-destination-name>MDBTransferBeanOutQueue</message-destination-name>
-        <config-property-setting name="PhysicalName">MDBTransferBeanOutQueue</config-property-setting>
-      </adminobject-instance>
+        <adminobject-interface>javax.jms.Queue</adminobject-interface>
+        <adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</adminobject-class>
+        <adminobject-instance>
+            <message-destination-name>MDBTransferBeanOutQueue</message-destination-name>
+            <config-property-setting name="PhysicalName">MDBTransferBeanOutQueue</config-property-setting>
+        </adminobject-instance>
     </adminobject>
     <adminobject>
-      <adminobject-interface>javax.jms.Queue</adminobject-interface>
-      <adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</adminobject-class>
-      <adminobject-instance>
-        <message-destination-name>SendReceiveQueue</message-destination-name>
-        <config-property-setting name="PhysicalName">SendReceiveQueue</config-property-setting>
-      </adminobject-instance>
+        <adminobject-interface>javax.jms.Queue</adminobject-interface>
+        <adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</adminobject-class>
+        <adminobject-instance>
+            <message-destination-name>SendReceiveQueue</message-destination-name>
+            <config-property-setting name="PhysicalName">SendReceiveQueue</config-property-setting>
+        </adminobject-instance>
     </adminobject>
-  </resourceadapter>
 
 </connector>

Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java	(original)
+++ geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java	Wed Oct 27 18:51:13 2004
@@ -24,18 +24,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
-import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
-import javax.naming.Reference;
 
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.DeploymentException;
@@ -47,10 +42,13 @@
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.j2ee.deployment.AppClientModule;
 import org.apache.geronimo.j2ee.deployment.EARContext;
-import org.apache.geronimo.j2ee.deployment.EJBRefContext;
 import org.apache.geronimo.j2ee.deployment.EJBReferenceBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
+import org.apache.geronimo.j2ee.deployment.RefContext;
+import org.apache.geronimo.j2ee.deployment.ResourceReferenceBuilder;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.J2EEAppClientModuleImpl;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
@@ -64,15 +62,11 @@
 import org.apache.geronimo.xbeans.geronimo.client.GerDependencyType;
 import org.apache.geronimo.xbeans.geronimo.client.GerGbeanType;
 import org.apache.geronimo.xbeans.geronimo.client.GerResourceType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerRemoteRefType;
 import org.apache.geronimo.xbeans.j2ee.ApplicationClientDocument;
 import org.apache.geronimo.xbeans.j2ee.ApplicationClientType;
 import org.apache.geronimo.xbeans.j2ee.EjbLocalRefType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.openejb.client.naming.RemoteEJBObjectFactory;
-import org.openejb.client.naming.RemoteEJBRefAddr;
 
 
 /**
@@ -89,15 +83,26 @@
     private final String clientApplicationName = "client-application";
     private final ObjectName transactionContextManagerObjectName;
     private final ObjectName connectionTrackerObjectName;
+    private final EJBReferenceBuilder ejbReferenceBuilder;
     private final ModuleBuilder connectorModuleBuilder;
+    private final ResourceReferenceBuilder resourceReferenceBuilder;
 
-    public AppClientModuleBuilder(ObjectName transactionContextManagerObjectName, ObjectName connectionTrackerObjectName, ModuleBuilder connectorModuleBuilder, ConfigurationStore store, Repository repository, Kernel kernel) {
+    public AppClientModuleBuilder(ObjectName transactionContextManagerObjectName,
+                                  ObjectName connectionTrackerObjectName,
+                                  EJBReferenceBuilder ejbReferenceBuilder,
+                                  ModuleBuilder connectorModuleBuilder,
+                                  ResourceReferenceBuilder resourceReferenceBuilder,
+                                  ConfigurationStore store,
+                                  Repository repository,
+                                  Kernel kernel) {
         this.kernel = kernel;
         this.repository = repository;
         this.store = store;
         this.transactionContextManagerObjectName = transactionContextManagerObjectName;
         this.connectionTrackerObjectName = connectionTrackerObjectName;
+        this.ejbReferenceBuilder = ejbReferenceBuilder;
         this.connectorModuleBuilder = connectorModuleBuilder;
+        this.resourceReferenceBuilder = resourceReferenceBuilder;
     }
 
     public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
@@ -163,14 +168,13 @@
             // load the geronimo-application-client.xml from either the supplied plan or from the earFile
             try {
                 if (plan instanceof XmlObject) {
-                    gerAppClient = (GerApplicationClientType) SchemaConversionUtils.getNestedObjectAsType(
-                            (XmlObject) plan,
+                    gerAppClient = (GerApplicationClientType) SchemaConversionUtils.getNestedObjectAsType((XmlObject) plan,
                             "application-client",
                             GerApplicationClientType.type);
                 } else {
                     GerApplicationClientDocument gerAppClientDoc = null;
                     if (plan != null) {
-                        gerAppClientDoc = GerApplicationClientDocument.Factory.parse((File)plan);
+                        gerAppClientDoc = GerApplicationClientDocument.Factory.parse((File) plan);
                     } else {
                         URL path = DeploymentUtil.createJarURL(moduleFile, "META-INF/geronimo-application-client.xml");
                         gerAppClientDoc = GerApplicationClientDocument.Factory.parse(path);
@@ -237,7 +241,7 @@
         } catch (IOException e) {
             throw new DeploymentException("Unable to copy app client module jar into configuration: " + moduleFile.getName());
         }
-        ((AppClientModule)module).setEarFile(earFile);
+        ((AppClientModule) module).setEarFile(earFile);
     }
 
     public void initContext(EARContext earContext, Module clientModule, ClassLoader cl) {
@@ -245,6 +249,8 @@
     }
 
     public String addGBeans(EARContext earContext, Module module, ClassLoader earClassLoader) throws DeploymentException {
+        J2eeContext earJ2eeContext = earContext.getJ2eeContext();
+
         AppClientModule appClientModule = (AppClientModule) module;
 
         ApplicationClientType appClient = (ApplicationClientType) appClientModule.getSpecDD();
@@ -272,17 +278,7 @@
         }
 
         // generate the object name for the app client
-        Properties nameProps = new Properties();
-        nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-        nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
-        nameProps.put("j2eeType", "AppClientModule");
-        nameProps.put("name", appClientModule.getName());
-        ObjectName appClientModuleName;
-        try {
-            appClientModuleName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Unable to construct ObjectName", e);
-        }
+        ObjectName appClientModuleName = NameFactory.getModuleName(null, null, null, appClientModule.getName(), NameFactory.APP_CLIENT_MODULE, earJ2eeContext);
 
         // create a gbean for the app client module and add it to the ear
         ReadOnlyContext componentContext;
@@ -310,17 +306,6 @@
 
                 // construct the app client deployment context... this is the same class used by the ear context
                 try {
-                    EJBReferenceBuilder ejbReferenceBuilder = new EJBReferenceBuilder() {
-                        public Reference createEJBLocalReference(String objectName, boolean isSession, String localHome, String local) {
-                            throw new UnsupportedOperationException("Application client cannot have a local ejb ref");
-                        }
-
-                        public Reference createEJBRemoteReference(String objectName, boolean isSession, String home, String remote) {
-                            RemoteEJBRefAddr addr = new RemoteEJBRefAddr(objectName);
-                            Reference reference = new Reference(null, addr, RemoteEJBObjectFactory.class.getName(), null);
-                            return reference;
-                        }
-                    };
 
                     URI clientConfigId = URI.create(geronimoAppClient.getClientConfigId());
                     URI clientParentId;
@@ -341,7 +326,7 @@
                             connectionTrackerObjectName,
                             null,
                             null,
-                            new EJBRefContext(earContext.getEJBRefContext(), ejbReferenceBuilder));
+                            RefContext.derivedClientRefContext(earContext.getRefContext(), ejbReferenceBuilder, resourceReferenceBuilder));
                 } catch (Exception e) {
                     throw new DeploymentException("Could not create a deployment context for the app client", e);
                 }
@@ -477,12 +462,12 @@
             } catch (Exception e) {
                 throw new DeploymentException(e);
             }
-        } catch(Throwable e) {
+        } catch (Throwable e) {
             DeploymentUtil.recursiveDelete(appClientConfiguration);
             if (e instanceof Error) {
-                throw (Error)e;
+                throw (Error) e;
             } else if (e instanceof DeploymentException) {
-                throw (DeploymentException)e;
+                throw (DeploymentException) e;
             } else if (e instanceof Exception) {
                 throw new DeploymentException(e);
             }
@@ -558,44 +543,20 @@
     }
 
     private ReadOnlyContext buildComponentContext(EARContext earContext, AppClientModule appClientModule, ApplicationClientType appClient, GerApplicationClientType geronimoAppClient, ClassLoader cl) throws DeploymentException {
-        Map ejbRefMap = mapRefs(geronimoAppClient.getEjbRefArray());
-        Map resourceRefMap = mapRefs(geronimoAppClient.getResourceRefArray());
-        Map resourceEnvRefMap = mapRefs(geronimoAppClient.getResourceEnvRefArray());
 
         return ENCConfigBuilder.buildComponentContext(earContext,
                 appClientModule.getModuleURI(),
                 null,
                 appClient.getEnvEntryArray(),
-                appClient.getEjbRefArray(), ejbRefMap,
-                new EjbLocalRefType[0], Collections.EMPTY_MAP,
-                appClient.getResourceRefArray(), resourceRefMap,
-                appClient.getResourceEnvRefArray(), resourceEnvRefMap,
+                appClient.getEjbRefArray(), geronimoAppClient.getEjbRefArray(),
+                new EjbLocalRefType[0], null,
+                appClient.getResourceRefArray(), geronimoAppClient.getResourceRefArray(),
+                appClient.getResourceEnvRefArray(), geronimoAppClient.getResourceEnvRefArray(),
                 appClient.getMessageDestinationRefArray(),
                 cl);
 
     }
 
-    private static Map mapRefs(GerRemoteRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerRemoteRefType ref = refs[i];
-                refMap.put(ref.getRefName(), ref);
-            }
-        }
-        return refMap;
-    }
-
-    private static Map mapRefs(GerLocalRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerLocalRefType ref = refs[i];
-                refMap.put(ref.getRefName(), ref);
-            }
-        }
-        return refMap;
-    }
 
     private URI getDependencyURI(GerDependencyType dep) throws DeploymentException {
         URI uri;
@@ -623,7 +584,9 @@
         GBeanInfoFactory infoFactory = new GBeanInfoFactory(AppClientModuleBuilder.class);
         infoFactory.addAttribute("transactionContextManagerObjectName", ObjectName.class, true);
         infoFactory.addAttribute("connectionTrackerObjectName", ObjectName.class, true);
+        infoFactory.addReference("EJBReferenceBuilder", EJBReferenceBuilder.class);
         infoFactory.addReference("ConnectorModuleBuilder", ModuleBuilder.class);
+        infoFactory.addReference("ResourceReferenceBuilder", ResourceReferenceBuilder.class);
         infoFactory.addReference("Store", ConfigurationStore.class);
         infoFactory.addReference("Repository", Repository.class);
 
@@ -631,7 +594,14 @@
 
         infoFactory.addInterface(ModuleBuilder.class);
 
-        infoFactory.setConstructor(new String[] {"transactionContextManagerObjectName", "connectionTrackerObjectName", "ConnectorModuleBuilder", "Store", "Repository", "kernel"});
+        infoFactory.setConstructor(new String[]{"transactionContextManagerObjectName",
+                                                "connectionTrackerObjectName",
+                                                "EJBReferenceBuilder",
+                                                "ConnectorModuleBuilder",
+                                                "ResourceReferenceBuilder",
+                                                "Store",
+                                                "Repository",
+                                                "kernel"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Added: geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/AppClientBuilderTest.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/AppClientBuilderTest.java	Wed Oct 27 18:51:13 2004
@@ -0,0 +1,20 @@
+package org.apache.geronimo.client.builder;
+
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+
+/**
+ */
+public class AppClientBuilderTest extends TestCase {
+
+    public void testAppClientGBean() throws Exception {
+        Kernel kernel = new Kernel("testDomain");
+        kernel.boot();
+        GBeanMBean gbean = new GBeanMBean(AppClientModuleBuilder.class.getName(), AppClientModuleBuilder.class.getClassLoader());
+        kernel.loadGBean(new ObjectName("testDomain:test=test"), gbean);
+
+    }
+}

Modified: geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java
==============================================================================
--- geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java	(original)
+++ geronimo/trunk/modules/client-builder/src/test/org/apache/geronimo/client/builder/PlanParsingTest.java	Wed Oct 27 18:51:13 2004
@@ -3,16 +3,16 @@
 import java.io.File;
 
 import junit.framework.TestCase;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType;
-import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument;
 import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument;
+import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 
 /**
  */
 public class PlanParsingTest extends TestCase {
 
-    private AppClientModuleBuilder builder = new AppClientModuleBuilder(null, null,null, null, null, null);
+    private AppClientModuleBuilder builder = new AppClientModuleBuilder(null, null,null, null, null, null, null, null);
     File basedir = new File(System.getProperty("basedir", "."));
 
     public void testResourceRef() throws Exception {
@@ -28,7 +28,7 @@
         appClient.setClientConfigId("clientConfigId");
         appClient.setConfigId("configId");
         appClient.setParentId("parentId");
-        GerLocalRefType ref = appClient.addNewResourceRef();
+        GerResourceRefType ref = appClient.addNewResourceRef();
         ref.setRefName("ref");
         ref.setTargetName("target");
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ActivationSpecInfo.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ActivationSpecInfo.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ActivationSpecInfo.java	Wed Oct 27 18:51:13 2004
@@ -31,15 +31,15 @@
  * */
 public class ActivationSpecInfo implements Serializable {
 
-    private final Class activationSpecClass;
+    private final String activationSpecClass;
     private final GBeanInfo activationSpecGBeanInfo;
 
-    public ActivationSpecInfo(Class activationSpecClass, GBeanInfo activationSpecGBeanInfo) {
+    public ActivationSpecInfo(String activationSpecClass, GBeanInfo activationSpecGBeanInfo) {
         this.activationSpecClass = activationSpecClass;
         this.activationSpecGBeanInfo = activationSpecGBeanInfo;
     }
 
-    public Class getActivationSpecClass() {
+    public String getActivationSpecClass() {
         return activationSpecClass;
     }
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java	Wed Oct 27 18:51:13 2004
@@ -79,7 +79,7 @@
      * Returns disconnectable proxy for binding in jndi.
      * @return proxy implementing adminObjectInterface.
      */
-    public Object getProxy() {
+    public Object $getResource() {
         return adminObject;
     }
 
@@ -126,7 +126,7 @@
         infoFactory.addAttribute("adminObjectInterface", Class.class, true);
         infoFactory.addAttribute("adminObjectClass", Class.class, true);
 
-        infoFactory.addOperation("getProxy");
+        infoFactory.addOperation("$getResource");
 
         infoFactory.setConstructor(new String[]{
             "adminObjectInterface",

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java	Wed Oct 27 18:51:13 2004
@@ -68,7 +68,7 @@
     private Object readResolve() throws ObjectStreamException {
         Kernel kernel = Kernel.getKernel(kernelName);
         try {
-            return kernel.invoke(targetName, "getMethodInterceptor");
+            return kernel.invoke(targetName, "$getMethodInterceptor");
         } catch (Exception e) {
             throw (InvalidObjectException)new InvalidObjectException("could not get method interceptor from ManagedConnectionFactoryWrapper").initCause(e);
         }

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java	Wed Oct 27 18:51:13 2004
@@ -26,17 +26,17 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Properties;
+import java.util.Set;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import javax.management.AttributeNotFoundException;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
+import javax.naming.Reference;
 
 import org.apache.geronimo.common.propertyeditor.PropertyEditors;
 import org.apache.geronimo.connector.ActivationSpecInfo;
@@ -62,6 +62,12 @@
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
+import org.apache.geronimo.j2ee.deployment.ResourceReferenceBuilder;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.naming.jmx.JMXObjectFactory;
+import org.apache.geronimo.naming.jmx.JMXRefAddr;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType;
 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectType;
@@ -87,16 +93,22 @@
 import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConnectorDocument10;
 import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConnectorType10;
 import org.apache.geronimo.xbeans.j2ee.connector_1_0.ResourceadapterType10;
+import org.apache.geronimo.kernel.Kernel;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
 /**
  * @version $Rev$ $Date$
  */
-public class ConnectorModuleBuilder implements ModuleBuilder {
+public class ConnectorModuleBuilder implements ModuleBuilder, ResourceReferenceBuilder {
     private static final String BASE_REALM_BRIDGE_NAME = "geronimo.security:service=RealmBridge,name=";
     private static final String BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME = "geronimo.security:service=Realm,type=PasswordCredential,name=";
-    private static final String BASE_WORK_MANAGER_NAME = ":type=WorkManager,name=";
+
+    private final Kernel kernel;
+
+    public ConnectorModuleBuilder(Kernel kernel) {
+        this.kernel = kernel;
+    }
 
     public Module createModule(File plan, JarFile moduleFile) throws DeploymentException {
         return createModule(plan, moduleFile, "rar", null, true);
@@ -222,12 +234,64 @@
     }
 
     public void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
-        // connectors do not add anything to the shared context
-        // TODO should the 1.5 ActivationSpecInfos be processed here? YES
+        J2eeContext earJ2eeContext = earContext.getJ2eeContext();
+        J2eeContext moduleJ2eeContext = new J2eeContextImpl(earJ2eeContext.getJ2eeDomainName(), earJ2eeContext.getJ2eeServerName(), earJ2eeContext.getJ2eeApplicationName(), module.getName(), null, null);
+        XmlObject specDD = module.getSpecDD();
+        GerConnectorType geronimoConnector = (GerConnectorType) module.getVendorDD();
+        GerResourceadapterType[] geronimoResourceAdapters = geronimoConnector.getResourceadapterArray();
+        for (int k = 0; k < geronimoResourceAdapters.length; k++) {
+            GerResourceadapterType geronimoResourceAdapter = geronimoResourceAdapters[k];
+            if (specDD instanceof ConnectorType) {
+                ResourceadapterType resourceadapter = ((ConnectorType) specDD).getResourceadapter();
+
+                if (resourceadapter.isSetResourceadapterClass()) {
+                    // set the resource adapter class and activationSpec info map
+                    try {
+                        if (resourceadapter.isSetInboundResourceadapter() && resourceadapter.getInboundResourceadapter().isSetMessageadapter()) {
+                            String resourceAdapterName = geronimoResourceAdapter.getResourceadapterInstance().getResourceadapterName();
+                            ObjectName resourceAdapterObjectName = NameFactory.getResourceComponentName(null, null, null, null, resourceAdapterName, NameFactory.JCA_RESOURCE_ADAPTER, moduleJ2eeContext);
+                            //get the ActivationSpec metadata as GBeanInfos
+                            Map activationSpecInfoMap = getActivationSpecInfoMap(resourceadapter.getInboundResourceadapter().getMessageadapter().getMessagelistenerArray(), cl);
+
+                            String containerId = resourceAdapterObjectName.getCanonicalName();
+                            earContext.getRefContext().addResourceAdapterId(module.getModuleURI(), resourceAdapterName, containerId);
+                            earContext.getRefContext().addActivationSpecInfos(resourceAdapterObjectName, activationSpecInfoMap);
+                        }
+                    } catch (Exception e) {
+                        throw new DeploymentException("Could not set ResourceAdapterClass", e);
+                    }
+                }
+            }
+            if (geronimoResourceAdapter.isSetOutboundResourceadapter()) {
+                GerConnectionDefinitionType[] connectionDefinitions = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray();
+                for (int i = 0; i < connectionDefinitions.length; i++) {
+                    GerConnectionDefinitionType connectionDefinition = connectionDefinitions[i];
+                    GerConnectiondefinitionInstanceType[] connectionDefinitionInstances = connectionDefinition.getConnectiondefinitionInstanceArray();
+                    for (int j = 0; j < connectionDefinitionInstances.length; j++) {
+                        GerConnectiondefinitionInstanceType connectionDefinitionInstance = connectionDefinitionInstances[j];
+                        String containerId = NameFactory.getResourceComponentNameString(null, null, null, null, connectionDefinitionInstance.getName(), NameFactory.JCA_MANAGED_CONNECTION_FACTORY, moduleJ2eeContext);
+                        earContext.getRefContext().addConnectionFactoryId(module.getModuleURI(), connectionDefinitionInstance.getName(), containerId);
+                    }
+                }
+            }
+        }
+        for (int i = 0; i < geronimoConnector.getAdminobjectArray().length; i++) {
+            GerAdminobjectType gerAdminObject = geronimoConnector.getAdminobjectArray()[i];
+            for (int j = 0; j < gerAdminObject.getAdminobjectInstanceArray().length; j++) {
+                GerAdminobjectInstanceType gerAdminObjectInstance = gerAdminObject.getAdminobjectInstanceArray()[j];
+
+                String adminObjectObjectName = NameFactory.getResourceComponentNameString(null, null, null, null, gerAdminObjectInstance.getMessageDestinationName(), NameFactory.JCA_ADMIN_OBJECT, moduleJ2eeContext);
+                earContext.getRefContext().addAdminObjectId(module.getModuleURI(), gerAdminObjectInstance.getMessageDestinationName(), adminObjectObjectName);
+            }
+        }
+
     }
 
     public String addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
-        addResourceAdapterModuleGBean(earContext, module, cl);
+        J2eeContext earJ2eeContext = earContext.getJ2eeContext();
+        J2eeContext moduleJ2eeContext = new J2eeContextImpl(earJ2eeContext.getJ2eeDomainName(), earJ2eeContext.getJ2eeServerName(), earJ2eeContext.getJ2eeApplicationName(), module.getName(), null, null);
+
+        addResourceAdapterModuleGBean(earContext, moduleJ2eeContext, module.getOriginalSpecDD(), cl);
 
         GerConnectorType geronimoConnector = (GerConnectorType) module.getVendorDD();
 
@@ -238,38 +302,27 @@
 
         XmlObject specDD = module.getSpecDD();
         if (specDD instanceof ConnectorType10) {
-            addConnectorGBeans(earContext, (ConnectorType10) specDD, geronimoConnector, cl);
+            addConnectorGBeans(earContext, moduleJ2eeContext, (ConnectorType10) specDD, geronimoConnector, cl);
         } else {
-            addConnectorGBeans(earContext, (ConnectorModule) module, (ConnectorType) specDD, geronimoConnector, cl);
+            addConnectorGBeans(earContext, moduleJ2eeContext, (ConnectorType) specDD, geronimoConnector, cl);
         }
 
         return null;
     }
 
-    private ObjectName addResourceAdapterModuleGBean(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+    private ObjectName addResourceAdapterModuleGBean(EARContext earContext, J2eeContext moduleJ2eeContext, String originalSpecDD, ClassLoader cl) throws DeploymentException {
         // build the objectName
-        Properties nameProps = new Properties();
-        nameProps.put("j2eeType", "ResourceAdapterModule");
-        nameProps.put("name", module.getName());
-        nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-        nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
-
-        ObjectName resourceAdapterModuleName = null;
-        try {
-            resourceAdapterModuleName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Unable to construct ResourceAdapterModule ObjectName", e);
-        }
+        ObjectName resourceAdapterModuleName = NameFactory.getModuleName(null, null, null, null, NameFactory.RESOURCE_ADAPTER_MODULE, moduleJ2eeContext);
 
         // initalize the GBean
         GBeanMBean resourceAdapterModule = new GBeanMBean(ResourceAdapterModuleImpl.GBEAN_INFO, cl);
-        try {
-            resourceAdapterModule.setReferencePatterns("J2EEServer", Collections.singleton(earContext.getServerObjectName()));
-            if (!earContext.getJ2EEApplicationName().equals("null")) {
-                resourceAdapterModule.setReferencePatterns("J2EEApplication", Collections.singleton(earContext.getApplicationObjectName()));
-            }
+        resourceAdapterModule.setReferencePattern(NameFactory.J2EE_SERVER, earContext.getServerObjectName());
+        if (!earContext.getJ2EEApplicationName().equals(NameFactory.NULL)) {
+            resourceAdapterModule.setReferencePattern(NameFactory.J2EE_APPLICATION, earContext.getApplicationObjectName());
+        }
 
-            resourceAdapterModule.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
+        try {
+            resourceAdapterModule.setAttribute("deploymentDescriptor", originalSpecDD);
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize EJBModule GBean", e);
         }
@@ -280,120 +333,112 @@
         return resourceAdapterModuleName;
     }
 
-    private void addConnectorGBeans(EARContext context, ConnectorType10 connector, GerConnectorType geronimoConnector, ClassLoader cl) throws DeploymentException {
+    private void addConnectorGBeans(EARContext earContext, J2eeContext j2eeContext, ConnectorType10 connector, GerConnectorType geronimoConnector, ClassLoader cl) throws DeploymentException {
         ResourceadapterType10 resourceAdapter = connector.getResourceadapter();
-        GerResourceadapterType geronimoResourceAdapter = geronimoConnector.getResourceadapter();
-        for (int i = 0; i < geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; i++) {
-            GerConnectionDefinitionType geronimoConnectionDefinition = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(i);
-            assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition";
-
-            for (int j = 0; j < geronimoConnectionDefinition.getConnectiondefinitionInstanceArray().length; j++) {
-                GerConnectiondefinitionInstanceType connectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j];
-                String managedConnectionFactoryClass = resourceAdapter.getManagedconnectionfactoryClass().getStringValue();
-                String connectionFactoryInterface = resourceAdapter.getConnectionfactoryInterface().getStringValue();
-                String connectionFactoryImplClass = resourceAdapter.getConnectionfactoryImplClass().getStringValue();
-                String connectionInterface = resourceAdapter.getConnectionInterface().getStringValue();
-                String connectionImplClass = resourceAdapter.getConnectionImplClass().getStringValue();
-                ConfigProperty[] configProperties = getConfigProperties(resourceAdapter.getConfigPropertyArray(), connectionfactoryInstance.getConfigPropertySettingArray());
+        GerResourceadapterType[] geronimoResourceAdapters = geronimoConnector.getResourceadapterArray();
+        for (int k = 0; k < geronimoResourceAdapters.length; k++) {
+            GerResourceadapterType geronimoResourceAdapter = geronimoResourceAdapters[k];
+
+            for (int i = 0; i < geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; i++) {
+                GerConnectionDefinitionType geronimoConnectionDefinition = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(i);
+                assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition";
+
+                for (int j = 0; j < geronimoConnectionDefinition.getConnectiondefinitionInstanceArray().length; j++) {
+                    GerConnectiondefinitionInstanceType connectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j];
+                    String managedConnectionFactoryClass = resourceAdapter.getManagedconnectionfactoryClass().getStringValue();
+                    String connectionFactoryInterface = resourceAdapter.getConnectionfactoryInterface().getStringValue();
+                    String connectionFactoryImplClass = resourceAdapter.getConnectionfactoryImplClass().getStringValue();
+                    String connectionInterface = resourceAdapter.getConnectionInterface().getStringValue();
+                    String connectionImplClass = resourceAdapter.getConnectionImplClass().getStringValue();
+                    ConfigProperty[] configProperties = getConfigProperties(resourceAdapter.getConfigPropertyArray(), connectionfactoryInstance.getConfigPropertySettingArray());
 
-                addOutboundGBeans(context, null, connectionfactoryInstance, configProperties, managedConnectionFactoryClass, connectionFactoryInterface, connectionFactoryImplClass, connectionInterface, connectionImplClass, cl);
+                    addOutboundGBeans(earContext, j2eeContext, null, connectionfactoryInstance, configProperties, managedConnectionFactoryClass, connectionFactoryInterface, connectionFactoryImplClass, connectionInterface, connectionImplClass, cl);
+                }
             }
         }
     }
 
-    private void addConnectorGBeans(EARContext earContext, ConnectorModule module, ConnectorType connector, GerConnectorType geronimoConnector, ClassLoader cl) throws DeploymentException {
+    private void addConnectorGBeans(EARContext earContext, J2eeContext moduleJ2eeContext, ConnectorType connector, GerConnectorType geronimoConnector, ClassLoader cl) throws DeploymentException {
         ResourceadapterType resourceadapter = connector.getResourceadapter();
-        GerResourceadapterType geronimoResourceAdapter = geronimoConnector.getResourceadapter();
-
-        //
-        // Resource Adapter
-        //
-
-        ObjectName resourceAdapterObjectName = null;
-        if (resourceadapter.isSetResourceadapterClass()) {
-            String resourceAdapterName = geronimoResourceAdapter.getResourceadapterInstance().getResourceadapterName();
-
-            // Create the resource adapter gbean
-            GBeanInfoFactory resourceAdapterInfoFactory = new GBeanInfoFactory("org.apache.geronimo.connector.ResourceAdapterWrapper", cl);
-            ConfigProperty[] configProperties = getConfigProperties(resourceadapter.getConfigPropertyArray(), geronimoResourceAdapter.getResourceadapterInstance().getConfigPropertySettingArray());
-            GBeanMBean resourceAdapterGBean = setUpDynamicGBean(resourceAdapterInfoFactory, configProperties, cl);
+        GerResourceadapterType[] geronimoResourceAdapters = geronimoConnector.getResourceadapterArray();
+        for (int k = 0; k < geronimoResourceAdapters.length; k++) {
+            GerResourceadapterType geronimoResourceAdapter = geronimoResourceAdapters[k];
+
+            //
+            // Resource Adapter
+            //
+
+            ObjectName resourceAdapterObjectName = null;
+            if (resourceadapter.isSetResourceadapterClass()) {
+                String resourceAdapterName = geronimoResourceAdapter.getResourceadapterInstance().getResourceadapterName();
+
+                // Create the resource adapter gbean
+                GBeanInfoFactory resourceAdapterInfoFactory = new GBeanInfoFactory("org.apache.geronimo.connector.ResourceAdapterWrapper", cl);
+                ConfigProperty[] configProperties = getConfigProperties(resourceadapter.getConfigPropertyArray(), geronimoResourceAdapter.getResourceadapterInstance().getConfigPropertySettingArray());
+                GBeanMBean resourceAdapterGBean = setUpDynamicGBean(resourceAdapterInfoFactory, configProperties, cl);
 
-            // set the resource adapter class and activationSpec info map
-            try {
-                resourceAdapterGBean.setAttribute("resourceAdapterClass", cl.loadClass(resourceadapter.getResourceadapterClass().getStringValue()));
-                if (resourceadapter.isSetInboundResourceadapter() && resourceadapter.getInboundResourceadapter().isSetMessageadapter()) {
-                    //get the ActivationSpec metadata as GBeanInfos
-                    Map activationSpecInfoMap = getActivationSpecInfoMap(resourceadapter.getInboundResourceadapter().getMessageadapter().getMessagelistenerArray(), cl);
-                    resourceAdapterGBean.setAttribute("activationSpecInfoMap", activationSpecInfoMap);
-                    earContext.addResourceAdapter(resourceAdapterName, module.getName(), activationSpecInfoMap);
+                // set the resource adapter class and activationSpec info map
+                try {
+                    resourceAdapterGBean.setAttribute("resourceAdapterClass", cl.loadClass(resourceadapter.getResourceadapterClass().getStringValue()));
+                    if (resourceadapter.isSetInboundResourceadapter() && resourceadapter.getInboundResourceadapter().isSetMessageadapter()) {
+                        //get the ActivationSpec metadata as GBeanInfos
+                        Map activationSpecInfoMap = getActivationSpecInfoMap(resourceadapter.getInboundResourceadapter().getMessageadapter().getMessagelistenerArray(), cl);
+                        resourceAdapterGBean.setAttribute("activationSpecInfoMap", activationSpecInfoMap);
+                    }
+                } catch (Exception e) {
+                    throw new DeploymentException("Could not set ResourceAdapterClass", e);
                 }
-            } catch (Exception e) {
-                throw new DeploymentException("Could not set ResourceAdapterClass", e);
-            }
-
-            // set the work manager name
-            try {
-                resourceAdapterGBean.setReferencePattern("WorkManager",
-                        ObjectName.getInstance(earContext.getJ2EEDomainName() + BASE_WORK_MANAGER_NAME + geronimoResourceAdapter.getResourceadapterInstance().getWorkmanagerName().getStringValue()));
-            } catch (MalformedObjectNameException e) {
-                throw new DeploymentException("Could not create object name for work manager", e);
-            }
-
-            // add it
-            try {
-                Properties nameProps = new Properties();
-                nameProps.put("j2eeType", "ResourceAdapter");
-                nameProps.put("name", resourceAdapterName);
-                nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-                nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
-                nameProps.put("ResourceAdapterModule", module.getName());
-
-                resourceAdapterObjectName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-            } catch (MalformedObjectNameException e) {
-                throw new DeploymentException("Could not construct resource adapter object name", e);
-            }
-            earContext.addGBean(resourceAdapterObjectName, resourceAdapterGBean);
-        }
 
-        //
-        // Outbound Managed Connectopn Factories (think JDBC data source or JMS connection factory)
-        //
+                // set the work manager name
+                ObjectName workManagerName = NameFactory.getComponentName(null, null, geronimoResourceAdapter.getResourceadapterInstance().getWorkmanagerName().trim(), NameFactory.JCA_WORK_MANAGER, moduleJ2eeContext);
+                resourceAdapterGBean.setReferencePattern("WorkManager", workManagerName);
 
-        // first we need a map of the published outbound adaptors by connection factory interface type
-        Map connectionDefinitions = new HashMap();
-        if (resourceadapter.isSetOutboundResourceadapter()) {
-            for (int j = 0; j < resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; j++) {
-                ConnectionDefinitionType connectionDefinition = resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray(j);
-                connectionDefinitions.put(connectionDefinition.getConnectionfactoryInterface().getStringValue(), connectionDefinition);
+                // add it
+                resourceAdapterObjectName = NameFactory.getResourceComponentName(null, null, null, null, resourceAdapterName, NameFactory.JCA_RESOURCE_ADAPTER, moduleJ2eeContext);
+                earContext.addGBean(resourceAdapterObjectName, resourceAdapterGBean);
             }
 
-            // ManagedConnectionFactory setup
-            if (geronimoResourceAdapter.isSetOutboundResourceadapter()) {
-                for (int i = 0; i < geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; i++) {
-                    GerConnectionDefinitionType geronimoConnectionDefinition = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(i);
-                    assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition";
-
-                    String connectionFactoryInterfaceName = geronimoConnectionDefinition.getConnectionfactoryInterface().getStringValue();
-                    ConnectionDefinitionType connectionDefinition = (ConnectionDefinitionType) connectionDefinitions.get(connectionFactoryInterfaceName);
-                    if (connectionDefinition == null) {
-                        throw new DeploymentException("No connection definition for ConnectionFactory class: " + connectionFactoryInterfaceName);
-                    }
+            //
+            // Outbound Managed Connectopn Factories (think JDBC data source or JMS connection factory)
+            //
+
+            // first we need a map of the published outbound adaptors by connection factory interface type
+            Map connectionDefinitions = new HashMap();
+            if (resourceadapter.isSetOutboundResourceadapter()) {
+                for (int j = 0; j < resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; j++) {
+                    ConnectionDefinitionType connectionDefinition = resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray(j);
+                    connectionDefinitions.put(connectionDefinition.getConnectionfactoryInterface().getStringValue(), connectionDefinition);
+                }
 
-                    for (int j = 0; j < geronimoConnectionDefinition.getConnectiondefinitionInstanceArray().length; j++) {
-                        GerConnectiondefinitionInstanceType connectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j];
-                        String managedConnectionFactoryClass = connectionDefinition.getManagedconnectionfactoryClass().getStringValue();
-                        String connectionFactoryInterface = connectionDefinition.getConnectionfactoryInterface().getStringValue();
-                        String connectionFactoryImplClass = connectionDefinition.getConnectionfactoryImplClass().getStringValue();
-                        String connectionInterface = connectionDefinition.getConnectionInterface().getStringValue();
-                        String connectionImplClass = connectionDefinition.getConnectionImplClass().getStringValue();
-                        ConfigProperty[] configProperties = getConfigProperties(connectionDefinition.getConfigPropertyArray(), connectionfactoryInstance.getConfigPropertySettingArray());
+                // ManagedConnectionFactory setup
+                if (geronimoResourceAdapter.isSetOutboundResourceadapter()) {
+                    for (int i = 0; i < geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; i++) {
+                        GerConnectionDefinitionType geronimoConnectionDefinition = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(i);
+                        assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition";
+
+                        String connectionFactoryInterfaceName = geronimoConnectionDefinition.getConnectionfactoryInterface().getStringValue();
+                        ConnectionDefinitionType connectionDefinition = (ConnectionDefinitionType) connectionDefinitions.get(connectionFactoryInterfaceName);
+                        if (connectionDefinition == null) {
+                            throw new DeploymentException("No connection definition for ConnectionFactory class: " + connectionFactoryInterfaceName);
+                        }
+
+                        for (int j = 0; j < geronimoConnectionDefinition.getConnectiondefinitionInstanceArray().length; j++) {
+                            GerConnectiondefinitionInstanceType connectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j];
+                            String managedConnectionFactoryClass = connectionDefinition.getManagedconnectionfactoryClass().getStringValue();
+                            String connectionFactoryInterface = connectionDefinition.getConnectionfactoryInterface().getStringValue();
+                            String connectionFactoryImplClass = connectionDefinition.getConnectionfactoryImplClass().getStringValue();
+                            String connectionInterface = connectionDefinition.getConnectionInterface().getStringValue();
+                            String connectionImplClass = connectionDefinition.getConnectionImplClass().getStringValue();
+                            ConfigProperty[] configProperties = getConfigProperties(connectionDefinition.getConfigPropertyArray(), connectionfactoryInstance.getConfigPropertySettingArray());
 
-                        addOutboundGBeans(earContext, resourceAdapterObjectName, connectionfactoryInstance, configProperties, managedConnectionFactoryClass, connectionFactoryInterface, connectionFactoryImplClass, connectionInterface, connectionImplClass, cl);
+                            addOutboundGBeans(earContext, moduleJ2eeContext, resourceAdapterObjectName, connectionfactoryInstance, configProperties, managedConnectionFactoryClass, connectionFactoryInterface, connectionFactoryImplClass, connectionInterface, connectionImplClass, cl);
+                        }
                     }
                 }
             }
-        }
 
+
+         }
         //
         // admin objects (think message queuse and topics)
         //
@@ -404,61 +449,47 @@
             AdminobjectType adminobject = resourceadapter.getAdminobjectArray()[i];
             adminObjectInterfaceMap.put(adminobject.getAdminobjectInterface().getStringValue(), adminobject);
         }
-
         // add configured admin objects
-        for (int i = 0; i < geronimoResourceAdapter.getAdminobjectArray().length; i++) {
-            GerAdminobjectType gerAdminObject = geronimoResourceAdapter.getAdminobjectArray()[i];
+        for (int i = 0; i < geronimoConnector.getAdminobjectArray().length; i++) {
+             GerAdminobjectType gerAdminObject = geronimoConnector.getAdminobjectArray()[i];
 
-            String adminObjectInterface = gerAdminObject.getAdminobjectInterface().getStringValue();
-            AdminobjectType adminObject = (AdminobjectType) adminObjectInterfaceMap.get(adminObjectInterface);
-            if (adminObject == null) {
-                throw new DeploymentException("No admin object declared for interface: " + adminObjectInterface);
-            }
-
-            for (int j = 0; j < gerAdminObject.getAdminobjectInstanceArray().length; j++) {
-                GerAdminobjectInstanceType gerAdminObjectInstance = gerAdminObject.getAdminobjectInstanceArray()[j];
-
-                // create the adminObjectGBean
-                GBeanInfoFactory adminObjectInfoFactory = new GBeanInfoFactory("org.apache.geronimo.connector.AdminObjectWrapper", cl);
-                ConfigProperty[] configProperties = getConfigProperties(adminObject.getConfigPropertyArray(), gerAdminObjectInstance.getConfigPropertySettingArray());
-                GBeanMBean adminObjectGBean = setUpDynamicGBean(adminObjectInfoFactory, configProperties, cl);
-
-                // set the standard properties
-                try {
-                    adminObjectGBean.setAttribute("adminObjectInterface", cl.loadClass(adminObjectInterface));
-                    adminObjectGBean.setAttribute("adminObjectClass", cl.loadClass(adminObject.getAdminobjectClass().getStringValue()));
-                } catch (Exception e) {
-                    throw new DeploymentException("Could not initialize AdminObject", e);
-                }
-
-                // add it
-                try {
-                    Properties nameProps = new Properties();
-                    nameProps.put("j2eeType", "JCAAdminObject");
-                    nameProps.put("name", gerAdminObjectInstance.getMessageDestinationName());
-                    nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-
-                    ObjectName adminObjectObjectName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-                    earContext.addGBean(adminObjectObjectName, adminObjectGBean);
-                } catch (MalformedObjectNameException e) {
-                    throw new DeploymentException("Could not create object name for admin object", e);
-                }
-            }
-        }
+             String adminObjectInterface = gerAdminObject.getAdminobjectInterface().getStringValue();
+             AdminobjectType adminObject = (AdminobjectType) adminObjectInterfaceMap.get(adminObjectInterface);
+             if (adminObject == null) {
+                 throw new DeploymentException("No admin object declared for interface: " + adminObjectInterface);
+             }
+
+             for (int j = 0; j < gerAdminObject.getAdminobjectInstanceArray().length; j++) {
+                 GerAdminobjectInstanceType gerAdminObjectInstance = gerAdminObject.getAdminobjectInstanceArray()[j];
+
+                 // create the adminObjectGBean
+                 GBeanInfoFactory adminObjectInfoFactory = new GBeanInfoFactory("org.apache.geronimo.connector.AdminObjectWrapper", cl);
+                 ConfigProperty[] configProperties = getConfigProperties(adminObject.getConfigPropertyArray(), gerAdminObjectInstance.getConfigPropertySettingArray());
+                 GBeanMBean adminObjectGBean = setUpDynamicGBean(adminObjectInfoFactory, configProperties, cl);
+
+                 // set the standard properties
+                 try {
+                     adminObjectGBean.setAttribute("adminObjectInterface", cl.loadClass(adminObjectInterface));
+                     adminObjectGBean.setAttribute("adminObjectClass", cl.loadClass(adminObject.getAdminobjectClass().getStringValue()));
+                 } catch (Exception e) {
+                     throw new DeploymentException("Could not initialize AdminObject", e);
+                 }
+
+                 // add it
+                 ObjectName adminObjectObjectName = NameFactory.getResourceComponentName(null, null, null, null, gerAdminObjectInstance.getMessageDestinationName(), NameFactory.JCA_ADMIN_OBJECT, moduleJ2eeContext);
+                 earContext.addGBean(adminObjectObjectName, adminObjectGBean);
+             }
+         }
     }
 
     private Map getActivationSpecInfoMap(MessagelistenerType[] messagelistenerArray, ClassLoader cl) throws DeploymentException {
         Map activationSpecInfos = new HashMap();
         for (int i = 0; i < messagelistenerArray.length; i++) {
             MessagelistenerType messagelistenerType = messagelistenerArray[i];
+            String messageListenerInterface = messagelistenerType.getMessagelistenerType().getStringValue().trim();
             ActivationspecType activationspec = messagelistenerType.getActivationspec();
             String activationSpecClassName = activationspec.getActivationspecClass().getStringValue();
             GBeanInfoFactory infoFactory = new GBeanInfoFactory("org.apache.geronimo.connector.ActivationSpecWrapper", cl);
-//            for (int j = 0; j < activationspec.getRequiredConfigPropertyArray().length; j++) {
-//                RequiredConfigPropertyType requiredConfigPropertyType = activationspec.getRequiredConfigPropertyArray()[j];
-//                String propertyName = requiredConfigPropertyType.getConfigPropertyName().getStringValue();
-//                infoFactory.addAttribute(new DynamicGAttributeInfo(propertyName, true));
-//            }
 
             //add all javabean properties that have both getter and setter.  Ignore the "required" flag from the dd.
             BeanInfo beanInfo;
@@ -487,8 +518,8 @@
             } catch (ClassNotFoundException e) {
                 throw new DeploymentException("Could not load ActivationSpec class", e);
             }
-            ActivationSpecInfo activationSpecInfo = new ActivationSpecInfo(activationSpecClass, gbeanInfo);
-            activationSpecInfos.put(activationSpecClassName, activationSpecInfo);
+            ActivationSpecInfo activationSpecInfo = new ActivationSpecInfo(activationSpecClassName, gbeanInfo);
+            activationSpecInfos.put(messageListenerInterface, activationSpecInfo);
         }
         return activationSpecInfos;
     }
@@ -596,7 +627,7 @@
         gbean.setAttribute(name, value);
     }
 
-    private ObjectName configureConnectionManager(GerConnectiondefinitionInstanceType connectionfactoryInstance, EARContext earContext, ClassLoader cl) throws DeploymentException {
+    private ObjectName configureConnectionManager(EARContext earContext, J2eeContext j2eeContext, GerConnectiondefinitionInstanceType connectionfactoryInstance, ClassLoader cl) throws DeploymentException {
         if (connectionfactoryInstance.getConnectionmanagerRef() != null) {
             //we don't configure anything, just use the supplied gbean
             try {
@@ -661,23 +692,14 @@
         }
 
         // add it
-        try {
-            Properties nameProps = new Properties();
-            nameProps.put("j2eeType", "ConnectionManager");
-            nameProps.put("name", connectionfactoryInstance.getName());
-            nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-
-            ObjectName connectionManagerFactoryObjectName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-            earContext.addGBean(connectionManagerFactoryObjectName, connectionManagerGBean);
-            return connectionManagerFactoryObjectName;
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Could not name ConnectionManager", e);
-        }
+        ObjectName connectionManagerObjectName = NameFactory.getResourceComponentName(null, null, null, null, connectionfactoryInstance.getName(), NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+        earContext.addGBean(connectionManagerObjectName, connectionManagerGBean);
+        return connectionManagerObjectName;
     }
 
-    private void addOutboundGBeans(EARContext earContext, ObjectName resourceAdapterObjectName, GerConnectiondefinitionInstanceType connectionfactoryInstance, ConfigProperty[] configProperties, String managedConnectionFactoryClass, String connectionFactoryInterface, String connectionFactoryImplClass, String connectionInterface, String connectionImplClass, ClassLoader cl) throws DeploymentException {
+    private void addOutboundGBeans(EARContext earContext, J2eeContext j2eeContext, ObjectName resourceAdapterObjectName, GerConnectiondefinitionInstanceType connectiondefinitionInstance, ConfigProperty[] configProperties, String managedConnectionFactoryClass, String connectionFactoryInterface, String connectionFactoryImplClass, String connectionInterface, String connectionImplClass, ClassLoader cl) throws DeploymentException {
         // ConnectionManager
-        ObjectName connectionManagerObjectName = configureConnectionManager(connectionfactoryInstance, earContext, cl);
+        ObjectName connectionManagerObjectName = configureConnectionManager(earContext, j2eeContext, connectiondefinitionInstance, cl);
 
         // ManagedConnectionFactory
         GBeanInfoFactory managedConnectionFactoryInfoFactory = new GBeanInfoFactory("org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper", cl);
@@ -688,20 +710,20 @@
             managedConnectionFactoryGBean.setAttribute("connectionFactoryImplClass", cl.loadClass(connectionFactoryImplClass));
             managedConnectionFactoryGBean.setAttribute("connectionInterface", cl.loadClass(connectionInterface));
             managedConnectionFactoryGBean.setAttribute("connectionImplClass", cl.loadClass(connectionImplClass));
-            managedConnectionFactoryGBean.setAttribute("globalJNDIName", connectionfactoryInstance.getGlobalJndiName());
+            managedConnectionFactoryGBean.setAttribute("globalJNDIName", connectiondefinitionInstance.getGlobalJndiName());
             if (resourceAdapterObjectName != null) {
                 managedConnectionFactoryGBean.setReferencePattern("ResourceAdapterWrapper", resourceAdapterObjectName);
             }
             managedConnectionFactoryGBean.setReferencePattern("ConnectionManagerFactory", connectionManagerObjectName);
-            if (connectionfactoryInstance.getCredentialInterface() != null && "javax.resource.spi.security.PasswordCredential".equals(connectionfactoryInstance.getCredentialInterface().getStringValue())) {
+            if (connectiondefinitionInstance.getCredentialInterface() != null && "javax.resource.spi.security.PasswordCredential".equals(connectiondefinitionInstance.getCredentialInterface().getStringValue())) {
                 GBeanMBean realmGBean = new GBeanMBean(PasswordCredentialRealm.getGBeanInfo(), cl);
-                realmGBean.setAttribute("realmName", BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectionfactoryInstance.getName());
-                ObjectName realmObjectNam = ObjectName.getInstance(BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectionfactoryInstance.getName());
+                realmGBean.setAttribute("realmName", BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectiondefinitionInstance.getName());
+                ObjectName realmObjectNam = ObjectName.getInstance(BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectiondefinitionInstance.getName());
                 earContext.addGBean(realmObjectNam, realmGBean);
                 managedConnectionFactoryGBean.setReferencePattern("ManagedConnectionFactoryListener", realmObjectNam);
             }
             //additional interfaces implemented by connection factory
-            FullyQualifiedClassType[] implementedInterfaceElements = connectionfactoryInstance.getImplementedInterfaceArray();
+            FullyQualifiedClassType[] implementedInterfaceElements = connectiondefinitionInstance.getImplementedInterfaceArray();
             Class[] implementedInterfaces = new Class[implementedInterfaceElements == null ? 0 : implementedInterfaceElements.length];
             for (int i = 0; i < implementedInterfaceElements.length; i++) {
                 FullyQualifiedClassType additionalInterfaceType = implementedInterfaceElements[i];
@@ -713,44 +735,20 @@
             throw new DeploymentException(e);
         }
 
-        ObjectName managedConnectionFactoryObjectName;
-        try {
-            Properties nameProps = new Properties();
-            nameProps.put("j2eeType", "JCAManagedConnectionFactory");
-            nameProps.put("name", connectionfactoryInstance.getName());
-            nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-
-            managedConnectionFactoryObjectName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-            earContext.addGBean(managedConnectionFactoryObjectName, managedConnectionFactoryGBean);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Could not construct ManagedConnectionFactory object name", e);
-        }
+        ObjectName managedConnectionFactoryObjectName = NameFactory.getResourceComponentName(null, null, null, null, connectiondefinitionInstance.getName(), NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+        earContext.addGBean(managedConnectionFactoryObjectName, managedConnectionFactoryGBean);
 
         // ConnectionFactory
         GBeanMBean connectionFactory = new GBeanMBean(JCAConnectionFactoryImpl.GBEAN_INFO, cl);
-        connectionFactory.setReferencePatterns("J2EEServer", Collections.singleton(earContext.getServerObjectName()));
+        connectionFactory.setReferencePattern("J2EEServer", earContext.getServerObjectName());
         try {
             connectionFactory.setAttribute("managedConnectionFactory", managedConnectionFactoryObjectName.getCanonicalName());
         } catch (Exception e) {
             throw new DeploymentException("Could not initialize JCAConnectionFactory", e);
         }
 
-        try {
-            Properties nameProps = new Properties();
-            nameProps.put("j2eeType", "JCAConnectionFactory");
-            nameProps.put("name", connectionfactoryInstance.getName());
-            if (resourceAdapterObjectName == null) {
-                nameProps.put("JCAResource", "null");
-            } else {
-                nameProps.put("JCAResource", resourceAdapterObjectName.getKeyProperty("name"));
-            }
-            nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-
-            ObjectName connectionFactoryObjectName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-            earContext.addGBean(connectionFactoryObjectName, connectionFactory);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Could not construct ConnectionFactory object name", e);
-        }
+        ObjectName connectionFactoryObjectName = NameFactory.getResourceComponentName(null, null, null, null, connectiondefinitionInstance.getName(), NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
+        earContext.addGBean(connectionFactoryObjectName, connectionFactory);
     }
 
     private static URI getDependencyURI(GerDependencyType dependency) throws DeploymentException {
@@ -770,6 +768,37 @@
         }
     }
 
+    //ResourceReferenceBuilder implementation
+    public Reference createResourceRef(String containerId, Class iface) throws DeploymentException {
+        Reference ref = new Reference(null, JMXObjectFactory.class.getName(), null);
+        ref.add(new JMXRefAddr(null, containerId, iface));
+        return ref;
+    }
+
+    public Reference createAdminObjectRef(String containerId, Class iface) throws DeploymentException {
+        Reference ref = new Reference(null, JMXObjectFactory.class.getName(), null);
+        ref.add(new JMXRefAddr(null, containerId, iface));
+        return ref;
+    }
+
+    public ObjectName locateResourceName(ObjectName query) throws DeploymentException {
+        Set names = kernel.listGBeans(query);
+        if (names.size() != 1) {
+            throw new DeploymentException("Unknown or ambiguous resource name query: " + query + " match count: " + names.size());
+        }
+        return (ObjectName) names.iterator().next();
+    }
+
+    public Object locateActivationSpecInfo(ObjectName resourceAdapterName, String messageListenerInterface) throws DeploymentException {
+        Map activationSpecInfos = null;
+        try {
+            activationSpecInfos = (Map) kernel.getAttribute(resourceAdapterName, "activationSpecInfoMap");
+        } catch (Exception e) {
+            throw new DeploymentException("Could not get activation spec infos for resource adapter named: " + resourceAdapterName, e);
+        }
+        return activationSpecInfos.get(messageListenerInterface);
+    }
+
     private final static class ConfigProperty {
         private final String name;
         private final String type;
@@ -804,7 +833,10 @@
 
     static {
         GBeanInfoFactory infoFactory = new GBeanInfoFactory(ConnectorModuleBuilder.class);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addInterface(ModuleBuilder.class);
+        infoFactory.addInterface(ResourceReferenceBuilder.class);
+        infoFactory.setConstructor(new String[] {"kernel"});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/JCAConnectionFactoryImpl.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/JCAConnectionFactoryImpl.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/JCAConnectionFactoryImpl.java	Wed Oct 27 18:51:13 2004
@@ -70,9 +70,9 @@
         if (!keyPropertyList.containsKey("JCAResource")) {
             throw new InvalidObjectNameException("JCAResource object name must contain a JCAResource property", objectName);
         }
-        if (keyPropertyList.size() != 4) {
-            throw new InvalidObjectNameException("JCAConnectionFactory object name can only have j2eeType, name, JCAResource, and J2EEServer properties", objectName);
-        }
+//        if (keyPropertyList.size() != 4) {
+//            throw new InvalidObjectNameException("JCAConnectionFactory object name can only have j2eeType, name, JCAResource, and J2EEServer properties", objectName);
+//        }
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigBean.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigBean.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigBean.java	Wed Oct 27 18:51:13 2004
@@ -54,9 +54,6 @@
         if (getResourceadapterInstance() == null) {
             resourceadapter.addNewResourceadapterInstance();
         }
-        if (getResourceadapterInstance().getWorkmanagerName() == null) {
-            getResourceadapterInstance().addNewWorkmanagerName();
-        }
         ConfigPropertiesHelper.initializeConfigSettings(ddBean, new ConfigPropertiesHelper.ConfigPropertiesSource() {
             public GerConfigPropertySettingType[] getConfigPropertySettingArray() {
                 return getResourceadapterInstance().getConfigPropertySettingArray();
@@ -108,34 +105,34 @@
         }
 
         //admin objects
-        DDBean[] adminObjecDdBeans = ddBean.getChildBean(getXpaths()[2]);
-        GerAdminobjectType[] adminobjectTypes = getResourceadapter().getAdminobjectArray();
-
-        if (adminobjectTypes.length == 0) {
-            //we are new
-            for (int i = 0; i < adminObjecDdBeans.length; i++) {
-                DDBean adminObjectDdBean = adminObjecDdBeans[i];
-                GerAdminobjectType adminobjectType = getResourceadapter().addNewAdminobject();
-                String adminObjectInterface = adminObjectDdBean.getText("adminobject-interface")[0];
-                String adminObjectClass = adminObjectDdBean.getText("adminobject-class")[0];
-                AdminObjectDConfigBean adminObjectDConfigBean = new AdminObjectDConfigBean(adminObjectDdBean, adminobjectType);
-                adminObjectsMap.put(new Key(adminObjectInterface, adminObjectClass), adminObjectDConfigBean);
-            }
-        } else {
-            //we are read in from xml.  Check correct length
-            assert adminObjecDdBeans.length == adminobjectTypes.length;
-            for (int i = 0; i < adminObjecDdBeans.length; i++) {
-                DDBean adminObjectDdBean = adminObjecDdBeans[i];
-                GerAdminobjectType adminobjectType = adminobjectTypes[i];
-                String adminObjectInterface = adminObjectDdBean.getText("adminobject-interface")[0];
-                assert(adminObjectInterface.equals(adminobjectType.getAdminobjectInterface().getStringValue()));
-                String adminObjectClass = adminObjectDdBean.getText("adminobject-class")[0];
-                assert(adminObjectClass.equals(adminobjectType.getAdminobjectClass().getStringValue()));
-                AdminObjectDConfigBean adminObjectDConfigBean = new AdminObjectDConfigBean(adminObjectDdBean, adminobjectType);
-                adminObjectsMap.put(new Key(adminObjectInterface, adminObjectClass), adminObjectDConfigBean);
-
-            }
-        }
+//        DDBean[] adminObjecDdBeans = ddBean.getChildBean(getXpaths()[2]);
+//        GerAdminobjectType[] adminobjectTypes = getResourceadapter().getAdminobjectArray();
+//
+//        if (adminobjectTypes.length == 0) {
+//            //we are new
+//            for (int i = 0; i < adminObjecDdBeans.length; i++) {
+//                DDBean adminObjectDdBean = adminObjecDdBeans[i];
+//                GerAdminobjectType adminobjectType = getResourceadapter().addNewAdminobject();
+//                String adminObjectInterface = adminObjectDdBean.getText("adminobject-interface")[0];
+//                String adminObjectClass = adminObjectDdBean.getText("adminobject-class")[0];
+//                AdminObjectDConfigBean adminObjectDConfigBean = new AdminObjectDConfigBean(adminObjectDdBean, adminobjectType);
+//                adminObjectsMap.put(new Key(adminObjectInterface, adminObjectClass), adminObjectDConfigBean);
+//            }
+//        } else {
+//            //we are read in from xml.  Check correct length
+//            assert adminObjecDdBeans.length == adminobjectTypes.length;
+//            for (int i = 0; i < adminObjecDdBeans.length; i++) {
+//                DDBean adminObjectDdBean = adminObjecDdBeans[i];
+//                GerAdminobjectType adminobjectType = adminobjectTypes[i];
+//                String adminObjectInterface = adminObjectDdBean.getText("adminobject-interface")[0];
+//                assert(adminObjectInterface.equals(adminobjectType.getAdminobjectInterface().getStringValue()));
+//                String adminObjectClass = adminObjectDdBean.getText("adminobject-class")[0];
+//                assert(adminObjectClass.equals(adminobjectType.getAdminobjectClass().getStringValue()));
+//                AdminObjectDConfigBean adminObjectDConfigBean = new AdminObjectDConfigBean(adminObjectDdBean, adminobjectType);
+//                adminObjectsMap.put(new Key(adminObjectInterface, adminObjectClass), adminObjectDConfigBean);
+//
+//            }
+//        }
 
     }
 
@@ -156,11 +153,11 @@
     }
 
     public String getWorkManager() {
-        return getResourceadapterInstance().getWorkmanagerName().getStringValue();
+        return getResourceadapterInstance().getWorkmanagerName();
     }
 
     public void setWorkManager(String workManager) {
-        getResourceadapterInstance().getWorkmanagerName().setStringValue(workManager);
+        getResourceadapterInstance().setWorkmanagerName(workManager);
     }
 
     public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException {

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigRoot.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigRoot.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapterDConfigRoot.java	Wed Oct 27 18:51:13 2004
@@ -84,7 +84,8 @@
         if (!getConnectorDocument().getConnector().getVersion().equals(GerVersionType.X_1_5)) {
             throw new IllegalStateException("Wrong version, expected 1.5");
         }
-        replaceResourceAdapterDConfigBean(getConnectorDocument().getConnector().getResourceadapter());
+        //TODO this is so totally wrong...
+        replaceResourceAdapterDConfigBean(getConnectorDocument().getConnector().getResourceadapterArray()[0]);
     }
 
     protected SchemaTypeLoader getSchemaTypeLoader() {

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapter_1_0DConfigRoot.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapter_1_0DConfigRoot.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ResourceAdapter_1_0DConfigRoot.java	Wed Oct 27 18:51:13 2004
@@ -79,7 +79,8 @@
         if (!getConnectorDocument().getConnector().getVersion().equals(GerVersionType.X_1_0)) {
             throw new IllegalStateException("Wrong version, expected 1.0");
         }
-        replaceConnectionDefinitionDConfigBean(getConnectorDocument().getConnector().getResourceadapter().getOutboundResourceadapter().getConnectionDefinitionArray(0));
+        //TODO this is so totally wrong...
+        replaceConnectionDefinitionDConfigBean(getConnectorDocument().getConnector().getResourceadapterArray()[0].getOutboundResourceadapter().getConnectionDefinitionArray(0));
     }
 
     protected SchemaTypeLoader getSchemaTypeLoader() {

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java	Wed Oct 27 18:51:13 2004
@@ -262,11 +262,11 @@
         return null;
     }
 
-    public Object getProxy() {
+    public Object $getResource() {
         return proxy;
     }
 
-    public Object getMethodInterceptor() {
+    public Object $getMethodInterceptor() {
         return interceptor;
     }
 
@@ -297,8 +297,8 @@
         infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addAttribute("objectName", String.class, false);
 
-        infoFactory.addOperation("getProxy");
-        infoFactory.addOperation("getMethodInterceptor");
+        infoFactory.addOperation("$getResource");
+        infoFactory.addOperation("$getMethodInterceptor");
 
         infoFactory.addInterface(ResourceManager.class);
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java	Wed Oct 27 18:51:13 2004
@@ -69,7 +69,7 @@
     }
 
     public void doStart() throws WaitingException, Exception {
-        dataSource = (DataSource) managedConnectionFactoryWrapper.getProxy();
+        dataSource = (DataSource) managedConnectionFactoryWrapper.$getResource();
     }
 
     public void doStop() throws WaitingException, Exception {

Modified: geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd
==============================================================================
--- geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd	(original)
+++ geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd	Wed Oct 27 18:51:13 2004
@@ -320,9 +320,10 @@
         <xsd:sequence>
             <xsd:element name="dependency" type="ger:dependencyType" minOccurs="0" maxOccurs="unbounded"/>
 
-            <!--TODO make this maxOccurs=unbounded-->
-            <xsd:element name="resourceadapter" type="ger:resourceadapterType"/>
+            <xsd:element name="resourceadapter" type="ger:resourceadapterType" maxOccurs="unbounded"/>
 
+            <xsd:element name="adminobject" type="ger:adminobjectType" minOccurs="0" maxOccurs="unbounded"/>
+            
             <xsd:element name="gbean" type="ger:gbeanType" minOccurs="0" maxOccurs="unbounded"/>
         </xsd:sequence>
 
@@ -416,10 +417,6 @@
                 type="ger:outbound-resourceadapterType"
                 minOccurs="0">
             </xsd:element>
-            <xsd:element name="adminobject"
-                type="ger:adminobjectType"
-                minOccurs="0"
-                maxOccurs="unbounded"/>
         </xsd:sequence>
     </xsd:complexType>
 
@@ -437,7 +434,7 @@
                 minOccurs="0"
                 maxOccurs="unbounded"/>
             <xsd:element name="workmanager-name"
-                type="j2ee:string"/>
+                type="xsd:string"/>
         </xsd:sequence>
     </xsd:complexType>
 

Modified: geronimo/trunk/modules/connector/src/test-data/connector_1_5/geronimo-ra.xml
==============================================================================
--- geronimo/trunk/modules/connector/src/test-data/connector_1_5/geronimo-ra.xml	(original)
+++ geronimo/trunk/modules/connector/src/test-data/connector_1_5/geronimo-ra.xml	Wed Oct 27 18:51:13 2004
@@ -86,25 +86,26 @@
                 </connectiondefinition-instance>
             </connection-definition>
         </outbound-resourceadapter>
-        <adminobject>
-            <adminobject-interface>org.apache.geronimo.connector.mock.MockAdminObject</adminobject-interface>
-            <adminobject-class>org.apache.geronimo.connector.mock.MockAdminObjectImpl</adminobject-class>
-            <adminobject-instance>
-                <message-destination-name>tweedledee</message-destination-name>
-                <config-property-setting name="Tweedle">Dee-value</config-property-setting>
-            </adminobject-instance>
-            <adminobject-instance>
-                <message-destination-name>tweedledum</message-destination-name>
-                <config-property-setting name="Tweedle">Dum-value</config-property-setting>
-            </adminobject-instance>
-        </adminobject>
     </resourceadapter>
 
+    <adminobject>
+        <adminobject-interface>org.apache.geronimo.connector.mock.MockAdminObject</adminobject-interface>
+        <adminobject-class>org.apache.geronimo.connector.mock.MockAdminObjectImpl</adminobject-class>
+        <adminobject-instance>
+            <message-destination-name>tweedledee</message-destination-name>
+            <config-property-setting name="Tweedle">Dee-value</config-property-setting>
+        </adminobject-instance>
+        <adminobject-instance>
+            <message-destination-name>tweedledum</message-destination-name>
+            <config-property-setting name="Tweedle">Dum-value</config-property-setting>
+        </adminobject-instance>
+    </adminobject>
+
     <!--normally this is in the j2ee-server-plan.xml.  It is included here so the gbeans can start in unit tests-->
     <gbean name="geronimo.connector:service=ConnectionTracker" class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator">
     </gbean>
 
-    <gbean name="geronimo.server:type=WorkManager,name=DefaultWorkManager" class="org.apache.geronimo.connector.work.GeronimoWorkManager">
+    <gbean name="test.domain:J2EEServer=testServer,j2eeType=JCAWorkManager,name=DefaultWorkManager" class="org.apache.geronimo.connector.work.GeronimoWorkManager">
         <attribute name="syncMaximumPoolSize" type="int">10</attribute>
         <attribute name="startMaximumPoolSize" type="int">10</attribute>
         <attribute name="scheduledMaximumPoolSize" type="int">10</attribute>

Modified: geronimo/trunk/modules/connector/src/test-data/data/external-application-plan.xml
==============================================================================
--- geronimo/trunk/modules/connector/src/test-data/data/external-application-plan.xml	(original)
+++ geronimo/trunk/modules/connector/src/test-data/data/external-application-plan.xml	Wed Oct 27 18:51:13 2004
@@ -159,20 +159,21 @@
                         </connectiondefinition-instance>
                     </connection-definition>
                 </outbound-resourceadapter>
-                <adminobject>
-                    <adminobject-interface>org.apache.geronimo.connector.mock.MockAdminObject</adminobject-interface>
-                    <adminobject-class>org.apache.geronimo.connector.mock.MockAdminObjectImpl</adminobject-class>
-                    <adminobject-instance>
-                        <message-destination-name>tweedledee</message-destination-name>
-                        <config-property-setting name="Tweedle">Dee-value</config-property-setting>
-                    </adminobject-instance>
-                    <adminobject-instance>
-                        <message-destination-name>tweedledum</message-destination-name>
-                        <config-property-setting name="Tweedle">Dum-value</config-property-setting>
-                    </adminobject-instance>
-                </adminobject>
             </resourceadapter>
 
+            <adminobject>
+                 <adminobject-interface>org.apache.geronimo.connector.mock.MockAdminObject</adminobject-interface>
+                 <adminobject-class>org.apache.geronimo.connector.mock.MockAdminObjectImpl</adminobject-class>
+                 <adminobject-instance>
+                     <message-destination-name>tweedledee</message-destination-name>
+                     <config-property-setting name="Tweedle">Dee-value</config-property-setting>
+                 </adminobject-instance>
+                 <adminobject-instance>
+                     <message-destination-name>tweedledum</message-destination-name>
+                     <config-property-setting name="Tweedle">Dum-value</config-property-setting>
+                 </adminobject-instance>
+             </adminobject>
+             
         </connector>
 
     </module>

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java	Wed Oct 27 18:51:13 2004
@@ -27,12 +27,10 @@
 import org.apache.geronimo.connector.mock.MockAdminObject;
 import org.apache.geronimo.connector.mock.MockAdminObjectImpl;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.naming.java.ComponentContextBuilder;
-import org.apache.geronimo.naming.java.ReadOnlyContext;
-import org.apache.geronimo.naming.jmx.JMXReferenceFactory;
-import org.apache.geronimo.naming.ReferenceFactory;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
 
 /**
  * @version $Rev$ $Date$
@@ -41,11 +39,10 @@
 
     private Kernel kernel;
     private ObjectName selfName;
-    private static final String KERNEL_NAME = "testKernel";
     private static final String TARGET_NAME = "testAOName";
 
     public void testProxy() throws Exception {
-        Object proxy = kernel.invoke(selfName, "getProxy");
+        Object proxy = kernel.invoke(selfName, "$getResource");
         assertNotNull(proxy);
         assertTrue(proxy instanceof MockAdminObject);
         MockAdminObject mockAdminObject = ((MockAdminObject) proxy).getSomething();
@@ -61,7 +58,7 @@
     }
 
     public void testSerialization() throws Exception {
-        MockAdminObject proxy = (MockAdminObject) kernel.invoke(selfName, "getProxy");
+        MockAdminObject proxy = (MockAdminObject) kernel.invoke(selfName, "$getResource");
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
         oos.writeObject(proxy);
@@ -87,26 +84,27 @@
 
     }
 
-
-    public void testLocalLookup() throws Exception {
-        ReferenceFactory referenceFactory = new JMXReferenceFactory("geronimo.server", "geronimo");
-        ComponentContextBuilder builder = new ComponentContextBuilder(referenceFactory);
-        GerLocalRefType localRef = GerLocalRefType.Factory.newInstance();
-        localRef.setRefName("resourceenvref");
-        localRef.setKernelName(KERNEL_NAME);
-        localRef.setTargetName(TARGET_NAME);
-        builder.addResourceEnvRef("resourceenvref", MockAdminObject.class, localRef);
-        ReadOnlyContext roc = builder.getContext();
-        Object o = roc.lookup("env/resourceenvref");
-        assertNotNull(o);
-        assertTrue(o instanceof MockAdminObject);
-    }
+//this should be in ENCConfigBuilder tests.
+//    public void testLocalLookup() throws Exception {
+//        ComponentContextBuilder builder = new ComponentContextBuilder();
+//        ENCConfigBuilder.addResourceEnvRefs(earContext, uri, resEnvRefs, cl, refMap, builder);
+//        GerLocalRefType localRef = GerLocalRefType.Factory.newInstance();
+//        localRef.setRefName("resourceenvref");
+//        localRef.setKernelName(KERNEL_NAME);
+//        localRef.setTargetName(TARGET_NAME);
+//        builder.
+//                addResourceEnvRef("resourceenvref", MockAdminObject.class, localRef);
+//        ReadOnlyContext roc = builder.getContext();
+//        Object o = roc.lookup("env/resourceenvref");
+//        assertNotNull(o);
+//        assertTrue(o instanceof MockAdminObject);
+//    }
 
     protected void setUp() throws Exception {
-        kernel = new Kernel(KERNEL_NAME, "test.domain");
+        J2eeContext j2eeContext = new J2eeContextImpl("test.domain", "geronimo.server", "testapp", "testmodule", TARGET_NAME, NameFactory.JMS_RESOURCE);
+        kernel = new Kernel(j2eeContext.getJ2eeServerName(), j2eeContext.getJ2eeDomainName());
         kernel.boot();
-        JMXReferenceFactory refFactory = new JMXReferenceFactory("geronimo.server", "geronimo");
-        selfName = refFactory.createAdminObjectObjectName(TARGET_NAME);
+        selfName = NameFactory.getResourceComponentName(null, null, null, null, null, null, j2eeContext);
 
         GBeanMBean aow = new GBeanMBean(AdminObjectWrapper.getGBeanInfo());
         aow.setAttribute("adminObjectInterface", MockAdminObject.class);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java	Wed Oct 27 18:51:13 2004
@@ -44,6 +44,10 @@
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
+import org.apache.geronimo.j2ee.deployment.RefContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -64,6 +68,7 @@
     XmlOptions xmlOptions;
     private List errors;
 
+
     public void testLoadJ2eeDeploymentDescriptor() throws Exception {
         InputStream j2eeInputStream = j2eeDD.openStream();
         ConnectorDocument10 connectorDocument = ConnectorDocument10.Factory.parse(j2eeInputStream);
@@ -76,7 +81,7 @@
     public void testLoadGeronimoDeploymentDescriptor() throws Exception {
         InputStream geronimoInputStream = geronimoDD.openStream();
         GerConnectorDocument connectorDocument = GerConnectorDocument.Factory.parse(geronimoInputStream);
-        assertNotNull(connectorDocument.getConnector().getResourceadapter());
+        assertEquals(1, connectorDocument.getConnector().getResourceadapterArray().length);
         if (!connectorDocument.validate(xmlOptions)) {
             fail(errors.toString());
         }
@@ -163,13 +168,15 @@
     }
 
     private void executeTestBuildModule(InstallAction action) throws Exception {
-        String j2eeDomainName = "geronimo.server";
-        String j2eeServerName = "TestGeronimoServer";
-        String j2eeModuleName = "org/apache/geronimo/j2ee/deployment/test";
-        String j2eeApplicationName = "null";
+//        String j2eeDomainName = "geronimo.server";
+//        String j2eeServerName = "TestGeronimoServer";
+//        String j2eeModuleName = "org/apache/geronimo/j2ee/deployment/test";
+//        String j2eeApplicationName = "null";
+        J2eeContext j2eeContext = new J2eeContextImpl("test.domain", "testServer", "null", "org/apache/geronimo/j2ee/deployment/test", null, null);
         ObjectName connectionTrackerName = new ObjectName("geronimo.connector:service=ConnectionTracker");
 
-        ConnectorModuleBuilder moduleBuilder = new ConnectorModuleBuilder();
+        Kernel kernel = new Kernel("testServer");
+        ConnectorModuleBuilder moduleBuilder = new ConnectorModuleBuilder(kernel);
         File rarFile = action.getRARFile();
 
         ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
@@ -178,7 +185,7 @@
         Thread.currentThread().setContextClassLoader(cl);
 
         JarFile rarJarFile = DeploymentUtil.createJarFile(rarFile);
-        Module module = moduleBuilder.createModule(action.getVendorDD(), rarJarFile, j2eeModuleName, action.getSpecDD(), null);
+        Module module = moduleBuilder.createModule(action.getVendorDD(), rarJarFile, j2eeContext.getJ2eeModuleName(), action.getSpecDD(), null);
         if (module == null) {
             throw new DeploymentException("Was not a connector module");
         }
@@ -191,14 +198,14 @@
                     module.getType(),
                     module.getParentId(),
                     null,
-                    j2eeDomainName,
-                    j2eeServerName,
-                    j2eeApplicationName,
+                    j2eeContext.getJ2eeDomainName(),
+                    j2eeContext.getJ2eeServerName(),
+                    j2eeContext.getJ2eeApplicationName(),
                     null,
                     connectionTrackerName,
                     null,
                     null,
-                    null);
+                    new RefContext(null, moduleBuilder));
 
             action.install(moduleBuilder, earContext, module);
             earContext.getClassLoader(null);
@@ -206,7 +213,7 @@
             moduleBuilder.addGBeans(earContext, module, cl);
             earContext.close();
 
-            verifyDeployment(tempDir, oldCl, j2eeDomainName, j2eeServerName, j2eeApplicationName, j2eeModuleName);
+            verifyDeployment(tempDir, j2eeContext, oldCl);
         } finally {
             module.close();
             DeploymentUtil.recursiveDelete(tempDir);
@@ -223,7 +230,7 @@
         JarFile rarFile = null;
         try {
             rarFile = DeploymentUtil.createJarFile(new File(basedir, "target/test-ear-noger.ear"));
-            EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, null, connectionTrackerName, null, null, null, null, null, null, new ConnectorModuleBuilder(), null, kernel);
+            EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, null, connectionTrackerName, null, null, null, null, null, null, new ConnectorModuleBuilder(kernel), null, null, kernel);
             File tempDir = null;
             try {
                 tempDir = DeploymentUtil.createTempDir();
@@ -240,7 +247,7 @@
     }
 
 
-    private void verifyDeployment(File unpackedDir, ClassLoader cl, String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName) throws Exception {
+    private void verifyDeployment(File unpackedDir, J2eeContext j2eeContext, ClassLoader cl) throws Exception {
         DataSource ds = null;
         Kernel kernel = null;
         try {
@@ -251,14 +258,14 @@
 
             GBeanMBean serverInfoGBean = new GBeanMBean(ServerInfo.GBEAN_INFO);
             serverInfoGBean.setAttribute("baseDirectory", ".");
-            ObjectName serverInfoObjectName = ObjectName.getInstance(j2eeDomainName + ":type=ServerInfo");
+            ObjectName serverInfoObjectName = ObjectName.getInstance(j2eeContext.getJ2eeDomainName() + ":type=ServerInfo");
             kernel.loadGBean(serverInfoObjectName, serverInfoGBean);
             kernel.startGBean(serverInfoObjectName);
             assertRunning(kernel, serverInfoObjectName);
 
             GBeanMBean j2eeServerGBean = new GBeanMBean(J2EEServerImpl.GBEAN_INFO);
             j2eeServerGBean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfoObjectName));
-            ObjectName j2eeServerObjectName = ObjectName.getInstance(j2eeDomainName + ":j2eeType=J2EEServer,name=" + j2eeServerName);
+            ObjectName j2eeServerObjectName = NameFactory.getServerName(null, null, j2eeContext);
             kernel.loadGBean(j2eeServerObjectName, j2eeServerGBean);
             kernel.startGBean(j2eeServerObjectName);
             assertRunning(kernel, j2eeServerObjectName);
@@ -272,81 +279,91 @@
             kernel.startRecursiveGBean(objectName);
             assertRunning(kernel, objectName);
 
-            ObjectName applicationObjectName = ObjectName.getInstance(j2eeDomainName + ":j2eeType=J2EEApplication,name=" + j2eeApplicationName + ",J2EEServer=" + j2eeServerName);
-            if (!j2eeApplicationName.equals("null")) {
+            ObjectName applicationObjectName = NameFactory.getApplicationName(null, null, null, j2eeContext);
+            if (!j2eeContext.getJ2eeApplicationName().equals("null")) {
                 assertRunning(kernel, applicationObjectName);
             } else {
                 Set applications = kernel.getMBeanServer().queryNames(applicationObjectName, null);
                 assertTrue("No application object should be registered for a standalone module", applications.isEmpty());
             }
 
-            ObjectName moduleName = ObjectName.getInstance(j2eeDomainName + ":j2eeType=ResourceAdapterModule,J2EEServer=" + j2eeServerName + ",J2EEApplication=" + j2eeApplicationName + ",name=" + j2eeModuleName);
+            ObjectName moduleName = NameFactory.getModuleName(null, null, null, null, NameFactory.RESOURCE_ADAPTER_MODULE, j2eeContext);
+//                    ObjectName.getInstance(j2eeDomainName + ":j2eeType=ResourceAdapterModule,J2EEServer=" + j2eeServerName + ",J2EEApplication=" + j2eeApplicationName + ",name=" + j2eeModuleName);
             assertRunning(kernel, moduleName);
 
             // FirstTestOutboundConnectionFactory
-            ObjectName firstConnectionManagerFactory = new ObjectName(j2eeDomainName +
-                    ":j2eeType=ConnectionManager" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=FirstTestOutboundConnectionFactory");
+            ObjectName firstConnectionManagerFactory = NameFactory.getResourceComponentName(null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+//                    new ObjectName(j2eeDomainName +
+//                    ":j2eeType=ConnectionManager" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstConnectionManagerFactory);
 
 
-            ObjectName firstOutCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",JCAResource=null" +
-                    ",name=FirstTestOutboundConnectionFactory");
+            ObjectName firstOutCF = NameFactory.getResourceComponentName(null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
+//                    new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",JCAResource=null" +
+//                    ",name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstOutCF);
 
             ObjectName firstOutSecurity = new ObjectName("geronimo.security:service=Realm,type=PasswordCredential,name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstOutSecurity);
 
-            ObjectName firstOutMCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAManagedConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=FirstTestOutboundConnectionFactory");
+            ObjectName firstOutMCF = NameFactory.getResourceComponentName(null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+//                    new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAManagedConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstOutMCF);
 
             // SecondTestOutboundConnectionFactory
-            ObjectName secondConnectionManagerFactory = new ObjectName(j2eeDomainName +
-                    ":j2eeType=ConnectionManager" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=SecondTestOutboundConnectionFactory");
+            ObjectName secondConnectionManagerFactory = NameFactory.getResourceComponentName(null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=ConnectionManager" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=SecondTestOutboundConnectionFactory");
             assertRunning(kernel, secondConnectionManagerFactory);
 
 
-            ObjectName secondOutCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",JCAResource=null" +
-                    ",name=SecondTestOutboundConnectionFactory");
+            ObjectName secondOutCF = NameFactory.getResourceComponentName(null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
+//new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",JCAResource=null" +
+//                    ",name=SecondTestOutboundConnectionFactory");
             assertRunning(kernel, secondOutCF);
 
-            ObjectName secondOutMCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAManagedConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=SecondTestOutboundConnectionFactory");
+            ObjectName secondOutMCF = NameFactory.getResourceComponentName(null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+//                    new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAManagedConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=SecondTestOutboundConnectionFactory");
             assertRunning(kernel, secondOutMCF);
 
             // ThirdTestOutboundConnectionFactory
-            ObjectName thirdConnectionManagerFactory = new ObjectName(j2eeDomainName +
-                    ":j2eeType=ConnectionManager" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=ThirdTestOutboundConnectionFactory");
+            ObjectName thirdConnectionManagerFactory = NameFactory.getResourceComponentName(null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+//new ObjectName(j2eeDomainName +
+//                    ":j2eeType=ConnectionManager" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=ThirdTestOutboundConnectionFactory");
             assertRunning(kernel, thirdConnectionManagerFactory);
 
 
-            ObjectName thirdOutCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",JCAResource=null" +
-                    ",name=ThirdTestOutboundConnectionFactory");
+            ObjectName thirdOutCF = NameFactory.getResourceComponentName(null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
+//new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",JCAResource=null" +
+//                    ",name=ThirdTestOutboundConnectionFactory");
             assertRunning(kernel, thirdOutCF);
 
-            ObjectName thirdOutMCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAManagedConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=ThirdTestOutboundConnectionFactory");
+            ObjectName thirdOutMCF = NameFactory.getResourceComponentName(null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+//                    new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAManagedConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=ThirdTestOutboundConnectionFactory");
             assertRunning(kernel, thirdOutMCF);
 
             kernel.stopGBean(objectName);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0DConfigBeanTest.java	Wed Oct 27 18:51:13 2004
@@ -83,7 +83,7 @@
         baos.close();
         InputStream is = new ByteArrayInputStream(bytes);
         GerConnectorDocument gcDoc = GerConnectorDocument.Factory.parse(is);
-        GerResourceadapterType ra = gcDoc.getConnector().getResourceadapter();
+        GerResourceadapterType ra = gcDoc.getConnector().getResourceadapterArray()[0];
 
         //connection definition
         GerConnectionDefinitionType connectionDefinitionType = ra.getOutboundResourceadapter().getConnectionDefinitionArray(0);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java	Wed Oct 27 18:51:13 2004
@@ -42,6 +42,10 @@
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
+import org.apache.geronimo.j2ee.deployment.RefContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -74,7 +78,7 @@
     public void testLoadGeronimoDeploymentDescriptor() throws Exception {
         InputStream geronimoInputStream = geronimoDD.openStream();
         GerConnectorDocument connectorDocument = GerConnectorDocument.Factory.parse(geronimoInputStream);
-        assertNotNull(connectorDocument.getConnector().getResourceadapter());
+        assertEquals(1, connectorDocument.getConnector().getResourceadapterArray().length);
         if (!connectorDocument.validate(xmlOptions)) {
             fail(errors.toString());
         }
@@ -108,14 +112,16 @@
     }
     
     private void executeTestBuildModule(InstallAction action) throws Exception {
-        String j2eeDomainName = "geronimo.server";
-        String j2eeServerName = "TestGeronimoServer";
-        String j2eeApplicationName = "null";
-        String j2eeModuleName = "org/apache/geronimo/j2ee/deployment/test";
+        J2eeContext j2eeContext = new J2eeContextImpl("test.domain", "testServer", "null", "org/apache/geronimo/j2ee/deployment/test", null, null);
+//        String j2eeDomainName = "geronimo.server";
+//        String j2eeServerName = "TestGeronimoServer";
+//        String j2eeApplicationName = "null";
+//        String j2eeModuleName = "org/apache/geronimo/j2ee/deployment/test";
         String resourceAdapterName = "testRA";
         ObjectName connectionTrackerName = new ObjectName("geronimo.connector:service=ConnectionTracker");
 
-        ModuleBuilder moduleBuilder = new ConnectorModuleBuilder();
+        Kernel kernel = new Kernel("testServer");
+        ConnectorModuleBuilder moduleBuilder = new ConnectorModuleBuilder(kernel);
         File rarFile = action.getRARFile();
 
         ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
@@ -124,7 +130,7 @@
         Thread.currentThread().setContextClassLoader(cl);
 
         Module module = moduleBuilder.createModule(null, DeploymentUtil.createJarFile(action.getRARFile()));
-        assertEquals(j2eeModuleName, module.getConfigId().toString());
+        assertEquals(j2eeContext.getJ2eeModuleName(), module.getConfigId().toString());
 
         File tempDir = null;
         try {
@@ -134,14 +140,14 @@
                     module.getType(),
                     module.getParentId(),
                     null,
-                    j2eeDomainName,
-                    j2eeServerName,
-                    j2eeApplicationName,
+                    j2eeContext.getJ2eeDomainName(),
+                    j2eeContext.getJ2eeServerName(),
+                    j2eeContext.getJ2eeApplicationName(),
                     null,
                     connectionTrackerName,
                     null,
                     null,
-                    null);
+                    new RefContext(null, null));
 
             action.install(moduleBuilder, earContext, module);
             earContext.getClassLoader(null);
@@ -149,14 +155,14 @@
             moduleBuilder.addGBeans(earContext, module, cl);
             earContext.close();
 
-            verifyDeployment(tempDir, oldCl, j2eeDomainName, j2eeServerName, j2eeApplicationName, j2eeModuleName, resourceAdapterName);
+            verifyDeployment(tempDir, oldCl, j2eeContext, resourceAdapterName);
         } finally {
             module.close();
             DeploymentUtil.recursiveDelete(tempDir);
         }
     }
 
-    private void verifyDeployment(File unpackedDir, ClassLoader cl, String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String resourceAdapterName) throws Exception {
+    private void verifyDeployment(File unpackedDir, ClassLoader cl, J2eeContext j2eeContext, String resourceAdapterName) throws Exception {
         DataSource ds = null;
         Kernel kernel = null;
         try {
@@ -167,14 +173,15 @@
 
             GBeanMBean serverInfoGBean = new GBeanMBean(ServerInfo.GBEAN_INFO);
             serverInfoGBean.setAttribute("baseDirectory", ".");
-            ObjectName serverInfoObjectName = ObjectName.getInstance(j2eeDomainName + ":type=ServerInfo");
+            ObjectName serverInfoObjectName = ObjectName.getInstance(j2eeContext.getJ2eeDomainName() + ":type=ServerInfo");
             kernel.loadGBean(serverInfoObjectName, serverInfoGBean);
             kernel.startGBean(serverInfoObjectName);
             assertRunning(kernel, serverInfoObjectName);
 
             GBeanMBean j2eeServerGBean = new GBeanMBean(J2EEServerImpl.GBEAN_INFO);
             j2eeServerGBean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfoObjectName));
-            ObjectName j2eeServerObjectName = ObjectName.getInstance(j2eeDomainName + ":j2eeType=J2EEServer,name=" + j2eeServerName);
+            ObjectName j2eeServerObjectName = NameFactory.getServerName(null, null, j2eeContext);
+//                    ObjectName.getInstance(j2eeDomainName + ":j2eeType=J2EEServer,name=" + j2eeServerName);
             kernel.loadGBean(j2eeServerObjectName, j2eeServerGBean);
             kernel.startGBean(j2eeServerObjectName);
             assertRunning(kernel, j2eeServerObjectName);
@@ -187,15 +194,16 @@
             //start configuration to load but not start gbeans.
             kernel.startGBean(objectName);
             //verify that activationSpecInfoMap is accessible and correct while ResourceAdapterGBean is stopped.
-            ObjectName resourceAdapter = new ObjectName(j2eeDomainName +
-                    ":j2eeType=ResourceAdapter" +
-                    ",name=testRA" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",J2EEApplication=" + j2eeApplicationName +
-                    ",ResourceAdapterModule=" + j2eeModuleName);
-            Map activationSpecInfoMap = (Map) kernel.getAttribute(resourceAdapter, "activationSpecInfoMap");
+            ObjectName resourceAdapterObjectName = NameFactory.getResourceComponentName(null, null, null, null, resourceAdapterName, NameFactory.JCA_RESOURCE_ADAPTER, j2eeContext);
+//                    new ObjectName(j2eeDomainName +
+//                    ":j2eeType=ResourceAdapter" +
+//                    ",name=testRA" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",J2EEApplication=" + j2eeApplicationName +
+//                    ",ResourceAdapterModule=" + j2eeModuleName);
+            Map activationSpecInfoMap = (Map) kernel.getAttribute(resourceAdapterObjectName, "activationSpecInfoMap");
             assertEquals(1, activationSpecInfoMap.size());
-            ActivationSpecInfo activationSpecInfo = (ActivationSpecInfo) activationSpecInfoMap.get("org.apache.geronimo.connector.mock.MockActivationSpec");
+            ActivationSpecInfo activationSpecInfo = (ActivationSpecInfo) activationSpecInfoMap.get("javax.jms.MessageListener");
             assertNotNull(activationSpecInfo);
             GBeanInfo activationSpecGBeanInfo = activationSpecInfo.getActivationSpecGBeanInfo();
             List attributes = activationSpecGBeanInfo.getPersistentAttributes();
@@ -208,104 +216,117 @@
             kernel.startRecursiveGBean(objectName);
             assertRunning(kernel, objectName);
 
-            ObjectName applicationObjectName = ObjectName.getInstance(j2eeDomainName + ":j2eeType=J2EEApplication,name=" + j2eeApplicationName + ",J2EEServer=" + j2eeServerName);
-            if (!j2eeApplicationName.equals("null")) {
+            ObjectName applicationObjectName = NameFactory.getApplicationName(null, null, null, j2eeContext);
+//            ObjectName.getInstance(j2eeDomainName + ":j2eeType=J2EEApplication,name=" + j2eeApplicationName + ",J2EEServer=" + j2eeServerName);
+            if (!j2eeContext.getJ2eeApplicationName().equals("null")) {
                 assertRunning(kernel, applicationObjectName);
             } else {
                 Set applications = kernel.getMBeanServer().queryNames(applicationObjectName, null);
                 assertTrue("No application object should be registered for a standalone module", applications.isEmpty());
             }
 
-            ObjectName moduleName = ObjectName.getInstance(j2eeDomainName + ":j2eeType=ResourceAdapterModule,J2EEServer=" + j2eeServerName + ",J2EEApplication=" + j2eeApplicationName + ",name=" + j2eeModuleName);
+            ObjectName moduleName = NameFactory.getModuleName(null, null, null, null, NameFactory.RESOURCE_ADAPTER_MODULE, j2eeContext);
+//            ObjectName.getInstance(j2eeDomainName + ":j2eeType=ResourceAdapterModule,J2EEServer=" + j2eeServerName + ",J2EEApplication=" + j2eeApplicationName + ",name=" + j2eeModuleName);
             assertRunning(kernel, moduleName);
 
             // ResourceAdapter
-            assertRunning(kernel, resourceAdapter);
-            assertAttributeValue(kernel, resourceAdapter, "RAStringProperty", "NewStringValue");
+            assertRunning(kernel, resourceAdapterObjectName);
+            assertAttributeValue(kernel, resourceAdapterObjectName, "RAStringProperty", "NewStringValue");
 
             // FirstTestOutboundConnectionFactory
-            ObjectName firstConnectionManagerFactory = new ObjectName(j2eeDomainName +
-                    ":j2eeType=ConnectionManager" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=FirstTestOutboundConnectionFactory");
+            ObjectName firstConnectionManagerFactory = NameFactory.getResourceComponentName(null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+//                    new ObjectName(j2eeDomainName +
+//                    ":j2eeType=ConnectionManager" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstConnectionManagerFactory);
 
 
-            ObjectName firstOutCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",JCAResource=" + resourceAdapterName +
-                    ",name=FirstTestOutboundConnectionFactory");
+            ObjectName firstOutCF = NameFactory.getResourceComponentName(null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
+//            new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",JCAResource=" + resourceAdapterName +
+//                    ",name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstOutCF);
 
             ObjectName firstOutSecurity = new ObjectName("geronimo.security:service=Realm,type=PasswordCredential,name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstOutSecurity);
 
-            ObjectName firstOutMCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAManagedConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=FirstTestOutboundConnectionFactory");
+            ObjectName firstOutMCF = NameFactory.getResourceComponentName(null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+//            new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAManagedConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=FirstTestOutboundConnectionFactory");
             assertRunning(kernel, firstOutMCF);
             assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty1", "newvalue1");
             assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty2", "originalvalue2");
             assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty3", "newvalue2");
 
             // SecondTestOutboundConnectionFactory
-            ObjectName secondConnectionManagerFactory = new ObjectName(j2eeDomainName +
-                    ":j2eeType=ConnectionManager" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=SecondTestOutboundConnectionFactory");
+            ObjectName secondConnectionManagerFactory = NameFactory.getResourceComponentName(null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+//new ObjectName(j2eeDomainName +
+//                    ":j2eeType=ConnectionManager" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=SecondTestOutboundConnectionFactory");
             assertRunning(kernel, secondConnectionManagerFactory);
 
 
-            ObjectName secondOutCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",JCAResource=" + resourceAdapterName +
-                    ",name=SecondTestOutboundConnectionFactory");
+            ObjectName secondOutCF = NameFactory.getResourceComponentName(null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",JCAResource=" + resourceAdapterName +
+//                    ",name=SecondTestOutboundConnectionFactory");
             assertRunning(kernel, secondOutCF);
 
-            ObjectName secondOutMCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAManagedConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=SecondTestOutboundConnectionFactory");
+            ObjectName secondOutMCF = NameFactory.getResourceComponentName(null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAManagedConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=SecondTestOutboundConnectionFactory");
             assertRunning(kernel, secondOutMCF);
 
             // ThirdTestOutboundConnectionFactory
-            ObjectName thirdConnectionManagerFactory = new ObjectName(j2eeDomainName +
-                    ":j2eeType=ConnectionManager" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=ThirdTestOutboundConnectionFactory");
+            ObjectName thirdConnectionManagerFactory = NameFactory.getResourceComponentName(null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=ConnectionManager" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=ThirdTestOutboundConnectionFactory");
             assertRunning(kernel, thirdConnectionManagerFactory);
 
 
-            ObjectName thirdOutCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",JCAResource=" + resourceAdapterName +
-                    ",name=ThirdTestOutboundConnectionFactory");
+            ObjectName thirdOutCF = NameFactory.getResourceComponentName(null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",JCAResource=" + resourceAdapterName +
+//                    ",name=ThirdTestOutboundConnectionFactory");
             assertRunning(kernel, thirdOutCF);
 
-            ObjectName thirdOutMCF = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAManagedConnectionFactory" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=ThirdTestOutboundConnectionFactory");
+            ObjectName thirdOutMCF = NameFactory.getResourceComponentName(null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAManagedConnectionFactory" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=ThirdTestOutboundConnectionFactory");
             assertRunning(kernel, thirdOutMCF);
 
             //
             //  Admin objects
             //
 
-            ObjectName tweedledeeAdminObject = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAAdminObject" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=tweedledee");
+            ObjectName tweedledeeAdminObject = NameFactory.getResourceComponentName(null, null, null, null, "tweedledee", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAAdminObject" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=tweedledee");
             assertRunning(kernel, tweedledeeAdminObject);
 
-            ObjectName tweedledumAdminObject = new ObjectName(j2eeDomainName +
-                    ":j2eeType=JCAAdminObject" +
-                    ",J2EEServer=" + j2eeServerName +
-                    ",name=tweedledum");
+            ObjectName tweedledumAdminObject = NameFactory.getResourceComponentName(null, null, null, null, "tweedledum", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
+// new ObjectName(j2eeDomainName +
+//                    ":j2eeType=JCAAdminObject" +
+//                    ",J2EEServer=" + j2eeServerName +
+//                    ",name=tweedledum");
             assertRunning(kernel, tweedledumAdminObject);
 
 

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5DConfigBeanTest.java	Wed Oct 27 18:51:13 2004
@@ -81,21 +81,21 @@
         assertEquals("StringValue", resourceAdapterSetting.getConfigPropertyValue());
         resourceAdapterSetting.setConfigPropertyValue("TestRAValue");
 
-        //admin objects
-        DDBean[] adminObjectdds = resourceAdapterdd.getChildBean(resourceAdapterDConfigBean.getXpaths()[2]);
-        assertEquals(1, adminObjectdds.length);
-        AdminObjectDConfigBean adminObjectDConfigBean = (AdminObjectDConfigBean)resourceAdapterDConfigBean.getDConfigBean(adminObjectdds[0]);
-        assertNotNull(adminObjectDConfigBean);
-        AdminObjectInstance adminObjectInstance1 = new AdminObjectInstance();
-        adminObjectDConfigBean.setAdminObjectInstance(new AdminObjectInstance[] {adminObjectInstance1});
-        ConfigPropertySettings adminObjectSetting1 = adminObjectInstance1.getConfigProperty()[0];
-        adminObjectSetting1.setConfigPropertyValue("TestAOValue1");
-
-        //add a second admin object in first position
-        AdminObjectInstance adminObjectInstance2 = new AdminObjectInstance();
-        adminObjectDConfigBean.setAdminObjectInstance(new AdminObjectInstance[] {adminObjectInstance2, adminObjectInstance1});
-        ConfigPropertySettings adminObjectSetting2 = adminObjectInstance2.getConfigProperty()[0];
-        adminObjectSetting2.setConfigPropertyValue("TestAOValue2");
+//        //admin objects
+//        DDBean[] adminObjectdds = resourceAdapterdd.getChildBean(resourceAdapterDConfigBean.getXpaths()[2]);
+//        assertEquals(1, adminObjectdds.length);
+//        AdminObjectDConfigBean adminObjectDConfigBean = (AdminObjectDConfigBean)resourceAdapterDConfigBean.getDConfigBean(adminObjectdds[0]);
+//        assertNotNull(adminObjectDConfigBean);
+//        AdminObjectInstance adminObjectInstance1 = new AdminObjectInstance();
+//        adminObjectDConfigBean.setAdminObjectInstance(new AdminObjectInstance[] {adminObjectInstance1});
+//        ConfigPropertySettings adminObjectSetting1 = adminObjectInstance1.getConfigProperty()[0];
+//        adminObjectSetting1.setConfigPropertyValue("TestAOValue1");
+//
+//        //add a second admin object in first position
+//        AdminObjectInstance adminObjectInstance2 = new AdminObjectInstance();
+//        adminObjectDConfigBean.setAdminObjectInstance(new AdminObjectInstance[] {adminObjectInstance2, adminObjectInstance1});
+//        ConfigPropertySettings adminObjectSetting2 = adminObjectInstance2.getConfigProperty()[0];
+//        adminObjectSetting2.setConfigPropertyValue("TestAOValue2");
 
         //outbound
         DDBean[] connectionDefinitiondds = resourceAdapterdd.getChildBean(resourceAdapterDConfigBean.getXpaths()[1]);
@@ -119,18 +119,18 @@
         baos.close();
         InputStream is = new ByteArrayInputStream(bytes);
         GerConnectorDocument gcDoc = GerConnectorDocument.Factory.parse(is);
-        GerResourceadapterType ra = gcDoc.getConnector().getResourceadapter();
+        GerResourceadapterType ra = gcDoc.getConnector().getResourceadapterArray()[0];
         GerResourceadapterInstanceType rai = ra.getResourceadapterInstance();
         assertEquals("TestRAName", rai.getResourceadapterName());
         GerConfigPropertySettingType rasetting = rai.getConfigPropertySettingArray(0);
         assertEquals("TestRAValue", rasetting.getStringValue());
 
         //admin object
-        GerAdminobjectType adminobjectType1 = ra.getAdminobjectArray(0);
-        GerAdminobjectInstanceType adminobjectInstanceType2 = adminobjectType1.getAdminobjectInstanceArray(0);
-        assertEquals("TestAOValue1", adminobjectInstanceType2.getConfigPropertySettingArray(0).getStringValue());
-        GerAdminobjectInstanceType adminobjectInstanceType1 = adminobjectType1.getAdminobjectInstanceArray(1);
-        assertEquals("TestAOValue2", adminobjectInstanceType1.getConfigPropertySettingArray(0).getStringValue());
+//        GerAdminobjectType adminobjectType1 = ra.getAdminobjectArray(0);
+//        GerAdminobjectInstanceType adminobjectInstanceType2 = adminobjectType1.getAdminobjectInstanceArray(0);
+//        assertEquals("TestAOValue1", adminobjectInstanceType2.getConfigPropertySettingArray(0).getStringValue());
+//        GerAdminobjectInstanceType adminobjectInstanceType1 = adminobjectType1.getAdminobjectInstanceArray(1);
+//        assertEquals("TestAOValue2", adminobjectInstanceType1.getConfigPropertySettingArray(0).getStringValue());
 
         //connection definition
         GerConnectionDefinitionType connectionDefinitionType = ra.getOutboundResourceadapter().getConnectionDefinitionArray(0);
@@ -150,17 +150,17 @@
         assertNotNull(resourceAdapterSetting);
         assertEquals("TestRAValue", resourceAdapterSetting.getConfigPropertyValue());
 
-        //admin objects
-        adminObjectDConfigBean = (AdminObjectDConfigBean)resourceAdapterDConfigBean.getDConfigBean(adminObjectdds[0]);
-        assertNotNull(adminObjectDConfigBean);
-        AdminObjectInstance[] adminObjectInstances = adminObjectDConfigBean.getAdminObjectInstance();
-        assertEquals(2, adminObjectInstances.length);
-        adminObjectSetting1 = adminObjectInstances[1].getConfigProperty()[0];
-        assertEquals("TestAOValue2", adminObjectSetting1.getConfigPropertyValue());
-
-        //second admin object is in first position ..not any longer:-(((
-        adminObjectSetting2 = adminObjectInstances[0].getConfigProperty()[0];
-        assertEquals("TestAOValue1", adminObjectSetting2.getConfigPropertyValue());
+//        //admin objects
+//        adminObjectDConfigBean = (AdminObjectDConfigBean)resourceAdapterDConfigBean.getDConfigBean(adminObjectdds[0]);
+//        assertNotNull(adminObjectDConfigBean);
+//        AdminObjectInstance[] adminObjectInstances = adminObjectDConfigBean.getAdminObjectInstance();
+//        assertEquals(2, adminObjectInstances.length);
+//        adminObjectSetting1 = adminObjectInstances[1].getConfigProperty()[0];
+//        assertEquals("TestAOValue2", adminObjectSetting1.getConfigPropertyValue());
+//
+//        //second admin object is in first position ..not any longer:-(((
+//        adminObjectSetting2 = adminObjectInstances[0].getConfigProperty()[0];
+//        assertEquals("TestAOValue1", adminObjectSetting2.getConfigPropertyValue());
 
         //outbound
         connectionDefinitionDConfigBean = (ConnectionDefinitionDConfigBean)resourceAdapterDConfigBean.getDConfigBean(connectionDefinitiondds[0]);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java	(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java	Wed Oct 27 18:51:13 2004
@@ -32,22 +32,20 @@
 import javax.resource.cci.ConnectionFactory;
 
 import junit.framework.TestCase;
+import org.apache.geronimo.connector.mock.ConnectionFactoryExtension;
 import org.apache.geronimo.connector.mock.MockConnection;
 import org.apache.geronimo.connector.mock.MockConnectionFactory;
 import org.apache.geronimo.connector.mock.MockManagedConnectionFactory;
-import org.apache.geronimo.connector.mock.ConnectionFactoryExtension;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.naming.ReferenceFactory;
-import org.apache.geronimo.naming.java.ComponentContextBuilder;
-import org.apache.geronimo.naming.java.ReadOnlyContext;
-import org.apache.geronimo.naming.jmx.JMXReferenceFactory;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
 
 /**
  * @version $Rev$ $Date$
@@ -63,7 +61,7 @@
     private static final String TARGET_NAME = "testCFName";
 
     public void testProxy() throws Exception {
-        Object proxy = kernel.invoke(managedConnectionFactoryName, "getProxy");
+        Object proxy = kernel.invoke(managedConnectionFactoryName, "$getResource");
         assertNotNull(proxy);
         assertTrue(proxy instanceof ConnectionFactory);
         Connection connection = ((ConnectionFactory) proxy).getConnection();
@@ -83,7 +81,7 @@
     }
 
     public void testSerialization() throws Exception {
-        ConnectionFactory proxy = (ConnectionFactory) kernel.invoke(managedConnectionFactoryName, "getProxy");
+        ConnectionFactory proxy = (ConnectionFactory) kernel.invoke(managedConnectionFactoryName, "$getResource");
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
         oos.writeObject(proxy);
@@ -129,19 +127,19 @@
         assertNotNull(cf2);
     }
 
-    public void testLocalLookup() throws Exception {
-        ReferenceFactory referenceFactory = new JMXReferenceFactory("geronimo.server", "geronimo");
-        ComponentContextBuilder builder = new ComponentContextBuilder(referenceFactory);
-        GerLocalRefType localRef = GerLocalRefType.Factory.newInstance();
-        localRef.setRefName("resourceref");
-        localRef.setKernelName(KERNEL_NAME);
-        localRef.setTargetName(TARGET_NAME);
-        builder.addResourceRef("resourceref", ConnectionFactory.class, localRef);
-        ReadOnlyContext roc = builder.getContext();
-        Object o = roc.lookup("env/resourceref");
-        assertNotNull(o);
-        assertTrue(o instanceof ConnectionFactory);
-    }
+//    public void testLocalLookup() throws Exception {
+//        ReferenceFactory referenceFactory = new JMXReferenceFactory("geronimo.server", "geronimo");
+//        ComponentContextBuilder builder = new ComponentContextBuilder();
+//        GerLocalRefType localRef = GerLocalRefType.Factory.newInstance();
+//        localRef.setRefName("resourceref");
+//        localRef.setKernelName(KERNEL_NAME);
+//        localRef.setTargetName(TARGET_NAME);
+////        builder.addResourceRef("resourceref", ConnectionFactory.class, localRef);
+//        ReadOnlyContext roc = builder.getContext();
+//        Object o = roc.lookup("env/resourceref");
+//        assertNotNull(o);
+//        assertTrue(o instanceof ConnectionFactory);
+//    }
 
     protected void setUp() throws Exception {
         kernel = new Kernel(KERNEL_NAME, "test.domain");
@@ -157,8 +155,8 @@
         cmfName = ObjectName.getInstance("test:role=ConnectionManagerFactory");
         kernel.loadGBean(cmfName, cmf);
 
-        JMXReferenceFactory refFactory = new JMXReferenceFactory("geronimo.server", "geronimo");
-        managedConnectionFactoryName = refFactory.createManagedConnectionFactoryObjectName(TARGET_NAME);
+        J2eeContext j2eeContext = new J2eeContextImpl("test.domain", "geronimo", "testapplication", "testmodule", TARGET_NAME, NameFactory.JCA_MANAGED_CONNECTION_FACTORY);
+        managedConnectionFactoryName = NameFactory.getResourceComponentName(null, null, null, null, null, null, j2eeContext);
 
         GBeanMBean mcfw = new GBeanMBean(ManagedConnectionFactoryWrapper.getGBeanInfo());
         mcfw.setAttribute("managedConnectionFactoryClass", MockManagedConnectionFactory.class);

Modified: geronimo/trunk/modules/derby-connector/geronimo-derby-connector.iml
==============================================================================
--- geronimo/trunk/modules/derby-connector/geronimo-derby-connector.iml	(original)
+++ geronimo/trunk/modules/derby-connector/geronimo-derby-connector.iml	Wed Oct 27 18:51:13 2004
@@ -7,7 +7,7 @@
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
     </content>
-    <orderEntry type="jdk" jdkName="java version &quot;1.4.2_03&quot;" />
+    <orderEntry type="jdk" jdkName="java version &quot;1.4.2_05&quot;" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module-library">
       <library name="derby">

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java	(original)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java	Wed Oct 27 18:51:13 2004
@@ -237,7 +237,9 @@
                     if (localName.equals("ejb-ref")
                             || localName.equals("ejb-local-ref")
                             || localName.equals("resource-ref")
-                            || localName.equals("resource-env-ref")) {
+                            || localName.equals("resource-env-ref")
+                            || localName.equals("cmp-connection-factory")
+                            || localName.equals("resource-adapter")) {
                         convertElementToSchema(cursor, end, GERONIMO_NAMING_NAMESPACE);
                     }
                 }

Modified: geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-post.xml
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-post.xml	(original)
+++ geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-post.xml	Wed Oct 27 18:51:13 2004
@@ -4,7 +4,11 @@
   <dependency>
     <uri>junit/jars/junit-3.8.jar</uri>
   </dependency>
-  <cmp-connection-factory>DefaultDatasource</cmp-connection-factory>
+    <nam:cmp-connection-factory>
+        <nam:application>null</nam:application>
+        <nam:module>org/apache/geronimo/DefaultDatabase</nam:module>
+        <nam:name>DefaultDatasource</nam:name>
+    </nam:cmp-connection-factory>
   <enterprise-beans>
     <!--
         ########################################################

Modified: geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-pre.xml
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-pre.xml	(original)
+++ geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/ejb-naming-pre.xml	Wed Oct 27 18:51:13 2004
@@ -9,7 +9,11 @@
         <uri>junit/jars/junit-3.8.jar</uri>
     </dependency>
 
-    <cmp-connection-factory>DefaultDatasource</cmp-connection-factory>
+    <cmp-connection-factory>
+        <application>null</application>
+        <module>org/apache/geronimo/DefaultDatabase</module>
+        <name>DefaultDatasource</name>
+    </cmp-connection-factory>
 
     <enterprise-beans>
         <!--

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java	Wed Oct 27 18:51:13 2004
@@ -75,6 +75,7 @@
     private final ModuleBuilder connectorConfigBuilder;
     private final ModuleBuilder appClientConfigBuilder;
     private final EJBReferenceBuilder ejbReferenceBuilder;
+    private final ResourceReferenceBuilder resourceReferenceBuilder;
     private final String j2eeServerName;
     private final String j2eeDomainName;
     private final ObjectName j2eeServer;
@@ -84,7 +85,7 @@
     private final ObjectName nonTransactionalTimerObjectName;
 
 
-    public EARConfigBuilder(ObjectName j2eeServer, ObjectName transactionContextManagerObjectName, ObjectName connectionTrackerObjectName, ObjectName transactionalTimerObjectName, ObjectName nonTransactionalTimerObjectName, Repository repository, ModuleBuilder ejbConfigBuilder, EJBReferenceBuilder ejbReferenceBuilder, ModuleBuilder webConfigBuilder, ModuleBuilder connectorConfigBuilder, ModuleBuilder appClientConfigBuilder, Kernel kernel) {
+    public EARConfigBuilder(ObjectName j2eeServer, ObjectName transactionContextManagerObjectName, ObjectName connectionTrackerObjectName, ObjectName transactionalTimerObjectName, ObjectName nonTransactionalTimerObjectName, Repository repository, ModuleBuilder ejbConfigBuilder, EJBReferenceBuilder ejbReferenceBuilder, ModuleBuilder webConfigBuilder, ModuleBuilder connectorConfigBuilder, ResourceReferenceBuilder resourceReferenceBuilder, ModuleBuilder appClientConfigBuilder, Kernel kernel) {
         this.kernel = kernel;
         this.repository = repository;
         this.j2eeServer = j2eeServer;
@@ -93,6 +94,7 @@
 
         this.ejbConfigBuilder = ejbConfigBuilder;
         this.ejbReferenceBuilder = ejbReferenceBuilder;
+        this.resourceReferenceBuilder = resourceReferenceBuilder;
         this.webConfigBuilder = webConfigBuilder;
         this.connectorConfigBuilder = connectorConfigBuilder;
         this.appClientConfigBuilder = appClientConfigBuilder;
@@ -275,7 +277,7 @@
                         connectionTrackerObjectName,
                         transactionalTimerObjectName,
                         nonTransactionalTimerObjectName,
-                        new EJBRefContext(ejbReferenceBuilder));
+                        new RefContext(ejbReferenceBuilder, resourceReferenceBuilder));
             } catch (MalformedObjectNameException e) {
                 throw new DeploymentException(e);
             }
@@ -544,6 +546,7 @@
         infoFactory.addReference("EJBReferenceBuilder", EJBReferenceBuilder.class);
         infoFactory.addReference("WebConfigBuilder", ModuleBuilder.class);
         infoFactory.addReference("ConnectorConfigBuilder", ModuleBuilder.class);
+        infoFactory.addReference("ResourceReferenceBuilder", ResourceReferenceBuilder.class);
         infoFactory.addReference("AppClientConfigBuilder", ModuleBuilder.class);
 
         infoFactory.addAttribute("kernel", Kernel.class, false);
@@ -561,6 +564,7 @@
             "EJBReferenceBuilder",
             "WebConfigBuilder",
             "ConnectorConfigBuilder",
+            "ResourceReferenceBuilder",
             "AppClientConfigBuilder",
             "kernel"
         });

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java	Wed Oct 27 18:51:13 2004
@@ -18,14 +18,14 @@
 
 import java.io.File;
 import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.DeploymentException;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 
@@ -33,11 +33,6 @@
  * @version $Rev$ $Date$
  */
 public class EARContext extends DeploymentContext {
-    private final Map resourceAdapterModules = new HashMap();
-    private final Map activationSpecInfos = new HashMap();
-    private final String j2eeDomainName;
-    private final String j2eeServerName;
-    private final String j2eeApplicationName;
     private final ObjectName domainObjectName;
     private final ObjectName serverObjectName;
     private final ObjectName applicationObjectName;
@@ -48,66 +43,38 @@
     private final ObjectName transactedTimerName;
     private final ObjectName nonTransactedTimerName;
 
-    private final EJBRefContext ejbRefContext;
+    private final RefContext refContext;
+    private final J2eeContext j2eeContext;
 
-    public EARContext(File baseDir, URI id, ConfigurationModuleType moduleType, URI parentID, Kernel kernel, String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, ObjectName transactionContextManagerObjectName, ObjectName connectionTrackerObjectName, ObjectName transactedTimerName, ObjectName nonTransactedTimerName, EJBRefContext ejbRefContext) throws MalformedObjectNameException, DeploymentException {
+    public EARContext(File baseDir, URI id, ConfigurationModuleType moduleType, URI parentID, Kernel kernel, String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, ObjectName transactionContextManagerObjectName, ObjectName connectionTrackerObjectName, ObjectName transactedTimerName, ObjectName nonTransactedTimerName, RefContext refContext) throws MalformedObjectNameException, DeploymentException {
         super(baseDir, id, moduleType, parentID, kernel);
-        this.j2eeDomainName = j2eeDomainName;
-        this.j2eeServerName = j2eeServerName;
+        j2eeContext = new J2eeContextImpl(j2eeDomainName, j2eeServerName, j2eeApplicationName == null ? NameFactory.NULL : j2eeApplicationName, null, null, null);
+        domainObjectName = NameFactory.getDomainName(null, j2eeContext);
+        serverObjectName = NameFactory.getServerName(null, null, j2eeContext);
 
-        if (j2eeApplicationName == null) {
-            j2eeApplicationName = "null";
-        }
-        this.j2eeApplicationName = j2eeApplicationName;
-
-        Properties domainNameProps = new Properties();
-        domainNameProps.put("j2eeType", "J2EEDomain");
-        domainNameProps.put("name", j2eeDomainName);
-        try {
-            domainObjectName = new ObjectName(j2eeDomainName, domainNameProps);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Unable to construct J2EEDomain ObjectName", e);
-        }
-
-        Properties serverNameProps = new Properties();
-        serverNameProps.put("j2eeType", "J2EEServer");
-        serverNameProps.put("name", j2eeServerName);
-        try {
-            serverObjectName = new ObjectName(j2eeDomainName, serverNameProps);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Unable to construct J2EEServer ObjectName", e);
-        }
-
-        if (!j2eeApplicationName.equals("null")) {
-            Properties applicationNameProps = new Properties();
-            applicationNameProps.put("j2eeType", "J2EEApplication");
-            applicationNameProps.put("name", j2eeApplicationName);
-            applicationNameProps.put("J2EEServer", j2eeServerName);
-            try {
-                applicationObjectName = new ObjectName(j2eeDomainName, applicationNameProps);
-            } catch (MalformedObjectNameException e) {
-                throw new DeploymentException("Unable to construct J2EEApplication ObjectName", e);
-            }
+        if (j2eeApplicationName != null) {
+            applicationObjectName = NameFactory.getApplicationName(null, null, null, j2eeContext);
         } else {
             applicationObjectName = null;
         }
+
         this.transactionContextManagerObjectName = transactionContextManagerObjectName;
         this.connectionTrackerObjectName = connectionTrackerObjectName;
         this.transactedTimerName = transactedTimerName;
         this.nonTransactedTimerName = nonTransactedTimerName;
-        this.ejbRefContext = ejbRefContext;
+        this.refContext = refContext;
     }
 
     public String getJ2EEDomainName() {
-        return j2eeDomainName;
+        return j2eeContext.getJ2eeDomainName();
     }
 
     public String getJ2EEServerName() {
-        return j2eeServerName;
+        return j2eeContext.getJ2eeServerName();
     }
 
     public String getJ2EEApplicationName() {
-        return j2eeApplicationName;
+        return j2eeContext.getJ2eeApplicationName();
     }
 
     public ObjectName getDomainObjectName() {
@@ -138,22 +105,11 @@
         return nonTransactedTimerName;
     }
 
-    public EJBRefContext getEJBRefContext() {
-        return ejbRefContext;
-    }
-
-    public void addResourceAdapter(String resourceAdapterName, String resourceAdapterModule, Map activationSpecInfoMap) {
-        resourceAdapterModules.put(resourceAdapterName, resourceAdapterModule);
-        activationSpecInfos.put(resourceAdapterName, activationSpecInfoMap);
-    }
-
-    public Object getActivationSpecInfo(String resourceAdapterName, String activationSpecClassName) {
-        Map activationSpecInfoMap = (Map) activationSpecInfos.get(resourceAdapterName);
-        Object activationSpecInfo = activationSpecInfoMap.get(activationSpecClassName);
-        return activationSpecInfo;
+    public RefContext getRefContext() {
+        return refContext;
     }
 
-    public String getResourceAdapterModule(String resourceAdapterName) {
-        return (String) resourceAdapterModules.get(resourceAdapterName);
+    public J2eeContext getJ2eeContext() {
+        return j2eeContext;
     }
 }

Copied: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java (from rev 55502, geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBRefContext.java)
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBRefContext.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java	Wed Oct 27 18:51:13 2004
@@ -20,37 +20,64 @@
 import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
-
+import javax.management.ObjectName;
 import javax.naming.Reference;
 
 import org.apache.geronimo.deployment.DeploymentException;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 
 /**
  * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
  */
-public class EJBRefContext {
+public class RefContext {
+
     private final EJBReferenceBuilder ejbReferenceBuilder;
+    private final ResourceReferenceBuilder resourceReferenceBuilder;
+
     private final Map ejbRemoteIndex;
     private final Map ejbLocalIndex;
     private final Map ejbInterfaceIndex;
 
-    public EJBRefContext(EJBReferenceBuilder ejbReferenceBuilder) {
+    private final Map resourceAdapterIndex;
+    private final Map connectionFactoryIndex;
+    private final Map adminObjectIndex;
+
+    private final Map activationSpecInfos;
+
+    public RefContext(EJBReferenceBuilder ejbReferenceBuilder, ResourceReferenceBuilder resourceReferenceBuilder) {
         assert ejbReferenceBuilder != null: "ejbReferenceBuilder is null";
+        assert resourceReferenceBuilder != null: "resourceReferenceBuilder is null";
 
         ejbRemoteIndex = new HashMap();
         ejbLocalIndex = new HashMap();
         ejbInterfaceIndex = new HashMap();
+        resourceAdapterIndex = new HashMap();
+        connectionFactoryIndex = new HashMap();
+        adminObjectIndex = new HashMap();
+        activationSpecInfos = new HashMap();
         this.ejbReferenceBuilder = ejbReferenceBuilder;
+        this.resourceReferenceBuilder = resourceReferenceBuilder;
     }
 
-    public EJBRefContext(EJBRefContext ejbRefContext, EJBReferenceBuilder ejbReferenceBuilder) {
+    public static RefContext derivedClientRefContext(RefContext refContext, EJBReferenceBuilder ejbReferenceBuilder, ResourceReferenceBuilder resourceReferenceBuilder) {
+        return new RefContext(refContext, ejbReferenceBuilder, resourceReferenceBuilder);
+    }
+
+    private RefContext(RefContext refContext, EJBReferenceBuilder ejbReferenceBuilder, ResourceReferenceBuilder resourceReferenceBuilder) {
         assert ejbReferenceBuilder != null: "ejbReferenceBuilder is null";
-        assert ejbRefContext != null: "ejbRefContext is null";
+        assert resourceReferenceBuilder != null: "resourceReferenceBuilder is null";
+        assert refContext != null: "ejbRefContext is null";
 
         this.ejbReferenceBuilder = ejbReferenceBuilder;
-        this.ejbRemoteIndex = ejbRefContext.ejbRemoteIndex;
-        this.ejbLocalIndex = ejbRefContext.ejbLocalIndex;
-        this.ejbInterfaceIndex = ejbRefContext.ejbInterfaceIndex;
+        this.resourceReferenceBuilder = resourceReferenceBuilder;
+        this.ejbRemoteIndex = refContext.ejbRemoteIndex;
+        this.ejbLocalIndex = new HashMap();//no local ejb refs
+        this.ejbInterfaceIndex = refContext.ejbInterfaceIndex;
+        resourceAdapterIndex = new HashMap();
+        this.connectionFactoryIndex = new HashMap();
+        this.adminObjectIndex = new HashMap();
+        this.activationSpecInfos = new HashMap();
     }
 
     public EJBReferenceBuilder getEjbReferenceBuilder() {
@@ -65,6 +92,14 @@
         return ejbLocalIndex;
     }
 
+    public Map getConnectionFactoryIndex() {
+        return connectionFactoryIndex;
+    }
+
+    public Map getAdminObjectIndex() {
+        return adminObjectIndex;
+    }
+
     public void addEJBRemoteId(URI modulePath, String name, String containerId, boolean isSession, String home, String remote) throws DeploymentException {
         Map references = (Map) ejbRemoteIndex.get(name);
         if (references == null || references.isEmpty()) {
@@ -103,24 +138,68 @@
         try {
             URI ejbURI = new URI(null, null, modulePath.getPath(), name);
             references.put(ejbURI, containerId);
-            URI moduelURI = new URI(null, null, modulePath.getPath(), null);
-            interfacesReferences.put(moduelURI, containerId);
+            URI moduleURI = new URI(null, null, modulePath.getPath(), null);
+            interfacesReferences.put(moduleURI, containerId);
         } catch (URISyntaxException e) {
             throw new DeploymentException(e);
         }
     }
 
-    public Reference getEJBRemoteRef(String objectName, boolean isSession, String home, String remote) throws DeploymentException {
-        if (ejbReferenceBuilder == null) {
-            throw new DeploymentException("No ejb reference builder");
+    public void addResourceAdapterId(URI modulePath, String name, String containerId) throws DeploymentException {
+        Map references = (Map) connectionFactoryIndex.get(name);
+        if (references == null || references.isEmpty()) {
+            references = new HashMap();
+            resourceAdapterIndex.put(name, references);
+        }
+
+        try {
+            URI cfURI = new URI(null, null, modulePath.getPath(), name);
+            references.put(cfURI, containerId);
+        } catch (URISyntaxException e) {
+            throw new DeploymentException(e);
+        }
+    }
+
+    public void addConnectionFactoryId(URI modulePath, String name, String containerId) throws DeploymentException {
+        Map references = (Map) connectionFactoryIndex.get(name);
+        if (references == null || references.isEmpty()) {
+            references = new HashMap();
+            connectionFactoryIndex.put(name, references);
+        }
+
+        try {
+            URI cfURI = new URI(null, null, modulePath.getPath(), name);
+            references.put(cfURI, containerId);
+        } catch (URISyntaxException e) {
+            throw new DeploymentException(e);
+        }
+    }
+
+
+    public void addAdminObjectId(URI modulePath, String name, String containerId) throws DeploymentException {
+        Map references = (Map) adminObjectIndex.get(name);
+        if (references == null || references.isEmpty()) {
+            references = new HashMap();
+            adminObjectIndex.put(name, references);
         }
+
+        try {
+            URI cfURI = new URI(null, null, modulePath.getPath(), name);
+            references.put(cfURI, containerId);
+        } catch (URISyntaxException e) {
+            throw new DeploymentException(e);
+        }
+    }
+
+
+
+    //lookup methods
+
+    public Reference getEJBRemoteRef(String objectName, boolean isSession, String home, String remote) throws DeploymentException {
         return ejbReferenceBuilder.createEJBRemoteReference(objectName, isSession, home, remote);
     }
 
     public Reference getEJBLocalRef(String objectName, boolean isSession, String localHome, String local) throws DeploymentException {
-        if (ejbReferenceBuilder == null) {
-            throw new DeploymentException("No ejb reference builder");
-        }
         return ejbReferenceBuilder.createEJBLocalReference(objectName, isSession, localHome, local);
     }
 
@@ -136,6 +215,47 @@
         return getEJBLocalRef(containerId, isSession, localHome, local);
     }
 
+    public Reference getConnectionFactoryRef(String containerId, Class iface) throws DeploymentException {
+        return resourceReferenceBuilder.createResourceRef(containerId, iface);
+    }
+
+    public String getResourceAdapterContainerId(URI module, String resourceLink, J2eeContext j2eeContext) throws DeploymentException, UnknownEJBRefException {
+        String name = resourceLink.substring(resourceLink.lastIndexOf('#') + 1);
+        try {
+            return getContainerId(module, resourceLink, (Map) connectionFactoryIndex.get(name));
+        } catch (UnknownEJBRefException e) {
+            ObjectName query = NameFactory.getComponentRestrictedQueryName(null, null, name, NameFactory.JCA_RESOURCE_ADAPTER, j2eeContext);
+            ObjectName containerName = resourceReferenceBuilder.locateResourceName(query);
+            return containerName.getCanonicalName();
+        }
+    }
+
+    public String getConnectionFactoryContainerId(URI module, String resourceLink, J2eeContext j2eeContext) throws DeploymentException, UnknownEJBRefException {
+        String name = resourceLink.substring(resourceLink.lastIndexOf('#') + 1);
+        try {
+            return getContainerId(module, resourceLink, (Map) connectionFactoryIndex.get(name));
+        } catch (UnknownEJBRefException e) {
+            ObjectName query = NameFactory.getComponentRestrictedQueryName(null, null, name, NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
+            ObjectName containerName = resourceReferenceBuilder.locateResourceName(query);
+            return containerName.getCanonicalName();
+        }
+    }
+
+    public Reference getAdminObjectRef(String containerId, Class iface) throws DeploymentException {
+        return resourceReferenceBuilder.createAdminObjectRef(containerId, iface);
+    }
+
+    public String getAdminObjectContainerId(URI module, String resourceLink, J2eeContext j2eeContext) throws DeploymentException, UnknownEJBRefException {
+        String name = resourceLink.substring(resourceLink.lastIndexOf('#') + 1);
+        try {
+            return getContainerId(module, resourceLink, (Map) adminObjectIndex.get(name));
+        } catch (UnknownEJBRefException e) {
+            ObjectName query = NameFactory.getComponentRestrictedQueryName(null, null, name, NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
+            ObjectName containerName = resourceReferenceBuilder.locateResourceName(query);
+            return containerName.getCanonicalName();
+        }
+    }
+
     private String getContainerId(URI module, String ejbLink, Map references) throws AmbiguousEJBRefException, UnknownEJBRefException {
         if (references == null || references.isEmpty()) {
             throw new UnknownEJBRefException(ejbLink);
@@ -207,6 +327,23 @@
 
         // there is more then one ejb that implements that interface... give up
         throw new UnresolvedEJBRefException(refName, ejbRefInfo, true);
+    }
+
+    //Resource adapter/activationspec support
+
+    public void addActivationSpecInfos(ObjectName resourceAdapterName, Map activationSpecInfoMap) throws DeploymentException {
+        Object old = activationSpecInfos.put(resourceAdapterName, activationSpecInfoMap);
+        if (old != null) {
+            throw new DeploymentException("Duplicate resource adapter name: " + resourceAdapterName);
+        }
+    }
+
+    public Object getActivationSpecInfo(ObjectName resourceAdapterName, String messageListenerInterfaceName) throws DeploymentException {
+        Map activationSpecInfoMap = (Map) activationSpecInfos.get(resourceAdapterName);
+        if (activationSpecInfoMap != null) {
+            return activationSpecInfoMap.get(messageListenerInterfaceName);
+        }
+        return resourceReferenceBuilder.locateActivationSpecInfo(resourceAdapterName, messageListenerInterfaceName);
     }
 
 }

Added: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ResourceReferenceBuilder.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ResourceReferenceBuilder.java	Wed Oct 27 18:51:13 2004
@@ -0,0 +1,36 @@
+/**
+ *
+ * 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.j2ee.deployment;
+
+import javax.naming.Reference;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.deployment.DeploymentException;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public interface ResourceReferenceBuilder {
+
+    Reference createResourceRef(String containerId, Class iface) throws DeploymentException;
+
+    Reference createAdminObjectRef(String containerId, Class iface) throws DeploymentException;
+
+    ObjectName locateResourceName(ObjectName query) throws DeploymentException;
+
+    Object locateActivationSpecInfo(ObjectName resourceAdapterName, String messageListenerInterface) throws DeploymentException;
+
+}

Added: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/J2eeContext.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/J2eeContext.java	Wed Oct 27 18:51:13 2004
@@ -0,0 +1,34 @@
+package org.apache.geronimo.j2ee.deployment.j2eeobjectnames;
+
+/**
+ */
+public interface J2eeContext {
+
+    String getJ2eeDomainName();
+
+    String getJ2eeServerName();
+
+    String getJ2eeApplicationName();
+
+    String getJ2eeModuleName();
+
+    String getJ2eeName();
+
+    String getJ2eeType();
+
+    //these override methods return the argument it if is non-null, otherwise the same value as
+    //the corresponding method above.
+
+    String getJ2eeDomainName(String override);
+
+    String getJ2eeServerName(String override);
+
+    String getJ2eeApplicationName(String override);
+
+    String getJ2eeModuleName(String override);
+
+    String getJ2eeName(String override);
+
+    String getJ2eeType(String override);
+
+}

Added: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/J2eeContextImpl.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/J2eeContextImpl.java	Wed Oct 27 18:51:13 2004
@@ -0,0 +1,72 @@
+package org.apache.geronimo.j2ee.deployment.j2eeobjectnames;
+
+/**
+ */
+public class J2eeContextImpl implements J2eeContext {
+
+    private final String domainName;
+    private final String serverName;
+    private final String applicationName;
+    private final String moduleName;
+    private final String j2eeName;
+    private final String j2eeType;
+
+    public J2eeContextImpl(String domainName, String serverName, String applicationName, String moduleName, String j2eeName, String j2eeType) {
+        this.domainName = domainName;
+        this.serverName = serverName;
+        this.applicationName = applicationName;
+        this.moduleName = moduleName;
+        this.j2eeName = j2eeName;
+        this.j2eeType = j2eeType;
+    }
+
+
+    public String getJ2eeDomainName() {
+        return domainName;
+    }
+
+    public String getJ2eeServerName() {
+        return serverName;
+    }
+
+    public String getJ2eeApplicationName() {
+        return applicationName;
+    }
+
+    public String getJ2eeModuleName() {
+        return moduleName;
+    }
+
+    public String getJ2eeName() {
+        return j2eeName;
+    }
+
+    public String getJ2eeType() {
+        return j2eeType;
+    }
+
+    public String getJ2eeDomainName(String override) {
+        return override == null? domainName: override;
+    }
+
+    public String getJ2eeServerName(String override) {
+        return override == null? serverName: override;
+    }
+
+    public String getJ2eeApplicationName(String override) {
+        return override == null? applicationName: override;
+    }
+
+    public String getJ2eeModuleName(String override) {
+        return override == null? moduleName: override;
+    }
+
+    //most likely the last 2 don't make any sense.
+    public String getJ2eeName(String override) {
+        return override == null? j2eeName: override;
+    }
+
+    public String getJ2eeType(String override) {
+        return override == null? j2eeType: override;
+    }
+}

Added: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/NameFactory.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/j2eeobjectnames/NameFactory.java	Wed Oct 27 18:51:13 2004
@@ -0,0 +1,214 @@
+package org.apache.geronimo.j2ee.deployment.j2eeobjectnames;
+
+import java.util.Properties;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.deployment.DeploymentException;
+
+/**
+ */
+public class NameFactory {
+
+    //name components
+    public static String J2EE_SERVER = "J2EEServer";
+    public static String J2EE_APPLICATION = "J2EEApplication";
+    public static String J2EE_MODULE = "J2EEModule";
+    public static String J2EE_TYPE = "j2eeType";
+    public static String J2EE_NAME = "name";
+
+    //types
+    public static String J2EE_DOMAIN = "J2EEDomain";
+    public static String JVM = "JVM";
+    public static String APP_CLIENT_MODULE = "AppClientModule";
+
+    public static String EJB = "EJB";
+    public static String EJB_MODULE = "EJBModule";
+    public static String MESSAGE_DRIVEN_BEAN = "MessageDrivenBean";
+    public static String ENTITY_BEAN = "EntityBean";
+    public static String STATEFUL_SESSION_BEAN = "StatefulSessionBean";
+    public static String STATELESS_SESSION_BEAN = "StatelessSessionBean";
+
+    public static String WEB_MODULE = "WebModule";
+    public static String SERVLET = "Servlet";
+
+    public static String RESOURCE_ADAPTER_MODULE = "ResourceAdapterModule";
+    public static String RESOURCE_ADAPTER = "ResourceAdapter";
+    public static String JAVA_MAIL_RESOURCE = "JavaMailResource";
+    public static String JCA_RESOURCE = "JCAResource";
+    public static String JCA_CONNECTION_FACTORY = "JCAConnectionFactory";
+    public static String JCA_MANAGED_CONNECTION_FACTORY = "JCAManagedConnectionFactory";
+    public static String JDBC_RESOURCE = "JDBCResource";
+    public static String JDBC_DATASOURCE = "JDBCDataSource";
+    public static String JDBC_DRIVER = "JDBCDriver";
+    public static String JMS_RESOURCE = "JMSResource";
+
+    public static String JNDI_RESOURCE = "JNDIResource";
+    public static String JTA_RESOURCE = "JTAResource";
+
+    public static String RMI_IIOP_RESOURCE = "RMI_IIOPResource";
+    public static String URL_RESOURCE = "URLResource";
+
+    //used for J2EEApplication= when component is not deployed in an ear.
+    public static String NULL = "null";
+
+    //geronimo extensions
+    public static final String JCA_ADMIN_OBJECT = "JCAAdminObject";
+    public static final String JCA_ACTIVATION_SPEC = "JCAActivationSpec";
+    public static final String JCA_RESOURCE_ADAPTER = "JCAResourceAdapter";
+    public static final String JCA_WORK_MANAGER = "JCAWorkManager";
+    public static final String JCA_CONNECTION_MANAGER = "JCAConnectionManager";
+
+    public static ObjectName getDomainName(String j2eeDomainName, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, J2EE_DOMAIN);
+        props.put(J2EE_NAME, context.getJ2eeDomainName(j2eeDomainName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid domain name", e);
+        }
+    }
+
+    public static ObjectName getServerName(String j2eeDomainName, String j2eeServerName, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, J2EE_SERVER);
+        props.put(J2EE_NAME, context.getJ2eeServerName(j2eeServerName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid server name", e);
+        }
+    }
+
+    public static ObjectName getApplicationName(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, J2EE_APPLICATION);
+        props.put(J2EE_SERVER, context.getJ2eeServerName(j2eeServerName));
+        props.put(J2EE_NAME, context.getJ2eeApplicationName(j2eeApplicationName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid application name", e);
+        }
+    }
+
+    public static ObjectName getModuleName(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String j2eeType, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, j2eeType);
+        props.put(J2EE_SERVER, context.getJ2eeServerName(j2eeServerName));
+        props.put(J2EE_APPLICATION, context.getJ2eeApplicationName(j2eeApplicationName));
+        props.put(J2EE_NAME, context.getJ2eeModuleName(j2eeModuleName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid module name", e);
+        }
+    }
+
+    public static ObjectName getEjbComponentName(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, context.getJ2eeType(j2eeType));
+        props.put(J2EE_SERVER, context.getJ2eeServerName(j2eeServerName));
+        props.put(J2EE_APPLICATION, context.getJ2eeApplicationName(j2eeApplicationName));
+        props.put(EJB_MODULE, context.getJ2eeModuleName(j2eeModuleName));
+        props.put(J2EE_NAME, context.getJ2eeName(j2eeName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid component name", e);
+        }
+    }
+
+    public static String getEjbComponentNameString(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+        return getEjbComponentName(j2eeDomainName, j2eeServerName, j2eeApplicationName, j2eeModuleName, j2eeName, j2eeType, context).getCanonicalName();
+    }
+
+    public static ObjectName getResourceComponentName(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, context.getJ2eeType(j2eeType));
+        props.put(J2EE_SERVER, context.getJ2eeServerName(j2eeServerName));
+        props.put(J2EE_APPLICATION, context.getJ2eeApplicationName(j2eeApplicationName));
+//        props.put(RESOURCE_ADAPTER_MODULE, context.getJ2eeModuleName(j2eeModuleName));
+        props.put(JCA_RESOURCE, context.getJ2eeModuleName(j2eeModuleName));
+        props.put(J2EE_NAME, context.getJ2eeName(j2eeName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid component name", e);
+        }
+    }
+
+    public static String getResourceComponentNameString(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+        return getResourceComponentName(j2eeDomainName, j2eeServerName, j2eeApplicationName, j2eeModuleName, j2eeName, j2eeType, context).getCanonicalName();
+    }
+
+    /**
+     * Creates a query for components that are in no application with given name.
+     * @param j2eeDomainName
+     * @param j2eeServerName
+     * @param j2eeName
+     * @param j2eeType
+     * @param context
+     * @return
+     * @throws DeploymentException
+     */
+
+    public static ObjectName getComponentRestrictedQueryName(String j2eeDomainName, String j2eeServerName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+//        Properties props = new Properties();
+//        props.put(J2EE_TYPE, context.getJ2eeType(j2eeType));
+//        props.put(J2EE_SERVER, context.getJ2eeServerName(j2eeServerName));
+//        props.put(J2EE_APPLICATION, NULL;
+//        props.put(RESOURCE_ADAPTER_MODULE, context.getJ2eeModuleName(j2eeModuleName));
+//        props.put(JCA_RESOURCE, context.getJ2eeModuleName(j2eeModuleName));
+//        props.put(J2EE_NAME, context.getJ2eeName(j2eeName));
+//        try {
+//            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+//        } catch (MalformedObjectNameException e) {
+//            throw new DeploymentException("Invalid component name", e);
+//        }
+        StringBuffer buffer = new StringBuffer(context.getJ2eeDomainName())
+                .append(":" + J2EE_TYPE + "=").append(context.getJ2eeType(j2eeType))
+                .append("," + J2EE_SERVER + "=").append(context.getJ2eeServerName(j2eeServerName))
+                .append("," + J2EE_APPLICATION + "=" + NULL)
+                .append("," + J2EE_NAME + "=").append(context.getJ2eeName(j2eeName))
+                .append(",*");
+        try {
+            return new ObjectName(buffer.toString());
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Unable to construct ObjectName", e);
+        }
+    }
+
+    public static ObjectName getWebComponentName(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, context.getJ2eeType(j2eeType));
+        props.put(J2EE_SERVER, context.getJ2eeServerName(j2eeServerName));
+        props.put(J2EE_APPLICATION, context.getJ2eeApplicationName(j2eeApplicationName));
+        props.put(WEB_MODULE, context.getJ2eeModuleName(j2eeModuleName));
+        props.put(J2EE_NAME, context.getJ2eeName(j2eeName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid component name", e);
+        }
+    }
+
+    public static String getWebComponentNameString(String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, String j2eeModuleName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+        return getResourceComponentName(j2eeDomainName, j2eeServerName, j2eeApplicationName, j2eeModuleName, j2eeName, j2eeType, context).getCanonicalName();
+    }
+
+    //for non-j2ee-deployable resources such as the transaction manager
+    public static ObjectName getComponentName(String j2eeDomainName, String j2eeServerName, String j2eeName, String j2eeType, J2eeContext context) throws DeploymentException {
+        Properties props = new Properties();
+        props.put(J2EE_TYPE, context.getJ2eeType(j2eeType));
+        props.put(J2EE_SERVER, context.getJ2eeServerName(j2eeServerName));
+        props.put(J2EE_NAME, context.getJ2eeName(j2eeName));
+        try {
+            return ObjectName.getInstance(context.getJ2eeDomainName(j2eeDomainName), props);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Invalid component name", e);
+        }
+    }
+
+}

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java	(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java	Wed Oct 27 18:51:13 2004
@@ -39,6 +39,7 @@
     private static MockEJBConfigBuilder ejbConfigBuilder = new MockEJBConfigBuilder();
     private static MockWARConfigBuilder webConfigBuilder = new MockWARConfigBuilder();
     private static MockConnectorConfigBuilder connectorConfigBuilder = new MockConnectorConfigBuilder();
+    private static ResourceReferenceBuilder resourceReferenceBuilder = null;
     private static ModuleBuilder appClientConfigBuilder;
 
     private static final String j2eeServerName = "someDomain";
@@ -200,7 +201,7 @@
     }
 
     public void testBuildConfiguration() throws Exception {
-        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, ejbConfigBuilder, null, webConfigBuilder, connectorConfigBuilder, appClientConfigBuilder, null);
+        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, ejbConfigBuilder, null, webConfigBuilder, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, null);
 
         File tempDir = null;
         try {
@@ -213,7 +214,7 @@
     }
 
     public void testNoEJBDeployer() throws Exception {
-        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, null, null, webConfigBuilder, connectorConfigBuilder, appClientConfigBuilder, null);
+        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, null, null, webConfigBuilder, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, null);
 
         File tempDir = null;
         try {
@@ -229,7 +230,7 @@
     }
 
     public void testNoWARDeployer() throws Exception {
-        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, ejbConfigBuilder, null, null, connectorConfigBuilder, appClientConfigBuilder, null);
+        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, ejbConfigBuilder, null, null, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, null);
 
         File tempDir = null;
         try {
@@ -245,7 +246,7 @@
     }
 
     public void testNoConnectorDeployer() throws Exception {
-        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, ejbConfigBuilder, null, webConfigBuilder, null, appClientConfigBuilder, null);
+        EARConfigBuilder configBuilder = new EARConfigBuilder(j2eeServer, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, ejbConfigBuilder, null, webConfigBuilder, null, resourceReferenceBuilder, appClientConfigBuilder, null);
 
         File tempDir = null;
         try {

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EJBRefContextTest.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EJBRefContextTest.java	(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EJBRefContextTest.java	Wed Oct 27 18:51:13 2004
@@ -18,8 +18,10 @@
 
 import java.net.URI;
 import javax.naming.Reference;
+import javax.management.ObjectName;
 
 import junit.framework.TestCase;
+import org.apache.geronimo.deployment.DeploymentException;
 
 /**
  * @version $Rev$ $Date$
@@ -43,27 +45,27 @@
     private final String car_gt_local = "car_gt_local";
     private final String car_enzo = "car_enzo";
     private final String car_enzo_local = "car_enzo_local";
-    private EJBRefContext ejbRefContext;
+    private RefContext refContext;
 
     public void testSimpleRefs() throws Exception {
-        assertReferenceEqual(coffee_peaberry, ejbRefContext.getEJBRemoteRef(coffee, "peaberry", true, null, null));
-        assertReferenceEqual(coffee_peaberry_local, ejbRefContext.getEJBLocalRef(coffee, "peaberry", true, null, null));
+        assertReferenceEqual(coffee_peaberry, refContext.getEJBRemoteRef(coffee, "peaberry", true, null, null));
+        assertReferenceEqual(coffee_peaberry_local, refContext.getEJBLocalRef(coffee, "peaberry", true, null, null));
     }
 
     public void testAmbiguousRefs() throws Exception {
-        assertReferenceEqual(coffee_java, ejbRefContext.getEJBRemoteRef(coffee, "java", true, null, null));
-        assertReferenceEqual(coffee_java_local, ejbRefContext.getEJBLocalRef(coffee, "java", true, null, null));
-        assertReferenceEqual(language_java, ejbRefContext.getEJBRemoteRef(language, "java", true, null, null));
-        assertReferenceEqual(language_java_local, ejbRefContext.getEJBLocalRef(language, "java", true, null, null));
+        assertReferenceEqual(coffee_java, refContext.getEJBRemoteRef(coffee, "java", true, null, null));
+        assertReferenceEqual(coffee_java_local, refContext.getEJBLocalRef(coffee, "java", true, null, null));
+        assertReferenceEqual(language_java, refContext.getEJBRemoteRef(language, "java", true, null, null));
+        assertReferenceEqual(language_java_local, refContext.getEJBLocalRef(language, "java", true, null, null));
 
         try {
-            ejbRefContext.getEJBRemoteRef(car, "java", true, null, null);
+            refContext.getEJBRemoteRef(car, "java", true, null, null);
             fail("should have thrown an AmbiguousEJBRefException");
         } catch (AmbiguousEJBRefException e) {
             // good
         }
         try {
-            ejbRefContext.getEJBLocalRef(car, "java", true, null, null);
+            refContext.getEJBLocalRef(car, "java", true, null, null);
             fail("should have thrown an AmbiguousEJBRefException");
         } catch (AmbiguousEJBRefException e) {
             // good
@@ -71,51 +73,51 @@
     }
 
     public void testRelativeRefs() throws Exception {
-        assertReferenceEqual(car_enzo, ejbRefContext.getEJBRemoteRef(coffee, "../../foo/bar/car.jar#enzo", true, null, null));
-        assertReferenceEqual(car_enzo_local, ejbRefContext.getEJBLocalRef(coffee, "../../foo/bar/car.jar#enzo", true, null, null));
-        assertReferenceEqual(car_enzo, ejbRefContext.getEJBRemoteRef(coffee, "./../funk/../../foo/bar/car.jar#enzo", true, null, null));
-        assertReferenceEqual(car_enzo_local, ejbRefContext.getEJBLocalRef(coffee, "./../funk/../../foo/bar/car.jar#enzo", true, null, null));
-        assertReferenceEqual(coffee_java, ejbRefContext.getEJBRemoteRef(coffee, "./coffee.jar#java", true, null, null));
-        assertReferenceEqual(coffee_java_local, ejbRefContext.getEJBLocalRef(coffee, "./coffee.jar#java", true, null, null));
-        assertReferenceEqual(coffee_java, ejbRefContext.getEJBRemoteRef(coffee, "coffee.jar#java", true, null, null));
-        assertReferenceEqual(coffee_java_local, ejbRefContext.getEJBLocalRef(coffee, "coffee.jar#java", true, null, null));
+        assertReferenceEqual(car_enzo, refContext.getEJBRemoteRef(coffee, "../../foo/bar/car.jar#enzo", true, null, null));
+        assertReferenceEqual(car_enzo_local, refContext.getEJBLocalRef(coffee, "../../foo/bar/car.jar#enzo", true, null, null));
+        assertReferenceEqual(car_enzo, refContext.getEJBRemoteRef(coffee, "./../funk/../../foo/bar/car.jar#enzo", true, null, null));
+        assertReferenceEqual(car_enzo_local, refContext.getEJBLocalRef(coffee, "./../funk/../../foo/bar/car.jar#enzo", true, null, null));
+        assertReferenceEqual(coffee_java, refContext.getEJBRemoteRef(coffee, "./coffee.jar#java", true, null, null));
+        assertReferenceEqual(coffee_java_local, refContext.getEJBLocalRef(coffee, "./coffee.jar#java", true, null, null));
+        assertReferenceEqual(coffee_java, refContext.getEJBRemoteRef(coffee, "coffee.jar#java", true, null, null));
+        assertReferenceEqual(coffee_java_local, refContext.getEJBLocalRef(coffee, "coffee.jar#java", true, null, null));
 
         try {
-            ejbRefContext.getEJBRemoteRef(coffee, "not_exist.jar#blah", true, null, null);
+            refContext.getEJBRemoteRef(coffee, "not_exist.jar#blah", true, null, null);
             fail("should have thrown an UnknownEJBRefException");
         } catch (UnknownEJBRefException e) {
             // good
         }
 
         try {
-            ejbRefContext.getEJBLocalRef(coffee, "not_exist.jar#blah", true, null, null);
+            refContext.getEJBLocalRef(coffee, "not_exist.jar#blah", true, null, null);
             fail("should have thrown an UnknownEJBRefException");
         } catch (UnknownEJBRefException e) {
             // good
         }
 
         try {
-            ejbRefContext.getEJBRemoteRef(coffee, "coffee.jar#blah", true, null, null);
+            refContext.getEJBRemoteRef(coffee, "coffee.jar#blah", true, null, null);
             fail("should have thrown an UnknownEJBRefException");
         } catch (UnknownEJBRefException e) {
             // good
         }
 
         try {
-            ejbRefContext.getEJBLocalRef(coffee, "coffee.jar#blah", true, null, null);
+            refContext.getEJBLocalRef(coffee, "coffee.jar#blah", true, null, null);
             fail("should have thrown an UnknownEJBRefException");
         } catch (UnknownEJBRefException e) {
             // good
         }
 
         try {
-            ejbRefContext.getEJBRemoteRef(coffee, "../../../../foo/bar/car.jar#enzo", true, null, null);
+            refContext.getEJBRemoteRef(coffee, "../../../../foo/bar/car.jar#enzo", true, null, null);
             fail("should have thrown an UnknownEJBRefException");
         } catch (UnknownEJBRefException e) {
             // good
         }
         try {
-            ejbRefContext.getEJBLocalRef(coffee, "../../../../foo/bar/car.jar#enzo", true, null, null);
+            refContext.getEJBLocalRef(coffee, "../../../../foo/bar/car.jar#enzo", true, null, null);
             fail("should have thrown an UnknownEJBRefException");
         } catch (UnknownEJBRefException e) {
             // good
@@ -123,18 +125,18 @@
     }
 
     public void testBasicImplicitRefs() throws Exception {
-        assertReferenceEqual(language_lisp, ejbRefContext.getImplicitEJBRemoteRef(coffee, "blah", true, "LispHome", "LispRemote"));
-        assertReferenceEqual(language_lisp_local, ejbRefContext.getImplicitEJBLocalRef(coffee, "blah", true, "LispLocalHome", "LispLocal"));
+        assertReferenceEqual(language_lisp, refContext.getImplicitEJBRemoteRef(coffee, "blah", true, "LispHome", "LispRemote"));
+        assertReferenceEqual(language_lisp_local, refContext.getImplicitEJBLocalRef(coffee, "blah", true, "LispLocalHome", "LispLocal"));
     }
 
     public void testInModuleImplicitRefs() throws Exception {
-        assertReferenceEqual(coffee_java_local, ejbRefContext.getImplicitEJBLocalRef(coffee, "blah", true, "LocalHome", "Local"));
-        assertReferenceEqual(car_enzo_local, ejbRefContext.getImplicitEJBLocalRef(car, "blah", true, "LocalHome", "Local"));
+        assertReferenceEqual(coffee_java_local, refContext.getImplicitEJBLocalRef(coffee, "blah", true, "LocalHome", "Local"));
+        assertReferenceEqual(car_enzo_local, refContext.getImplicitEJBLocalRef(car, "blah", true, "LocalHome", "Local"));
     }
 
     public void testAmbiguousModuleImplicitRefs() throws Exception {
         try {
-            ejbRefContext.getImplicitEJBLocalRef(language, "blah", true, "LocalHome", "Local");
+            refContext.getImplicitEJBLocalRef(language, "blah", true, "LocalHome", "Local");
             fail("should have thrown an UnresolvedEJBRefException");
         } catch (UnresolvedEJBRefException e) {
             // good
@@ -143,7 +145,7 @@
 
     public void testNoMatchImplicitRefs() throws Exception {
         try {
-            ejbRefContext.getImplicitEJBLocalRef(language, "blah", true, "foo", "bar");
+            refContext.getImplicitEJBLocalRef(language, "blah", true, "foo", "bar");
             fail("should have thrown an UnresolvedEJBRefException");
         } catch (UnresolvedEJBRefException e) {
             // good
@@ -151,7 +153,7 @@
     }
 
     protected void setUp() throws Exception {
-        ejbRefContext = new EJBRefContext(new EJBReferenceBuilder() {
+        refContext = new RefContext(new EJBReferenceBuilder() {
             public Reference createEJBLocalReference(String objectName, boolean isSession, String localHome, String local) {
                 return new FakeReference(objectName);
             }
@@ -159,22 +161,39 @@
             public Reference createEJBRemoteReference(String objectName, boolean isSession, String home, String remote) {
                 return new FakeReference(objectName);
             }
+        }, new ResourceReferenceBuilder() {
+
+            public Reference createResourceRef(String containerId, Class iface) {
+                return null;
+            }
+
+            public Reference createAdminObjectRef(String containerId, Class iface) {
+                return null;
+            }
+
+            public ObjectName locateResourceName(ObjectName query) throws DeploymentException {
+                return null;
+            }
+
+            public Object locateActivationSpecInfo(ObjectName resourceAdapterName, String messageListenerInterface) throws DeploymentException {
+                return null;
+            }
         });
 
-        ejbRefContext.addEJBRemoteId(coffee, "peaberry", coffee_peaberry, true, "CoffeeHome", "CoffeeRemote");
-        ejbRefContext.addEJBLocalId(coffee, "peaberry", coffee_peaberry_local, true, "CoffeeLocalHome", "CoffeeLocal");
-        ejbRefContext.addEJBRemoteId(coffee, "java", coffee_java, true, "CoffeeHome", "CoffeeRemote");
-        ejbRefContext.addEJBLocalId(coffee, "java", coffee_java_local, true, "LocalHome", "Local");
-
-        ejbRefContext.addEJBRemoteId(language, "lisp", language_lisp, true, "LispHome", "LispRemote");
-        ejbRefContext.addEJBLocalId(language, "lisp", language_lisp_local, true, "LispLocalHome", "LispLocal");
-        ejbRefContext.addEJBRemoteId(language, "java", language_java, true, "JavaHome", "JavaRemote");
-        ejbRefContext.addEJBLocalId(language, "java", language_java_local, true, "JavaLocalHome", "JavaLocal");
-
-        ejbRefContext.addEJBRemoteId(car, "gt", car_gt, true, "GTHome", "GTRemote");
-        ejbRefContext.addEJBLocalId(car, "gt", car_gt_local, true, "GTLocalHome", "GTLocalRemote");
-        ejbRefContext.addEJBRemoteId(car, "enzo", car_enzo, true, "EnzoHome", "EnzoRemote");
-        ejbRefContext.addEJBLocalId(car, "enzo", car_enzo_local, true, "LocalHome", "Local");
+        refContext.addEJBRemoteId(coffee, "peaberry", coffee_peaberry, true, "CoffeeHome", "CoffeeRemote");
+        refContext.addEJBLocalId(coffee, "peaberry", coffee_peaberry_local, true, "CoffeeLocalHome", "CoffeeLocal");
+        refContext.addEJBRemoteId(coffee, "java", coffee_java, true, "CoffeeHome", "CoffeeRemote");
+        refContext.addEJBLocalId(coffee, "java", coffee_java_local, true, "LocalHome", "Local");
+
+        refContext.addEJBRemoteId(language, "lisp", language_lisp, true, "LispHome", "LispRemote");
+        refContext.addEJBLocalId(language, "lisp", language_lisp_local, true, "LispLocalHome", "LispLocal");
+        refContext.addEJBRemoteId(language, "java", language_java, true, "JavaHome", "JavaRemote");
+        refContext.addEJBLocalId(language, "java", language_java_local, true, "JavaLocalHome", "JavaLocal");
+
+        refContext.addEJBRemoteId(car, "gt", car_gt, true, "GTHome", "GTRemote");
+        refContext.addEJBLocalId(car, "gt", car_gt_local, true, "GTLocalHome", "GTLocalRemote");
+        refContext.addEJBRemoteId(car, "enzo", car_enzo, true, "EnzoHome", "EnzoRemote");
+        refContext.addEJBLocalId(car, "enzo", car_enzo_local, true, "LocalHome", "Local");
     }
 
     private void assertReferenceEqual(String expected, Reference reference) {

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java	(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java	Wed Oct 27 18:51:13 2004
@@ -25,18 +25,10 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.LinkedList;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
-import javax.management.AttributeNotFoundException;
-import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
-import javax.management.ReflectionException;
 import javax.transaction.UserTransaction;
 
 import org.apache.geronimo.deployment.DeploymentException;
@@ -49,10 +41,14 @@
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.jetty.JettyClassLoader;
 import org.apache.geronimo.jetty.JettyWebAppContext;
 import org.apache.geronimo.jetty.JettyWebAppJACCContext;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
+import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
@@ -71,17 +67,13 @@
 import org.apache.geronimo.xbeans.geronimo.jetty.JettySecurityType;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerRemoteRefType;
-import org.apache.geronimo.xbeans.j2ee.ResourceRefType;
-import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
-import org.apache.geronimo.xbeans.j2ee.WebAppType;
-import org.apache.geronimo.xbeans.j2ee.ServletMappingType;
 import org.apache.geronimo.xbeans.j2ee.FilterMappingType;
 import org.apache.geronimo.xbeans.j2ee.SecurityConstraintType;
-import org.apache.geronimo.xbeans.j2ee.WebResourceCollectionType;
+import org.apache.geronimo.xbeans.j2ee.ServletMappingType;
 import org.apache.geronimo.xbeans.j2ee.UrlPatternType;
-
+import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
+import org.apache.geronimo.xbeans.j2ee.WebAppType;
+import org.apache.geronimo.xbeans.j2ee.WebResourceCollectionType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
@@ -262,6 +254,8 @@
     }
 
     public String addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+        J2eeContext earJ2eeContext = earContext.getJ2eeContext();
+        J2eeContext moduleJ2eeContext = new J2eeContextImpl(earJ2eeContext.getJ2eeDomainName(), earJ2eeContext.getJ2eeServerName(), earJ2eeContext.getJ2eeApplicationName(), module.getName(), null, null);
         WebModule webModule = (WebModule) module;
 
         WebAppType webApp = (WebAppType) webModule.getSpecDD();
@@ -293,17 +287,7 @@
             }
         }
 
-        Properties nameProps = new Properties();
-        nameProps.put("J2EEServer", earContext.getJ2EEServerName());
-        nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
-        nameProps.put("j2eeType", "WebModule");
-        nameProps.put("name", webModule.getName());
-        ObjectName webModuleName;
-        try {
-            webModuleName = new ObjectName(earContext.getJ2EEDomainName(), nameProps);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Unable to construct ObjectName", e);
-        }
+        ObjectName webModuleName = NameFactory.getModuleName(null, null, null, null, NameFactory.WEB_MODULE, moduleJ2eeContext);
 
         UserTransaction userTransaction = new OnlineUserTransaction();
         ReadOnlyContext compContext = buildComponentContext(earContext, webModule, webApp, jettyWebApp, userTransaction, webClassLoader);
@@ -332,7 +316,8 @@
             gbean.setAttribute("userTransaction", userTransaction);
             gbean.setAttribute("webClassPath", webClassPath);
             // unsharableResources, applicationManagedSecurityResources
-            setResourceEnvironment(gbean, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
+            GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(gbean);
+            ENCConfigBuilder.setResourceEnvironment(earContext, webModule.getModuleURI(), rebuilder, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
 
             gbean.setAttribute("contextPath", webModule.getContextRoot());
             gbean.setAttribute("contextPriorityClassLoader", Boolean.valueOf(contextPriorityClassLoader));
@@ -378,44 +363,19 @@
     }
 
     private ReadOnlyContext buildComponentContext(EARContext earContext, WebModule webModule, WebAppType webApp, JettyWebAppType jettyWebApp, UserTransaction userTransaction, ClassLoader cl) throws DeploymentException {
-        Map ejbRefMap = mapRefs(jettyWebApp.getEjbRefArray());
-        Map ejbLocalRefMap = mapRefs(jettyWebApp.getEjbLocalRefArray());
-        Map resourceRefMap = mapRefs(jettyWebApp.getResourceRefArray());
-        Map resourceEnvRefMap = mapRefs(jettyWebApp.getResourceEnvRefArray());
 
         return ENCConfigBuilder.buildComponentContext(earContext,
                 webModule.getModuleURI(),
                 userTransaction,
                 webApp.getEnvEntryArray(),
-                webApp.getEjbRefArray(), ejbRefMap,
-                webApp.getEjbLocalRefArray(), ejbLocalRefMap,
-                webApp.getResourceRefArray(), resourceRefMap,
-                webApp.getResourceEnvRefArray(), resourceEnvRefMap,
+                webApp.getEjbRefArray(), jettyWebApp.getEjbRefArray(),
+                webApp.getEjbLocalRefArray(), jettyWebApp.getEjbLocalRefArray(),
+                webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray(),
+                webApp.getResourceEnvRefArray(), jettyWebApp.getResourceEnvRefArray(),
                 webApp.getMessageDestinationRefArray(),
                 cl);
     }
 
-    private static Map mapRefs(GerLocalRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerLocalRefType ref = refs[i];
-                refMap.put(ref.getRefName(), ref);
-            }
-        }
-        return refMap;
-    }
-
-    private static Map mapRefs(GerRemoteRefType[] refs) {
-        Map refMap = new HashMap();
-        if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerRemoteRefType ref = refs[i];
-                refMap.put(ref.getRefName(), ref);
-            }
-        }
-        return refMap;
-    }
 
     private static Security buildSecurityConfig(JettyWebAppType jettyWebApp) {
         Security security = null;
@@ -473,34 +433,6 @@
         return principal;
     }
 
-    private void setResourceEnvironment(GBeanMBean bean, ResourceRefType[] resourceRefArray, GerLocalRefType[] jettyResourceRefArray) throws AttributeNotFoundException, ReflectionException {
-        Map openejbNames = new HashMap();
-        for (int i = 0; i < jettyResourceRefArray.length; i++) {
-            GerLocalRefType jettyLocalRefType = jettyResourceRefArray[i];
-            openejbNames.put(jettyLocalRefType.getRefName(), jettyLocalRefType.getTargetName());
-        }
-        Set unshareableResources = new HashSet();
-        Set applicationManagedSecurityResources = new HashSet();
-        for (int i = 0; i < resourceRefArray.length; i++) {
-            ResourceRefType resourceRefType = resourceRefArray[i];
-            String name = (String) openejbNames.get(resourceRefType.getResRefName().getStringValue());
-            if ("Unshareable".equals(getJ2eeStringValue(resourceRefType.getResSharingScope()))) {
-                unshareableResources.add(name);
-            }
-            if ("Application".equals(resourceRefType.getResAuth().getStringValue())) {
-                applicationManagedSecurityResources.add(name);
-            }
-        }
-        bean.setAttribute("unshareableResources", unshareableResources);
-        bean.setAttribute("applicationManagedSecurityResources", applicationManagedSecurityResources);
-    }
-
-    private static String getJ2eeStringValue(org.apache.geronimo.xbeans.j2ee.String string) {
-        if (string == null) {
-            return null;
-        }
-        return string.getStringValue();
-    }
 
     private URI getDependencyURI(JettyDependencyType dep) throws DeploymentException {
         URI uri;

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java	(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java	Wed Oct 27 18:51:13 2004
@@ -25,8 +25,6 @@
 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
 import org.apache.geronimo.naming.deployment.ENCHelper;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerRemoteRefType;
 import org.apache.xmlbeans.SchemaTypeLoader;
 
 /**
@@ -38,76 +36,8 @@
     WebAppDConfigBean(DDBean ddBean, JettyWebAppType webApp) {
         super(ddBean, webApp);
 
-        ENCHelper.XmlEnvRefs envRefs = new ENCHelper.XmlEnvRefs() {
-            public GerRemoteRefType[] getEjbRefs() {
-                return getWebApp().getEjbRefArray();
-            }
+        ENCHelper.XmlEnvRefs envRefs = new ENCHelper.XmlEnvRefs(webApp.getEjbRefArray(), webApp.getEjbLocalRefArray(), webApp.getResourceRefArray(), webApp.getResourceEnvRefArray()); 
 
-            public GerRemoteRefType addNewEjbRef() {
-                return getWebApp().addNewEjbRef();
-            }
-
-            public GerRemoteRefType setEjbRef(int i, GerRemoteRefType remoteRef) {
-                getWebApp().setEjbRefArray(i, remoteRef);
-                return getWebApp().getEjbRefArray(i);
-            }
-
-            public void removeEjbRef(int i) {
-                getWebApp().removeEjbRef(i);
-            }
-
-            public GerLocalRefType[] getEjbLocalRefs() {
-                return getWebApp().getEjbLocalRefArray();
-            }
-
-            public GerLocalRefType addNewEjbLocalRef() {
-                return getWebApp().addNewEjbLocalRef();
-            }
-
-            public GerLocalRefType setEjbLocalRef(int i, GerLocalRefType localRef) {
-                getWebApp().setEjbLocalRefArray(i, localRef);
-                return getWebApp().getEjbLocalRefArray(i);
-            }
-
-            public void removeEjbLocalRef(int i) {
-                getWebApp().removeEjbLocalRef(i);
-            }
-
-            public GerLocalRefType[] getResourceEnvRefs() {
-                return getWebApp().getResourceEnvRefArray();
-            }
-
-            public GerLocalRefType addNewResourceEnvRef() {
-                return getWebApp().addNewResourceEnvRef();
-            }
-
-            public GerLocalRefType setResourceEnvRef(int i, GerLocalRefType localRef) {
-                getWebApp().setResourceEnvRefArray(i, localRef);
-                return getWebApp().getResourceEnvRefArray(i);
-            }
-
-            public void removeResourceEnvRef(int i) {
-                getWebApp().removeResourceEnvRef(i);
-            }
-
-            public GerLocalRefType[] getResourceRefs() {
-                return getWebApp().getResourceRefArray();
-            }
-
-            public GerLocalRefType addNewResourceRef() {
-                return getWebApp().addNewResourceRef();
-            }
-
-            public GerLocalRefType setResourceRef(int i, GerLocalRefType localRef) {
-                getWebApp().setResourceRefArray(i, localRef);
-                return getWebApp().getResourceRefArray(i);
-            }
-
-            public void removeResourceRef(int i) {
-                getWebApp().removeResourceRef(i);
-            }
-
-        };
         //which version are we dealing with?
         String version = ddBean.getRoot().getAttributeValue("version");
         if ("2.4".equals(version)) {

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java	(original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java	Wed Oct 27 18:51:13 2004
@@ -6,7 +6,7 @@
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 
 /**
  */
@@ -27,7 +27,7 @@
         jettyWebAppType.setConfigId("configId");
         jettyWebAppType.setParentId("parentId");
         jettyWebAppType.setContextPriorityClassloader(false);
-        GerLocalRefType ref = jettyWebAppType.addNewResourceRef();
+        GerResourceRefType ref = jettyWebAppType.addNewResourceRef();
         ref.setRefName("ref");
         ref.setTargetName("target");
 

Modified: geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java
==============================================================================
--- geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java	(original)
+++ geronimo/trunk/modules/mail/src/java/org/apache/geronimo/mail/MailGBean.java	Wed Oct 27 18:51:13 2004
@@ -67,7 +67,7 @@
         this.authenticator = authenticator;
     }
 
-    public Object getProxy() {
+    public Object $getResource() {
         if (useDefault) {
             if (authenticator == null) {
                 return Session.getDefaultInstance(properties);
@@ -107,7 +107,7 @@
         infoFactory.addAttribute("useDefault", Boolean.TYPE, true);
         infoFactory.addAttribute("properties", Properties.class, true);
         infoFactory.addReference("Authenticator", Authenticator.class);
-        infoFactory.addOperation("getProxy");
+        infoFactory.addOperation("$getResource");
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java
==============================================================================
--- geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java	(original)
+++ geronimo/trunk/modules/mail/src/test/org/apache/geronimo/mail/MailGBeanTest.java	Wed Oct 27 18:51:13 2004
@@ -37,7 +37,7 @@
     private static final String KERNEL_NAME = "testKernel";
 
     public void testProxy() throws Exception {
-        Object proxy = kernel.invoke(mailName, "getProxy");
+        Object proxy = kernel.invoke(mailName, "$getResource");
 
         assertNotNull(proxy);
         assertTrue(proxy instanceof Session);
@@ -55,7 +55,7 @@
         GBeanMBean cmf = new GBeanMBean(MailGBean.getGBeanInfo());
         cmf.setAttribute("useDefault", new Boolean(true));
         cmf.setAttribute("properties", new Properties());
-        mailName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEType=JavaMailResource,name=default");
+        mailName = ObjectName.getInstance("geronimo.server:J2EEServer=geronimo,J2EEApplication=null,J2EEType=JavaMailResource,name=default");
         kernel.loadGBean(mailName, cmf);
 
         kernel.startGBean(mailName);

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java	(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java	Wed Oct 27 18:51:13 2004
@@ -17,20 +17,29 @@
 
 package org.apache.geronimo.naming.deployment;
 
+import java.net.MalformedURLException;
 import java.net.URI;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import javax.naming.NamingException;
 import javax.naming.Reference;
 import javax.transaction.UserTransaction;
 
 import org.apache.geronimo.deployment.DeploymentException;
 import org.apache.geronimo.j2ee.deployment.EARContext;
-import org.apache.geronimo.j2ee.deployment.EJBRefContext;
+import org.apache.geronimo.j2ee.deployment.RefContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.naming.java.ComponentContextBuilder;
 import org.apache.geronimo.naming.java.ReadOnlyContext;
-import org.apache.geronimo.naming.jmx.JMXReferenceFactory;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerRemoteRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 import org.apache.geronimo.xbeans.j2ee.EjbLocalRefType;
 import org.apache.geronimo.xbeans.j2ee.EjbRefType;
 import org.apache.geronimo.xbeans.j2ee.EnvEntryType;
@@ -39,11 +48,8 @@
 import org.apache.geronimo.xbeans.j2ee.ResourceRefType;
 
 /**
- *
- *
  * @version $Rev$ $Date$
- *
- * */
+ */
 public class ENCConfigBuilder {
 
     public static void addEnvEntries(EnvEntryType[] envEntries, ComponentContextBuilder builder) throws DeploymentException {
@@ -63,31 +69,82 @@
 
     }
 
-    public static void addResourceRefs(ResourceRefType[] resourceRefs, ClassLoader cl, Map refAdapterMap, ComponentContextBuilder builder) throws DeploymentException {
+    public static void addResourceRefs(EARContext earContext, URI uri, ResourceRefType[] resourceRefs, Map refMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
+        if (refMap == null) {
+            refMap = Collections.EMPTY_MAP;
+        }
+        RefContext refContext = earContext.getRefContext();
+        J2eeContext j2eeContext = earContext.getJ2eeContext();
+
         for (int i = 0; i < resourceRefs.length; i++) {
             ResourceRefType resourceRef = resourceRefs[i];
             String name = resourceRef.getResRefName().getStringValue();
             String type = resourceRef.getResType().getStringValue();
+            GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(name);
             Class iface = null;
             try {
                 iface = cl.loadClass(type);
             } catch (ClassNotFoundException e) {
                 throw new DeploymentException("could not load class " + type, e);
             }
-            GerLocalRefType localRef = (GerLocalRefType) refAdapterMap.get(name);
-            if (localRef == null) {
-                throw  new DeploymentException("No geronimo configuration for resource ref named: " + name);
-            }
-            try {
-                builder.addResourceRef(name, iface, localRef);
-            } catch (NamingException e) {
-                throw new DeploymentException("Invalid resource-ref definition for name: " + name, e);
+            Reference ref = null;
+            if (iface == URL.class) {
+                if (gerResourceRef == null || !gerResourceRef.isSetUrl()) {
+                    throw new DeploymentException("No url supplied to resolve: " + name);
+                }
+                try {
+                    //TODO expose jsr-77 objects for these guys
+                    builder.bind(name, new URL(gerResourceRef.getUrl()));
+                } catch (MalformedURLException e) {
+                    throw  new DeploymentException("Could not convert " + gerResourceRef.getUrl() + " to URL", e);
+                } catch (NamingException e) {
+                    throw  new DeploymentException("Could not bind " + name, e);
+                }
+            } else {
+                String containerId = getResourceContainerId(name, uri, gerResourceRef, refContext, j2eeContext);
+
+                ref = refContext.getConnectionFactoryRef(containerId, iface);
+                try {
+                    builder.bind(name, ref);
+                } catch (NamingException e) {
+                    throw new DeploymentException("Invalid resource-ref definition for name: " + name, e);
+                }
             }
         }
 
     }
 
-    public static void addResourceEnvRefs(ResourceEnvRefType[] resourceEnvRefArray, ClassLoader cl, Map refAdapterMap, ComponentContextBuilder builder) throws DeploymentException {
+    private static String getResourceContainerId(String name, URI uri, GerResourceRefType gerResourceRef, RefContext refContext, J2eeContext j2eeContext) throws DeploymentException {
+        String containerId = null;
+        if (gerResourceRef == null) {
+            //try to resolve ref based only matching resource-ref-name
+            //throws exception if it can't locate ref.
+            containerId = refContext.getConnectionFactoryContainerId(uri, name, j2eeContext);
+        } else if (gerResourceRef.isSetResourceLink()) {
+            containerId = refContext.getConnectionFactoryContainerId(uri, gerResourceRef.getResourceLink(), j2eeContext);
+        } else if (gerResourceRef.isSetTargetName()) {
+            containerId = gerResourceRef.getTargetName();
+        } else {
+            //construct name from components
+            containerId = NameFactory.getResourceComponentNameString(gerResourceRef.getDomain(),
+                    gerResourceRef.getServer(),
+                    gerResourceRef.getApplication(),
+                    gerResourceRef.getModule(),
+                    gerResourceRef.getName(),
+                    //todo determine type from iface class
+                    gerResourceRef.getType() == null ? NameFactory.JCA_MANAGED_CONNECTION_FACTORY : gerResourceRef.getType(),
+                    j2eeContext);
+        }
+        return containerId;
+    }
+
+    public static void addResourceEnvRefs(EARContext earContext, URI uri, ResourceEnvRefType[] resourceEnvRefArray, Map refMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
+        if (refMap == null) {
+            refMap = Collections.EMPTY_MAP;
+        }
+        RefContext refContext = earContext.getRefContext();
+        J2eeContext j2eeContext = earContext.getJ2eeContext();
+
         for (int i = 0; i < resourceEnvRefArray.length; i++) {
             ResourceEnvRefType resourceEnvRef = resourceEnvRefArray[i];
             String name = resourceEnvRef.getResourceEnvRefName().getStringValue();
@@ -98,19 +155,44 @@
             } catch (ClassNotFoundException e) {
                 throw new DeploymentException("could not load class " + type, e);
             }
-            GerLocalRefType localRef = (GerLocalRefType) refAdapterMap.get(name);
-            if (localRef == null) {
-                throw  new DeploymentException("No geronimo configuration for resource env ref named: " + name);
-            }
+            GerResourceEnvRefType gerResourceEnvRef = (GerResourceEnvRefType) refMap.get(name);
+            String containerId = getAdminObjectContainerId(name, uri, gerResourceEnvRef, refContext, j2eeContext);
+            Reference ref = refContext.getAdminObjectRef(containerId, iface);
+
             try {
-                builder.addResourceEnvRef(name, iface, localRef);
+                builder.bind(name, ref);
             } catch (NamingException e) {
-                throw new DeploymentException("Invalid resource-env-ref definition for name: " + name, e);
+                throw new DeploymentException("Invalid resource-ref definition for name: " + name, e);
             }
         }
     }
 
-    public static void addMessageDestinationRefs(MessageDestinationRefType[] messageDestinationRefs, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
+    private static String getAdminObjectContainerId(String name, URI uri, GerResourceEnvRefType gerResourceEnvRef, RefContext refContext, J2eeContext j2eeContext) throws DeploymentException {
+        String containerId = null;
+        if (gerResourceEnvRef == null) {
+            //try to resolve ref based only matching resource-ref-name
+            //throws exception if it can't locate ref.
+            containerId = refContext.getAdminObjectContainerId(uri, name, j2eeContext);
+        } else if (gerResourceEnvRef.isSetMessageDestinationLink()) {
+            containerId = refContext.getAdminObjectContainerId(uri, gerResourceEnvRef.getMessageDestinationLink(), j2eeContext);
+        } else if (gerResourceEnvRef.isSetTargetName()) {
+            containerId = gerResourceEnvRef.getTargetName();
+        } else {
+            //construct name from components
+            containerId = NameFactory.getResourceComponentNameString(gerResourceEnvRef.getDomain(),
+                    gerResourceEnvRef.getServer(),
+                    gerResourceEnvRef.getApplication(),
+                    gerResourceEnvRef.getModule(),
+                    gerResourceEnvRef.getName(),
+                    NameFactory.JMS_RESOURCE,
+                    //gerResourceEnvRef.getType(),
+                    j2eeContext);
+        }
+        return containerId;
+    }
+
+    public static void addMessageDestinationRefs(EARContext earContext, URI uri, MessageDestinationRefType[] messageDestinationRefs, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
+        RefContext refContext = earContext.getRefContext();
         for (int i = 0; i < messageDestinationRefs.length; i++) {
             MessageDestinationRefType messageDestinationRef = messageDestinationRefs[i];
             String name = messageDestinationRef.getMessageDestinationRefName().getStringValue();
@@ -122,8 +204,12 @@
             } catch (ClassNotFoundException e) {
                 throw new DeploymentException("could not load class " + type, e);
             }
+            //try to resolve ref based only matching resource-ref-name
+            //throws exception if it can't locate ref.
+            String containerId = refContext.getAdminObjectContainerId(uri, linkName, earContext.getJ2eeContext());
+            Reference ref = refContext.getAdminObjectRef(containerId, iface);
             try {
-                builder.addMessageDestinationRef(name, linkName, iface);
+                builder.bind(name, ref);
             } catch (NamingException e) {
                 throw new DeploymentException("Invalid message-destination-ref definition for name: " + name, e);
             }
@@ -133,7 +219,8 @@
     }
 
     public static void addEJBRefs(EARContext earContext, URI uri, EjbRefType[] ejbRefs, Map ejbRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        EJBRefContext ejbRefContext = earContext.getEJBRefContext();
+        RefContext refContext = earContext.getRefContext();
+        J2eeContext j2eeContext = earContext.getJ2eeContext();
         for (int i = 0; i < ejbRefs.length; i++) {
             EjbRefType ejbRef = ejbRefs[i];
 
@@ -148,7 +235,7 @@
             boolean isSession = "Session".equals(ejbRef.getEjbRefType().getStringValue());
 
             String ejbLink = null;
-            GerRemoteRefType remoteRef = (GerRemoteRefType) ejbRefMap.get(ejbRefName);
+            GerEjbRefType remoteRef = (GerEjbRefType) ejbRefMap.get(ejbRefName);
             if (remoteRef != null && remoteRef.isSetEjbLink()) {
                 ejbLink = remoteRef.getEjbLink();
             } else if (ejbRef.isSetEjbLink()) {
@@ -157,11 +244,23 @@
 
             Reference ejbReference;
             if (ejbLink != null) {
-                ejbReference = ejbRefContext.getEJBRemoteRef(uri, ejbLink, isSession, home, remote);
+                ejbReference = refContext.getEJBRemoteRef(uri, ejbLink, isSession, home, remote);
             } else if (remoteRef != null) {
-                ejbReference = ejbRefContext.getEJBRemoteRef(remoteRef.getTargetName(), isSession, home, remote);
+                if (remoteRef.isSetTargetName()) {
+                    ejbReference = refContext.getEJBRemoteRef(remoteRef.getTargetName(), isSession, home, remote);
+                } else {
+                    String containerId = NameFactory.getEjbComponentNameString(remoteRef.getDomain(),
+                            remoteRef.getServer(),
+                            remoteRef.getApplication(),
+                            remoteRef.getModule(),
+                            remoteRef.getName(),
+                            remoteRef.getType(),
+                            j2eeContext);
+                    ejbReference = refContext.getEJBRemoteRef(containerId, isSession, home, remote);
+
+                }
             } else {
-                ejbReference = ejbRefContext.getImplicitEJBRemoteRef(uri, ejbRefName, isSession, home, remote);
+                ejbReference = refContext.getImplicitEJBRemoteRef(uri, ejbRefName, isSession, home, remote);
             }
             try {
                 builder.bind(ejbRefName, ejbReference);
@@ -172,7 +271,8 @@
     }
 
     public static void addEJBLocalRefs(EARContext earContext, URI uri, EjbLocalRefType[] ejbLocalRefs, Map ejbLocalRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        EJBRefContext ejbRefContext = earContext.getEJBRefContext();
+        RefContext refContext = earContext.getRefContext();
+        J2eeContext j2eeContext = earContext.getJ2eeContext();
         for (int i = 0; i < ejbLocalRefs.length; i++) {
             EjbLocalRefType ejbLocalRef = ejbLocalRefs[i];
 
@@ -187,7 +287,7 @@
             boolean isSession = "Session".equals(ejbLocalRef.getEjbRefType().getStringValue());
 
             String ejbLink = null;
-            GerLocalRefType localRef = (GerLocalRefType) ejbLocalRefMap.get(ejbRefName);
+            GerEjbLocalRefType localRef = (GerEjbLocalRefType) ejbLocalRefMap.get(ejbRefName);
             if (localRef != null && localRef.isSetEjbLink()) {
                 ejbLink = localRef.getEjbLink();
             } else if (ejbLocalRef.isSetEjbLink()) {
@@ -196,11 +296,23 @@
 
             Reference ejbReference;
             if (ejbLink != null) {
-                ejbReference = ejbRefContext.getEJBLocalRef(uri, ejbLink, isSession, localHome, local);
+                ejbReference = refContext.getEJBLocalRef(uri, ejbLink, isSession, localHome, local);
             } else if (localRef != null) {
-                ejbReference = ejbRefContext.getEJBLocalRef(localRef.getTargetName(), isSession, localHome, local);
+                if (localRef.isSetTargetName()) {
+                    ejbReference = refContext.getEJBLocalRef(localRef.getTargetName(), isSession, localHome, local);
+                } else {
+                    String containerId = NameFactory.getEjbComponentNameString(localRef.getDomain(),
+                            localRef.getServer(),
+                            localRef.getApplication(),
+                            localRef.getModule(),
+                            localRef.getName(),
+                            localRef.getType(),
+                            j2eeContext);
+                    ejbReference = refContext.getEJBLocalRef(containerId, isSession, localHome, local);
+
+                }
             } else {
-                ejbReference = ejbRefContext.getImplicitEJBLocalRef(uri, ejbLink, isSession, localHome, local);
+                ejbReference = refContext.getImplicitEJBLocalRef(uri, ejbLink, isSession, localHome, local);
             }
             try {
                 builder.bind(ejbRefName, ejbReference);
@@ -251,11 +363,33 @@
         if (string == null) {
             return null;
         }
-        return string.getStringValue();
+        return string.getStringValue().trim();
     }
 
-    public static ReadOnlyContext buildComponentContext(EARContext earContext, URI uri, UserTransaction userTransaction, EnvEntryType[] envEntries, EjbRefType[] ejbRefs, Map ejbRefMap, EjbLocalRefType[] ejbLocalRefs, Map ejbLocalRefMap, ResourceRefType[] resourceRefs, Map resourceRefMap, ResourceEnvRefType[] resourceEnvRefs, Map resourceEnvRefMap, MessageDestinationRefType[] messageDestinationRefs, ClassLoader cl) throws DeploymentException {
-        ComponentContextBuilder builder = new ComponentContextBuilder(new JMXReferenceFactory(earContext.getJ2EEDomainName(), earContext.getJ2EEServerName()));
+
+    public static void setResourceEnvironment(EARContext earContext, URI uri, ResourceEnvironmentBuilder builder, ResourceRefType[] resourceRefs, GerResourceRefType[] gerResourceRefs) throws DeploymentException {
+        RefContext refContext = earContext.getRefContext();
+        J2eeContext j2eeContext = earContext.getJ2eeContext();
+        Map refMap = mapResourceRefs(gerResourceRefs);
+        Set unshareableResources = new HashSet();
+        Set applicationManagedSecurityResources = new HashSet();
+        for (int i = 0; i < resourceRefs.length; i++) {
+            ResourceRefType resourceRefType = resourceRefs[i];
+            GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(resourceRefType.getResRefName().getStringValue());
+            String containerId = getResourceContainerId(getJ2eeStringValue(resourceRefType.getResRefName()), uri, gerResourceRef, refContext, j2eeContext);
+            if ("Unshareable".equals(getJ2eeStringValue(resourceRefType.getResSharingScope()))) {
+                unshareableResources.add(containerId);
+            }
+            if ("Application".equals(getJ2eeStringValue(resourceRefType.getResAuth()))) {
+                applicationManagedSecurityResources.add(containerId);
+            }
+        }
+        builder.setUnshareableResources(unshareableResources);
+        builder.setApplicationManagedSecurityResources(applicationManagedSecurityResources);
+    }
+
+    public static ReadOnlyContext buildComponentContext(EARContext earContext, URI uri, UserTransaction userTransaction, EnvEntryType[] envEntries, EjbRefType[] ejbRefs, GerEjbRefType[] gerEjbRefs, EjbLocalRefType[] ejbLocalRefs, GerEjbLocalRefType[] gerEjbLocalRef, ResourceRefType[] resourceRefs, GerResourceRefType[] gerResourceRef, ResourceEnvRefType[] resourceEnvRefs, GerResourceEnvRefType[] gerResourceEnvRef, MessageDestinationRefType[] messageDestinationRefs, ClassLoader cl) throws DeploymentException {
+        ComponentContextBuilder builder = new ComponentContextBuilder();
 
         if (userTransaction != null) {
             try {
@@ -268,23 +402,65 @@
         addEnvEntries(envEntries, builder);
 
         // ejb-ref
-        addEJBRefs(earContext, uri, ejbRefs, ejbRefMap, cl, builder);
+        addEJBRefs(earContext, uri, ejbRefs, mapEjbRefs(gerEjbRefs), cl, builder);
 
         // ejb-local-ref
-        addEJBLocalRefs(earContext, uri, ejbLocalRefs, ejbLocalRefMap, cl, builder);
+        addEJBLocalRefs(earContext, uri, ejbLocalRefs, mapEjbLocalRefs(gerEjbLocalRef), cl, builder);
 
         // resource-ref
-        if (!resourceRefMap.isEmpty()) {
-            addResourceRefs(resourceRefs, cl, resourceRefMap, builder);
-        }
+        addResourceRefs(earContext, uri, resourceRefs, mapResourceRefs(gerResourceRef), cl, builder);
 
         // resource-env-ref
-        if (!resourceEnvRefMap.isEmpty()) {
-            addResourceEnvRefs(resourceEnvRefs, cl, resourceEnvRefMap, builder);
-        }
+        addResourceEnvRefs(earContext, uri, resourceEnvRefs, mapResourceEnvRefs(gerResourceEnvRef), cl, builder);
 
-        addMessageDestinationRefs(messageDestinationRefs, cl, builder);
+        addMessageDestinationRefs(earContext, uri, messageDestinationRefs, cl, builder);
 
         return builder.getContext();
     }
+
+    private static Map mapEjbRefs(GerEjbRefType[] refs) {
+        Map refMap = new HashMap();
+        if (refs != null) {
+            for (int i = 0; i < refs.length; i++) {
+                GerEjbRefType ref = refs[i];
+                refMap.put(ref.getRefName(), ref);
+            }
+        }
+        return refMap;
+    }
+
+    private static Map mapEjbLocalRefs(GerEjbLocalRefType[] refs) {
+        Map refMap = new HashMap();
+        if (refs != null) {
+            for (int i = 0; i < refs.length; i++) {
+                GerEjbLocalRefType ref = refs[i];
+                refMap.put(ref.getRefName(), ref);
+            }
+        }
+        return refMap;
+    }
+
+    private static Map mapResourceRefs(GerResourceRefType[] refs) {
+        Map refMap = new HashMap();
+        if (refs != null) {
+            for (int i = 0; i < refs.length; i++) {
+                GerResourceRefType ref = refs[i];
+                refMap.put(ref.getRefName(), ref);
+            }
+        }
+        return refMap;
+    }
+
+    private static Map mapResourceEnvRefs(GerResourceEnvRefType[] refs) {
+        Map refMap = new HashMap();
+        if (refs != null) {
+            for (int i = 0; i < refs.length; i++) {
+                GerResourceEnvRefType ref = refs[i];
+                refMap.put(ref.getRefName(), ref);
+            }
+        }
+        return refMap;
+    }
+
+
 }

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCHelper.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCHelper.java	(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ENCHelper.java	Wed Oct 27 18:51:13 2004
@@ -24,14 +24,14 @@
 import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
 import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
 
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerRemoteRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 import org.apache.xmlbeans.SchemaTypeLoader;
 import org.apache.xmlbeans.XmlBeans;
 
 /**
- *
- *
  * @version $Rev$ $Date$
  */
 public class ENCHelper {
@@ -72,105 +72,105 @@
             ddEjbRefs = new DDBean[0];
         }
         ejbRefs = new RemoteRefDConfigBean[ddEjbRefs.length];
-        GerRemoteRefType[] xmlEjbRefs = envRefs.getEjbRefs();
+        GerEjbRefType[] xmlEjbRefs = envRefs.getEjbRefs();
         Map ejbRefMap = new HashMap();
         for (int i = 0; i < xmlEjbRefs.length; i++) {
-            GerRemoteRefType refAdapter = xmlEjbRefs[i];
+            GerEjbRefType refAdapter = xmlEjbRefs[i];
             ejbRefMap.put(refAdapter.getRefName(), refAdapter);
-            envRefs.removeEjbRef(0);
-        }
-        for (int i = 0; i < ddEjbRefs.length; i++) {
-            DDBean ddRef = ddEjbRefs[i];
-            String name = ddRef.getText(namePaths[0])[0];
-            GerRemoteRefType refAdapter;
-            if (ejbRefMap.get(name) == null) {
-                refAdapter = envRefs.addNewEjbRef();
-                refAdapter.setRefName(name);
-            } else {
-                refAdapter = (GerRemoteRefType) ejbRefMap.get(name);
-                envRefs.setEjbRef(i, refAdapter);
-            }
-            ejbRefs[i] = new RemoteRefDConfigBean(ddRef, refAdapter, namePaths[0]);
-        }
-
-        DDBean[] ddEjbLocalRefs = ddBean.getChildBean(xpaths[1]);
-        if (ddEjbLocalRefs == null) {
-            ddEjbLocalRefs = new DDBean[0];
-        }
-        ejbLocalRefs = new LocalRefDConfigBean[ddEjbLocalRefs.length];
-        GerLocalRefType[] xmlEjbLocalRefs = envRefs.getEjbLocalRefs();
-        Map ejbLocalRefMap = new HashMap();
-        for (int i = 0; i < xmlEjbLocalRefs.length; i++) {
-            GerLocalRefType refAdapter = xmlEjbLocalRefs[i];
-            ejbLocalRefMap.put(refAdapter.getRefName(), refAdapter);
-            envRefs.removeEjbLocalRef(0);
-        }
-        for (int i = 0; i < ddEjbLocalRefs.length; i++) {
-            DDBean ddRef = ddEjbLocalRefs[i];
-            String name = ddRef.getText(namePaths[1])[0];
-            GerLocalRefType refAdapter;
-            if (ejbLocalRefMap.get(name) == null) {
-                refAdapter = envRefs.addNewEjbLocalRef();
-                refAdapter.setRefName(name);
-            } else {
-                refAdapter = (GerLocalRefType) ejbLocalRefMap.get(name);
-                envRefs.setEjbLocalRef(i, refAdapter);
-            }
-            ejbLocalRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[1]);
-        }
-
-
-        DDBean[] ddResourceEnvRefs = ddBean.getChildBean(xpaths[2]);
-        if (ddResourceEnvRefs == null) {
-            ddResourceEnvRefs = new DDBean[0];
-        }
-        resourceEnvRefs = new LocalRefDConfigBean[ddResourceEnvRefs.length];
-        GerLocalRefType[] xmlResourceEnvRefs = envRefs.getResourceEnvRefs();
-        Map resourceEnvRefMap = new HashMap();
-        for (int i = 0; i < xmlResourceEnvRefs.length; i++) {
-            GerLocalRefType refAdapter = xmlResourceEnvRefs[i];
-            resourceEnvRefMap.put(refAdapter.getRefName(), refAdapter);
-            envRefs.removeResourceEnvRef(0);
-        }
-        for (int i = 0; i < ddResourceEnvRefs.length; i++) {
-            DDBean ddRef = ddResourceEnvRefs[i];
-            String name = ddRef.getText(namePaths[2])[0];
-            GerLocalRefType refAdapter;
-            if (resourceEnvRefMap.get(name) == null) {
-                refAdapter = envRefs.addNewResourceEnvRef();
-                refAdapter.setRefName(name);
-            } else {
-                refAdapter = (GerLocalRefType) resourceEnvRefMap.get(name);
-                envRefs.setResourceEnvRef(i, refAdapter);
-            }
-            resourceEnvRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[2]);
-        }
-
-        DDBean[] ddResourceRefs = ddBean.getChildBean(xpaths[3]);
-        if (ddResourceRefs == null) {
-            ddResourceRefs = new DDBean[0];
-        }
-        resourceRefs = new LocalRefDConfigBean[ddResourceRefs.length];
-        GerLocalRefType[] xmlResourceRefs = envRefs.getResourceRefs();
-        Map resourceRefMap = new HashMap();
-        for (int i = 0; i < xmlResourceRefs.length; i++) {
-            GerLocalRefType refAdapter = xmlResourceRefs[i];
-            resourceRefMap.put(refAdapter.getRefName(), refAdapter);
-            envRefs.removeResourceRef(0);
-        }
-        for (int i = 0; i < ddResourceRefs.length; i++) {
-            DDBean ddRef = ddResourceRefs[i];
-            String name = ddRef.getText(namePaths[3])[0];
-            GerLocalRefType refAdapter;
-            if (resourceRefMap.get(name) == null) {
-                refAdapter = envRefs.addNewResourceRef();
-                refAdapter.setRefName(name);
-            } else {
-                refAdapter = (GerLocalRefType) resourceRefMap.get(name);
-                envRefs.setResourceRef(i, refAdapter);
-            }
-            resourceRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[3]);
+//            envRefs.removeEjbRef(0);
         }
+//        for (int i = 0; i < ddEjbRefs.length; i++) {
+//            DDBean ddRef = ddEjbRefs[i];
+//            String name = ddRef.getText(namePaths[0])[0];
+//            GerRemoteRefType refAdapter;
+//            if (ejbRefMap.get(name) == null) {
+//                refAdapter = envRefs.addNewEjbRef();
+//                refAdapter.setRefName(name);
+//            } else {
+//                refAdapter = (GerRemoteRefType) ejbRefMap.get(name);
+//                envRefs.setEjbRef(i, refAdapter);
+//            }
+//            ejbRefs[i] = new RemoteRefDConfigBean(ddRef, refAdapter, namePaths[0]);
+//        }
+//
+//        DDBean[] ddEjbLocalRefs = ddBean.getChildBean(xpaths[1]);
+//        if (ddEjbLocalRefs == null) {
+//            ddEjbLocalRefs = new DDBean[0];
+//        }
+//        ejbLocalRefs = new LocalRefDConfigBean[ddEjbLocalRefs.length];
+//        GerLocalRefType[] xmlEjbLocalRefs = envRefs.getEjbLocalRefs();
+//        Map ejbLocalRefMap = new HashMap();
+//        for (int i = 0; i < xmlEjbLocalRefs.length; i++) {
+//            GerLocalRefType refAdapter = xmlEjbLocalRefs[i];
+//            ejbLocalRefMap.put(refAdapter.getRefName(), refAdapter);
+//            envRefs.removeEjbLocalRef(0);
+//        }
+//        for (int i = 0; i < ddEjbLocalRefs.length; i++) {
+//            DDBean ddRef = ddEjbLocalRefs[i];
+//            String name = ddRef.getText(namePaths[1])[0];
+//            GerLocalRefType refAdapter;
+//            if (ejbLocalRefMap.get(name) == null) {
+//                refAdapter = envRefs.addNewEjbLocalRef();
+//                refAdapter.setRefName(name);
+//            } else {
+//                refAdapter = (GerLocalRefType) ejbLocalRefMap.get(name);
+//                envRefs.setEjbLocalRef(i, refAdapter);
+//            }
+//            ejbLocalRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[1]);
+//        }
+//
+//
+//        DDBean[] ddResourceEnvRefs = ddBean.getChildBean(xpaths[2]);
+//        if (ddResourceEnvRefs == null) {
+//            ddResourceEnvRefs = new DDBean[0];
+//        }
+//        resourceEnvRefs = new LocalRefDConfigBean[ddResourceEnvRefs.length];
+//        GerLocalRefType[] xmlResourceEnvRefs = envRefs.getResourceEnvRefs();
+//        Map resourceEnvRefMap = new HashMap();
+//        for (int i = 0; i < xmlResourceEnvRefs.length; i++) {
+//            GerLocalRefType refAdapter = xmlResourceEnvRefs[i];
+//            resourceEnvRefMap.put(refAdapter.getRefName(), refAdapter);
+//            envRefs.removeResourceEnvRef(0);
+//        }
+//        for (int i = 0; i < ddResourceEnvRefs.length; i++) {
+//            DDBean ddRef = ddResourceEnvRefs[i];
+//            String name = ddRef.getText(namePaths[2])[0];
+//            GerLocalRefType refAdapter;
+//            if (resourceEnvRefMap.get(name) == null) {
+//                refAdapter = envRefs.addNewResourceEnvRef();
+//                refAdapter.setRefName(name);
+//            } else {
+//                refAdapter = (GerLocalRefType) resourceEnvRefMap.get(name);
+//                envRefs.setResourceEnvRef(i, refAdapter);
+//            }
+//            resourceEnvRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[2]);
+//        }
+//
+//        DDBean[] ddResourceRefs = ddBean.getChildBean(xpaths[3]);
+//        if (ddResourceRefs == null) {
+//            ddResourceRefs = new DDBean[0];
+//        }
+//        resourceRefs = new LocalRefDConfigBean[ddResourceRefs.length];
+//        GerLocalRefType[] xmlResourceRefs = envRefs.getResourceRefs();
+//        Map resourceRefMap = new HashMap();
+//        for (int i = 0; i < xmlResourceRefs.length; i++) {
+//            GerLocalRefType refAdapter = xmlResourceRefs[i];
+//            resourceRefMap.put(refAdapter.getRefName(), refAdapter);
+//            envRefs.removeResourceRef(0);
+//        }
+//        for (int i = 0; i < ddResourceRefs.length; i++) {
+//            DDBean ddRef = ddResourceRefs[i];
+//            String name = ddRef.getText(namePaths[3])[0];
+//            GerLocalRefType refAdapter;
+//            if (resourceRefMap.get(name) == null) {
+//                refAdapter = envRefs.addNewResourceRef();
+//                refAdapter.setRefName(name);
+//            } else {
+//                refAdapter = (GerLocalRefType) resourceRefMap.get(name);
+//                envRefs.setResourceRef(i, refAdapter);
+//            }
+//            resourceRefs[i] = new LocalRefDConfigBean(ddRef, refAdapter, namePaths[3]);
+//        }
 
     }
 
@@ -217,66 +217,62 @@
         }
     }
 
-      public void removeDConfigBean(DConfigBean dcBean) throws BeanNotFoundException {
+    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);
+        /*
+              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);
               }
-          } 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 {
-        GerRemoteRefType[] getEjbRefs();
-
-        GerRemoteRefType addNewEjbRef();
-
-        GerRemoteRefType setEjbRef(int i, GerRemoteRefType refAdapter);
-
-        void removeEjbRef(int i);
-
-        GerLocalRefType[] getEjbLocalRefs();
-
-        GerLocalRefType addNewEjbLocalRef();
-
-        GerLocalRefType setEjbLocalRef(int i, GerLocalRefType refAdapter);
-
-        void removeEjbLocalRef(int i);
-
-        GerLocalRefType[] getResourceEnvRefs();
+              */
+    }
 
-        GerLocalRefType addNewResourceEnvRef();
 
-        GerLocalRefType setResourceEnvRef(int i, GerLocalRefType refAdapter);
+    public static class XmlEnvRefs {
+        private final GerEjbRefType[] ejbRefs;
+        private final GerEjbLocalRefType[] ejbLocalRefs;
+        private final GerResourceRefType[] resourceRefs;
+        private final GerResourceEnvRefType[] resourceEnvRefs;
 
-        void removeResourceEnvRef(int i);
+        public XmlEnvRefs(GerEjbRefType[] ejbRefs, GerEjbLocalRefType[] ejbLocalRefs, GerResourceRefType[] resourceRefs, GerResourceEnvRefType[] resourceEnvRefs) {
+            this.ejbRefs = ejbRefs;
+            this.ejbLocalRefs = ejbLocalRefs;
+            this.resourceRefs = resourceRefs;
+            this.resourceEnvRefs = resourceEnvRefs;
+        }
 
-        GerLocalRefType[] getResourceRefs();
+        public GerEjbRefType[] getEjbRefs() {
+            return ejbRefs;
+        }
 
-        GerLocalRefType addNewResourceRef();
+        public GerEjbLocalRefType[] getEjbLocalRefs() {
+            return ejbLocalRefs;
+        }
 
-        GerLocalRefType setResourceRef(int i, GerLocalRefType refAdapter);
+        public GerResourceRefType[] getResourceRefs() {
+            return resourceRefs;
+        }
 
-        void removeResourceRef(int i);
+        public GerResourceEnvRefType[] getResourceEnvRefs() {
+            return resourceEnvRefs;
+        }
 
     }
 }

Added: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/GBeanResourceEnvironmentBuilder.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/GBeanResourceEnvironmentBuilder.java	Wed Oct 27 18:51:13 2004
@@ -0,0 +1,61 @@
+package org.apache.geronimo.naming.deployment;
+
+import java.util.Set;
+
+import javax.management.ReflectionException;
+import javax.management.AttributeNotFoundException;
+import javax.management.Attribute;
+
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+
+/**
+ */
+public class GBeanResourceEnvironmentBuilder implements ResourceEnvironmentBuilder {
+
+    private final GBeanMBean gbean;
+
+    public GBeanResourceEnvironmentBuilder(GBeanMBean gbean) {
+        this.gbean = gbean;
+    }
+
+    public Set getUnshareableResources() {
+        try {
+            return (Set)gbean.getAttribute("unshareableResources");
+        } catch (ReflectionException e) {
+            throw (IllegalStateException)new IllegalStateException().initCause(e);
+        } catch (AttributeNotFoundException e) {
+            throw (IllegalStateException)new IllegalStateException().initCause(e);
+        }
+    }
+
+    public void setUnshareableResources(Set unshareableResources) {
+        try {
+            gbean.setAttribute(new Attribute("unshareableResources", unshareableResources));
+         } catch (ReflectionException e) {
+             throw (IllegalStateException)new IllegalStateException().initCause(e);
+         } catch (AttributeNotFoundException e) {
+             throw (IllegalStateException)new IllegalStateException().initCause(e);
+         }
+
+    }
+
+    public Set getApplicationManagedSecurityResources() {
+        try {
+             return (Set)gbean.getAttribute("applicationManagedSecurityResources");
+         } catch (ReflectionException e) {
+             throw (IllegalStateException)new IllegalStateException().initCause(e);
+         } catch (AttributeNotFoundException e) {
+             throw (IllegalStateException)new IllegalStateException().initCause(e);
+         }
+    }
+
+    public void setApplicationManagedSecurityResources(Set applicationManagedSecurityResources) {
+        try {
+             gbean.setAttribute(new Attribute("applicationManagedSecurityResources", applicationManagedSecurityResources));
+         } catch (ReflectionException e) {
+             throw (IllegalStateException)new IllegalStateException().initCause(e);
+         } catch (AttributeNotFoundException e) {
+             throw (IllegalStateException)new IllegalStateException().initCause(e);
+         }
+    }
+}

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/LocalRefDConfigBean.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/LocalRefDConfigBean.java	(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/LocalRefDConfigBean.java	Wed Oct 27 18:51:13 2004
@@ -20,9 +20,9 @@
 import javax.enterprise.deploy.model.DDBean;
 
 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
 
 import org.apache.xmlbeans.SchemaTypeLoader;
+import org.apache.xmlbeans.XmlObject;
 
 /**
  *
@@ -31,9 +31,9 @@
  */
 public class LocalRefDConfigBean extends DConfigBeanSupport {
 
-    protected final GerLocalRefType ref;
+    protected final XmlObject ref;
 
-    public LocalRefDConfigBean(DDBean ddBean, GerLocalRefType ref, String namePath) {
+    public LocalRefDConfigBean(DDBean ddBean, XmlObject ref, String namePath) {
         super(ddBean, ref);
         this.ref = ref;
 
@@ -41,32 +41,36 @@
     }
 
     String getRefName() {
-        return ref.getRefName();
+//        return ref.getRefName();
+        return null;
     }
 
     public String getExternalUri() {
-        return ref.getExternalUri();
+        return null;
+//        return ref.getExternalUri();
     }
 
     public void setExternalUri(String targetURI) {
-        ref.setExternalUri(targetURI);
+//        ref.setExternalUri(targetURI);
     }
 
 
     public String getKernelName() {
-        return ref.getKernelName();
+        return null;
+//        return ref.getKernelName();
     }
 
     public void setKernelName(String kernelName) {
-        ref.setKernelName(kernelName);
+//        ref.setKernelName(kernelName);
     }
 
     public String getTargetName() {
-        return ref.getTargetName();
+        return null;
+//        return ref.getTargetName();
     }
 
     public void setTargetName(String targetName) {
-        ref.setTargetName(targetName);
+//        ref.setTargetName(targetName);
     }
 
     protected SchemaTypeLoader getSchemaTypeLoader() {

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/RemoteRefDConfigBean.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/RemoteRefDConfigBean.java	(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/RemoteRefDConfigBean.java	Wed Oct 27 18:51:13 2004
@@ -19,10 +19,9 @@
 
 import javax.enterprise.deploy.model.DDBean;
 
-import org.apache.xmlbeans.SchemaTypeLoader;
-
-import org.apache.geronimo.xbeans.geronimo.naming.GerRemoteRefType;
 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
+import org.apache.xmlbeans.SchemaTypeLoader;
+import org.apache.xmlbeans.XmlObject;
 
 
 /**
@@ -33,9 +32,9 @@
  * */
 public class RemoteRefDConfigBean extends DConfigBeanSupport {
 
-    protected final GerRemoteRefType ref;
+    protected final XmlObject ref;
 
-    public RemoteRefDConfigBean(DDBean ddBean, GerRemoteRefType ref, String namePath) {
+    public RemoteRefDConfigBean(DDBean ddBean, XmlObject ref, String namePath) {
         super(ddBean, ref);
         this.ref = ref;
 
@@ -43,32 +42,36 @@
     }
 
     String getRefName() {
-        return ref.getRefName();
+        return null;
+//        return ref.getRefName();
     }
 
     public String getExternalUri() {
-        return ref.getExternalUri();
+        return null;
+//        return ref.getExternalUri();
     }
 
     public void setExternalUri(String targetURI) {
-        ref.setExternalUri(targetURI);
+//        ref.setExternalUri(targetURI);
     }
 
 
     public String getKernelName() {
-        return ref.getKernelName();
+        return null;
+//        return ref.getKernelName();
     }
 
     public void setKernelName(String kernelName) {
-        ref.setKernelName(kernelName);
+//        ref.setKernelName(kernelName);
     }
 
     public String getTargetName() {
-        return ref.getTargetName();
+        return null;
+//        return ref.getTargetName();
     }
 
     public void setTargetName(String targetName) {
-        ref.setTargetName(targetName);
+//        ref.setTargetName(targetName);
     }
 
     protected SchemaTypeLoader getSchemaTypeLoader() {

Added: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ResourceEnvironmentBuilder.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/deployment/ResourceEnvironmentBuilder.java	Wed Oct 27 18:51:13 2004
@@ -0,0 +1,19 @@
+package org.apache.geronimo.naming.deployment;
+
+import java.util.Set;
+
+/**
+ *
+ *
+ * @version $Revision: 1.1 $ $Date: 2004/06/25 21:35:11 $
+ *
+ * */
+public interface ResourceEnvironmentBuilder {
+    Set getUnshareableResources();
+
+    void setUnshareableResources(Set unshareableResources);
+
+    Set getApplicationManagedSecurityResources();
+
+    void setApplicationManagedSecurityResources(Set applicationManagedSecurityResources);
+}

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java	(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java	Wed Oct 27 18:51:13 2004
@@ -17,28 +17,19 @@
 
 package org.apache.geronimo.naming.java;
 
-import java.net.MalformedURLException;
-import java.net.URL;
-import javax.management.MalformedObjectNameException;
 import javax.naming.NamingException;
 import javax.transaction.UserTransaction;
 
-import org.apache.geronimo.naming.ReferenceFactory;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
-import org.apache.geronimo.xbeans.geronimo.naming.GerRemoteRefType;
-
 /**
- *
+ * TODO consider removing this class. The only purpose is to slightly hide the internalBind method.
  *
  * @version $Rev$ $Date$
  */
 public class ComponentContextBuilder {
     private static final String ENV = "env/";
-    private final ReferenceFactory referenceFactory;
     private final ReadOnlyContext context;
 
-    public ComponentContextBuilder(ReferenceFactory referenceFactory) {
-        this.referenceFactory = referenceFactory;
+    public ComponentContextBuilder() {
         this.context = new ReadOnlyContext();
         try {
             context.internalBind("env", new ReadOnlyContext());
@@ -98,61 +89,6 @@
             throw new IllegalArgumentException("Invalid class for env-entry " + name + ", " + type);
         }
         context.internalBind(ENV + name, value);
-    }
-
-    public void addResourceRef(String name, Class iface, GerLocalRefType localRef) throws NamingException {
-        if (localRef.isSetExternalUri()) {
-            try {
-                context.internalBind(ENV + name, new URL(localRef.getExternalUri()));
-            } catch (MalformedURLException e) {
-                throw (NamingException) new NamingException("Could not convert " + localRef + " to URL").initCause(e);
-            }
-        } else if (localRef.isSetResourceLink()) {
-            try {
-                bind(name, referenceFactory.buildResourceLinkReference(localRef, iface));
-            } catch (MalformedObjectNameException e) {
-                throw (NamingException) new NamingException("invalid object name").initCause(e);
-            }
-        } else if (localRef.isSetTargetName()) {
-            try {
-                bind(name, referenceFactory.buildConnectionFactoryReference(localRef, iface));
-            } catch (MalformedObjectNameException e) {
-                throw (NamingException) new NamingException("invalid object name").initCause(e);
-            }
-        }
-    }
-
-    public void addResourceEnvRef(String name, Class iface, GerLocalRefType localRef) throws NamingException {
-        try {
-            bind(name, referenceFactory.buildAdminObjectReference(localRef, iface));
-        } catch (MalformedObjectNameException e) {
-            throw (NamingException) new NamingException("invalid object name").initCause(e);
-        }
-    }
-
-    //TODO this works only if there is only one kernel running.
-    public void addMessageDestinationRef(String name, String linkName, Class iface) throws NamingException {
-        try {
-            bind(name, referenceFactory.buildMessageDestinationReference(linkName, iface));
-        } catch (MalformedObjectNameException e) {
-            throw (NamingException) new NamingException("invalid object name").initCause(e);
-        }
-    }
-
-    public void addEjbRef(String name, Class iface, GerRemoteRefType remoteRef) throws NamingException {
-        try {
-            bind(name, referenceFactory.buildEjbReference(remoteRef, iface));
-        } catch (MalformedObjectNameException e) {
-            throw (NamingException) new NamingException("invalid object name").initCause(e);
-        }
-    }
-
-    public void addEjbLocalRef(String name, Class iface, GerLocalRefType localRef) throws NamingException {
-        try {
-            bind(name, referenceFactory.buildEjbLocalReference(localRef, iface));
-        } catch (MalformedObjectNameException e) {
-            throw (NamingException) new NamingException("invalid object name").initCause(e);
-        }
     }
 
 }

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java	(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java	Wed Oct 27 18:51:13 2004
@@ -24,15 +24,14 @@
 import javax.naming.RefAddr;
 import javax.naming.Reference;
 import javax.naming.spi.ObjectFactory;
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
 
 import org.apache.geronimo.kernel.Kernel;
 
 /**
- *
- *
  * @version $Rev$ $Date$
- *
- * */
+ */
 public class JMXObjectFactory implements ObjectFactory {
 
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
@@ -43,16 +42,24 @@
             if (!(refAddr instanceof JMXRefAddr)) {
                 throw new IllegalStateException("Invalid ref addr in a Connectionfactory ref: " + refAddr);
             }
-            JMXRefAddr jmxRefAddr = (JMXRefAddr)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");
+
+            ObjectName target = null;
+            try {
+                target = ObjectName.getInstance(jmxRefAddr.getContainerId());
+            } catch (MalformedObjectNameException e) {
+                throw (IllegalArgumentException) new IllegalArgumentException("Invalid object name in jmxRefAddr: " + jmxRefAddr.getContainerId()).initCause(e);
+            }
+            
+            Object proxy = kernel.invoke(target, "$getResource");
             if (proxy == null) {
-                throw new IllegalStateException("Proxy not returned. Target " + jmxRefAddr.getTargetName() + " not started");
+                throw new IllegalStateException("Proxy not returned. Target " + jmxRefAddr.getContainerId() + " not started");
             }
             if (!jmxRefAddr.getInterface().isAssignableFrom(proxy.getClass())) {
                 throw new ClassCastException("Proxy does not implement expected interface " + jmxRefAddr.getInterface());

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java	(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java	Wed Oct 27 18:51:13 2004
@@ -19,9 +19,7 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
-
 import javax.naming.RefAddr;
-import javax.management.ObjectName;
 
 /**
  *
@@ -33,30 +31,25 @@
 
     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 String containerId;
     private final static String SCHEME = "geronimo";
     private final Class iface;
 
-    public JMXRefAddr(String serverName, String kernelName, ObjectName targetname, Class iface) {
+    public JMXRefAddr(String kernelName, String containerId, Class iface) {
         super(TYPE);
-        this.serverName = serverName;
         this.kernelName = kernelName;
-        this.targetName = targetname;
+        this.containerId = containerId;
         this.iface = iface;
     }
 
-    public String getServerName() {
-        return serverName;
-    }
 
     public String getKernelName() {
         return kernelName;
     }
 
-    public ObjectName getTargetName() {
-        return targetName;
+    public String getContainerId() {
+        return containerId;
     }
 
     public Class getInterface() {
@@ -65,7 +58,7 @@
 
     public Object getContent() {
         try {
-            return new URI(SCHEME, kernelName, targetName.toString(), null);
+            return new URI(SCHEME, kernelName, containerId, null);
         } catch (URISyntaxException e) {
             throw (IllegalStateException)new IllegalStateException("invalid jmx ref addr").initCause(e);
         }

Modified: geronimo/trunk/modules/naming/src/schema/geronimo-naming.xsd
==============================================================================
--- geronimo/trunk/modules/naming/src/schema/geronimo-naming.xsd	(original)
+++ geronimo/trunk/modules/naming/src/schema/geronimo-naming.xsd	Wed Oct 27 18:51:13 2004
@@ -38,12 +38,12 @@
  temporary (I hope) individual elements while xmlbeans group handling is straightened out
  -->
 
-    <xsd:element name="ejb-ref" type="gernaming:remote-refType"/>
-    <xsd:element name="ejb-local-ref" type="gernaming:local-refType"/>
+    <xsd:element name="ejb-ref" type="gernaming:ejb-refType"/>
+    <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType"/>
     <!-- leave web services out until I know what they do -->
     <!--xsd:group ref="service-refGroup"/-->
-    <xsd:element name="resource-ref" type="gernaming:local-refType"/>
-    <xsd:element name="resource-env-ref" type="gernaming:local-refType"/>
+    <xsd:element name="resource-ref" type="gernaming:resource-refType"/>
+    <xsd:element name="resource-env-ref" type="gernaming:resource-env-refType"/>
     
     <xsd:group name="jndiEnvironmentRefsGroup">
         <xsd:annotation>
@@ -55,43 +55,99 @@
             </xsd:documentation>
         </xsd:annotation>
         <xsd:sequence>
-            <xsd:element name="ejb-ref" type="gernaming:remote-refType" minOccurs="0" maxOccurs="unbounded"/>
-            <xsd:element name="ejb-local-ref" type="gernaming:local-refType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="ejb-ref" type="gernaming:ejb-refType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType" minOccurs="0" maxOccurs="unbounded"/>
             <!-- leave web services out until I know what they do -->
             <!--xsd:group ref="service-refGroup"/-->
-            <xsd:element name="resource-ref" type="gernaming:local-refType" minOccurs="0" maxOccurs="unbounded"/>
-            <xsd:element name="resource-env-ref" type="gernaming:local-refType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="resource-ref" type="gernaming:resource-refType" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="resource-env-ref" type="gernaming:resource-env-refType" minOccurs="0" maxOccurs="unbounded"/>
         </xsd:sequence>
     </xsd:group>
 
-    <xsd:complexType name="remote-refType">
+    <!--target-name is the entire object name of the gbean to get the bound object from by calling $getResource-->
+    <!--ejb-link acts like ejb-link in spec descriptors-->
+    <!--resource-link contains the name of the outbound-connectionfactory-instance -->
+    <!--message-destination-link acts like message-destination-link in spec descriptors-->
+    <!--url in resource-ref contains the url for URL typed resource refs-->
+    <!--Possibly the external-uri element should be revived to connect to other naming systems-->
+    <!--when server to server communication exists we will need an element in ejb-ref to specify the geronimo server
+    we wish to talk to.  It might be possible to use the objectName server element for this depending on what we decide it means-->
+    <!--otherwise you can supply the entire object name using the objectNameGroup-->
+
+    <xsd:complexType name="ejb-refType">
         <xsd:sequence>
             <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:group ref="gernaming:objectNameGroup"/>
                 <xsd:element name="ejb-link" type="xsd:string"/>
+                <xsd:element name="target-name" type="xsd:string"/>
             </xsd:choice>
         </xsd:sequence>
     </xsd:complexType>
 
-    <xsd:complexType name="local-refType">
+    <xsd:complexType name="ejb-local-refType">
         <xsd:sequence>
             <xsd:element name="ref-name" type="xsd:string"/>
             <xsd:choice>
-                <xsd:sequence>
-                    <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:group ref="gernaming:objectNameGroup"/>
                 <xsd:element name="ejb-link" type="xsd:string"/>
+                <xsd:element name="target-name" type="xsd:string"/>
+            </xsd:choice>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="resource-refType">
+        <xsd:sequence>
+            <xsd:element name="ref-name" type="xsd:string"/>
+            <xsd:choice>
+                <xsd:group ref="gernaming:objectNameGroup"/>
                 <xsd:element name="resource-link" type="xsd:string"/>
+                <xsd:element name="target-name" type="xsd:string"/>
+                <xsd:element name="url" type="xsd:string"/>
             </xsd:choice>
         </xsd:sequence>
     </xsd:complexType>
+
+    <!--used by openejb cmp datasource specification -->
+    <xsd:element name="cmp-connection-factory" type="gernaming:resource-locatorType"/>
+
+    <!--used by openejb mdb resource adapter specification -->
+    <xsd:element name="resource-adapter" type="gernaming:resource-locatorType"/>
+
+    <xsd:complexType name="resource-locatorType">
+        <xsd:sequence>
+            <xsd:choice>
+                <xsd:group ref="gernaming:objectNameGroup"/>
+                <xsd:element name="resource-link" type="xsd:string"/>
+                <xsd:element name="target-name" type="xsd:string"/>
+                <xsd:element name="url" type="xsd:string"/>
+            </xsd:choice>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="resource-env-refType">
+        <xsd:sequence>
+            <xsd:element name="ref-name" type="xsd:string"/>
+            <xsd:choice>
+                <xsd:group ref="gernaming:objectNameGroup"/>
+                <xsd:element name="message-destination-link" type="xsd:string"/>
+                <xsd:element name="target-name" type="xsd:string"/>
+            </xsd:choice>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:group name="objectNameGroup">
+         <xsd:annotation>
+             <xsd:documentation>This group contains the components of a jsr-77 object name</xsd:documentation>
+         </xsd:annotation>
+         <xsd:sequence>
+             <xsd:element name="domain" type="xsd:string" minOccurs="0"/>
+             <xsd:element name="server" type="xsd:string" minOccurs="0"/>
+             <xsd:element name="application" type="xsd:string" minOccurs="0"/>
+             <xsd:element name="module" type="xsd:string" minOccurs="0"/>
+             <xsd:element name="type" type="xsd:string" minOccurs="0"/>
+             <xsd:element name="name" type="xsd:string"/>
+         </xsd:sequence>
+     </xsd:group>
 
 </xsd:schema>

Modified: geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java	(original)
+++ geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java	Wed Oct 27 18:51:13 2004
@@ -32,8 +32,6 @@
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.naming.jmx.JMXReferenceFactory;
-import org.apache.geronimo.xbeans.geronimo.naming.GerLocalRefType;
 
 /**
  * @version $Rev$ $Date$
@@ -42,7 +40,6 @@
     private ComponentContextBuilder builder;
 
     private List proxy;
-    private JMXReferenceFactory referenceFactory;
 
     public void testFreeze() {
         ReadOnlyContext context = builder.getContext();
@@ -104,20 +101,16 @@
         assertEquals(booleanVal, context.lookup("env/boolean"));
     }
 
-    public void testResourceEnv() throws Exception {
+    public void xtestResourceEnv() throws Exception {
         proxy = new ArrayList();
-        GerLocalRefType localRef = GerLocalRefType.Factory.newInstance();
-        localRef.setRefName("resourceenvref");
-        localRef.setKernelName("test.kernel");
-        localRef.setTargetName("testAdminObject");
-        builder.addResourceEnvRef("resourceenvref", List.class, localRef);
+//        builder.addResourceEnvRef("resourceenvref", List.class, localRef);
 
         ReadOnlyContext roc = builder.getContext();
         Kernel kernel = new Kernel("test.kernel", "test.domain");
         kernel.boot();
         try {
             assertEquals(kernel, Kernel.getKernel("test.kernel"));
-            ObjectName proxyFactoryName = referenceFactory.createAdminObjectObjectName("testAdminObject");
+            ObjectName proxyFactoryName = null;//referenceFactory.createAdminObjectObjectName("testAdminObject");
             GBeanMBean gbean = new GBeanMBean(getGbeanInfo());
             gbean.setAttribute("Content", proxy);
             kernel.loadGBean(proxyFactoryName, gbean);
@@ -141,8 +134,8 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        referenceFactory = new JMXReferenceFactory("geronimo.server", "geronimo");
-        builder = new ComponentContextBuilder(referenceFactory);
+//        referenceFactory = new JMXReferenceFactory("geronimo.server", "geronimo");
+        builder = new ComponentContextBuilder();
     }
 
     public static class TestProxyFactory {

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java	(original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java	Wed Oct 27 18:51:13 2004
@@ -282,7 +282,7 @@
 
     public void doStart() throws WaitingException, Exception {
         if (managedConnectionFactoryWrapper != null) {
-            dataSource = (DataSource) managedConnectionFactoryWrapper.getProxy();
+            dataSource = (DataSource) managedConnectionFactoryWrapper.$getResource();
         }
         if (createSequenceSQL != null && !createSequenceSQL.equals("")) {
             execSQL(createSequenceSQL);

Mime
View raw message