geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject cvs commit: incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local StopCommand.java
Date Tue, 01 Jun 2004 16:06:51 GMT
jboynes     2004/06/01 09:06:51

  Modified:    modules/kernel/src/java/org/apache/geronimo/kernel/config
                        ConfigurationManager.java
               modules/deployment/src/java/org/apache/geronimo/deployment
                        DeploymentContext.java
               modules/jetty/src/java/org/apache/geronimo/jetty/deployment
                        JettyModuleBuilder.java
               modules/kernel/src/java/org/apache/geronimo/kernel
                        Kernel.java
               modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local
                        StopCommand.java
  Added:       modules/kernel/src/java/org/apache/geronimo/kernel/config
                        ConfigurationManagerImpl.java
  Log:
  Make ConfigurationManager an interface
  
  Revision  Changes    Path
  1.5       +20 -164   incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java
  
  Index: ConfigurationManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ConfigurationManager.java	27 May 2004 01:06:00 -0000	1.4
  +++ ConfigurationManager.java	1 Jun 2004 16:06:50 -0000	1.5
  @@ -1,6 +1,6 @@
   /**
    *
  - * Copyright 2003-2004 The Apache Software Foundation
  + * Copyright 2004 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -14,86 +14,30 @@
    *  See the License for the specific language governing permissions and
    *  limitations under the License.
    */
  -
   package org.apache.geronimo.kernel.config;
   
   import java.io.IOException;
   import java.net.URI;
   import java.net.URL;
  -import java.util.Collection;
  -import java.util.HashSet;
  -import java.util.Iterator;
  -import java.util.LinkedList;
   import java.util.List;
  -import java.util.Set;
  -import javax.management.InstanceNotFoundException;
   import javax.management.MalformedObjectNameException;
   import javax.management.ObjectName;
   
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
  -import org.apache.geronimo.gbean.GBeanInfo;
  -import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.kernel.Kernel;
   
   /**
  + * 
  + * 
    * @version $Revision$ $Date$
    */
  -public class ConfigurationManager {
  -    private static final Log log = LogFactory.getLog(ConfigurationManager.class);
  -    private final Kernel kernel;
  -    private final Collection stores;
  -
  -    public ConfigurationManager() {
  -        kernel = null;
  -        stores = null;
  -    }
  -
  -    public ConfigurationManager(Kernel kernel, Collection stores) {
  -        this.kernel = kernel;
  -        this.stores = stores;
  -    }
  -
  -    public boolean isLoaded(URI configID) {
  -        try {
  -            ObjectName name = getConfigObjectName(configID);
  -            return kernel.isLoaded(name);
  -        } catch (MalformedObjectNameException e) {
  -            return false;
  -        }
  -    }
  -
  -    public ObjectName load(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException
{
  -        Set storeSnapshot = getStoreSnapshot();
  -
  -        for (Iterator iterator = storeSnapshot.iterator(); iterator.hasNext();) {
  -            ConfigurationStore store = (ConfigurationStore) iterator.next();
  -            if (store.containsConfiguration(configID)) {
  -                GBeanMBean config = store.getConfiguration(configID);
  -                URL baseURL = store.getBaseURL(configID);
  -                return load(config, baseURL);
  -            }
  -        }
  -        throw new NoSuchConfigException("A configuration with the specifiec id could not
be found: " + configID);
  -    }
  -
  -    public ObjectName load(GBeanMBean config, URL rootURL) throws InvalidConfigException
{
  -        URI configID;
  -        try {
  -            configID = (URI) config.getAttribute("ID");
  -        } catch (Exception e) {
  -            throw new InvalidConfigException("Cannot get config ID", e);
  -        }
  -        ObjectName configName;
  -        try {
  -            configName = getConfigObjectName(configID);
  -        } catch (MalformedObjectNameException e) {
  -            throw new InvalidConfigException("Cannot convert ID to ObjectName: ", e);
  -        }
  -        load(config, rootURL, configName);
  -        return configName;
  -    }
  +public interface ConfigurationManager {
  +    boolean isLoaded(URI configID);
  +
  +    ObjectName getConfigObjectName(URI configID) throws MalformedObjectNameException;
  +
  +    ObjectName load(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException;
  +
  +    ObjectName load(GBeanMBean config, URL rootURL) throws InvalidConfigException;
   
       /**
        * Load the supplied Configuration into the Kernel and override the default JMX name.
  @@ -103,101 +47,13 @@
        * @param config the GBeanMBean representing the Configuration
        * @param rootURL the URL to be used to resolve relative paths in the configuration
        * @param configName the JMX ObjectName to register the Configuration under
  -     * @throws InvalidConfigException if the Configuration is not valid
  +     * @throws org.apache.geronimo.kernel.config.InvalidConfigException if the Configuration
is not valid
        */
  -    public void load(GBeanMBean config, URL rootURL, ObjectName configName) throws InvalidConfigException
{
  -        try {
  -            kernel.loadGBean(configName, config);
  -        } catch (InvalidConfigException e) {
  -            throw e;
  -        } catch (Exception e) {
  -            throw new InvalidConfigException("Unable to register configuraton", e);
  -        }
  -
  -        try {
  -            config.setAttribute("BaseURL", rootURL);
  -        } catch (Exception e) {
  -            try {
  -                kernel.unloadGBean(configName);
  -            } catch (Exception ignored) {
  -                // ignore
  -            }
  -            throw new InvalidConfigException("Cannot set BaseURL", e);
  -        }
  -        log.info("Loaded Configuration " + configName);
  -    }
  -
  -    public List loadRecursive(URI configID) throws NoSuchConfigException, IOException,
InvalidConfigException {
  -        try {
  -            LinkedList ancestors = new LinkedList();
  -            while (configID != null && !isLoaded(configID)) {
  -                ObjectName name = load(configID);
  -                ancestors.addFirst(name);
  -                configID = (URI) kernel.getAttribute(name, "ParentID");
  -            }
  -            return ancestors;
  -        } catch (NoSuchConfigException e) {
  -            throw e;
  -        } catch (IOException e) {
  -            throw e;
  -        } catch (InvalidConfigException e) {
  -            throw e;
  -        } catch (Exception e) {
  -            throw new InvalidConfigException(e);
  -        }
  -    }
  -
  -    public void unload(URI configID) throws NoSuchConfigException {
  -        ObjectName configName;
  -        try {
  -            configName = getConfigObjectName(configID);
  -        } catch (MalformedObjectNameException e) {
  -            throw new NoSuchConfigException("Cannot convert ID to ObjectName: ", e);
  -        }
  -        unload(configName);
  -    }
  -
  -    public void unload(ObjectName configName) throws NoSuchConfigException {
  -        try {
  -            kernel.unloadGBean(configName);
  -        } catch (InstanceNotFoundException e) {
  -            throw new NoSuchConfigException("No config registered: " + configName, e);
  -        }
  -        log.info("Unloaded Configuration " + configName);
  -    }
  -
  -    private Set getStoreSnapshot() {
  -        Set storeSnapshot = new HashSet(stores);
  -        if (storeSnapshot.size() == 0) {
  -            throw new UnsupportedOperationException("There are no installed ConfigurationStores");
  -        }
  -        return storeSnapshot;
  -    }
  -
  -    public static ObjectName getConfigObjectName(URI configID) throws MalformedObjectNameException
{
  -        return new ObjectName("geronimo.config:name=" + ObjectName.quote(configID.toString()));
  -    }
  -
  -    public static final GBeanInfo GBEAN_INFO;
  -
  -    static {
  -        GBeanInfoFactory infoFactory = new GBeanInfoFactory(ConfigurationManager.class);
  -        infoFactory.addReference("Kernel", Kernel.class);
  -        infoFactory.addReference("Stores", ConfigurationStore.class);
  -        infoFactory.addOperation("isLoaded", new Class[]{URI.class});
  -        infoFactory.addOperation("load", new Class[]{URI.class});
  -        infoFactory.addOperation("load", new Class[]{GBeanMBean.class, URL.class});
  -        infoFactory.addOperation("load", new Class[]{GBeanMBean.class, URL.class, ObjectName.class});
  -        infoFactory.addOperation("loadRecursive", new Class[]{URI.class});
  -        infoFactory.addOperation("unload", new Class[]{URI.class});
  -        infoFactory.addOperation("unload", new Class[]{ObjectName.class});
  -
  -        infoFactory.setConstructor(new String[]{"Kernel", "Stores"},
  -                new Class[]{Kernel.class, Collection.class});
  -        GBEAN_INFO = infoFactory.getBeanInfo();
  -    }
  -
  -    public static GBeanInfo getGBeanInfo() {
  -        return GBEAN_INFO;
  -    }
  +    void load(GBeanMBean config, URL rootURL, ObjectName configName) throws InvalidConfigException;
  +
  +    List loadRecursive(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException;
  +
  +    void unload(URI configID) throws NoSuchConfigException;
  +
  +    void unload(ObjectName configName) throws NoSuchConfigException;
   }
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
  
  Index: ConfigurationManagerImpl.java
  ===================================================================
  /**
   *
   * Copyright 2003-2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.kernel.config;
  
  import java.io.IOException;
  import java.net.URI;
  import java.net.URL;
  import java.util.Collection;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Set;
  import javax.management.InstanceNotFoundException;
  import javax.management.MalformedObjectNameException;
  import javax.management.ObjectName;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.geronimo.gbean.GBeanInfo;
  import org.apache.geronimo.gbean.GBeanInfoFactory;
  import org.apache.geronimo.gbean.jmx.GBeanMBean;
  import org.apache.geronimo.kernel.Kernel;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/06/01 16:06:50 $
   */
  public class ConfigurationManagerImpl implements ConfigurationManager {
      private static final Log log = LogFactory.getLog(ConfigurationManagerImpl.class);
      private final Kernel kernel;
      private final Collection stores;
  
      public ConfigurationManagerImpl(Kernel kernel, Collection stores) {
          this.kernel = kernel;
          this.stores = stores;
      }
  
      public boolean isLoaded(URI configID) {
          try {
              ObjectName name = getConfigObjectName(configID);
              return kernel.isLoaded(name);
          } catch (MalformedObjectNameException e) {
              return false;
          }
      }
  
      public ObjectName load(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException
{
          Set storeSnapshot = getStoreSnapshot();
  
          for (Iterator iterator = storeSnapshot.iterator(); iterator.hasNext();) {
              ConfigurationStore store = (ConfigurationStore) iterator.next();
              if (store.containsConfiguration(configID)) {
                  GBeanMBean config = store.getConfiguration(configID);
                  URL baseURL = store.getBaseURL(configID);
                  return load(config, baseURL);
              }
          }
          throw new NoSuchConfigException("A configuration with the specifiec id could not
be found: " + configID);
      }
  
      public ObjectName load(GBeanMBean config, URL rootURL) throws InvalidConfigException
{
          URI configID;
          try {
              configID = (URI) config.getAttribute("ID");
          } catch (Exception e) {
              throw new InvalidConfigException("Cannot get config ID", e);
          }
          ObjectName configName;
          try {
              configName = getConfigObjectName(configID);
          } catch (MalformedObjectNameException e) {
              throw new InvalidConfigException("Cannot convert ID to ObjectName: ", e);
          }
          load(config, rootURL, configName);
          return configName;
      }
  
      public void load(GBeanMBean config, URL rootURL, ObjectName configName) throws InvalidConfigException
{
          try {
              kernel.loadGBean(configName, config);
          } catch (InvalidConfigException e) {
              throw e;
          } catch (Exception e) {
              throw new InvalidConfigException("Unable to register configuraton", e);
          }
  
          try {
              config.setAttribute("BaseURL", rootURL);
          } catch (Exception e) {
              try {
                  kernel.unloadGBean(configName);
              } catch (Exception ignored) {
                  // ignore
              }
              throw new InvalidConfigException("Cannot set BaseURL", e);
          }
          log.info("Loaded Configuration " + configName);
      }
  
      public List loadRecursive(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException
{
          try {
              LinkedList ancestors = new LinkedList();
              while (configID != null && !isLoaded(configID)) {
                  ObjectName name = load(configID);
                  ancestors.addFirst(name);
                  configID = (URI) kernel.getAttribute(name, "ParentID");
              }
              return ancestors;
          } catch (NoSuchConfigException e) {
              throw e;
          } catch (IOException e) {
              throw e;
          } catch (InvalidConfigException e) {
              throw e;
          } catch (Exception e) {
              throw new InvalidConfigException(e);
          }
      }
  
      public void unload(URI configID) throws NoSuchConfigException {
          ObjectName configName;
          try {
              configName = getConfigObjectName(configID);
          } catch (MalformedObjectNameException e) {
              throw new NoSuchConfigException("Cannot convert ID to ObjectName: ", e);
          }
          unload(configName);
      }
  
      public void unload(ObjectName configName) throws NoSuchConfigException {
          try {
              kernel.unloadGBean(configName);
          } catch (InstanceNotFoundException e) {
              throw new NoSuchConfigException("No config registered: " + configName, e);
          }
          log.info("Unloaded Configuration " + configName);
      }
  
      private Set getStoreSnapshot() {
          Set storeSnapshot = new HashSet(stores);
          if (storeSnapshot.size() == 0) {
              throw new UnsupportedOperationException("There are no installed ConfigurationStores");
          }
          return storeSnapshot;
      }
  
      public ObjectName getConfigObjectName(URI configID) throws MalformedObjectNameException
{
          return new ObjectName("geronimo.config:name=" + ObjectName.quote(configID.toString()));
      }
  
      public static final GBeanInfo GBEAN_INFO;
  
      static {
          GBeanInfoFactory infoFactory = new GBeanInfoFactory(ConfigurationManagerImpl.class);
          infoFactory.addReference("Kernel", Kernel.class);
          infoFactory.addReference("Stores", ConfigurationStore.class);
          infoFactory.addInterface(ConfigurationManager.class);
          infoFactory.setConstructor(new String[]{"Kernel", "Stores"},
                  new Class[]{Kernel.class, Collection.class});
          GBEAN_INFO = infoFactory.getBeanInfo();
      }
  
      public static GBeanInfo getGBeanInfo() {
          return GBEAN_INFO;
      }
  }
  
  
  
  1.11      +4 -3      incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
  
  Index: DeploymentContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DeploymentContext.java	19 May 2004 20:53:59 -0000	1.10
  +++ DeploymentContext.java	1 Jun 2004 16:06:50 -0000	1.11
  @@ -81,10 +81,11 @@
           }
   
           if (kernel != null && parentID != null) {
  -            ObjectName parentName = ConfigurationManager.getConfigObjectName(parentID);
  +            ConfigurationManager configurationManager = kernel.getConfigurationManager();
  +            ObjectName parentName = configurationManager.getConfigObjectName(parentID);
               config.setReferencePatterns("Parent", Collections.singleton(parentName));
               try {
  -                ancestors = kernel.getConfigurationManager().loadRecursive(parentID);
  +                ancestors = configurationManager.loadRecursive(parentID);
               } catch (Exception e) {
                   throw new DeploymentException("Unable to load parents", e);
               }
  
  
  
  1.5       +2 -3      incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
  
  Index: JettyModuleBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JettyModuleBuilder.java	30 May 2004 19:09:57 -0000	1.4
  +++ JettyModuleBuilder.java	1 Jun 2004 16:06:50 -0000	1.5
  @@ -56,7 +56,6 @@
   import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
   import org.apache.geronimo.j2ee.deployment.WebModule;
   import org.apache.geronimo.jetty.JettyWebApplicationContext;
  -import org.apache.geronimo.kernel.config.ConfigurationManager;
   import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
   import org.apache.geronimo.naming.java.ComponentContextBuilder;
   import org.apache.geronimo.naming.java.ReadOnlyContext;
  @@ -244,7 +243,7 @@
               gbean.setAttribute("ComponentContext", compContext);
               gbean.setAttribute("UserTransaction", userTransaction);
               setResourceEnvironment(gbean, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
  -            gbean.setReferencePatterns("Configuration", Collections.singleton(ConfigurationManager.getConfigObjectName(configID)));
  +            gbean.setReferencePatterns("Configuration", Collections.singleton(new ObjectName("geronimo.config:name="
+ ObjectName.quote(configID.toString())))); // @todo this is used to resolve relative URIs,
we should fix this
               gbean.setReferencePatterns("JettyContainer", Collections.singleton(new ObjectName("*:type=WebContainer,container=Jetty")));
// @todo configurable
               gbean.setReferencePatterns("TransactionManager", Collections.singleton(new
ObjectName("*:type=TransactionManager,*")));
               gbean.setReferencePatterns("TrackedConnectionAssociator", Collections.singleton(new
ObjectName("*:type=ConnectionTracker,*")));
  
  
  
  1.27      +4 -3      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Kernel.java	27 May 2004 01:06:00 -0000	1.26
  +++ Kernel.java	1 Jun 2004 16:06:51 -0000	1.27
  @@ -39,8 +39,9 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.gbean.jmx.DependencyService;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.kernel.config.ConfigurationManager;
  +import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
   import org.apache.geronimo.kernel.config.InvalidConfigException;
  +import org.apache.geronimo.kernel.config.ConfigurationManager;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
   
   
  @@ -303,7 +304,7 @@
           mbServer.registerMBean(this, KERNEL);
           mbServer.registerMBean(new DependencyService(), DEPENDENCY_SERVICE);
   
  -        configurationManagerGBean = new GBeanMBean(ConfigurationManager.GBEAN_INFO);
  +        configurationManagerGBean = new GBeanMBean(ConfigurationManagerImpl.GBEAN_INFO);
           configurationManagerGBean.setReferencePatterns("Kernel", Collections.singleton(KERNEL));
           configurationManagerGBean.setReferencePatterns("Stores", Collections.singleton(CONFIGURATION_STORE_PATTERN));
           mbServer.registerMBean(configurationManagerGBean, CONFIGURATION_MANAGER_NAME);
  
  
  
  1.6       +3 -2      incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
  
  Index: StopCommand.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StopCommand.java	10 Mar 2004 09:58:49 -0000	1.5
  +++ StopCommand.java	1 Jun 2004 16:06:51 -0000	1.6
  @@ -46,7 +46,8 @@
                   TargetModuleID module = modules[i];
   
                   URI moduleID = URI.create(module.getModuleID());
  -                ObjectName name = ConfigurationManager.getConfigObjectName(moduleID);
  +                ConfigurationManager configurationManager = kernel.getConfigurationManager();
  +                ObjectName name = configurationManager.getConfigObjectName(moduleID);
                   kernel.getMBeanServer().invoke(name, "stop", null, null);
                   addModule(module);
               }
  
  
  

Mime
View raw message