You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2015/07/18 20:12:45 UTC
svn commit: r1691760 [2/2] - in /felix/trunk/scr/src:
main/java/org/apache/felix/scr/impl/
main/java/org/apache/felix/scr/impl/manager/
test/java/org/apache/felix/scr/integration/
test/java/org/apache/felix/scr/integration/components/deadlock/ test/res...
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java?rev=1691760&r1=1691759&r2=1691760&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java Sat Jul 18 18:12:45 2015
@@ -27,13 +27,11 @@ import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
-import org.osgi.framework.AllServiceListener;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
/**
@@ -72,7 +70,7 @@ import org.osgi.framework.ServiceReferen
* @param <S>
* @param <T>
*/
-public class ServiceTracker<S, T> {
+public class ServiceTracker<S, T, U extends ServiceEvent> {
/* set this to true to compile in debug messages */
static final boolean DEBUG = false;
/**
@@ -85,27 +83,18 @@ public class ServiceTracker<S, T> {
*
* @since 1.1
*/
- protected final Filter filter;
+ protected final Filter eventFilter;
/**
* The {@code ServiceTrackerCustomizer} for this tracker.
*/
- final ServiceTrackerCustomizer<S, T> customizer;
+ final ServiceTrackerCustomizer<S, T, U> customizer;
/**
* Filter string for use when adding the ServiceListener. If this field is
* set, then certain optimizations can be taken since we don't have a user
* supplied filter.
*/
- final String listenerFilter;
- /**
- * Class name to be tracked. If this field is set, then we are tracking by
- * class name.
- */
- private final String trackClass;
- /**
- * Reference to be tracked. If this field is set, then we are tracking a
- * single ServiceReference.
- */
- private final ServiceReference<S> trackReference;
+ final String initialReferenceFilterString;
+
/**
* Tracked services: {@code ServiceReference} -> customized Object and
* {@code ServiceListener} object
@@ -129,93 +118,9 @@ public class ServiceTracker<S, T> {
return tracked;
}
- /**
- * Cached ServiceReference for getServiceReference.
- *
- * This field is volatile since it is accessed by multiple threads.
- */
- private volatile ServiceReference<S> cachedReference;
- /**
- * Cached service object for getService.
- *
- * This field is volatile since it is accessed by multiple threads.
- */
- private volatile T cachedService;
+ private ExtendedServiceListenerContext<U> extendedServiceListenerContext;
+ private String classFilterString;
- /**
- * Create a {@code ServiceTracker} on the specified {@code ServiceReference}
- * .
- *
- * <p>
- * The service referenced by the specified {@code ServiceReference} will be
- * tracked by this {@code ServiceTracker}.
- *
- * @param context The {@code BundleContext} against which the tracking is
- * done.
- * @param reference The {@code ServiceReference} for the service to be
- * tracked.
- * @param customizer The customizer object to call when services are added,
- * modified, or removed in this {@code ServiceTracker}. If customizer
- * is {@code null}, then this {@code ServiceTracker} will be used as
- * the {@code ServiceTrackerCustomizer} and this
- * {@code ServiceTracker} will call the
- * {@code ServiceTrackerCustomizer} methods on itself.
- */
- public ServiceTracker(final BundleContext context, final ServiceReference<S> reference, final ServiceTrackerCustomizer<S, T> customizer) {
- this.context = context;
- this.trackReference = reference;
- this.trackClass = null;
- this.customizer = customizer;
- this.listenerFilter = "(" + Constants.SERVICE_ID + "=" + reference.getProperty(Constants.SERVICE_ID).toString() + ")";
- try {
- this.filter = context.createFilter(listenerFilter);
- } catch (InvalidSyntaxException e) {
- /*
- * we could only get this exception if the ServiceReference was
- * invalid
- */
- IllegalArgumentException iae = new IllegalArgumentException("unexpected InvalidSyntaxException: " + e.getMessage());
- iae.initCause(e);
- throw iae;
- }
- }
-
- /**
- * Create a {@code ServiceTracker} on the specified class name.
- *
- * <p>
- * Services registered under the specified class name will be tracked by
- * this {@code ServiceTracker}.
- *
- * @param context The {@code BundleContext} against which the tracking is
- * done.
- * @param clazz The class name of the services to be tracked.
- * @param customizer The customizer object to call when services are added,
- * modified, or removed in this {@code ServiceTracker}. If customizer
- * is {@code null}, then this {@code ServiceTracker} will be used as
- * the {@code ServiceTrackerCustomizer} and this
- * {@code ServiceTracker} will call the
- * {@code ServiceTrackerCustomizer} methods on itself.
- */
- public ServiceTracker(final BundleContext context, final String clazz, final ServiceTrackerCustomizer<S, T> customizer) {
- this.context = context;
- this.trackReference = null;
- this.trackClass = clazz;
- this.customizer = customizer;
- // we call clazz.toString to verify clazz is non-null!
- this.listenerFilter = "(" + Constants.OBJECTCLASS + "=" + clazz + ")";
- try {
- this.filter = context.createFilter(listenerFilter);
- } catch (InvalidSyntaxException e) {
- /*
- * we could only get this exception if the clazz argument was
- * malformed
- */
- IllegalArgumentException iae = new IllegalArgumentException("unexpected InvalidSyntaxException: " + e.getMessage());
- iae.initCause(e);
- throw iae;
- }
- }
/**
* Create a {@code ServiceTracker} on the specified {@code Filter} object.
@@ -226,51 +131,38 @@ public class ServiceTracker<S, T> {
*
* @param context The {@code BundleContext} against which the tracking is
* done.
- * @param filter The {@code Filter} to select the services to be tracked.
* @param customizer The customizer object to call when services are added,
* modified, or removed in this {@code ServiceTracker}. If customizer
* is null, then this {@code ServiceTracker} will be used as the
* {@code ServiceTrackerCustomizer} and this {@code ServiceTracker}
* will call the {@code ServiceTrackerCustomizer} methods on itself.
* @param initialActive Initial active state of the tracker.
+ * @param bundleComponentActivator TODO
+ * @param eventFilter The {@code Filter} to select the services to be tracked.
+ * @param classFilterString TODO
+ * @param initialReferenceFilterString TODO
* @since 1.1
*/
- public ServiceTracker(final BundleContext context, final Filter filter, final ServiceTrackerCustomizer<S, T> customizer, boolean initialActive) {
+ public ServiceTracker(final BundleContext context,
+ final ServiceTrackerCustomizer<S, T, U> customizer,
+ boolean initialActive,
+ ExtendedServiceListenerContext<U> bundleComponentActivator,
+ final Filter eventFilter,
+ final String classFilterString,
+ final String initialReferenceFilterString) {
+ if ((context == null)) {
+ /*
+ * we throw a NPE here to be consistent with the other constructors
+ */
+ throw new NullPointerException( "BundleContext");
+ }
this.context = context;
- this.trackReference = null;
- this.trackClass = null;
- this.listenerFilter = filter.toString();
- this.filter = filter;
+ this.initialReferenceFilterString = initialReferenceFilterString;
+ this.eventFilter = eventFilter;
this.customizer = customizer;
this.active = initialActive;
- if ((context == null)) {
- /*
- * we throw a NPE here to be consistent with the other constructors
- */
- throw new NullPointerException( "BundleContext");
- }
- }
-
- /**
- * Create a {@code ServiceTracker} on the specified class.
- *
- * <p>
- * Services registered under the name of the specified class will be tracked
- * by this {@code ServiceTracker}.
- *
- * @param context The {@code BundleContext} against which the tracking is
- * done.
- * @param clazz The class of the services to be tracked.
- * @param customizer The customizer object to call when services are added,
- * modified, or removed in this {@code ServiceTracker}. If customizer
- * is {@code null}, then this {@code ServiceTracker} will be used as
- * the {@code ServiceTrackerCustomizer} and this
- * {@code ServiceTracker} will call the
- * {@code ServiceTrackerCustomizer} methods on itself.
- * @since 1.5
- */
- public ServiceTracker(final BundleContext context, final Class<S> clazz, final ServiceTrackerCustomizer<S, T> customizer) {
- this(context, clazz.getName(), customizer);
+ this.extendedServiceListenerContext = bundleComponentActivator;
+ this.classFilterString = classFilterString;
}
/**
@@ -315,25 +207,13 @@ public class ServiceTracker<S, T> {
return;
}
if (DEBUG) {
- System.out.println("ServiceTracker.open: " + filter);
+ System.out.println("ServiceTracker.open: " + eventFilter);
}
- t = trackAllServices ? new AllTracked( trackingCount ) : new Tracked( trackingCount );
+ t = new Tracked( trackingCount );
synchronized (t) {
try {
- context.addServiceListener(t, listenerFilter);
- ServiceReference<S>[] references = null;
- if (trackClass != null) {
- references = getInitialReferences(trackAllServices, trackClass, null);
- } else {
- if (trackReference != null) {
- if (trackReference.getBundle() != null) {
- ServiceReference<S>[] single = new ServiceReference[] {trackReference};
- references = single;
- }
- } else { /* user supplied filter */
- references = getInitialReferences(trackAllServices, null, listenerFilter);
- }
- }
+ extendedServiceListenerContext.addServiceListener(classFilterString, eventFilter, t);
+ ServiceReference<S>[] references = getInitialReferences(null, initialReferenceFilterString);
/* set tracked with the initial references */
t.setInitial(references);
} catch (InvalidSyntaxException e) {
@@ -349,18 +229,16 @@ public class ServiceTracker<S, T> {
/**
* Returns the list of initial {@code ServiceReference}s that will be
* tracked by this {@code ServiceTracker}.
- *
- * @param trackAllServices If {@code true}, use
- * {@code getAllServiceReferences}.
* @param className The class name with which the service was registered, or
* {@code null} for all services.
* @param filterString The filter criteria or {@code null} for all services.
+ *
* @return The list of initial {@code ServiceReference}s.
* @throws InvalidSyntaxException If the specified filterString has an
* invalid syntax.
*/
- private ServiceReference<S>[] getInitialReferences(boolean trackAllServices, String className, String filterString) throws InvalidSyntaxException {
- ServiceReference<S>[] result = (ServiceReference<S>[]) ((trackAllServices) ? context.getAllServiceReferences(className, filterString) : context.getServiceReferences(className, filterString));
+ private ServiceReference<S>[] getInitialReferences(String className, String filterString) throws InvalidSyntaxException {
+ ServiceReference<S>[] result = (ServiceReference<S>[]) context.getServiceReferences(className, filterString);
return result;
}
@@ -386,7 +264,7 @@ public class ServiceTracker<S, T> {
return map;
}
if (DEBUG) {
- System.out.println("ServiceTracker.close: " + filter);
+ System.out.println("ServiceTracker.close: " + eventFilter);
}
outgoing.close();
synchronized ( outgoing )
@@ -397,7 +275,7 @@ public class ServiceTracker<S, T> {
// references = getServiceReferences();
// tracked = null;
try {
- context.removeServiceListener(outgoing);
+ extendedServiceListenerContext.removeServiceListener(classFilterString, eventFilter, outgoing);
} catch (IllegalStateException e) {
/* In case the context was stopped. */
}
@@ -412,9 +290,7 @@ public class ServiceTracker<S, T> {
// }
// }
if (DEBUG) {
- if ((cachedReference == null) && (cachedService == null)) {
- System.out.println("ServiceTracker.close[cached cleared]: " + filter);
- }
+ System.out.println("ServiceTracker.close[cached cleared]: " + eventFilter);
}
return map;
}
@@ -427,7 +303,7 @@ public class ServiceTracker<S, T> {
return;
}
if (DEBUG) {
- System.out.println("ServiceTracker.close: " + filter);
+ System.out.println("ServiceTracker.close: " + eventFilter);
}
}
for (ServiceReference<S> ref: toUntrack.keySet()) {
@@ -479,7 +355,7 @@ public class ServiceTracker<S, T> {
*
* @param reference The reference to modified service.
* @param service The service object for the modified service.
- * @see ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, Object, int)
+ * @see ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, Object, int, ServiceEvent)
*/
public void modifiedService(ServiceReference<S> reference, T service, int trackingCount) {
/* do nothing */
@@ -504,67 +380,13 @@ public class ServiceTracker<S, T> {
*
* @param reference The reference to removed service.
* @param service The service object for the removed service.
- * @see ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference, Object, int)
+ * @see ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference, Object, int, ServiceEvent)
*/
public void removedService(ServiceReference<S> reference, T service, int trackingCount) {
context.ungetService(reference);
}
/**
- * Wait for at least one service to be tracked by this
- * {@code ServiceTracker}. This method will also return when this
- * {@code ServiceTracker} is closed.
- *
- * <p>
- * It is strongly recommended that {@code waitForService} is not used during
- * the calling of the {@code BundleActivator} methods.
- * {@code BundleActivator} methods are expected to complete in a short
- * period of time.
- *
- * <p>
- * This implementation calls {@link #getService()} to determine if a service
- * is being tracked.
- *
- * @param timeout The time interval in milliseconds to wait. If zero, the
- * method will wait indefinitely.
- * @return Returns the result of {@link #getService()}.
- * @throws InterruptedException If another thread has interrupted the
- * current thread.
- * @throws IllegalArgumentException If the value of timeout is negative.
- */
- public T waitForService(long timeout) throws InterruptedException {
- if (timeout < 0) {
- throw new IllegalArgumentException("timeout value is negative");
- }
-
- T object = getService();
- if (object != null) {
- return object;
- }
-
- final long endTime = (timeout == 0) ? 0 : (System.currentTimeMillis() + timeout);
- do {
- final Tracked t = tracked();
- if (t == null) { /* if ServiceTracker is not open */
- return null;
- }
- synchronized (t) {
- if (t.size() == 0) {
- t.wait(timeout);
- }
- }
- object = getService();
- if (endTime > 0) { // if we have a timeout
- timeout = endTime - System.currentTimeMillis();
- if (timeout <= 0) { // that has expired
- break;
- }
- }
- } while (object == null);
- return object;
- }
-
- /**
* Return an array of {@code ServiceReference}s for all services being
* tracked by this {@code ServiceTracker}.
*
@@ -586,76 +408,6 @@ public class ServiceTracker<S, T> {
}
}
- /**
- * Returns a {@code ServiceReference} for one of the services being tracked
- * by this {@code ServiceTracker}.
- *
- * <p>
- * If multiple services are being tracked, the service with the highest
- * ranking (as specified in its {@code service.ranking} property) is
- * returned. If there is a tie in ranking, the service with the lowest
- * service ID (as specified in its {@code service.id} property); that is,
- * the service that was registered first is returned. This is the same
- * algorithm used by {@code BundleContext.getServiceReference}.
- *
- * <p>
- * This implementation calls {@link #getServiceReferences()} to get the list
- * of references for the tracked services.
- *
- * @return A {@code ServiceReference} or {@code null} if no services are
- * being tracked.
- * @since 1.1
- */
- public ServiceReference<S> getServiceReference() {
- ServiceReference<S> reference = cachedReference;
- if (reference != null) {
- if (DEBUG) {
- System.out.println("ServiceTracker.getServiceReference[cached]: " + filter);
- }
- return reference;
- }
- if (DEBUG) {
- System.out.println("ServiceTracker.getServiceReference: " + filter);
- }
- ServiceReference<S>[] references = getServiceReferences();
- int length = (references == null) ? 0 : references.length;
- if (length == 0) { /* if no service is being tracked */
- return null;
- }
- int index = 0;
- if (length > 1) { /* if more than one service, select highest ranking */
- int rankings[] = new int[length];
- int count = 0;
- int maxRanking = Integer.MIN_VALUE;
- for (int i = 0; i < length; i++) {
- Object property = references[i].getProperty(Constants.SERVICE_RANKING);
- int ranking = (property instanceof Integer) ? ((Integer) property).intValue() : 0;
- rankings[i] = ranking;
- if (ranking > maxRanking) {
- index = i;
- maxRanking = ranking;
- count = 1;
- } else {
- if (ranking == maxRanking) {
- count++;
- }
- }
- }
- if (count > 1) { /* if still more than one service, select lowest id */
- long minId = Long.MAX_VALUE;
- for (int i = 0; i < length; i++) {
- if (rankings[i] == maxRanking) {
- long id = ((Long) (references[i].getProperty(Constants.SERVICE_ID))).longValue();
- if (id < minId) {
- index = i;
- minId = id;
- }
- }
- }
- }
- }
- return cachedReference = references[index];
- }
/**
* Returns the service object for the specified {@code ServiceReference} if
@@ -708,34 +460,6 @@ public class ServiceTracker<S, T> {
}
}
- /**
- * Returns a service object for one of the services being tracked by this
- * {@code ServiceTracker}.
- *
- * <p>
- * If any services are being tracked, this implementation returns the result
- * of calling {@code getService(getServiceReference())}.
- *
- * @return A service object or {@code null} if no services are being
- * tracked.
- */
- public T getService() {
- T service = cachedService;
- if (service != null) {
- if (DEBUG) {
- System.out.println("ServiceTracker.getService[cached]: " + filter);
- }
- return service;
- }
- if (DEBUG) {
- System.out.println("ServiceTracker.getService: " + filter);
- }
- ServiceReference<S> reference = getServiceReference();
- if (reference == null) {
- return null;
- }
- return cachedService = getService(reference);
- }
/**
* Remove a service from this {@code ServiceTracker}.
@@ -810,10 +534,8 @@ public class ServiceTracker<S, T> {
* between the listener thread and the user thread.
*/
void modified() {
- cachedReference = null; /* clear cached value */
- cachedService = null; /* clear cached value */
if (DEBUG) {
- System.out.println("ServiceTracker.modified: " + filter);
+ System.out.println("ServiceTracker.modified: " + eventFilter);
}
}
@@ -1106,11 +828,12 @@ public class ServiceTracker<S, T> {
if (DEBUG) {
System.out.println("AbstractTracked.trackInitial: " + item); //$NON-NLS-1$
}
- trackAdding(item, null); /*
- * Begin tracking it. We call trackAdding
- * since we have already put the item in the
- * adding list.
- */
+ /*
+ * Begin tracking it. We call trackAdding
+ * since we have already put the item in the
+ * adding list.
+ */
+ trackAdding(item, null);
}
}
@@ -1410,7 +1133,7 @@ public class ServiceTracker<S, T> {
*
* @ThreadSafe
*/
- private class Tracked extends AbstractTracked<ServiceReference<S>, T, ServiceEvent> implements ServiceListener {
+ private class Tracked extends AbstractTracked<ServiceReference<S>, T, U> implements ExtendedServiceListener<U> {
/**
* Tracked constructor.
* @param trackingCount
@@ -1425,7 +1148,7 @@ public class ServiceTracker<S, T> {
*
* @param event {@code ServiceEvent} object from the framework.
*/
- final public void serviceChanged(final ServiceEvent event) {
+ final public void serviceChanged(final U event) {
/*
* Check if we had a delayed call (which could happen when we
* close).
@@ -1484,12 +1207,12 @@ public class ServiceTracker<S, T> {
* @return Customized object for the tracked item or {@code null} if the
* item is not to be tracked.
*/
- final T customizerAdding( final ServiceReference<S> item, final ServiceEvent related ) {
+ final T customizerAdding( final ServiceReference<S> item, final U related ) {
return customizer.addingService( item );
}
- final void customizerAdded( final ServiceReference<S> item, final ServiceEvent related, final T object, int trackingCount, int serviceCount ) {
- customizer.addedService( item, object, trackingCount, serviceCount );
+ final void customizerAdded( final ServiceReference<S> item, final U related, final T object, int trackingCount, int serviceCount ) {
+ customizer.addedService( item, object, trackingCount, serviceCount, related );
}
/**
@@ -1501,8 +1224,8 @@ public class ServiceTracker<S, T> {
* @param object Customized object for the tracked item.
* @param trackingCount
*/
- final void customizerModified( final ServiceReference<S> item, final ServiceEvent related, final T object, int trackingCount ) {
- customizer.modifiedService( item, object, trackingCount );
+ final void customizerModified( final ServiceReference<S> item, final U related, final T object, int trackingCount ) {
+ customizer.modifiedService( item, object, trackingCount, related );
}
/**
@@ -1514,8 +1237,8 @@ public class ServiceTracker<S, T> {
* @param object Customized object for the tracked item.
* @param trackingCount
*/
- final void customizerRemoved( final ServiceReference<S> item, final ServiceEvent related, final T object, int trackingCount ) {
- customizer.removedService(item, object, trackingCount );
+ final void customizerRemoved( final ServiceReference<S> item, final U related, final T object, int trackingCount ) {
+ customizer.removedService(item, object, trackingCount, related );
}
}
@@ -1526,13 +1249,13 @@ public class ServiceTracker<S, T> {
* @since 1.3
* @ThreadSafe
*/
- private class AllTracked extends Tracked implements AllServiceListener {
- /**
- * AllTracked constructor.
- * @param trackingCount
- */
- AllTracked( AtomicInteger trackingCount ) {
- super( trackingCount );
- }
- }
+// private class AllTracked extends Tracked<U> implements AllServiceListener {
+// /**
+// * AllTracked constructor.
+// * @param trackingCount
+// */
+// AllTracked( AtomicInteger trackingCount ) {
+// super( trackingCount );
+// }
+// }
}
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTrackerCustomizer.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTrackerCustomizer.java?rev=1691760&r1=1691759&r2=1691760&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTrackerCustomizer.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTrackerCustomizer.java Sat Jul 18 18:12:45 2015
@@ -16,6 +16,7 @@
package org.apache.felix.scr.impl.manager;
+import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceReference;
/**
@@ -47,7 +48,7 @@ import org.osgi.framework.ServiceReferen
* @ThreadSafe
* @version $Id: c14b8d47026b6bd4ba1f2db7bf7e755d00fc6f6a $
*/
-public interface ServiceTrackerCustomizer<S, T> {
+public interface ServiceTrackerCustomizer<S, T, U extends ServiceEvent> {
/**
* A service is being added to the {@code ServiceTracker}.
*
@@ -69,7 +70,7 @@ public interface ServiceTrackerCustomize
*/
public T addingService( ServiceReference<S> reference );
- public void addedService( ServiceReference<S> reference, T service, int trackingCount, int serviceCount );
+ public void addedService( ServiceReference<S> reference, T service, int trackingCount, int serviceCount, U event );
/**
* A service tracked by the {@code ServiceTracker} has been modified.
@@ -79,10 +80,11 @@ public interface ServiceTrackerCustomize
* {@code ServiceTracker} has had it properties modified.
*
* @param reference The reference to the service that has been modified.
- * @param service The service object for the specified referenced service.
- * @param trackingCount
+ * @param service The service object for the specified referenced service.
+ * @param trackingCount
+ * @param event TODO
*/
- public void modifiedService( ServiceReference<S> reference, T service, int trackingCount );
+ public void modifiedService( ServiceReference<S> reference, T service, int trackingCount, U event );
/**
* A service tracked by the {@code ServiceTracker} has been removed.
@@ -94,7 +96,8 @@ public interface ServiceTrackerCustomize
* @param reference The reference to the service that has been removed.
* @param service The service object for the specified referenced service.
* @param trackingCount
+ * @param event TODO
*/
- public void removedService( ServiceReference<S> reference, T service, int trackingCount );
+ public void removedService( ServiceReference<S> reference, T service, int trackingCount, U event );
}
Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1691760&r1=1691759&r2=1691760&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java Sat Jul 18 18:12:45 2015
@@ -374,7 +374,7 @@ public abstract class ComponentTestBase
Collection<ServiceReference<S>> srs;
try {
srs = bundleContext.getServiceReferences(clazz, filter);
- Assert.assertEquals(1, srs.size());
+ Assert.assertEquals("Nothing for filter: " + filter, 1, srs.size());
ServiceReference<S> sr = srs.iterator().next();
S s = bundleContext.getService(sr);
Assert.assertNotNull(s);
Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java?rev=1691760&r1=1691759&r2=1691760&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java Sat Jul 18 18:12:45 2015
@@ -46,18 +46,20 @@ public class LocateTest extends Componen
{
bundleContext.registerService( Object.class, new Object(), null );
- findComponentConfigurationByName( "AsyncLocate", ComponentConfigurationDTO.ACTIVE );
+ findComponentConfigurationByName( "Consumer", ComponentConfigurationDTO.ACTIVE );
- final String pid = "SimpleComponent";
+ final String pid = "TestComponent";
Configuration config = getConfigurationAdmin().getConfiguration( pid, null );
final Hashtable props = new Hashtable();
+ //wrong target property, will not bind
props.put( "target", "bar" );
config.update(props);
delay();
//when deadlock is present the state is actually unsatisfied.
- ComponentConfigurationDTO cc = findComponentConfigurationByName( pid, ComponentConfigurationDTO.ACTIVE );
- delay();
+ ComponentConfigurationDTO cc = findComponentConfigurationByName( pid, ComponentConfigurationDTO.SATISFIED );
+// delay();
+ //correct target property: will bind as new properties are propagated.
props.put( "target", "foo" );
config.update(props);
delay();
Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java?rev=1691760&r1=1691759&r2=1691760&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java Sat Jul 18 18:12:45 2015
@@ -31,12 +31,12 @@ public class Consumer
this.cc = cc;
}
- protected void setSimpleComponent(TestComponent sc)
+ protected void setTestComponent(TestComponent tc)
{
- sc.doIt( );
+ tc.doIt( );
}
- protected void unsetSimpleComponent(ServiceReference<TestComponent> sr)
+ protected void unsetTestComponent(ServiceReference<TestComponent> sr)
{
}
Modified: felix/trunk/scr/src/test/resources/integration_test_locate.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_locate.xml?rev=1691760&r1=1691759&r2=1691760&view=diff
==============================================================================
--- felix/trunk/scr/src/test/resources/integration_test_locate.xml (original)
+++ felix/trunk/scr/src/test/resources/integration_test_locate.xml Sat Jul 18 18:12:45 2015
@@ -11,7 +11,7 @@
language governing permissions and limitations under the License. -->
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
- <scr:component name="SimpleComponent"
+ <scr:component name="TestComponent"
configuration-policy="require">
<implementation class="org.apache.felix.scr.integration.components.deadlock.TestComponent" />
<service>
@@ -28,17 +28,17 @@
</scr:component>
- <scr:component name="AsyncLocate"
+ <scr:component name="Consumer"
immediate="true">
<implementation class="org.apache.felix.scr.integration.components.deadlock.Consumer" />
<reference
- name="SimpleComponent"
+ name="TestComponent"
interface="org.apache.felix.scr.integration.components.deadlock.TestComponent"
cardinality="0..1"
policy="dynamic"
- bind="setSimpleComponent"
- unbind="unsetSimpleComponent"
- target='target="foo"'
+ bind="setTestComponent"
+ unbind="unsetTestComponent"
+ target='(target=foo)'
/>
</scr:component>