geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r829303 - in /geronimo/server/trunk/framework: configs/j2ee-system/src/main/plan/ modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/
Date Sat, 24 Oct 2009 04:07:01 GMT
Author: xuhaihong
Date: Sat Oct 24 04:07:00 2009
New Revision: 829303

URL: http://svn.apache.org/viewvc?rev=829303&view=rev
Log:
GERONIMO-4925 Temporarily enable the EditableConfigurationManager to avoid those plug-in compile
errors.

Modified:
    geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java

Modified: geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml?rev=829303&r1=829302&r2=829303&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/framework/configs/j2ee-system/src/main/plan/plan.xml Sat Oct 24
04:07:00 2009
@@ -89,9 +89,9 @@
     </gbean>
 
     <!--Configuration Manager service-->
-    <gbean name="ConfigurationManager" class="org.apache.geronimo.kernel.config.KernelConfigurationManager">
+    <gbean name="ConfigurationManager" class="org.apache.geronimo.kernel.config.EditableKernelConfigurationManager">
         <!--<attribute name="defaultStoreNameQuery">?name=MasterConfigurationStore</attribute>-->
-        <!--<attribute name="defaultStoreNameQuery">?name=Local</attribute>-->
+        <attribute name="defaultStoreNameQuery">?name=Local</attribute>
         <reference name="Repositories"></reference>
         <reference name="Stores"></reference>
         <reference name="Watchers"></reference>

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=829303&r1=829302&r2=829303&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
Sat Oct 24 04:07:00 2009
@@ -342,23 +342,23 @@
      * @return The EdtiableConfigurationManager, or none if there is not one available.
      * @throws IllegalStateException Occurs if there are multiple EditableConfigurationManagers
in the kernel.
      */
