geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r109305 - in geronimo/trunk/modules: connector-builder/src/java/org/apache/geronimo/connector/deployment deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/service
Date Wed, 01 Dec 2004 06:52:30 GMT
Author: dain
Date: Tue Nov 30 22:52:30 2004
New Revision: 109305

URL: http://svn.apache.org/viewcvs?view=rev&rev=109305
Log:
Removed my objection to starting the configurations.
Added code to verify that the configurations are actually started.
Converted more GBeanMBean usage to GBeanData.

Modified:
   geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java?view=diff&rev=109305&p1=geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java&r1=109304&p2=geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java&r2=109305
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Tue Nov 30 22:52:30 2004
@@ -37,9 +37,9 @@
 import javax.naming.Reference;
 
 import org.apache.geronimo.common.propertyeditor.PropertyEditors;
-import org.apache.geronimo.connector.ResourceAdapterModuleImpl;
-import org.apache.geronimo.connector.AdminObjectWrapper;
 import org.apache.geronimo.connector.ActivationSpecWrapper;
+import org.apache.geronimo.connector.AdminObjectWrapper;
+import org.apache.geronimo.connector.ResourceAdapterModuleImpl;
 import org.apache.geronimo.connector.outbound.JCAConnectionFactoryImpl;
 import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
@@ -61,7 +61,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.j2ee.deployment.ConnectorModule;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
@@ -362,7 +361,7 @@
         GBeanData resourceAdapterModuleData = earContext.getRefContext().getResourceAdapterModuleData(resourceAdapterModuleName);
 
         // add it
-        earContext.addGBean(resourceAdapterModuleData, cl);
+        earContext.addGBean(resourceAdapterModuleData);
 
         GerConnectorType geronimoConnector = (GerConnectorType) module.getVendorDD();
 
@@ -407,7 +406,7 @@
                     throw new DeploymentException("Could not construct resource adapter object
name", e);
                 }
                 resourceAdapterInstanceGBeanData.setName(resourceAdapterObjectName);
-                earContext.addGBean(resourceAdapterInstanceGBeanData, cl);
+                earContext.addGBean(resourceAdapterInstanceGBeanData);
             }
 
             // Outbound Managed Connection Factories (think JDBC data source or JMS connection
factory)
@@ -419,7 +418,7 @@
                     assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition";
 
                     String connectionFactoryInterfaceName = geronimoConnectionDefinition.getConnectionfactoryInterface().getStringValue().trim();
-                    GBeanData connectionFactoryGBeanData = (GBeanData) earContext.getRefContext().getConnectionFactoryInfo(resourceAdapterModuleObjectName,
connectionFactoryInterfaceName);
+                    GBeanData connectionFactoryGBeanData = earContext.getRefContext().getConnectionFactoryInfo(resourceAdapterModuleObjectName,
connectionFactoryInterfaceName);
 
                     if (connectionFactoryGBeanData == null) {
                         throw new DeploymentException("No connection definition for ConnectionFactory
class: " + connectionFactoryInterfaceName);
@@ -440,7 +439,7 @@
             GerAdminobjectType gerAdminObject = geronimoConnector.getAdminobjectArray()[i];
 
             String adminObjectInterface = gerAdminObject.getAdminobjectInterface().getStringValue();
-            GBeanData adminObjectGBeanData = (GBeanData) earContext.getRefContext().getAdminObjectInfo(resourceAdapterModuleObjectName,
adminObjectInterface);
+            GBeanData adminObjectGBeanData = earContext.getRefContext().getAdminObjectInfo(resourceAdapterModuleObjectName,
adminObjectInterface);
 
             if (adminObjectGBeanData == null) {
                 throw new DeploymentException("No admin object declared for interface: "
+ adminObjectInterface);
@@ -458,7 +457,7 @@
                     throw new DeploymentException("Could not construct admin object object
name", e);
                 }
                 adminObjectInstanceGBeanData.setName(adminObjectObjectName);
-                earContext.addGBean(adminObjectInstanceGBeanData, cl);
+                earContext.addGBean(adminObjectInstanceGBeanData);
             }
         }
     }
@@ -617,14 +616,25 @@
             }
         }
 
