geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/configuration LocalConfigStore.java
Date Sat, 05 Jun 2004 00:37:16 GMT
dain        2004/06/04 17:37:16

  Modified:    modules/kernel/src/java/org/apache/geronimo/gbean
                        GBeanContext.java
               modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        GBeanMBean.java GBeanMBeanContext.java
               modules/kernel/src/java/org/apache/geronimo/kernel/config
                        Configuration.java ConfigurationManagerImpl.java
                        ConfigurationStore.java
               modules/kernel/src/java/org/apache/geronimo/kernel
                        Kernel.java
               modules/system/src/java/org/apache/geronimo/system/configuration
                        LocalConfigStore.java
  Log:
  Removed getServer and getObjectName as they are no longer needed with the introduction of
special gbean attributes
  
  Revision  Changes    Path
  1.7       +1 -12     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanContext.java
  
  Index: GBeanContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- GBeanContext.java	4 Jun 2004 22:31:56 -0000	1.6
  +++ GBeanContext.java	5 Jun 2004 00:37:15 -0000	1.7
  @@ -17,9 +17,6 @@
   
   package org.apache.geronimo.gbean;
   
  -import javax.management.ObjectName;
  -
  -
   /**
    * Context handle for a GBean which allows the bean to determin the current state, and
to change the
    * current state.
  @@ -61,12 +58,4 @@
        * The component is guaranteed to be in the failed state when the method returns.
        */
       void fail();
  -
  -    /**
  -     * Gets the object name of the gbean
  -     *
  -     * @return the objec name of the gbean
  -     * @deprecated use an objectName GBeanAttribute instead
  -     */
  -    ObjectName getObjectName();
   }
  
  
  
  1.22      +2 -2      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
  
  Index: GBeanMBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- GBeanMBean.java	4 Jun 2004 22:31:56 -0000	1.21
  +++ GBeanMBean.java	5 Jun 2004 00:37:16 -0000	1.22
  @@ -476,7 +476,7 @@
       public synchronized ObjectName preRegister(MBeanServer server, ObjectName objectName)