-//    public static EditableConfigurationManager getEditableConfigurationManager(Kernel kernel)
{
-//        Set names = kernel.listGBeans(new AbstractNameQuery(EditableConfigurationManager.class.getName()));
-//        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
-//            AbstractName abstractName = (AbstractName) iterator.next();
-//            if (!kernel.isRunning(abstractName)) {
-//                iterator.remove();
-//            }
-//        }
-//        if (names.isEmpty()) {
-//            return null; // may be one, just not editable
-//        }
-//        if (names.size() > 1) {
-//            throw new IllegalStateException("More than one Configuration Manager was found
in the kernel");
-//        }
-//        AbstractName configurationManagerName = (AbstractName) names.iterator().next();
-//        return (EditableConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName,
EditableConfigurationManager.class);
-//    }
+    public static EditableConfigurationManager getEditableConfigurationManager(Kernel kernel)
{
+        Set names = kernel.listGBeans(new AbstractNameQuery(EditableConfigurationManager.class.getName()));
+        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+            AbstractName abstractName = (AbstractName) iterator.next();
+            if (!kernel.isRunning(abstractName)) {
+                iterator.remove();
+            }
+        }
+        if (names.isEmpty()) {
+            return null; // may be one, just not editable
+        }
+        if (names.size() > 1) {
+            throw new IllegalStateException("More than one Configuration Manager was found
in the kernel");
+        }
+        AbstractName configurationManagerName = (AbstractName) names.iterator().next();
+        return (EditableConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName,
EditableConfigurationManager.class);
+    }
 
     public static void releaseConfigurationManager(Kernel kernel, ConfigurationManager configurationManager)
{
 //        kernel.getProxyManager().destroyProxy(configurationManager);

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java?rev=829303&r1=829302&r2=829303&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java
Sat Oct 24 04:07:00 2009
@@ -25,20 +25,20 @@
 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.annotation.GBean;
+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.gbean.annotation.ParamReference;
-import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.kernel.osgi.BundleClassLoader;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactManager;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.ListableRepository;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -52,12 +52,12 @@
 
     public EditableKernelConfigurationManager(@ParamSpecial(type = SpecialAttributeType.kernel)
Kernel kernel,
                                               @ParamAttribute(name = GBEAN_ATTR_DEFAULT_STORE_NAME_QUERY)
AbstractNameQuery defaultStoreNameQuery,
-                                              @ParamReference(name = "ConfigurationStore")
Collection<ConfigurationStore> stores,
-                                              @ParamReference(name = "AttributeStore") ManageableAttributeStore
attributeStore,
+                                              @ParamReference(name = "Stores", namingType
= "ConfigurationStore") Collection<ConfigurationStore> stores,
+                                              @ParamReference(name = "AttributeStore", namingType
= "AttributeStore") ManageableAttributeStore attributeStore,
                                               @ParamReference(name = "PersistentConfigurationList")
PersistentConfigurationList configurationList,
-                                              @ParamReference(name = "ArtifactManager") ArtifactManager
artifactManager,
-                                              @ParamReference(name = "ArtifactResolver")
ArtifactResolver artifactResolver,
-                                              @ParamReference(name = "Repositories") Collection<ListableRepository>
repositories,
+                                              @ParamReference(name = "ArtifactManager", namingType
= "ArtifactManager") ArtifactManager artifactManager,
+                                              @ParamReference(name = "ArtifactResolver",
namingType = "ArtifactResolver") ArtifactResolver artifactResolver,
+                                              @ParamReference(name = "Repositories", namingType
= "Repository") Collection<ListableRepository> repositories,
                                               @ParamReference(name = "Watchers") Collection<DeploymentWatcher>
watchers,
                                               @ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext) {
         super(kernel,
@@ -69,8 +69,7 @@
                 repositories,
                 watchers,
                 bundleContext);
-        this.defaultStoreNameQuery = defaultStoreNameQuery;
-        throw new RuntimeException("more than deprecated");
+        this.defaultStoreNameQuery = defaultStoreNameQuery;        
     }
 
     @Override
@@ -92,106 +91,106 @@
     }
 
     public void addGBeanToConfiguration(Artifact configurationId, GBeanData gbean, boolean
start) throws InvalidConfigException {
-//        Configuration configuration = getConfiguration(configurationId);
-//
-//        try {
-//            // add the gbean to the configuration
-//            configuration.addGBean(gbean);
-//        } catch (GBeanAlreadyExistsException e) {
-//            throw new InvalidConfigException("Cound not add GBean " + gbean.getAbstractName()
+ " to configuration " + configurationId, e);
-//        }
-//
-//        addGBeanToConfiguration(configuration, gbean, start);
+        Configuration configuration = getConfiguration(configurationId);
+
+        try {
+            // add the gbean to the configuration
+            configuration.addGBean(gbean);
+        } catch (GBeanAlreadyExistsException e) {
+            throw new InvalidConfigException("Cound not add GBean " + gbean.getAbstractName()
+ " to configuration " + configurationId, e);
+        }
+
+        addGBeanToConfiguration(configuration, gbean, start);
     }
 
     public void addGBeanToConfiguration(Artifact configurationId, String name, GBeanData
gbean, boolean start) throws InvalidConfigException {
-//        Configuration configuration = getConfiguration(configurationId);
-//
-//        try {
-//            // add the gbean to the configuration
-//            configuration.addGBean(name, gbean);
-//        } catch (GBeanAlreadyExistsException e) {
-//            throw new InvalidConfigException("Cound not add GBean " + gbean.getAbstractName()
+ " to configuration " + configurationId, e);
-//        }
-//
-//        addGBeanToConfiguration(configuration, gbean, start);
-    }
-
-//    private void addGBeanToConfiguration(Configuration configuration, GBeanData gbean,
boolean start) throws InvalidConfigException {
-//        ClassLoader configurationClassLoader = configuration.getConfigurationClassLoader();
-//        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
-//        try {
-//            Thread.currentThread().setContextClassLoader(configurationClassLoader);
-//
-//            log.trace("Registering GBean " + gbean.getAbstractName());
-//
-//
-//            // preprocess the gbean data before loading it into the kernel
-//            ConfigurationUtil.preprocessGBeanData(configuration.getAbstractName(), configuration,
gbean);
-//
-//            // register the bean with the kernel
-//            kernel.loadGBean(gbean, configurationClassLoader);
-//
-//            // start the configuration
-//            if (start) {
-//                try {
-//                    kernel.startRecursiveGBean(gbean.getAbstractName());
-//                } catch (GBeanNotFoundException e) {
-//                    throw new InvalidConfigException("How could we not find a GBean that
we just loaded ('" + gbean.getAbstractName() + "')?", e);
-//                }
-//            }
-//
-//        } catch(Exception e) {
-//            // clean up failed gbean
-//            try {
-//                configuration.removeGBean(gbean.getAbstractName());
-//            } catch (GBeanNotFoundException e1) {
-//                // this is good
-//            }
-//            try {
-//                kernel.stopGBean(gbean.getAbstractName());
-//            } catch (GBeanNotFoundException e1) {
-//                // this is good
-//            }
-//            try {
-//                kernel.unloadGBean(gbean.getAbstractName());
-//            } catch (GBeanNotFoundException e1) {
-//                // this is good
-//            }
-//
-//            if (e instanceof InvalidConfigException) {
-//                throw (InvalidConfigException) e;
-//            }
-//            throw new InvalidConfigException("Cound not add GBean " + gbean.getAbstractName()
+ " to configuration " + configuration.getId(), e);
-//        } finally {
-//            Thread.currentThread().setContextClassLoader(oldCl);
-//        }
-//
-//        if (attributeStore != null) {
-//            attributeStore.addGBean(configuration.getId(), gbean, configurationClassLoader);
-//        }
-//    }
+        Configuration configuration = getConfiguration(configurationId);
+
+        try {
+            // add the gbean to the configuration
+            configuration.addGBean(name, gbean);
+        } catch (GBeanAlreadyExistsException e) {
+            throw new InvalidConfigException("Cound not add GBean " + gbean.getAbstractName()
+ " to configuration " + configurationId, e);
+        }
+
+        addGBeanToConfiguration(configuration, gbean, start);
+    }
+
+    private void addGBeanToConfiguration(Configuration configuration, GBeanData gbean, boolean
start) throws InvalidConfigException {
+        ClassLoader configurationClassLoader = new BundleClassLoader(configuration.getBundle());
+        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(configurationClassLoader);
+
+            log.trace("Registering GBean " + gbean.getAbstractName());
+
+
+            // preprocess the gbean data before loading it into the kernel
+            ConfigurationUtil.preprocessGBeanData(configuration.getAbstractName(), configuration,
gbean);
+
+            // register the bean with the kernel
+            kernel.loadGBean(gbean, configuration.getBundleContext());
+
+            // start the configuration
+            if (start) {
+                try {
+                    kernel.startRecursiveGBean(gbean.getAbstractName());
+                } catch (GBeanNotFoundException e) {
+                    throw new InvalidConfigException("How could we not find a GBean that
we just loaded ('" + gbean.getAbstractName() + "')?", e);
+                }
+            }
+
+        } catch(Exception e) {
+            // clean up failed gbean
+            try {
+                configuration.removeGBean(gbean.getAbstractName());
+            } catch (GBeanNotFoundException e1) {
+                // this is good
+            }
+            try {
+                kernel.stopGBean(gbean.getAbstractName());
+            } catch (GBeanNotFoundException e1) {
+                // this is good
+            }
+            try {
+                kernel.unloadGBean(gbean.getAbstractName());
+            } catch (GBeanNotFoundException e1) {
+                // this is good
+            }
+
+            if (e instanceof InvalidConfigException) {
+                throw (InvalidConfigException) e;
+            }
+            throw new InvalidConfigException("Cound not add GBean " + gbean.getAbstractName()
+ " to configuration " + configuration.getId(), e);
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldCl);
+        }
+
+        if (attributeStore != null) {
+            attributeStore.addGBean(configuration.getId(), gbean, configuration.getBundle());
+        }
+    }
 
     public void removeGBeanFromConfiguration(Artifact configurationId, AbstractName gbeanName)