-        //we configure our connection manager
-        GerConnectionmanagerType connectionManager = connectionfactoryInstance.getConnectionmanager();
-        GBeanMBean connectionManagerGBean;
+        // create the object name for our connection manager
+        ObjectName connectionManagerObjectName = null;
         try {
-            connectionManagerGBean = new GBeanMBean(GBeanInfo.getGBeanInfo("org.apache.geronimo.connector.outbound.GenericConnectionManager",
cl), cl);
+            connectionManagerObjectName = NameFactory.getResourceComponentName(null, null,
null, null, connectionfactoryInstance.getName(), NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Could not construct connection manager object
name", e);
+        }
+
+        // create the data holder for our connection manager
+        GBeanInfo gbeanInfo;
+        try {
+            gbeanInfo = GBeanInfo.getGBeanInfo("org.apache.geronimo.connector.outbound.GenericConnectionManager",
cl);
         } catch (InvalidConfigurationException e) {
             throw new DeploymentException("Unable to create GMBean", e);
         }
+        GBeanData connectionManagerGBean = new GBeanData(connectionManagerObjectName, gbeanInfo);
+
+        //we configure our connection manager
+        GerConnectionmanagerType connectionManager = connectionfactoryInstance.getConnectionmanager();
         TransactionSupport transactionSupport = null;
         if (connectionManager.isSetNoTransaction()) {
             transactionSupport = NoTransactions.INSTANCE;
@@ -685,14 +695,7 @@
             throw new DeploymentException("Problem setting up ConnectionManager", e);
         }
 
-        // add it
-        ObjectName connectionManagerObjectName = null;
-        try {
-            connectionManagerObjectName = NameFactory.getResourceComponentName(null, null,
null, null, connectionfactoryInstance.getName(), NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
-        } catch (MalformedObjectNameException e) {
-            throw new DeploymentException("Could not construct connection manager object
name", e);
-        }
-        earContext.addGBean(connectionManagerObjectName, connectionManagerGBean);
+        earContext.addGBean(connectionManagerGBean);
         return connectionManagerObjectName;
     }
 
@@ -718,11 +721,11 @@
             }
             managedConnectionFactoryInstanceGBeanData.setReferencePattern("ConnectionManagerFactory",
connectionManagerObjectName);
             if (connectiondefinitionInstance.getCredentialInterface() != null &&
"javax.resource.spi.security.PasswordCredential".equals(connectiondefinitionInstance.getCredentialInterface().getStringValue()))
{
-                GBeanMBean realmGBean = new GBeanMBean(PasswordCredentialRealm.getGBeanInfo(),
cl);
+                ObjectName realmObjectName = ObjectName.getInstance(BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME
+ connectiondefinitionInstance.getName());
+                GBeanData realmGBean = new GBeanData(realmObjectName, PasswordCredentialRealm.getGBeanInfo());
                 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);
-                managedConnectionFactoryInstanceGBeanData.setReferencePattern("ManagedConnectionFactoryListener",
realmObjectNam);
+                earContext.addGBean(realmGBean);
+                managedConnectionFactoryInstanceGBeanData.setReferencePattern("ManagedConnectionFactoryListener",
realmObjectName);
             }
             //additional interfaces implemented by connection factory
             FullyQualifiedClassType[] implementedInterfaceElements = connectiondefinitionInstance.getImplementedInterfaceArray();
@@ -744,7 +747,7 @@
             throw new DeploymentException("Could not construct managed connection factory
object name", e);
         }
         managedConnectionFactoryInstanceGBeanData.setName(managedConnectionFactoryObjectName);
-        earContext.addGBean(managedConnectionFactoryInstanceGBeanData, cl);
+        earContext.addGBean(managedConnectionFactoryInstanceGBeanData);
 
         // ConnectionFactory
         ObjectName connectionFactoryObjectName = null;
@@ -757,7 +760,7 @@
         connectionFactoryGBeanData.setReferencePattern("J2EEServer", earContext.getServerObjectName());
         connectionFactoryGBeanData.setAttribute("managedConnectionFactory", managedConnectionFactoryObjectName.getCanonicalName());
 
