james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1142322 - /james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/AbstractServiceTracker.java
Date Sat, 02 Jul 2011 21:57:09 GMT
Author: norman
Date: Sat Jul  2 21:57:09 2011
New Revision: 1142322

URL: http://svn.apache.org/viewvc?rev=1142322&view=rev
Log:
Add some javadocs. See JAMES-835

Modified:
    james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/AbstractServiceTracker.java

Modified: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/AbstractServiceTracker.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/AbstractServiceTracker.java?rev=1142322&r1=1142321&r2=1142322&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/AbstractServiceTracker.java
(original)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/AbstractServiceTracker.java
Sat Jul  2 21:57:09 2011
@@ -44,7 +44,7 @@ import org.springframework.osgi.service.
  * This {@link BundleListener} use the extender pattern to scan all loaded
  * bundles if a class name with a given name is present. If so it register in
  * the {@link BeanDefinitionRegistry} and also register it to
- * {@link BundleContext} as service. This allows to dynamic load and unload osgi
+ * {@link BundleContext} as service. This allows to dynamic load and unload OSGI
  * bundles
  * 
  */
@@ -71,6 +71,7 @@ public abstract class AbstractServiceTra
     public void bundleChanged(BundleEvent event) {
         Bundle b = event.getBundle();
 
+        // Check if the event was fired for this class
         if (b.equals(this.context.getBundle())) {
             return;
         }
@@ -80,21 +81,26 @@ public abstract class AbstractServiceTra
             Enumeration<?> entrs = b.findEntries("/", "*.class", true);
             if (entrs != null) {
 
+                // Loop over all the classes 
                 while (entrs.hasMoreElements()) {
                     URL e = (URL) entrs.nextElement();
                     String file = e.getFile();
 
                     String className = file.replaceAll("/", ".").replaceAll(".class", "").replaceFirst(".",
"");
                     if (className.equals(configuredClass)) {
+                        
+                        // Get the right service properties from the resolver
                         Properties p = new Properties();
                         p.putAll(resolver.getServiceProperties(getComponentName()));
                         Class<?> clazz = getServiceClass();
+                        
                         // Create the definition and register it
                         BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
                         BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(className).getBeanDefinition();
                         registry.registerBeanDefinition(getComponentName(), def);
 
-                        reg = b.getBundleContext().registerService(clazz.getName(), factory.getBean(clazz),
p);
+                        // register the bean as service in the BundleContext
+                        reg = b.getBundleContext().registerService(clazz.getName(), factory.getBean(getComponentName(),
clazz), p);
                     }
                 }
             }
@@ -130,6 +136,7 @@ public abstract class AbstractServiceTra
 
     @Override
     public void destroy() throws Exception {
+        // Its time to unregister the listener so we are sure resources are released
         if (context != null) {
             context.removeBundleListener(this);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message