throws GBeanNotFoundException, InvalidConfigException {
-//        Configuration configuration = getConfiguration(configurationId);
-//        if (!configuration.containsGBean(gbeanName)) {
-//            throw new GBeanNotFoundException(gbeanName);
-//        }
-//        configuration.removeGBean(gbeanName);
-//
-//        try {
-//            if (kernel.getGBeanState(gbeanName) == State.RUNNING_INDEX) {
-//                kernel.stopGBean(gbeanName);
-//            }
-//            kernel.unloadGBean(gbeanName);
-//        } catch (GBeanNotFoundException e) {
-//            // Bean is no longer loaded
-//        }
-//
-//        // Make sure it's not loaded next time the configuration is loaded
-//        if (attributeStore != null) {
-//            attributeStore.setShouldLoad(configurationId, gbeanName, false);
-//        }
+        Configuration configuration = getConfiguration(configurationId);
+        if (!configuration.containsGBean(gbeanName)) {
+            throw new GBeanNotFoundException(gbeanName);
+        }
+        configuration.removeGBean(gbeanName);
+
+        try {
+            if (kernel.getGBeanState(gbeanName) == State.RUNNING_INDEX) {
+                kernel.stopGBean(gbeanName);
+            }
+            kernel.unloadGBean(gbeanName);
+        } catch (GBeanNotFoundException e) {
+            // Bean is no longer loaded
+        }
+
+        // Make sure it's not loaded next time the configuration is loaded
+        if (attributeStore != null) {
+            attributeStore.setShouldLoad(configurationId, gbeanName, false);
+        }
     }
 
 



Mime
View raw message