felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r889178 - in /felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl: ResourceAdapterImpl.java ServiceImpl.java
Date Thu, 10 Dec 2009 10:53:15 GMT
Author: marrs
Date: Thu Dec 10 10:53:01 2009
New Revision: 889178

URL: http://svn.apache.org/viewvc?rev=889178&view=rev
Log:
simplified updating of instances and propagation of properties

Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterImpl.java
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterImpl.java?rev=889178&r1=889177&r2=889178&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ResourceAdapterImpl.java
Thu Dec 10 10:53:01 2009
@@ -34,7 +34,6 @@
 	}
 
 	public void added(Resource resource) {
-		System.out.println("ADDED " + resource);
 		m_manager.add(m_manager.createService()
 			.setInterface(m_iface.getName(), null)
 			.setImplementation(m_impl)
@@ -48,5 +47,4 @@
 
 	public void removed(Resource resource) {
 	}
-
 }

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java?rev=889178&r1=889177&r2=889178&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
Thu Dec 10 10:53:01 2009
@@ -35,18 +35,12 @@
 
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.dependencies.Dependency;
-import org.apache.felix.dm.impl.dependencies.BundleDependencyImpl;
-import org.apache.felix.dm.impl.dependencies.ConfigurationDependencyImpl;
 import org.apache.felix.dm.impl.dependencies.DependencyActivation;
 import org.apache.felix.dm.impl.dependencies.DependencyService;
-import org.apache.felix.dm.impl.dependencies.ResourceDependencyImpl;
-import org.apache.felix.dm.impl.dependencies.ServiceDependencyImpl;
 import org.apache.felix.dm.management.ServiceComponent;
 import org.apache.felix.dm.management.ServiceComponentDependency;
-import org.apache.felix.dm.resources.Resource;
 import org.apache.felix.dm.service.Service;
 import org.apache.felix.dm.service.ServiceStateListener;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
@@ -421,7 +415,7 @@
 
 	public synchronized void setServiceProperties(Dictionary serviceProperties) {
 	    m_serviceProperties = serviceProperties;
-	    if (isBound() && (m_serviceName != null)) {
+	    if ((m_registration != null) && (m_serviceName != null)) {
 	        m_registration.setProperties(calculateServiceProperties());
 	    }
 	}
@@ -814,36 +808,44 @@
     }
 
     private void updateInstance(Dependency dependency) {
-        if (dependency instanceof ServiceDependencyImpl) {
-            ServiceDependencyImpl sd = (ServiceDependencyImpl) dependency;
-            // update the dependency in the service instance (it will use
-            // a null object if necessary)
-            if (sd.isAutoConfig()) {
-                configureImplementation(sd.getInterface(), sd.getService(), sd.getAutoConfigName());
-            }
-        }
-        else if (dependency instanceof ConfigurationDependencyImpl) {
-        	ConfigurationDependencyImpl cd = (ConfigurationDependencyImpl) dependency;
-        	if (cd.isPropagated()) {
-        		// change service properties accordingly, but only if the service was already registered
-        	    if (m_registration != null) {
-            		Dictionary props = calculateServiceProperties();
-            		m_registration.setProperties(props);
-        	    }
-        	}
-        }
-        else if (dependency instanceof BundleDependencyImpl) {
-            BundleDependencyImpl bd = (BundleDependencyImpl) dependency;
-            if (bd.isAutoConfig()) {
-                configureImplementation(Bundle.class, bd.getBundle()); // TODO support AutoConfigName
-            }
-        }
-        else if (dependency instanceof ResourceDependencyImpl) {
-            ResourceDependencyImpl rd = (ResourceDependencyImpl) dependency;
-            if (rd.isAutoConfig()) {
-                configureImplementation(Resource.class, rd.getResource()); // TODO support
AutoConfigName
+        
+        if (dependency.isAutoConfig()) {
+            configureImplementation(dependency.getAutoConfigType(), dependency.getAutoConfigInstance(),
dependency.getAutoConfigName());
+            if (dependency.isPropagated() && m_registration != null) {
+                m_registration.setProperties(calculateServiceProperties());
             }
         }
+        
+//        if (dependency instanceof ServiceDependencyImpl) {
+//            ServiceDependencyImpl sd = (ServiceDependencyImpl) dependency;
+//            // update the dependency in the service instance (it will use
+//            // a null object if necessary)
+//            if (sd.isAutoConfig()) {
+//                configureImplementation(sd.getInterface(), sd.getService(), sd.getAutoConfigName());
+//            }
+//        }
+//        else if (dependency instanceof ConfigurationDependencyImpl) {
+//        	ConfigurationDependencyImpl cd = (ConfigurationDependencyImpl) dependency;
+//        	if (cd.isPropagated()) {
+//        		// change service properties accordingly, but only if the service was already
registered
+//        	    if (m_registration != null) {
+//            		Dictionary props = calculateServiceProperties();
+//            		m_registration.setProperties(props);
+//        	    }
+//        	}
+//        }
+//        else if (dependency instanceof BundleDependencyImpl) {
+//            BundleDependencyImpl bd = (BundleDependencyImpl) dependency;
+//            if (bd.isAutoConfig()) {
+//                configureImplementation(Bundle.class, bd.getBundle()); // TODO support
AutoConfigName
+//            }
+//        }
+//        else if (dependency instanceof ResourceDependencyImpl) {
+//            ResourceDependencyImpl rd = (ResourceDependencyImpl) dependency;
+//            if (rd.isAutoConfig()) {
+//                configureImplementation(Resource.class, rd.getResource()); // TODO support
AutoConfigName
+//            }
+//        }
     }
 
     /**
@@ -1031,14 +1033,6 @@
         return (state.isAllRequiredAvailable());
     }
     
-    private boolean isBound() {
-        State state;
-        synchronized (m_dependencies) {
-            state = m_state;
-        }
-        return (state.isBound());
-    }
-
     // ServiceComponent interface
     
     static class SCDImpl implements ServiceComponentDependency {



Mime
View raw message