throws Exception {
           ObjectName returnValue = super.preRegister(server, objectName);
   
  -        gbeanContext = new GBeanMBeanContext(server, this, objectName);
  +        gbeanContext = new GBeanMBeanContext(this);
           setAttribute("objectName", getObjectName());
           setAttribute("gbeanContext", gbeanContext);
           setAttribute("classLoader", classLoader);
  
  
  
  1.7       +2 -39     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanContext.java
  
  Index: GBeanMBeanContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- GBeanMBeanContext.java	4 Jun 2004 23:05:25 -0000	1.6
  +++ GBeanMBeanContext.java	5 Jun 2004 00:37:16 -0000	1.7
  @@ -17,9 +17,6 @@
   
   package org.apache.geronimo.gbean.jmx;
   
  -import javax.management.MBeanServer;
  -import javax.management.ObjectName;
  -
   import org.apache.geronimo.gbean.GBeanContext;
   import org.apache.geronimo.kernel.management.State;
   
  @@ -28,51 +25,17 @@
    */
   public final class GBeanMBeanContext implements GBeanContext {
       /**
  -     * The MBean server in which the Geronimo MBean is registered.
  -     */
  -    private final MBeanServer server;
  -
  -    /**
        * The GeronimoMBean which owns the target.
        */
       private final GBeanMBean gmbean;
   
       /**
  -     * The object name of the Geronimo MBean.
  -     */
  -    private final ObjectName objectName;
  -
  -    /**
        * Creates a new context for a target.
        *
  -     * @param server a reference to the mbean server in which the Geronimo Mbean is registered
        * @param gmbean the Geronimo Mbean the contains the target
  -     * @param objectName the registered name of the Geronimo MBean
        */
  -    public GBeanMBeanContext(MBeanServer server, GBeanMBean gmbean, ObjectName objectName)
{
  -        this.server = server;
  +    public GBeanMBeanContext(GBeanMBean gmbean) {
           this.gmbean = gmbean;
  -        this.objectName = objectName;
  -    }
  -
  -    /**
  -     * Gets a reference to the MBean server in which the Geronimo MBean is registered.
  -     *
  -     * @return a reference to the MBean server in which the Geronimo MBean is registered
  -     * @deprecated use a kernel GBeanAttribute instead
  -     */
  -    public MBeanServer getServer() {
  -        return server;
  -    }
  -
  -    /**
  -     * Gets the registered name of the Geronimo MBean
  -     *
  -     * @return the registered name of the Geronimo MBean
  -     * @deprecated use an objectName GBeanAttribute instead
  -     */
  -    public ObjectName getObjectName() {
  -        return objectName;
       }
   
       /**
  
  
  
  1.21      +15 -9     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
  
  Index: Configuration.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Configuration.java	2 Jun 2004 05:33:03 -0000	1.20
  +++ Configuration.java	5 Jun 2004 00:37:16 -0000	1.21
  @@ -50,8 +50,8 @@
   import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.geronimo.gbean.GReferenceInfo;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.gbean.jmx.GBeanMBeanContext;
   import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.kernel.jmx.JMXUtil;
   import org.apache.geronimo.kernel.repository.MissingDependencyException;
   import org.apache.geronimo.kernel.repository.Repository;
   
  @@ -87,6 +87,8 @@
   public class Configuration implements GBean {
       private static final Log log = LogFactory.getLog(Configuration.class);
   
  +    private final Kernel kernel;
  +    private final ObjectName objectName;
       private final URI id;
       private final URI parentID;
       private final ConfigurationParent parent;
  @@ -95,7 +97,6 @@
       private final byte[] gbeanState;
       private final Collection repositories;
   
  -    private GBeanMBeanContext context;
       private URL baseURL;
       private Map gbeans;
   
  @@ -113,7 +114,9 @@
        * @param repositories a Collection<Repository> of repositories used to resolve
dependencies
        * @param dependencies a List<URI> of dependencies
        */
  -    public Configuration(URI id, URI parentID, ConfigurationParent parent, List classPath,
byte[] gbeanState, Collection repositories, List dependencies) {
  +    public Configuration(Kernel kernel, String objectName, URI id, URI parentID, ConfigurationParent
parent, List classPath, byte[] gbeanState, Collection repositories, List dependencies) {
  +        this.kernel = kernel;
  +        this.objectName = JMXUtil.getObjectName(objectName);
           this.id = id;
           this.parentID = parentID;
           this.parent = parent;
  @@ -124,7 +127,6 @@
       }
   
       public void setGBeanContext(GBeanContext context) {
  -        this.context = (GBeanMBeanContext) context;
       }
   
       public void doStart() throws Exception {
  @@ -170,7 +172,7 @@
               gbeans = loadGBeans(gbeanState, classLoader);
   
               // register all the GBeans
  -            MBeanServer mbServer = context.getServer();
  +            MBeanServer mbServer = kernel.getMBeanServer();
               for (Iterator i = gbeans.entrySet().iterator(); i.hasNext();) {
                   Map.Entry entry = (Map.Entry) i.next();
                   ObjectName name = (ObjectName) entry.getKey();
  @@ -187,7 +189,7 @@
                       }
                       throw e;
                   }
  -                mbServer.invoke(Kernel.DEPENDENCY_SERVICE, "addDependency", new Object[]{name,
context.getObjectName()}, new String[]{ObjectName.class.getName(), ObjectName.class.getName()});
  +                mbServer.invoke(Kernel.DEPENDENCY_SERVICE, "addDependency", new Object[]{name,
objectName}, new String[]{ObjectName.class.getName(), ObjectName.class.getName()});
               }
           } finally {
               Thread.currentThread().setContextClassLoader(oldCl);
  @@ -200,11 +202,11 @@
           log.info("Stopping configuration " + id);
   
           // unregister all GBeans
  -        MBeanServer mbServer = context.getServer();
  +        MBeanServer mbServer = kernel.getMBeanServer();
           for (Iterator i = gbeans.keySet().iterator(); i.hasNext();) {
               ObjectName name = (ObjectName) i.next();
               try {
  -                mbServer.invoke(Kernel.DEPENDENCY_SERVICE, "removeDependency", new Object[]{name,
context.getObjectName()}, new String[]{ObjectName.class.getName(), ObjectName.class.getName()});
  +                mbServer.invoke(Kernel.DEPENDENCY_SERVICE, "removeDependency", new Object[]{name,
objectName}, new String[]{ObjectName.class.getName(), ObjectName.class.getName()});
               } catch (Exception e) {
                   // ignore
                   log.warn("Could not remove dependency for child " + name, e);
  @@ -385,6 +387,8 @@
   
       static {
           GBeanInfoFactory infoFactory = new GBeanInfoFactory(Configuration.class);
  +        infoFactory.addAttribute("kernel", Kernel.class, false);
  +        infoFactory.addAttribute("objectName", String.class, false);
           infoFactory.addAttribute("ID", URI.class, true);
           infoFactory.addAttribute("ParentID", URI.class, true);
           infoFactory.addAttribute("ClassPath", List.class, true);
  @@ -397,6 +401,8 @@
           infoFactory.addReference("Repositories", Repository.class);
   
           infoFactory.setConstructor(new String[]{
  +            "kernel",
  +            "objectName",
               "ID",
               "ParentID",
               "Parent",
  
  
  
  1.5       +7 -10     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
  
  Index: ConfigurationManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ConfigurationManagerImpl.java	4 Jun 2004 04:33:58 -0000	1.4
  +++ ConfigurationManagerImpl.java	5 Jun 2004 00:37:16 -0000	1.5
  @@ -24,12 +24,9 @@
   import java.util.Collection;
   import java.util.LinkedList;
   import java.util.List;
  -import java.util.Set;
  -import java.util.Properties;
   import javax.management.InstanceNotFoundException;
   import javax.management.MalformedObjectNameException;
   import javax.management.ObjectName;
  -import javax.management.MBeanServer;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -56,18 +53,18 @@
       public List listStores() {
           List storeSnapshot = getStores();
           List result = new ArrayList(storeSnapshot.size());
  -        for (int i=0; i < storeSnapshot.size(); i++) {
  +        for (int i = 0; i < storeSnapshot.size(); i++) {
               ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
  -            result.add(store.getObjectName());
  +            result.add(JMXUtil.getObjectName(store.getObjectName()));
           }
           return result;
       }
   
       public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
           List storeSnapshot = getStores();
  -        for (int i=0; i < storeSnapshot.size(); i++) {
  +        for (int i = 0; i < storeSnapshot.size(); i++) {
               ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
  -            if (storeName.equals(store.getObjectName())) {
  +            if (storeName.equals(JMXUtil.getObjectName(store.getObjectName()))) {
                   List ids = store.listConfiguations();
                   List result = new ArrayList(ids.size());
                   for (int j = 0; j < ids.size(); j++) {
  @@ -81,7 +78,7 @@
                       State state;
                       if (kernel.isLoaded(configName)) {
                           try {
  -                            state = State.fromInteger((Integer)kernel.getAttribute(configName,
"state"));
  +                            state = State.fromInteger((Integer) kernel.getAttribute(configName,
"state"));
                           } catch (Exception e) {
                               state = null;
                           }
  @@ -108,7 +105,7 @@
       public ObjectName load(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException
{
           List storeSnapshot = getStores();
   
  -        for (int i=0; i < storeSnapshot.size(); i++) {
  +        for (int i = 0; i < storeSnapshot.size(); i++) {
               ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
               if (store.containsConfiguration(configID)) {
                   GBeanMBean config = store.getConfiguration(configID);
  
  
  
  1.8       +4 -4      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
  
  Index: ConfigurationStore.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConfigurationStore.java	2 Jun 2004 19:50:41 -0000	1.7
  +++ ConfigurationStore.java	5 Jun 2004 00:37:16 -0000	1.8
  @@ -22,8 +22,6 @@
   import java.net.URL;
   import java.util.List;
   
  -import javax.management.ObjectName;
  -
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
   
   /**
  @@ -71,12 +69,14 @@
   
       /**
        * Return the object name for the store.
  +     *
        * @return the object name for the store
        */
  -    ObjectName getObjectName();
  +    String getObjectName();
   
       /**
        * Return the configurations in the store
  +     *
        * @return a List<URI> of configurations in the store
        */
       List listConfiguations();
  
  
  
  1.34      +1 -5      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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Kernel.java	4 Jun 2004 22:29:14 -0000	1.33
  +++ Kernel.java	5 Jun 2004 00:37:16 -0000	1.34
  @@ -344,14 +344,12 @@
           log = LogFactory.getLog(Kernel.class.getName());
           log.info("Starting boot");
   
  -//        if (kernelName != null) {
           synchronized (kernels) {
               if (kernels.containsKey(kernelName)) {
                   throw new IllegalStateException("A kernel is already running this kernel
name: " + kernelName);
               }
               kernels.put(kernelName, new KernelReference(kernelName, this));
           }
  -//        }
   
           mbServer = MBeanServerFactory.createMBeanServer(domainName);
           mbServer.registerMBean(this, KERNEL);
  @@ -444,11 +442,9 @@
               notify();
           }
   
  -//        if (kernelName != null) {
           synchronized (kernels) {
               kernels.remove(kernelName);
           }
  -//        }
   
           log.info("Kernel shutdown complete");
       }
  
  
  
  1.7       +12 -14    incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
  
  Index: LocalConfigStore.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalConfigStore.java	3 Jun 2004 07:24:21 -0000	1.6
  +++ LocalConfigStore.java	5 Jun 2004 00:37:16 -0000	1.7
  @@ -30,15 +30,13 @@
   import java.net.MalformedURLException;
   import java.net.URI;
   import java.net.URL;
  +import java.util.ArrayList;
   import java.util.Iterator;
  -import java.util.Properties;
   import java.util.List;
  -import java.util.ArrayList;
  +import java.util.Properties;
   import java.util.zip.ZipEntry;
   import java.util.zip.ZipInputStream;
   
  -import javax.management.ObjectName;
  -
   import org.apache.geronimo.gbean.GBean;
   import org.apache.geronimo.gbean.GBeanContext;
   import org.apache.geronimo.gbean.GBeanInfo;
  @@ -59,34 +57,34 @@
    */
   public class LocalConfigStore implements ConfigurationStore, GBean {
       private static final String INDEX_NAME = "index.properties";
  +    private final String objectName;
       private final URI root;
       private final ServerInfo serverInfo;
       private File rootDir;
       private final Properties index = new Properties();
       private int maxId;
  -    private GBeanContext context;
   
       /**
        * Constructor is only used for direct testing with out a kernel.
  -     * @param rootDir
        */
       public LocalConfigStore(File rootDir) {
  +        objectName = null;
           serverInfo = null;
           this.root = null;
           this.rootDir = rootDir;
       }
   
  -    public LocalConfigStore(URI root, ServerInfo serverInfo) {
  +    public LocalConfigStore(String objectName, URI root, ServerInfo serverInfo) {
  +        this.objectName = objectName;
           this.root = root;
           this.serverInfo = serverInfo;
       }
   
       public void setGBeanContext(GBeanContext context) {
  -        this.context = context;
       }
   
  -    public ObjectName getObjectName() {
  -        return context.getObjectName();
  +    public String getObjectName() {
  +        return objectName;
       }
   
       public void doStart() throws WaitingException, FileNotFoundException, IOException {
  @@ -273,12 +271,12 @@
       static {
           GBeanInfoFactory infoFactory = new GBeanInfoFactory(LocalConfigStore.class);
   
  +        infoFactory.addAttribute("objectName", String.class, false);
           infoFactory.addAttribute("root", URI.class, true);
  -        infoFactory.addInterface(ConfigurationStore.class);
  -
           infoFactory.addReference("ServerInfo", ServerInfo.class);
  +        infoFactory.addInterface(ConfigurationStore.class);
   
  -        infoFactory.setConstructor(new String[]{"root", "ServerInfo"});
  +        infoFactory.setConstructor(new String[]{"objectName", "root", "ServerInfo"});
   
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
  
  
  

Mime
View raw message