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/kernel/src/java/org/apache/geronimo/kernel Kernel.java
Date Fri, 04 Jun 2004 22:29:14 GMT
dain        2004/06/04 15:29:14

  Modified:    modules/kernel/src/java/org/apache/geronimo/kernel
                        Kernel.java
  Log:
  Fixed problem where default kernel name was null and null names were not being added to
the kernels map, so kernels were lost.
  
  Revision  Changes    Path
  1.33      +17 -11    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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Kernel.java	4 Jun 2004 17:27:00 -0000	1.32
  +++ Kernel.java	4 Jun 2004 22:29:14 -0000	1.33
  @@ -23,7 +23,7 @@
   import java.lang.ref.WeakReference;
   import java.net.URI;
   import java.util.Collections;
  -import java.util.Hashtable;
  +import java.util.HashMap;
   import java.util.LinkedList;
   import java.util.List;
   import java.util.Map;
  @@ -85,7 +85,7 @@
       public static final ObjectName DEPENDENCY_SERVICE = JMXUtil.getObjectName("geronimo.boot:role=DependencyService");
   
   
  -    private static final Map kernels = new Hashtable();
  +    private static final Map kernels = new HashMap();
       private static final ReferenceQueue queue = new ReferenceQueue();
       private final String kernelName;
       private final String domainName;
  @@ -117,7 +117,7 @@
        * @param domainName the domain name to be used for the JMX MBeanServer
        */
       public Kernel(String domainName) {
  -        this(null, domainName);
  +        this(domainName, domainName);
       }
   
       /**
  @@ -146,6 +146,9 @@
        * @return the kernel that was registered with that name
        */
       public static Kernel getKernel(String name) {
  +        if (name == null) {
  +            return getSingleKernel();
  +        }
           synchronized (kernels) {
               processQueue();
               KernelReference ref = (KernelReference) kernels.get(name);
  @@ -341,11 +344,14 @@
           log = LogFactory.getLog(Kernel.class.getName());
           log.info("Starting boot");
   
  -        if (kernelName != null) {
  -            synchronized (kernels) {
  -                kernels.put(kernelName, new KernelReference(kernelName, this));
  +//        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);
  @@ -438,11 +444,11 @@
               notify();
           }
   
  -        if (kernelName != null) {
  -            synchronized (kernels) {
  -                kernels.remove(kernelName);
  -            }
  +//        if (kernelName != null) {
  +        synchronized (kernels) {
  +            kernels.remove(kernelName);
           }
  +//        }
   
           log.info("Kernel shutdown complete");
       }
  
  
  

Mime
View raw message