felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1097256 - /felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/
Date Wed, 27 Apr 2011 21:48:42 GMT
Author: marrs
Date: Wed Apr 27 21:48:41 2011
New Revision: 1097256

URL: http://svn.apache.org/viewvc?rev=1097256&view=rev
Log:
FilterService now implements ComponentDeclaration, as it should have done all along. ComponentImpl
now treats keys in a map of properties as objects, instead of assuming they're all strings.

Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java?rev=1097256&r1=1097255&r2=1097256&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AdapterServiceImpl.java
Wed Apr 27 21:48:41 2011
@@ -48,7 +48,7 @@ public class AdapterServiceImpl extends 
      */
     public AdapterServiceImpl(DependencyManager dm, Class adapteeInterface, String adapteeFilter,
String autoConfig, String add, String change, String remove) {
         super(dm.createComponent()); // This service will be filtered by our super class,
allowing us to take control.
-        m_service.setImplementation(new AdapterImpl(adapteeInterface, adapteeFilter, autoConfig,
add, change, remove))
+        m_component.setImplementation(new AdapterImpl(adapteeInterface, adapteeFilter, autoConfig,
add, change, remove))
                  .add(dm.createServiceDependency()
                       .setService(adapteeInterface, adapteeFilter)
                       .setAutoConfig(false)
@@ -92,7 +92,7 @@ public class AdapterServiceImpl extends 
                     props.put(key, m_serviceProperties.get(key));
                 }
             }
-            List dependencies = m_service.getDependencies();
+            List dependencies = m_component.getDependencies();
             dependencies.remove(0);
             ServiceDependency dependency = m_manager.createServiceDependency()
                  .setService(m_adapteeInterface, ref)
@@ -112,7 +112,7 @@ public class AdapterServiceImpl extends 
                 .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy) // if
not set, no effect
                 .add(dependency);
             
