geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1140357 - in /geronimo/server/trunk: framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/enc/ framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/java/ plugins/client/client-deployer/src/main/p...
Date Mon, 27 Jun 2011 22:58:11 GMT
Author: djencks
Date: Mon Jun 27 22:58:09 2011
New Revision: 1140357

URL: http://svn.apache.org/viewvc?rev=1140357&view=rev
Log:
GERONIMO-5066 Use naming Reference to set up Datasources and use them to get global scope datasources from server to app client

Added:
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java   (with props)
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java   (contents, props changed)
      - copied, changed from r1140356, geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java
Removed:
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java
Modified:
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/enc/EnterpriseNamingContext.java
    geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/java/RootContext.java
    geronimo/server/trunk/plugins/client/client-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/server/trunk/plugins/connector-1_6/client-transaction-1_6/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
    geronimo/server/trunk/plugins/connector-1_6/transaction-1_6/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
    geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/enc/EnterpriseNamingContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/enc/EnterpriseNamingContext.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/enc/EnterpriseNamingContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/enc/EnterpriseNamingContext.java Mon Jun 27 22:58:09 2011
@@ -49,6 +49,12 @@ public final class EnterpriseNamingConte
 
     public static Context livenReferences(Map<String, Object> componentContext, UserTransaction userTransaction, Kernel kernel, ClassLoader classLoader, Bundle bundle, String prefix)
             throws NamingException {
+        Map<String, Object> map = livenReferencesToMap(componentContext, userTransaction, kernel, classLoader, bundle, prefix);
+
+        return new ImmutableContext(map, false);
+    }
+
+    public static Map<String, Object> livenReferencesToMap(Map<String, Object> componentContext, UserTransaction userTransaction, Kernel kernel, ClassLoader classLoader, Bundle bundle, String prefix) throws NamingException {
         Map<String, Object> map = new HashMap<String, Object>();
         boolean containsEnv = false;
         if (componentContext != null) {
@@ -84,8 +90,7 @@ public final class EnterpriseNamingConte
         if (userTransaction != null) {
             map.put(prefix + "UserTransaction", userTransaction);
         }
-
-        return new ImmutableContext(map, false);
+        return map;
     }
 
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/java/RootContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/java/RootContext.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/java/RootContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-naming/src/main/java/org/apache/geronimo/naming/java/RootContext.java Mon Jun 27 22:58:09 2011
@@ -63,7 +63,7 @@ public class RootContext extends Immutab
                 return compCtx.lookup(name);
             } catch (NamingException e1) {
 
-                if (openejbRemoteContextURI.get() != null && (name.startsWith("global/") || name.startsWith("app/"))) {
+                if (openejbRemoteContextURI.get() != null && (name.startsWith("global/"))) {
 
                     Properties p = new Properties();
                     p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");

Modified: geronimo/server/trunk/plugins/client/client-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/client/client-deployer/src/main/plan/plan.xml?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/client/client-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/client/client-deployer/src/main/plan/plan.xml Mon Jun 27 22:58:09 2011
@@ -53,7 +53,7 @@
             </pattern>
             <pattern>
                 <name>DataSourceBuilder</name>
-            </pattern>            
+            </pattern>
             <pattern>
                 <name>ClientResourceRefBuilder</name>
             </pattern>

Modified: geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java Mon Jun 27 22:58:09 2011
@@ -41,6 +41,7 @@ import javax.xml.bind.JAXBException;
 import org.apache.geronimo.client.AppClientContainer;
 import org.apache.geronimo.client.StaticJndiContextPlugin;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.datasource.deployment.DataSourceBuilder;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
@@ -52,10 +53,11 @@ import org.apache.geronimo.deployment.xm
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.SingleElementCollection;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.j2ee.deployment.AppClientModule;
 import org.apache.geronimo.j2ee.deployment.ApplicationInfo;
 import org.apache.geronimo.j2ee.deployment.ConnectorModule;
@@ -104,6 +106,7 @@ import org.slf4j.LoggerFactory;
 /**
  * @version $Rev:385232 $ $Date$
  */
+@GBean(j2eeType = NameFactory.MODULE_BUILDER)
 public class AppClientModuleBuilder implements ModuleBuilder, CorbaGBeanNameSource, GBeanLifecycle {
     private static final Logger log = LoggerFactory.getLogger(AppClientModuleBuilder.class);
     private static final String LINE_SEP = System.getProperty("line.separator");
@@ -123,7 +126,7 @@ public class AppClientModuleBuilder impl
     private final AbstractNameQuery transactionManagerObjectName;
     private final AbstractNameQuery connectionTrackerObjectName;
     private final AbstractNameQuery credentialStoreName;
-    private final SingleElementCollection connectorModuleBuilder;
+    private final SingleElementCollection<ModuleBuilder> connectorModuleBuilder;
     private final NamespaceDrivenBuilderCollection serviceBuilder;
     private final NamingBuilderCollection namingBuilders;
     private final Collection<ModuleBuilderExtension> moduleBuilderExtensions;
@@ -166,21 +169,21 @@ public class AppClientModuleBuilder impl
                 port);
     }
 
-    public AppClientModuleBuilder(AbstractNameQuery transactionManagerObjectName,
-                                  AbstractNameQuery connectionTrackerObjectName,
-                                  AbstractNameQuery corbaGBeanObjectName,
-                                  AbstractNameQuery credentialStoreName,
-                                  AbstractNameQuery globalContextAbstractName,
-                                  Collection<Repository> repositories,
-                                  Collection<ModuleBuilder> connectorModuleBuilder,
-                                  Collection<NamespaceDrivenBuilder> serviceBuilder,
-                                  Collection<NamingBuilder> namingBuilders,
-                                  Collection<ModuleBuilderExtension> moduleBuilderExtensions,
-                                  ArtifactResolver clientArtifactResolver,
-                                  Environment defaultClientEnvironment,
-                                  Environment defaultServerEnvironment,
-                                  String host,
-                                  int port) throws URISyntaxException{
+    public AppClientModuleBuilder(@ParamAttribute(name = "transactionManagerObjectName") AbstractNameQuery transactionManagerObjectName,
+                                  @ParamAttribute(name = "connectionTrackerObjectName") AbstractNameQuery connectionTrackerObjectName,
+                                  @ParamAttribute(name = "corbaGBeanObjectName") AbstractNameQuery corbaGBeanObjectName,
+                                  @ParamAttribute(name = "credentialStoreName") AbstractNameQuery credentialStoreName,
+                                  @ParamAttribute(name = "globalContextAbstractName") AbstractNameQuery globalContextAbstractName,
+                                  @ParamReference(name = "Repositories", namingType = "Repository") Collection<Repository> repositories,
+                                  @ParamReference(name = "ConnectorModuleBuilder", namingType = NameFactory.MODULE_BUILDER) Collection<ModuleBuilder> connectorModuleBuilder,
+                                  @ParamReference(name = "ServiceBuilders", namingType = NameFactory.MODULE_BUILDER) Collection<NamespaceDrivenBuilder> serviceBuilder,
+                                  @ParamReference(name = "NamingBuilders", namingType = NameFactory.MODULE_BUILDER) Collection<NamingBuilder> namingBuilders,
+                                  @ParamReference(name = "ModuleBuilderExtensions", namingType = NameFactory.MODULE_BUILDER) Collection<ModuleBuilderExtension> moduleBuilderExtensions,
+                                  @ParamReference(name = "ClientArtifactResolver", namingType = "ArtifactResolver") ArtifactResolver clientArtifactResolver,
+                                  @ParamAttribute(name = "defaultClientEnvironment") Environment defaultClientEnvironment,
+                                  @ParamAttribute(name = "defaultServerEnvironment") Environment defaultServerEnvironment,
+                                  @ParamAttribute(name = "host") String host,
+                                  @ParamAttribute(name = "port") int port) throws URISyntaxException{
         this(defaultClientEnvironment,
                 defaultServerEnvironment,
                 transactionManagerObjectName,
@@ -818,7 +821,6 @@ public class AppClientModuleBuilder impl
                    appClientModule.getJndiScope(JndiScope.module).put("module/ModuleName", moduleName);
                     
                     namingBuilders.buildNaming(appClient, geronimoAppClient, appClientModule, buildingContext);
-
                     if (!appClient.isMetadataComplete()) {
                         appClient.setMetadataComplete(true);
                         module.setOriginalSpecDD(module.getSpecDD().toString());
@@ -1075,50 +1077,4 @@ public class AppClientModuleBuilder impl
         return true;
     }
 
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(AppClientModuleBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addAttribute("defaultClientEnvironment", Environment.class, true, true);
-        infoBuilder.addAttribute("defaultServerEnvironment", Environment.class, true, true);
-        infoBuilder.addAttribute("transactionManagerObjectName", AbstractNameQuery.class, true);
-        infoBuilder.addAttribute("connectionTrackerObjectName", AbstractNameQuery.class, true);
-        infoBuilder.addAttribute("corbaGBeanObjectName", AbstractNameQuery.class, true);
-        infoBuilder.addAttribute("credentialStoreName", AbstractNameQuery.class, true);
-        infoBuilder.addAttribute("globalContextAbstractName", AbstractNameQuery.class, true);
-        infoBuilder.addReference("Repositories", Repository.class, "Repository");
-        infoBuilder.addReference("ConnectorModuleBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("NamingBuilders", NamingBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("ModuleBuilderExtensions", ModuleBuilderExtension.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("ClientArtifactResolver", ArtifactResolver.class, "ArtifactResolver");
-        infoBuilder.addAttribute("host", String.class, true);
-        infoBuilder.addAttribute("port", int.class, true);
-
-        infoBuilder.addInterface(ModuleBuilder.class);
-
-        infoBuilder.setConstructor(new String[]{"transactionManagerObjectName",
-                "connectionTrackerObjectName",
-                "corbaGBeanObjectName",
-                "credentialStoreName",
-                "globalContextAbstractName",
-                "Repositories",
-                "ConnectorModuleBuilder",
-                "ServiceBuilders",
-                "NamingBuilders",
-                "ModuleBuilderExtensions",
-                "ClientArtifactResolver",
-                "defaultClientEnvironment",
-                "defaultServerEnvironment",
-                "host",
-                "port"
-        });
-
-        GBEAN_INFO = infoBuilder.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
-
 }

Modified: geronimo/server/trunk/plugins/connector-1_6/client-transaction-1_6/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/client-transaction-1_6/src/main/plan/plan.xml?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/client-transaction-1_6/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/connector-1_6/client-transaction-1_6/src/main/plan/plan.xml Mon Jun 27 22:58:09 2011
@@ -76,4 +76,13 @@
         </reference>
     </gbean>
 
+    <gbean name="DataSourceGBeanObjectFactory" class="org.apache.geronimo.datasource.DataSourceGBeanObjectFactory">
+        <reference name="ConnectionTracker">
+            <name>ConnectionTracker</name>
+        </reference>
+        <reference name="TransactionManager">
+            <name>TransactionManager</name>
+        </reference>
+    </gbean>
+
 </module>

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java (original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java Mon Jun 27 22:58:09 2011
@@ -47,7 +47,13 @@ public class DataSourceDescription imple
     private int maxPoolSize = -1;
     private int minPoolSize = -1;
     private int maxIdleTime = -1;
-    private int maxStatements = -1; 
+    private int maxStatements = -1;
+
+    //extra geronimo properties
+    private int blockingTimeoutMilliseconds = -1;
+    private boolean xaTransactionCaching = true;
+    private boolean xaThreadCaching = false;
+    private String osgiServiceName;
     
     public String getName() {
         return name;
@@ -192,7 +198,39 @@ public class DataSourceDescription imple
     public void setMaxStatements(int maxStatements) {
         this.maxStatements = maxStatements;
     }
-    
+
+    public int getBlockingTimeoutMilliseconds() {
+        return blockingTimeoutMilliseconds;
+    }
+
+    public void setBlockingTimeoutMilliseconds(int blockingTimeoutMilliseconds) {
+        this.blockingTimeoutMilliseconds = blockingTimeoutMilliseconds;
+    }
+
+    public String getOsgiServiceName() {
+        return osgiServiceName;
+    }
+
+    public void setOsgiServiceName(String osgiServiceName) {
+        this.osgiServiceName = osgiServiceName;
+    }
+
+    public boolean isXaThreadCaching() {
+        return xaThreadCaching;
+    }
+
+    public void setXaThreadCaching(boolean xaThreadCaching) {
+        this.xaThreadCaching = xaThreadCaching;
+    }
+
+    public boolean isXaTransactionCaching() {
+        return xaTransactionCaching;
+    }
+
+    public void setXaTransactionCaching(boolean xaTransactionCaching) {
+        this.xaTransactionCaching = xaTransactionCaching;
+    }
+
     public boolean hasStandardProperties() {
         return (databaseName != null
                 || password != null

Added: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java?rev=1140357&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java (added)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java Mon Jun 27 22:58:09 2011
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.datasource;
+
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.util.Hashtable;
+
+import javax.naming.BinaryRefAddr;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.OsgiService;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+
+@GBean
+@OsgiService
+public class DataSourceGBeanObjectFactory implements ObjectFactory {
+    public static final String OSGI_JNDI_SERVICE_NAME = "osgi.jndi.service.name";
+    public static final String	BUNDLE_CONTEXT		= "osgi.service.jndi.bundleContext";
+    private BundleContext bundleContext;
+    private ConnectionTracker connectionTracker;
+    private RecoverableTransactionManager txManager;
+
+    public DataSourceGBeanObjectFactory(@ParamSpecial(type = SpecialAttributeType.bundleContext)BundleContext bundleContext,
+                                        @ParamReference(name = "ConnectionTracker", namingType = NameFactory.JCA_CONNECTION_TRACKER)ConnectionTracker connectionTracker,
+                                        @ParamReference(name = "TransactionManager", namingType = NameFactory.JTA_RESOURCE)RecoverableTransactionManager txManager) {
+        this.bundleContext = bundleContext;
+        this.connectionTracker = connectionTracker;
+        this.txManager = txManager;
+    }
+
+    @Override
+    public Object getObjectInstance(Object o, Name name, Context context, Hashtable<?, ?> hashtable) throws Exception {
+        if (o instanceof Reference) {
+            Reference ref = (Reference) o;
+            if (ref.getClassName().equals(DataSourceService.class.getName())) {
+                BinaryRefAddr addr = (BinaryRefAddr) ref.get(0);
+                ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) addr.getContent());
+                ObjectInputStream in = new ObjectInputStream(bais);
+                DataSourceDescription dataSourceDescription = (DataSourceDescription) in.readObject();
+                Hashtable dict = new Hashtable();
+                dict.put(OSGI_JNDI_SERVICE_NAME, dataSourceDescription.getOsgiServiceName());
+                ServiceReference[] serviceReferences = bundleContext.getServiceReferences(javax.sql.DataSource.class.getName(), "(" + OSGI_JNDI_SERVICE_NAME + "=" + dataSourceDescription.getOsgiServiceName() + ")");
+                if (serviceReferences != null && serviceReferences.length > 0) {
+                    Object result = bundleContext.getService(serviceReferences[0]);
+                    return result;
+                }
+                String objectName = null;
+//                BundleContext bundleContext = (BundleContext) hashtable.get(BUNDLE_CONTEXT);
+                DataSourceService dataSourceGBean = new DataSourceService(dataSourceDescription, connectionTracker, txManager, objectName, null);
+                bundleContext.registerService(new String[] {javax.sql.DataSource.class.getName()}, dataSourceGBean, dict);
+                return dataSourceGBean.$getResource();
+            }
+        }
+
+        return null;
+    }
+}

Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBeanObjectFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java (from r1140356, geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java?p2=geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java&p1=geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java&r1=1140356&r2=1140357&rev=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java (original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java Mon Jun 27 22:58:09 2011
@@ -17,10 +17,17 @@
 
 package org.apache.geronimo.datasource;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
 import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.naming.BinaryRefAddr;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.resource.Referenceable;
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.security.auth.Subject;
@@ -36,20 +43,11 @@ import org.apache.geronimo.connector.out
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.annotation.GBean;
-import org.apache.geronimo.gbean.annotation.OsgiService;
-import org.apache.geronimo.gbean.annotation.ParamAttribute;
-import org.apache.geronimo.gbean.annotation.ParamReference;
-import org.apache.geronimo.gbean.annotation.ParamSpecial;
-import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.naming.ResourceSource;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 import org.apache.xbean.recipe.ObjectRecipe;
 import org.apache.xbean.recipe.Option;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceException;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
@@ -64,33 +62,22 @@ import org.tranql.connector.jdbc.Abstrac
 /**
  * @version $Revision$
  */
-@GBean
-@OsgiService
-public class DataSourceGBean implements ResourceSource<ResourceException>, ServiceFactory {
+public class DataSourceService implements ResourceSource<ResourceException>, ServiceFactory {
     
-    private static final Logger log = LoggerFactory.getLogger(DataSourceGBean.class);
+    private static final Logger log = LoggerFactory.getLogger(DataSourceService.class);
         
     private final DataSourceDescription dataSourceDescription;
-    private final transient ClassLoader classLoader;
-    private final transient GenericConnectionManager connectionManager;
+    private final GenericConnectionManager connectionManager;
+    private Reference reference;
 
-    public DataSourceGBean(@ParamAttribute(name="dataSourceDescription") DataSourceDescription dataSourceDescription,
-                           @ParamAttribute(name="defaultMaxSize") int defaultMaxSize,
-                           @ParamAttribute(name="defaultMinSize") int defaultMinSize,
-                           @ParamAttribute(name="defaultBlockingTimeoutMilliseconds") int defaultBlockingTimeoutMilliseconds,
-                           @ParamAttribute(name="defaultIdleTimeoutMinutes") int defaultIdleTimeoutMinutes,
-                           @ParamAttribute(name="defaultXATransactionCaching") boolean defaultXATransactionCaching,
-                           @ParamAttribute(name="defaultXAThreadCaching") boolean defaultXAThreadCaching,
-                           @ParamReference(name="ConnectionTracker", namingType = NameFactory.JCA_CONNECTION_TRACKER) ConnectionTracker connectionTracker,
-                           @ParamReference(name="TransactionManager", namingType = NameFactory.JTA_RESOURCE) RecoverableTransactionManager transactionManager,
-                           @ParamSpecial(type=SpecialAttributeType.objectName) String objectName,
-                           @ParamSpecial(type=SpecialAttributeType.abstractName) AbstractName abstractName,
-                           @ParamSpecial(type=SpecialAttributeType.classLoader) ClassLoader classLoader,
-                           @ParamSpecial(type=SpecialAttributeType.bundleContext) BundleContext bundleContext)
+    public DataSourceService(DataSourceDescription dataSourceDescription,
+                             ConnectionTracker connectionTracker,
+                             RecoverableTransactionManager transactionManager,
+                             String objectName,
+                             ClassLoader classLoader)
         throws Exception {
         this.dataSourceDescription = dataSourceDescription;        
-        this.classLoader = classLoader;
-        
+
         String dsName = dataSourceDescription.getName();
         String dsClass = dataSourceDescription.getClassName();
         
@@ -103,24 +90,20 @@ public class DataSourceGBean implements 
         if (instance instanceof XADataSource) {
             mcf = new XADataSourceMCF((XADataSource) instance);
             if (dataSourceDescription.isTransactional()) {
-                transactionSupport = new XATransactions(defaultXATransactionCaching, defaultXAThreadCaching);
+                transactionSupport = new XATransactions(dataSourceDescription.isXaTransactionCaching(), dataSourceDescription.isXaThreadCaching());
             } else {
                 transactionSupport = NoTransactions.INSTANCE;
             }
-            pooling = createPool(defaultMinSize, 
-                                 defaultMaxSize, 
-                                 defaultBlockingTimeoutMilliseconds, 
-                                 defaultIdleTimeoutMinutes);
+            pooling = createPool(
+            );
         } else if (instance instanceof ConnectionPoolDataSource) {
             mcf = new PooledConnectionDataSourceMCF((ConnectionPoolDataSource) instance);
             if (dataSourceDescription.isTransactional()) {
                 log.warn("[{}] Transactional property is true but DataSource does not support transactions", dsName); 
             }
             transactionSupport = NoTransactions.INSTANCE;
-            pooling = createPool(defaultMinSize, 
-                                 defaultMaxSize, 
-                                 defaultBlockingTimeoutMilliseconds, 
-                                 defaultIdleTimeoutMinutes);
+            pooling = createPool(
+            );
         } else if (instance instanceof DataSource) {
             mcf = new LocalDataSourceMCF((DataSource) instance, true);
             if (dataSourceDescription.isTransactional()) {
@@ -137,14 +120,24 @@ public class DataSourceGBean implements 
         
         this.connectionManager = 
             new GenericConnectionManager(transactionSupport, pooling, null, connectionTracker, transactionManager, mcf, objectName, classLoader);
-                
+        reference = buildReference(dataSourceDescription);
         connectionManager.doRecovery();
     }
-    
+
+    public static Reference buildReference(DataSourceDescription dataSourceDescription) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oas = new ObjectOutputStream(baos);
+        oas.writeObject(dataSourceDescription);
+        oas.flush();
+        byte[] content = baos.toByteArray();
+        RefAddr addr = new BinaryRefAddr(DataSourceDescription.class.getName(), content);
+        return new Reference(DataSourceService.class.getName(), addr, DataSourceGBeanObjectFactory.class.getName(), null);
+    }
+
     @Override
     public Object getService(Bundle bundle, ServiceRegistration serviceRegistration) {
         try {
-            return connectionManager.createConnectionFactory();
+            return $getResource();
         } catch (ResourceException e) {
             throw new ServiceException("Error creating connection factory", e);
         }
@@ -156,8 +149,9 @@ public class DataSourceGBean implements 
 
     private Object createDataSource() throws Exception {
         String className = dataSourceDescription.getClassName();
-        Class clazz = classLoader.loadClass(className);
-            
+        //TODO also try our provider registry
+        Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+
         Map<String, Object> properties = new HashMap<String, Object>();
             
         // standard settings
@@ -205,22 +199,23 @@ public class DataSourceGBean implements 
         }
     }
 
-    private PoolingSupport createPool(int defaultMinSize, 
-                                      int defaultMaxSize, 
-                                      int defaultBlockingTimeoutMilliseconds, 
-                                      int defaultIdleTimeoutMinutes) {
+    private PoolingSupport createPool() {
         return new SinglePool(
-                dataSourceDescription.getMaxPoolSize() != -1 ? dataSourceDescription.getMaxPoolSize() : defaultMaxSize,
-                dataSourceDescription.getMinPoolSize() != -1 ? dataSourceDescription.getMinPoolSize() : defaultMinSize,
-                defaultBlockingTimeoutMilliseconds,
-                dataSourceDescription.getMaxIdleTime() != -1 ? dataSourceDescription.getMaxIdleTime() : defaultIdleTimeoutMinutes,
+                dataSourceDescription.getMaxPoolSize(),
+                dataSourceDescription.getMinPoolSize(),
+                dataSourceDescription.getBlockingTimeoutMilliseconds(),
+                dataSourceDescription.getMaxIdleTime(),
                 false,
                 false,
                 true);
     }
     
     public Object $getResource() throws ResourceException {
-        return connectionManager.createConnectionFactory();
+        Object o = connectionManager.createConnectionFactory();
+        if (o instanceof Referenceable) {
+            ((Referenceable)o).setReference(reference);
+        }
+        return o;
     }
     
     private class PooledConnectionDataSourceMCF extends AbstractPooledConnectionDataSourceMCF {

Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java (original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java Mon Jun 27 22:58:09 2011
@@ -17,6 +17,7 @@
 
 package org.apache.geronimo.datasource.deployment;
 
+import java.io.IOException;
 import java.sql.Connection;
 import java.util.Collection;
 import java.util.Collections;
@@ -29,19 +30,14 @@ import javax.annotation.sql.DataSourceDe
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.connector.deployment.ConnectorModuleBuilder;
 import org.apache.geronimo.datasource.DataSourceDescription;
-import org.apache.geronimo.datasource.DataSourceGBean;
+import org.apache.geronimo.datasource.DataSourceService;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
-import org.apache.geronimo.gbean.annotation.ParamSpecial;
-import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
-import org.apache.geronimo.naming.reference.JndiReference;
 import org.apache.openejb.jee.DataSource;
 import org.apache.openejb.jee.InjectionTarget;
 import org.apache.openejb.jee.IsolationLevel;
@@ -50,11 +46,6 @@ import org.apache.openejb.jee.Property;
 import org.apache.openejb.jee.Text;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
@@ -62,8 +53,6 @@ import org.slf4j.LoggerFactory;
 @GBean(j2eeType = NameFactory.MODULE_BUILDER)
 public class DataSourceBuilder extends AbstractNamingBuilder {
 
-    private static final Logger log = LoggerFactory.getLogger(DataSourceBuilder.class);
-
     private final int defaultMaxSize;
     private final int defaultMinSize;
     private final int defaultBlockingTimeoutMilliseconds;
@@ -71,7 +60,6 @@ public class DataSourceBuilder extends A
     private final boolean defaultXATransactionCaching;
     private final boolean defaultXAThreadCaching;
     
-    private final PackageAdmin packageAdmin;
     private final QNameSet dataSourceQNameSet;
 
     public DataSourceBuilder(@ParamAttribute(name = "eeNamespaces") String[] eeNamespaces,
@@ -80,8 +68,7 @@ public class DataSourceBuilder extends A
                              @ParamAttribute(name = "defaultBlockingTimeoutMilliseconds") int defaultBlockingTimeoutMilliseconds,
                              @ParamAttribute(name = "defaultIdleTimeoutMinutes") int defaultIdleTimeoutMinutes,
                              @ParamAttribute(name = "defaultXATransactionCaching") boolean defaultXATransactionCaching,
-                             @ParamAttribute(name = "defaultXAThreadCaching") boolean defaultXAThreadCaching,
-                             @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle) {
+                             @ParamAttribute(name = "defaultXAThreadCaching") boolean defaultXAThreadCaching) {
         this.defaultMaxSize = defaultMaxSize;
         this.defaultMinSize = defaultMinSize;
         this.defaultBlockingTimeoutMilliseconds = defaultBlockingTimeoutMilliseconds;
@@ -89,14 +76,11 @@ public class DataSourceBuilder extends A
         this.defaultXATransactionCaching = defaultXATransactionCaching;
         this.defaultXAThreadCaching = defaultXAThreadCaching;
         
-        ServiceReference sr = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
-        this.packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(sr);
-        
         this.dataSourceQNameSet = buildQNameSet(eeNamespaces, "data-source");
     }
     
     public void buildNaming(JndiConsumer specDD, XmlObject plan, Module module, Map<EARContext.Key, Object> sharedContext) throws DeploymentException {
-                        
+
         // step 1: process annotations and update deployment descriptor
         if ((module != null) && (module.getClassFinder() != null)) {
 
@@ -104,7 +88,7 @@ public class DataSourceBuilder extends A
             classes = module.getClassFinder().findAnnotatedClasses(DataSourceDefinitions.class);
             if (classes != null) {
                 for (Class<?> clazz : classes) {
-                    DataSourceDefinitions dsDefinitions = (DataSourceDefinitions) clazz.getAnnotation(DataSourceDefinitions.class);
+                    DataSourceDefinitions dsDefinitions = clazz.getAnnotation(DataSourceDefinitions.class);
                     for (DataSourceDefinition dsDefinition : dsDefinitions.value()) {
                         processDefinition(dsDefinition, specDD);
                     }
@@ -114,7 +98,7 @@ public class DataSourceBuilder extends A
             classes = module.getClassFinder().findAnnotatedClasses(DataSourceDefinition.class);
             if (classes != null) {
                 for (Class<?> clazz : classes) {
-                    DataSourceDefinition dsDefinition = (DataSourceDefinition) clazz.getAnnotation(DataSourceDefinition.class);
+                    DataSourceDefinition dsDefinition = clazz.getAnnotation(DataSourceDefinition.class);
                     processDefinition(dsDefinition, specDD);
                 }
             }
@@ -124,17 +108,13 @@ public class DataSourceBuilder extends A
         Collection<DataSource> dataSources = specDD.getDataSource();
         if (dataSources != null) {
             for (DataSource dataSource: dataSources) {
-                try {
-                    addDataSourceGBean(module, sharedContext, dataSource);
-                } catch (GBeanAlreadyExistsException e) {
-                    throw new DeploymentException("Error creating DataSource gbean", e);
-                }
+                addDataSourceGBean(module, sharedContext, dataSource);
             }
         }        
     }
 
     private void addDataSourceGBean(Module module, Map<EARContext.Key, Object> sharedContext, DataSource ds)
-        throws GBeanAlreadyExistsException {
+        throws DeploymentException {
                         
         String jndiName = ds.getKey();
         
@@ -151,23 +131,7 @@ public class DataSourceBuilder extends A
                        
         AbstractName dataSourceAbstractName = earContext.getNaming().createChildName(module.getModuleName(), name, "GBean");
 
-        GBeanData dataSourceGBean = new GBeanData(dataSourceAbstractName, DataSourceGBean.class);
-        
         DataSourceDescription dsDescription = createDataSourceDescription(ds);
-        dataSourceGBean.setAttribute("dataSourceDescription", dsDescription);
-        
-        dataSourceGBean.setAttribute("defaultMaxSize", defaultMaxSize);
-        dataSourceGBean.setAttribute("defaultMinSize", defaultMinSize);
-        dataSourceGBean.setAttribute("defaultBlockingTimeoutMilliseconds", defaultBlockingTimeoutMilliseconds);
-        dataSourceGBean.setAttribute("defaultIdleTimeoutMinutes", defaultIdleTimeoutMinutes);
-        
-        dataSourceGBean.setAttribute("defaultXATransactionCaching", defaultXATransactionCaching);
-        dataSourceGBean.setAttribute("defaultXAThreadCaching", defaultXAThreadCaching);
-        
-        dataSourceGBean.setReferencePattern("ConnectionTracker", earContext.getConnectionTrackerName());
-        dataSourceGBean.setReferencePattern("TransactionManager", earContext.getTransactionManagerName());
-
-        dataSourceGBean.setServiceInterfaces(new String[] { javax.sql.DataSource.class.getName() });
         String osgiJndiName = null;
         if (dsDescription.getProperties() != null) {
             osgiJndiName = dsDescription.getProperties().get(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME);
@@ -175,12 +139,14 @@ public class DataSourceBuilder extends A
         if (osgiJndiName == null) {
             osgiJndiName = module.getEarContext().getNaming().toOsgiJndiName(dataSourceAbstractName);
         }
-        dataSourceGBean.getServiceProperties().put(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME, osgiJndiName);
-        
-        earContext.addGBean(dataSourceGBean);
-                
-        Object ref = new JndiReference("aries:services/" + osgiJndiName);
-        put(jndiName, ref, module.getJndiContext(), Collections.<InjectionTarget>emptyList(), sharedContext);
+        dsDescription.setOsgiServiceName(osgiJndiName);
+
+        try {
+            Object ref = DataSourceService.buildReference(dsDescription);
+            put(jndiName, ref, module.getJndiContext(), Collections.<InjectionTarget>emptyList(), sharedContext);
+        } catch (IOException e) {
+            throw new DeploymentException("Could not construct Reference for datasource " + dsDescription, e);
+        }
     }
     
     private DataSource processDefinition(DataSourceDefinition dsDefinition, JndiConsumer annotatedApp) {
@@ -367,22 +333,21 @@ public class DataSourceBuilder extends A
             dsDescription.setInitialPoolSize(ds.getInitialPoolSize());
         }
         
-        if (ds.getMaxPoolSize() != null) {
-            dsDescription.setMaxPoolSize(ds.getMaxPoolSize());
-        }
-        
-        if (ds.getMinPoolSize() != null) {
-            dsDescription.setMinPoolSize(ds.getMinPoolSize());
-        }
-        
+            dsDescription.setMaxPoolSize(ds.getMaxPoolSize() != null? ds.getMaxPoolSize(): defaultMaxSize);
+
+            dsDescription.setMinPoolSize(ds.getMinPoolSize() != null? ds.getMinPoolSize(): defaultMinSize);
+
         if (ds.getMaxStatements() != null) {
             dsDescription.setMaxStatements(ds.getMaxStatements());
         }
         
-        if (ds.getMaxIdleTime() != null) {
-            dsDescription.setMaxIdleTime(ds.getMaxIdleTime());
-        }
-        
+            dsDescription.setMaxIdleTime(ds.getMaxIdleTime() != null? ds.getMaxIdleTime(): defaultIdleTimeoutMinutes);
+
+        //geronimo specific properties
+        dsDescription.setBlockingTimeoutMilliseconds(defaultBlockingTimeoutMilliseconds);
+        dsDescription.setXaThreadCaching(defaultXAThreadCaching);
+        dsDescription.setXaTransactionCaching(defaultXATransactionCaching);
+
         return dsDescription;
     }
         

Modified: geronimo/server/trunk/plugins/connector-1_6/transaction-1_6/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/transaction-1_6/src/main/plan/plan.xml?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/transaction-1_6/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/connector-1_6/transaction-1_6/src/main/plan/plan.xml Mon Jun 27 22:58:09 2011
@@ -132,4 +132,13 @@
         <attribute name="abstractNameQuery">?#org.apache.geronimo.naming.ResourceSource</attribute>
     </gbean>
 
+    <gbean name="DataSourceGBeanObjectFactory" class="org.apache.geronimo.datasource.DataSourceGBeanObjectFactory">
+        <reference name="ConnectionTracker">
+            <name>ConnectionTracker</name>
+        </reference>
+        <reference name="TransactionManager">
+            <name>TransactionManager</name>
+        </reference>
+    </gbean>
+
 </module>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java Mon Jun 27 22:58:09 2011
@@ -34,6 +34,7 @@ import org.apache.geronimo.gbean.annotat
 import org.apache.geronimo.gjndi.FederatedContext;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
+import org.apache.xbean.naming.context.ImmutableContext;
 import org.osgi.framework.Bundle;
 
 /**
@@ -44,6 +45,7 @@ public class ApplicationJndi implements 
 
     private final Context applicationContext;
     private final Context globalAdditions;
+    private final Map<String, Object> liveGlobalMap;
     private final FederatedContext globalContext;
 
     public ApplicationJndi(@ParamAttribute(name = "globalContextSegment") Map<String, Object> globalContextSegment,
@@ -53,7 +55,8 @@ public class ApplicationJndi implements 
                            @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
                            @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle
                            ) throws NamingException {
-        this.globalAdditions = EnterpriseNamingContext.livenReferences(globalContextSegment, null, kernel, classLoader, bundle, JndiScope.global.name() + "/");
+        this.liveGlobalMap = EnterpriseNamingContext.livenReferencesToMap(globalContextSegment, null, kernel, classLoader, bundle, JndiScope.global.name() + "/");
+        this.globalAdditions = new ImmutableContext(this.liveGlobalMap, false);
         this.globalContext = globalContext;
         this.globalContext.federateContext(this.globalAdditions);
         this.applicationContext = EnterpriseNamingContext.livenReferences(applicationContext, null, kernel, classLoader, bundle, JndiScope.app.name() + "/");
@@ -67,6 +70,10 @@ public class ApplicationJndi implements 
         return globalContext;
     }
 
+    public Map<String, Object> getGlobalMap() {
+        return liveGlobalMap;
+    }
+
     @Override
     public void doStart() throws Exception {
     }

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java Mon Jun 27 22:58:09 2011
@@ -43,6 +43,7 @@ import org.apache.geronimo.gbean.annotat
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.jndi.ApplicationJndi;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.persistence.PersistenceUnitGBean;
@@ -102,12 +103,13 @@ public class OpenEjbSystemGBean implemen
     private Properties properties; 
     
     public OpenEjbSystemGBean(RecoverableTransactionManager transactionManager) throws Exception {
-        this(transactionManager, null, null, null, OpenEjbSystemGBean.class.getClassLoader(), new Properties());
+        this(transactionManager, null, null, null, null, OpenEjbSystemGBean.class.getClassLoader(), new Properties());
     }
 
     public OpenEjbSystemGBean(@ParamReference(name = "TransactionManager", namingType = NameFactory.JTA_RESOURCE) RecoverableTransactionManager transactionManager,
                               @ParamReference(name = "ResourceAdapterWrappers", namingType = NameFactory.JCA_RESOURCE_ADAPTER) Collection<ResourceAdapterWrapper> resourceAdapters,
                               @ParamReference(name = "PersistenceUnitGBeans", namingType = NameFactory.PERSISTENCE_UNIT) Collection<PersistenceUnitGBean> persistenceUnitGBeans,
+                              @ParamReference(name = "ApplicationJndis") Collection<ApplicationJndi> applicationJndis,
 //                              @ParamReference(name = "OpenEjbContext")DeepBindableContext openejbContext,
                               @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
                               @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
@@ -131,7 +133,8 @@ public class OpenEjbSystemGBean implemen
 //        System.setProperty("openejb.naming", "xbean");
         boolean offline = true;
         configurationFactory = new ConfigurationFactory(offline);
-        assembler = new Assembler(new XBeanJndiFactory());
+        final XBeanJndiFactory jndiFactory = new XBeanJndiFactory();
+        assembler = new Assembler(jndiFactory);
 
         // install application server
         ApplicationServer applicationServer = new ServerFederation();
@@ -174,6 +177,21 @@ public class OpenEjbSystemGBean implemen
         // process all resource adapters
         processResourceAdapterWrappers(resourceAdapters);
         processPersistenceUnitGBeans(persistenceUnitGBeans);
+
+        if (applicationJndis instanceof ReferenceCollection) {
+            ((ReferenceCollection)applicationJndis).addReferenceCollectionListener(new ReferenceCollectionListener() {
+                @Override
+                public void memberAdded(ReferenceCollectionEvent referenceCollectionEvent) {
+                     jndiFactory.addGlobals(((ApplicationJndi)referenceCollectionEvent.getMember()).getGlobalMap());
+                }
+
+                @Override
+                public void memberRemoved(ReferenceCollectionEvent referenceCollectionEvent) {
+                    jndiFactory.removeGlobals(((ApplicationJndi) referenceCollectionEvent.getMember()).getGlobalMap());
+                }
+            });
+
+        }
     }
 
     private void setDefaultProperty(String key, String value) {

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java Mon Jun 27 22:58:09 2011
@@ -27,6 +27,7 @@ import java.util.Map;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
+import org.apache.geronimo.gjndi.FederatedContext;
 import org.apache.geronimo.j2ee.jndi.JndiKey;
 import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.openejb.SystemException;
@@ -80,5 +81,27 @@ public class XBeanJndiFactory implements
     public Context createRootContext() {
         return rootContext;
     }
+
+    public void addGlobals(Map<String, Object> globals) {
+        for (Map.Entry<String, Object> entry: globals.entrySet()) {
+            String name = "openejb/global/" + entry.getKey();
+            try {
+                rootContext.bind(name, entry.getValue());
+            } catch (NamingException e) {
+                //??
+            }
+        }
+    }
+
+    public void removeGlobals(Map<String, Object> globals) {
+        for (Map.Entry<String, Object> entry: globals.entrySet()) {
+            String name = "openejb/global/" + entry.getKey();
+            try {
+                rootContext.unbind(name);
+            } catch (NamingException e) {
+                //??
+            }
+        }
+    }
 }
 

Modified: geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml?rev=1140357&r1=1140356&r2=1140357&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml Mon Jun 27 22:58:09 2011
@@ -33,6 +33,7 @@
         </reference>
         <reference name="ResourceAdapterWrappers"/>
         <reference name="PersistenceUnitGBeans"/>
+        <reference name="ApplicationJndis"/>
     </gbean>
 
     <gbean name="ExtendedEntityManagerRegistry" class="org.apache.geronimo.openejb.EntityManagerRegistryImpl">



Mime
View raw message