-        earContext.addGBean(connectionFactoryGBeanData, cl);
+        earContext.addGBean(connectionFactoryGBeanData);
     }
 
     private static URI getDependencyURI(GerDependencyType dependency) throws DeploymentException
{

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?view=diff&rev=109305&p1=geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java&r1=109304&p2=geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java&r2=109305
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Tue Nov 30 22:52:30 2004
@@ -67,7 +67,7 @@
      */
     private final ConfigurationModuleType type;
     private final Kernel kernel;
-    private final GBeanMBean config;
+    private final GBeanData config;
     private final Map gbeans = new HashMap();
     private final Set dependencies = new LinkedHashSet();
     private final LinkedHashSet classPath = new LinkedHashSet();
@@ -95,7 +95,7 @@
         this.baseDir = baseDir;
         this.baseUri = baseDir.toURI();
 
-        config = new GBeanMBean(Configuration.GBEAN_INFO);
+        config = new GBeanData(Configuration.getConfigurationObjectName(configID), Configuration.GBEAN_INFO);
 
         try {
             config.setAttribute("ID", configID);
@@ -117,16 +117,21 @@
             }
 
             try {
-                // todo it is a really bad to start the configurations
-                ObjectName currentConfig = parentName;
-                while ( State.RUNNING != State.fromInteger((Integer) kernel.getAttribute(currentConfig,
"state")) ) {
-                    kernel.startGBean(currentConfig);
-                    URI currentParentID = (URI) kernel.getAttribute(currentConfig, "parentID");
-                    if ( null == currentParentID ) {
+                // starting with the current config start all parents until
+                // there are either no more parents or a parent is already running
+                for (Iterator iterator = ancestors.iterator(); iterator.hasNext();) {
+                    ObjectName name = (ObjectName) iterator.next();
+                    if (isRunning(kernel, name) ) {
+                        // configuration is already running... we can stop now
                         break;
                     }
-                    currentConfig = Configuration.getConfigurationObjectName(currentParentID);
+                    kernel.startGBean(name);
+                    if (!isRunning(kernel, name) ) {
+                        throw new DeploymentException("Failed to start parent configuration:
" + name);
+                    }
                 }
+            } catch (DeploymentException e) {
+                throw e;
             } catch (Exception e) {
                 throw new DeploymentException(e);
             }
@@ -145,6 +150,10 @@
         }
     }
 
+    private static boolean isRunning(Kernel kernel, ObjectName name) throws Exception {
+        return State.RUNNING_INDEX == ((Integer) kernel.getAttribute(name, "state")).intValue();
+    }
+
     public URI getConfigID() {
         return configID;
     }
@@ -157,13 +166,16 @@
         return baseDir;
     }
 
+    /**
+     * @deprecated use addGBean(GBeanData gbean)
+     */
     public void addGBean(ObjectName name, GBeanMBean gbean) {
         gbeans.put(name, gbean);
     }
 
-    public void addGBean(GBeanData gbean, ClassLoader classLoader) {
-        GBeanMBean gbeanMBean = new GBeanMBean(gbean, classLoader);
-        gbeans.put(gbean.getName(), gbeanMBean);
+    public void addGBean(GBeanData gbean) {
+        assert gbean.getName() != null: "GBean name is null";
+        gbeans.put(gbean.getName(), gbean);
     }
 
     public void addDependency(URI uri) {
@@ -421,9 +433,7 @@
         try {
             out = new ObjectOutputStream(new FileOutputStream(configSer));
             try {
-                GBeanData gbeanData = config.getGBeanData();
-                gbeanData.setName(Configuration.getConfigurationObjectName(configID));
-                gbeanData.writeExternal(out);
+                config.writeExternal(out);
             } catch (IOException e) {
                 throw e;
             } catch (Exception e) {

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java?view=diff&rev=109305&p1=geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java&r1=109304&p2=geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java&r2=109305
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanHelper.java
Tue Nov 30 22:52:30 2004
@@ -45,6 +45,6 @@
             builder.setReference(gbean.getReferencesName(j), gbean.getReferencesPatternArray(j));
         }
 
-        context.addGBean(builder.getGBeanData(), cl);
+        context.addGBean(builder.getGBeanData());
     }
 }

Mime
View raw message