Author: mes
Date: 2012-01-11 16:04:41 -0800 (Wed, 11 Jan 2012)
New Revision: 27989

Modified:
   
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/AbstractCyActivator.java
   
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/CyServiceRegistrar.java
   
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/internal/CyServiceRegistrarImpl.java
Log:
fixes #480 Now we simply filter out any package names that start with java to 
avoid registering any core interfaces as services

Modified: 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/AbstractCyActivator.java
===================================================================
--- 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/AbstractCyActivator.java
       2012-01-11 23:46:08 UTC (rev 27988)
+++ 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/AbstractCyActivator.java
       2012-01-12 00:04:41 UTC (rev 27989)
@@ -188,7 +188,9 @@
 
        /**
         * A utility method that registers the specified service object as an 
OSGi service for
-        * all interfaces that the object implements.
+        * all interfaces that the object implements. Note that this method 
will NOT register 
+        * services for any packages with names that begin with "java", which 
is an effort to 
+        * avoid registering meaningless services for core Java APIs.
         * @param bc The BundleContext used to find services.
         * @param service The object to be registered as one or more services.
         * @param props The service properties to be registered with each 
service. 
@@ -196,8 +198,12 @@
        protected final void registerAllServices(final BundleContext bc, final 
Object service, final Properties props) {
                List<Class<?>> interfaces = 
RegisterUtil.getAllInterfaces(service.getClass());
                logger.debug("attempting to register " + interfaces.size() + " 
services for: " + service.toString());
-               for ( Class<?> c : interfaces ) 
-                       registerService(bc, service, c, props);
+               for ( Class<?> c : interfaces )  {
+                       if ( c.getName().startsWith("java") ) 
+                               logger.debug("NOT registering service: " + 
service.toString() + " as type " + c.getName() + " because it is a core java 
interface.");
+                       else 
+                               registerService(bc, service, c, props);
+               }
        }
 
        /**

Modified: 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/CyServiceRegistrar.java
===================================================================
--- 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/CyServiceRegistrar.java
        2012-01-11 23:46:08 UTC (rev 27988)
+++ 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/CyServiceRegistrar.java
        2012-01-12 00:04:41 UTC (rev 27989)
@@ -32,7 +32,10 @@
        /**
         * This method registers an object as an OSGi service
         * for all interfaces that the object implements
-        * and with the specified properties.
+        * and with the specified properties. Note that this method
+        * will NOT register services for any packages with names that
+        * begin with "java", which is an effort to avoid registering
+        * meaningless services for core Java APIs.
         * @param o The object to be registered as a service for all
         * interfaces that the object implements.
         * @param props The service properties. 

Modified: 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/internal/CyServiceRegistrarImpl.java
===================================================================
--- 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/internal/CyServiceRegistrarImpl.java
   2012-01-11 23:46:08 UTC (rev 27988)
+++ 
core3/api/trunk/service-api/src/main/java/org/cytoscape/service/util/internal/CyServiceRegistrarImpl.java
   2012-01-12 00:04:41 UTC (rev 27989)
@@ -23,8 +23,12 @@
        }
 
        public void registerAllServices(Object o, Dictionary props) {
-               for ( Class c : RegisterUtil.getAllInterfaces(o.getClass()) ) 
-                       registerService(o,c,props);
+               for ( Class c : RegisterUtil.getAllInterfaces(o.getClass()) ) {
+                       if ( c.getName().startsWith("java") ) 
+                               logger.debug("NOT registering service: " + 
o.toString() + " as type " + c.getName() + " because it is a core java 
interface.");
+                       else   
+                               registerService(o,c,props);
+               }
        }
 
        public void registerService(Object o, Class c, Dictionary props) {

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to