-            configureAutoConfigState(service, m_service);
+            configureAutoConfigState(service, m_component);
             
             for (int i = 0; i < dependencies.size(); i++) {
                 service.add(((Dependency) dependencies.get(i)).createCopy());

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java?rev=1097256&r1=1097255&r2=1097256&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/AspectServiceImpl.java
Wed Apr 27 21:48:41 2011
@@ -41,7 +41,7 @@ public class AspectServiceImpl extends F
     public AspectServiceImpl(DependencyManager dm, Class aspectInterface, String aspectFilter,
int ranking, String autoConfig, String add, String change, String remove)
     { 
         super(dm.createComponent()); // This service will be filtered by our super class,
allowing us to take control.
-        m_service.setImplementation(new AspectImpl(aspectInterface, aspectFilter, ranking,
autoConfig, add, change, remove))
+        m_component.setImplementation(new AspectImpl(aspectInterface, aspectFilter, ranking,
autoConfig, add, change, remove))
              .add(dm.createServiceDependency()
                   .setService(aspectInterface, createDependencyFilterForAspect(aspectFilter))
                   .setAutoConfig(false)
@@ -82,7 +82,7 @@ public class AspectServiceImpl extends F
         }
         
         public Component createService(Object[] params) {
-            List dependencies = m_service.getDependencies();
+            List dependencies = m_component.getDependencies();
             // remove our internal dependency
             dependencies.remove(0);
             // replace it with one that points to the specific service that just was passed
in
@@ -104,7 +104,7 @@ public class AspectServiceImpl extends F
                 .setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy) // if
not set, no effect
                 .add(dependency);
             
-            configureAutoConfigState(service, m_service);
+            configureAutoConfigState(service, m_component);
             
             for (int i = 0; i < dependencies.size(); i++) {
                 service.add(((Dependency) dependencies.get(i)).createCopy());

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java?rev=1097256&r1=1097255&r2=1097256&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/BundleAdapterServiceImpl.java
Wed Apr 27 21:48:41 2011
@@ -42,7 +42,7 @@ public class BundleAdapterServiceImpl ex
     public BundleAdapterServiceImpl(DependencyManager dm, int bundleStateMask, String bundleFilter,
boolean propagate)
     {
         super(dm.createComponent()); // This service will be filtered by our super class,
allowing us to take control.
-        m_service.setImplementation(new BundleAdapterImpl(bundleStateMask, bundleFilter,
propagate))
+        m_component.setImplementation(new BundleAdapterImpl(bundleStateMask, bundleFilter,
propagate))
                  .add(dm.createBundleDependency()
                       .setFilter(bundleFilter)
                       .setStateMask(bundleStateMask)
@@ -70,7 +70,7 @@ public class BundleAdapterServiceImpl ex
                     props.put(key, m_serviceProperties.get(key));
                 }
             }
-            List dependencies = m_service.getDependencies();
+            List dependencies = m_component.getDependencies();
             // the first dependency is always the dependency on the bundle, which
             // will be replaced with a more specific dependency below
             dependencies.remove(0);

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java?rev=1097256&r1=1097255&r2=1097256&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
Wed Apr 27 21:48:41 2011
@@ -1108,11 +1108,11 @@ public class ComponentImpl implements Co
         if (properties != null) {
             Enumeration enumeration = properties.keys();
             while (enumeration.hasMoreElements()) {
-                String key = (String) enumeration.nextElement();
+                Object key = enumeration.nextElement();
                 if (result.length() > 0) {
                     result.append(',');
                 }
-                result.append(key);
+                result.append(key.toString());
                 result.append('=');
                 Object value = properties.get(key);
                 if (value instanceof String[]) {

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java?rev=1097256&r1=1097255&r2=1097256&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FactoryConfigurationAdapterServiceImpl.java
Wed Apr 27 21:48:41 2011
@@ -48,7 +48,7 @@ public class FactoryConfigurationAdapter
         super(dm.createComponent()); // This service will be filtered by our super class,
allowing us to take control.
         Hashtable props = new Hashtable();
         props.put(Constants.SERVICE_PID, factoryPid);
-        m_service
+        m_component
             .setInterface(ManagedServiceFactory.class.getName(), props)
             .setImplementation(new AdapterImpl(factoryPid, update, propagate));
     }
@@ -58,7 +58,7 @@ public class FactoryConfigurationAdapter
         super(dm.createComponent()); // This service will be filtered by our super class,
allowing us to take control.
         Hashtable props = new Hashtable();
         props.put(Constants.SERVICE_PID, factoryPid);
-        m_service
+        m_component
             .setInterface(ManagedServiceFactory.class.getName(), props)
             .setImplementation(new MetaTypeAdapterImpl(factoryPid, update, propagate,
                 bctx, logger, heading, description,
@@ -132,7 +132,7 @@ public class FactoryConfigurationAdapter
             Dictionary serviceProperties = m_propagate ? mergeSettings(m_serviceProperties,
settings) : m_serviceProperties;
             newService.setInterface(m_serviceInterfaces, serviceProperties);
             newService.setImplementation(impl);
-            List dependencies = m_service.getDependencies();
+            List dependencies = m_component.getDependencies();
             newService.add(dependencies);
             newService.setComposition(m_compositionInstance, m_compositionMethod); // if
not set, no effect
             newService.setCallbacks(m_callbackObject, m_init, m_start, m_stop, m_destroy);
// if not set, no effect

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java?rev=1097256&r1=1097255&r2=1097256&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/FilterService.java
Wed Apr 27 21:48:41 2011
@@ -24,19 +24,22 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.felix.dm.Component;
+import org.apache.felix.dm.ComponentDeclaration;
+import org.apache.felix.dm.ComponentDependencyDeclaration;
 import org.apache.felix.dm.ComponentStateListener;
 import org.apache.felix.dm.Dependency;
 import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
 /**
- * This class allows to filter a Service interface. All Aspect/Adapters extends this class
- * in order to add functionality to the default Service implementation.
+ * This class allows to filter a Component interface. All Aspect/Adapters extend this class
+ * in order to add functionality to the default Component implementation.
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public class FilterService implements Component {
-    protected ComponentImpl m_service;
+public class FilterService implements Component, ComponentDeclaration {
+    protected ComponentImpl m_component;
     protected List m_stateListeners = new ArrayList();
     protected String m_init = "init";
     protected String m_start = "start";
@@ -52,16 +55,16 @@ public class FilterService implements Co
     protected Dictionary m_serviceProperties;
 
     public FilterService(Component service) {
-        m_service = (ComponentImpl) service;
+        m_component = (ComponentImpl) service;
     }
 
     public Component add(Dependency dependency) {
-        m_service.add(dependency);
+        m_component.add(dependency);
         // Add the dependency (if optional) to all already instantiated services.
         // If the dependency is required, our internal service will be stopped/restarted,
so in this case
         // we have nothing to do.
         if (! dependency.isRequired()) {
-            AbstractDecorator ad = (AbstractDecorator) m_service.getService();
+            AbstractDecorator ad = (AbstractDecorator) m_component.getService();
             if (ad != null)
             {
                 ad.addDependency(dependency);
@@ -71,7 +74,7 @@ public class FilterService implements Co
     }
 
     public Component add(List dependencies) {
-        m_service.add(dependencies);
+        m_component.add(dependencies);
         // Add the dependencies to all already instantiated services.
         // If one dependency from the list is required, we have nothing to do, since our
internal
         // service will be stopped/restarted.
@@ -83,7 +86,7 @@ public class FilterService implements Co
         }
         // Ok, the list contains no required dependencies: add optionals dependencies in
already instantiated
         // services.
-        AbstractDecorator ad = (AbstractDecorator) m_service.getService();
+        AbstractDecorator ad = (AbstractDecorator) m_component.getService();
         if (ad != null) {
             ad.addDependencies(dependencies);
         }
@@ -95,18 +98,18 @@ public class FilterService implements Co
             m_stateListeners.add(listener);
         }
         // Add the listener to all already instantiated services.
-        AbstractDecorator ad = (AbstractDecorator) m_service.getService();
+        AbstractDecorator ad = (AbstractDecorator) m_component.getService();
         if (ad != null) {
             ad.addStateListener(listener);
         }
     }
 
     public List getDependencies() {
-        return m_service.getDependencies();
+        return m_component.getDependencies();
     }
 
     public Object getService() {
-        return m_service.getService();
+        return m_component.getService();
     }
 
     public synchronized Dictionary getServiceProperties() {
@@ -114,17 +117,17 @@ public class FilterService implements Co
     }
 
     public ServiceRegistration getServiceRegistration() {
-        return m_service.getServiceRegistration();
+        return m_component.getServiceRegistration();
     }
 
     public Component remove(Dependency dependency) {
-        m_service.remove(dependency);
+        m_component.remove(dependency);
         // Remove the dependency (if optional) from all already instantiated services.
         // If the dependency is required, our internal service will be stopped, so in this
case
         // we have nothing to do.
         if (!dependency.isRequired())
         {
-            AbstractDecorator ad = (AbstractDecorator) m_service.getService();
+            AbstractDecorator ad = (AbstractDecorator) m_component.getService();
             if (ad != null)
             {
                 ad.removeDependency(dependency);
@@ -138,14 +141,14 @@ public class FilterService implements Co
             m_stateListeners.remove(listener);
         }
         // Remove the listener from all already instantiated services.
-        AbstractDecorator ad = (AbstractDecorator) m_service.getService();
+        AbstractDecorator ad = (AbstractDecorator) m_component.getService();
         if (ad != null) {
             ad.removeStateListener(listener);
         }
     }
 
     public synchronized Component setCallbacks(Object instance, String init, String start,
String stop, String destroy) {
-        m_service.ensureNotActive();
+        m_component.ensureNotActive();
         m_callbackObject = instance;
         m_init = init;
         m_start = start;
@@ -160,20 +163,20 @@ public class FilterService implements Co
     }
 
     public synchronized Component setComposition(Object instance, String getMethod) {
-        m_service.ensureNotActive();
+        m_component.ensureNotActive();
         m_compositionInstance = instance;
         m_compositionMethod = getMethod;
         return this;
     }
 
     public synchronized Component setComposition(String getMethod) {
-        m_service.ensureNotActive();
+        m_component.ensureNotActive();
         m_compositionMethod = getMethod;
         return this;
     }
 
     public synchronized Component setFactory(Object factory, String createMethod) {
-        m_service.ensureNotActive();
+        m_component.ensureNotActive();
         m_factory = factory;
         m_factoryCreateMethod = createMethod;
         return this;
@@ -184,7 +187,7 @@ public class FilterService implements Co
     }
 
     public synchronized Component setImplementation(Object implementation) {
-        m_service.ensureNotActive();
+        m_component.ensureNotActive();
         m_serviceImpl = implementation;
         return this;
     }
@@ -194,7 +197,7 @@ public class FilterService implements Co
     }
 
     public synchronized Component setInterface(String[] serviceInterfaces, Dictionary properties)
{
-        m_service.ensureNotActive();
+        m_component.ensureNotActive();
         if (serviceInterfaces != null) {
             m_serviceInterfaces = new String[serviceInterfaces.length];
             System.arraycopy(serviceInterfaces, 0, m_serviceInterfaces, 0, serviceInterfaces.length);
@@ -209,7 +212,7 @@ public class FilterService implements Co
         }
         // Set the properties to all already instantiated services.
         if (serviceProperties != null) {
-            AbstractDecorator ad = (AbstractDecorator) m_service.getService();
+            AbstractDecorator ad = (AbstractDecorator) m_component.getService();
             if (ad != null) {
                 ad.setServiceProperties(serviceProperties);
             }
@@ -218,40 +221,56 @@ public class FilterService implements Co
     }
 
     public void start() {
-        m_service.start();
+        m_component.start();
     }
 
     public void stop() {
-        m_service.stop();
+        m_component.stop();
     }
     
     public void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures,
Object[][] parameters) {
-        m_service.invokeCallbackMethod(instances, methodName, signatures, parameters);
+        m_component.invokeCallbackMethod(instances, methodName, signatures, parameters);
     }
     
     public Object[] getCompositionInstances() {
-        return m_service.getCompositionInstances();
+        return m_component.getCompositionInstances();
     }
     
     public DependencyManager getDependencyManager() {
-        return m_service.getDependencyManager();
+        return m_component.getDependencyManager();
     }
 
     public Component setAutoConfig(Class clazz, boolean autoConfig) {
-        m_service.setAutoConfig(clazz, autoConfig);
+        m_component.setAutoConfig(clazz, autoConfig);
         return this;
     }
 
     public Component setAutoConfig(Class clazz, String instanceName) {
-        m_service.setAutoConfig(clazz, instanceName);
+        m_component.setAutoConfig(clazz, instanceName);
         return this;
     }
     
     public boolean getAutoConfig(Class clazz) {
-        return m_service.getAutoConfig(clazz);
+        return m_component.getAutoConfig(clazz);
     }
     
     public String getAutoConfigInstance(Class clazz) {
-        return m_service.getAutoConfigInstance(clazz);
+        return m_component.getAutoConfigInstance(clazz);
+    }
+
+    public ComponentDependencyDeclaration[] getComponentDependencies() {
+        return m_component.getComponentDependencies();
+    }
+
+    public String getName() {
+        return m_component.getName();
+    }
+
+    public int getState() {
+        return m_component.getState();
+    }
+
+    public BundleContext getBundleContext() {
+        return m_component.getBundleContext();
     };
 }
\ No newline at end of file

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java?rev=1097256&r1=1097255&r2=1097256&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterServiceImpl.java
Wed Apr 27 21:48:41 2011
@@ -47,7 +47,7 @@ public class ResourceAdapterServiceImpl 
         super(dm.createComponent()); // This service will be filtered by our super class,
allowing us to take control.
         m_callbackInstance = callbackInstance;
         m_callbackChanged = callbackChanged;
-        m_service.setImplementation(new ResourceAdapterImpl(resourceFilter, propagate))
+        m_component.setImplementation(new ResourceAdapterImpl(resourceFilter, propagate))
             .add(dm.createResourceDependency()
                  .setFilter(resourceFilter)
                  .setAutoConfig(false)
@@ -58,7 +58,7 @@ public class ResourceAdapterServiceImpl 
         super(dm.createComponent()); // This service will be filtered by our super class,
allowing us to take control.
         m_callbackInstance = callbackInstance;
         m_callbackChanged = callbackChanged;
-        m_service.setImplementation(new ResourceAdapterImpl(resourceFilter, propagateCallbackInstance,
propagateCallbackMethod))
+        m_component.setImplementation(new ResourceAdapterImpl(resourceFilter, propagateCallbackInstance,
propagateCallbackMethod))
             .add(dm.createResourceDependency()
                  .setFilter(resourceFilter)
                  .setAutoConfig(false)
@@ -96,7 +96,7 @@ public class ResourceAdapterServiceImpl 
                     props.put(key, m_serviceProperties.get(key));
                 }
             }
-            List dependencies = m_service.getDependencies();
+            List dependencies = m_component.getDependencies();
             // the first dependency is always the dependency on the resource, which
             // will be replaced with a more specific dependency below
             dependencies.remove(0);



Mime
View raw message