[jboss-osgi-commits] JBoss-OSGI SVN: r88202 - in projects/jboss-osgi/trunk: bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal and 11 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue May 5 06:40:46 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-05 06:40:41 -0400 (Tue, 05 May 2009)
New Revision: 88202

Modified:
   projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java
   projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
   projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java
Log:
Remove unwanted ServiceRegistration

Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -49,7 +49,7 @@
 {
    private LogService log;
    private JMXServiceURL serviceURL;
-   private JMXConnectorServer conServer;
+   private JMXConnectorServer jmxConnectorServer;
 
    public JMXConnectorService(BundleContext context, MBeanServer mbeanServer, String host, int rmiPort)
    {
@@ -82,7 +82,7 @@
          
          // create new connector server and start it
          serviceURL = new JMXServiceURL("service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + jmxConnectorServerPath);
-         conServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
+         jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
 
          log.log(LogService.LOG_DEBUG, "JMX Connector created: " + serviceURL);
       }
@@ -103,15 +103,14 @@
 
    public void start()
    {
-      if (conServer == null)
+      if (jmxConnectorServer == null)
          throw new IllegalStateException("JMXConnector not available");
       
       ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
       try
       {
          Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-         
-         conServer.start();
+         jmxConnectorServer.start();
          log.log(LogService.LOG_INFO, "JMXConnector started: " + serviceURL);
       }
       catch (IOException ex)
@@ -126,14 +125,20 @@
 
    public void stop()
    {
+      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
       try
       {
-         conServer.stop();
+         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+         jmxConnectorServer.stop();
          log.log(LogService.LOG_DEBUG, "JMXConnector stopped");
       }
       catch (IOException ex)
       {
          log.log(LogService.LOG_WARNING, "Cannot stop JMXConnector", ex);
       }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(ctxLoader);
+      }
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -27,7 +27,6 @@
 import org.jboss.osgi.jndi.NamingService;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.log.LogService;
 
 /**
@@ -42,7 +41,6 @@
    public static final String REMOTE_JNDI_RMI_PORT = "org.jboss.osgi.jndi.rmi.port";
    public static final String REMOTE_JNDI_PORT = "org.jboss.osgi.jndi.port";
 
-   private ServiceRegistration regNaming;
    private JNPServer jnpServer;
    private LogService log;
 
@@ -65,19 +63,12 @@
       jnpServer = new JNPServer(context, jndiHost, Integer.parseInt(jndiPort), Integer.parseInt(jndiRmiPort));
       jnpServer.start();
       
-      regNaming = context.registerService(NamingService.class.getName(), new NamingServiceImpl(), null);
+      context.registerService(NamingService.class.getName(), new NamingServiceImpl(), null);
       log.log(LogService.LOG_DEBUG, "NamingService registered");
    }
 
    public void stop(BundleContext context)
    {
-      if (regNaming != null)
-      {
-         regNaming.unregister();
-         regNaming = null;
-         log.log(LogService.LOG_DEBUG, "NamingService unregistered");
-      }
-      
       if (jnpServer != null)
       {
          jnpServer.stop();

Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -54,7 +54,6 @@
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.log.LogService;
 
 /**
@@ -67,7 +66,6 @@
 {
    private BundleContext context;
    private EmbeddedBeansDeployer deployer;
-   private ServiceRegistration registration;
    private LogService log;
 
    private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
@@ -79,7 +77,7 @@
       this.log = new LogServiceTracker(context);
 
       VFS.init();
-      
+
       deployer = new EmbeddedBeansDeployer(context);
    }
 
@@ -157,7 +155,7 @@
    {
       // Get the required MBeanServer
       MBeanServer mbeanServer = getMBeanServer();
-      
+
       // Preregister some beans
       try
       {
@@ -182,21 +180,15 @@
       }
 
       log.log(LogService.LOG_DEBUG, "Register MicrocontainerService");
-      registration = context.registerService(MicrocontainerService.class.getName(), this, null);
-      
-      // Register the MicrocontainerServiceMBean 
+      context.registerService(MicrocontainerService.class.getName(), this, null);
+
+      // Register the MicrocontainerServiceMBean
       registerMicrocontainerServiceMBean(mbeanServer);
    }
 
    void stop()
    {
-      if (registration != null)
-      {
-         log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerService");
-         unregisterMicrocontainerServiceMBean(getMBeanServer());
-         registration.unregister();
-         registration = null;
-      }
+      unregisterMicrocontainerServiceMBean(getMBeanServer());
    }
 
    private MBeanServer getMBeanServer()
@@ -204,7 +196,7 @@
       ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
       if (sref == null)
          throw new IllegalStateException("No MBeanServer registered");
-      
+
       MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
       return mbeanServer;
    }

Modified: projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -29,7 +29,6 @@
 import org.jboss.osgi.spi.logging.RemoteLogReaderService;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 /**
  * [TODO]
@@ -47,7 +46,6 @@
    private Boolean isReader = Boolean.FALSE;
    private Boolean isSender = Boolean.FALSE;
    private RemoteLogReaderServiceImpl readerService;
-   private ServiceRegistration readerRegistration;
    private RemoteLogListener remoteSender;
    
    public void start(BundleContext context)
@@ -78,7 +76,7 @@
          if (isReader == true)
          {
             readerService = new RemoteLogReaderServiceImpl(context, props);
-            readerRegistration = context.registerService(RemoteLogReaderService.class.getName(), readerService, props);
+            context.registerService(RemoteLogReaderService.class.getName(), readerService, props);
             readerService.start();
          }
          
@@ -98,9 +96,6 @@
    {
       if (isReader == true)
       {
-         readerRegistration.unregister();
-         readerRegistration = null;
-         
          readerService.stop();
          readerService = null;
       }

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,7 +25,6 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 /**
  * A Service Activator
@@ -35,8 +34,6 @@
  */
 public class ServiceActivator implements BundleActivator
 {
-  private ServiceRegistration registration;
-  
   /*
    * Implements BundleActivator.start(). 
    * Registers an instance of a HttpEndpoint Service using the bundle context.
@@ -44,7 +41,7 @@
   public void start(BundleContext context)
   {
     EndpointService service = new EndpointService(context);
-    registration = context.registerService(EndpointService.class.getName(), service, null);
+    context.registerService(EndpointService.class.getName(), service, null);
   }
 
   /*
@@ -52,10 +49,5 @@
    */
   public void stop(BundleContext context)
   {
-    if (registration != null)
-    {
-      registration.unregister();
-      registration = null;
-    }
   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,7 +25,6 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 /**
  * A Service Activator
@@ -35,20 +34,13 @@
  */
 public class ServiceActivator implements BundleActivator
 {
-  private ServiceRegistration registration;
-  
   public void start(BundleContext context)
   {
     MBeanTestService service = new MBeanTestService(context);
-    registration = context.registerService(MBeanTestService.class.getName(), service, null);
+    context.registerService(MBeanTestService.class.getName(), service, null);
   }
 
   public void stop(BundleContext context)
   {
-    if (registration != null)
-    {
-      registration.unregister();
-      registration = null;
-    }
   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,7 +25,6 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 /**
  * A Service Activator
@@ -35,20 +34,13 @@
  */
 public class SomeServiceActivator implements BundleActivator
 {
-  private ServiceRegistration registration;
-  
   public void start(BundleContext context)
   {
     SomeService service = new SomeService();
-    registration = context.registerService(SomeService.class.getName(), service, null);
+    context.registerService(SomeService.class.getName(), service, null);
   }
 
   public void stop(BundleContext context)
   {
-    if (registration != null)
-    {
-      registration.unregister();
-      registration = null;
-    }
   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 public class ServiceActivator implements BundleActivator
 {
-   private ServiceRegistration registration;
-
    public void start(BundleContext context)
    {
       ServiceA service = new ServiceA(context);
-      registration = context.registerService(ServiceA.class.getName(), service, null);
+      context.registerService(ServiceA.class.getName(), service, null);
    }
 
    public void stop(BundleContext context)
    {
-      if (registration != null)
-      {
-         registration.unregister();
-         registration = null;
-      }
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 public class ServiceActivator implements BundleActivator
 {
-   private ServiceRegistration registration;
-
    public void start(BundleContext context)
    {
       ServiceB service = new ServiceB(context);
-      registration = context.registerService(ServiceB.class.getName(), service, null);
+      context.registerService(ServiceB.class.getName(), service, null);
    }
 
    public void stop(BundleContext context)
    {
-      if (registration != null)
-      {
-         registration.unregister();
-         registration = null;
-      }
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 public class ServiceActivator implements BundleActivator
 {
-   private ServiceRegistration registration;
-
    public void start(BundleContext context)
    {
       ServiceA service = new ServiceA(context);
-      registration = context.registerService(ServiceA.class.getName(), service, null);
+      context.registerService(ServiceA.class.getName(), service, null);
    }
 
    public void stop(BundleContext context)
    {
-      if (registration != null)
-      {
-         registration.unregister();
-         registration = null;
-      }
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 public class ServiceActivator implements BundleActivator
 {
-   private ServiceRegistration registration;
-
    public void start(BundleContext context)
    {
       ServiceB service = new ServiceB();
-      registration = context.registerService(ServiceB.class.getName(), service, null);
+      context.registerService(ServiceB.class.getName(), service, null);
    }
 
    public void stop(BundleContext context)
    {
-      if (registration != null)
-      {
-         registration.unregister();
-         registration = null;
-      }
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 public class ServiceActivator implements BundleActivator
 {
-   private ServiceRegistration registration;
-
    public void start(BundleContext context)
    {
       ServiceB service = new ServiceB();
-      registration = context.registerService(ServiceB.class.getName(), service, null);
+      context.registerService(ServiceB.class.getName(), service, null);
    }
 
    public void stop(BundleContext context)
    {
-      if (registration != null)
-      {
-         registration.unregister();
-         registration = null;
-      }
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java	2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java	2009-05-05 10:40:41 UTC (rev 88202)
@@ -28,22 +28,19 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
 public class ServiceActivator implements BundleActivator
 {
-   private ServiceRegistration regA, regB;
-
    public void start(BundleContext context)
    {
       ServiceA serviceA = new ServiceA(context);
-      regA = context.registerService(ServiceA.class.getName(), serviceA, null);
+      context.registerService(ServiceA.class.getName(), serviceA, null);
       
       Dictionary<String, String> props = new Hashtable<String, String>();
       props.put("service.pid", ServiceB.class.getName());
       
       ServiceB serviceB = new ServiceB(context);
-      regB = context.registerService(ServiceB.class.getName(), serviceB, props);
+      context.registerService(ServiceB.class.getName(), serviceB, props);
       
       serviceB.updateConfig("xxx", "yyy");
       serviceB.updateConfig("xxx", "zzz");
@@ -51,15 +48,5 @@
 
    public void stop(BundleContext context)
    {
-      if (regA != null)
-      {
-         regA.unregister();
-         regA = null;
-      }
-      if (regB != null)
-      {
-         regB.unregister();
-         regB = null;
-      }
    }
 }
\ No newline at end of file




More information about the jboss-osgi-commits mailing list