aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-10-24 11:41:49 (EDT)
committerOleg Besedin2011-10-31 13:56:49 (EDT)
commit5ac37d109d815c15a42bf8b626b87870570533e1 (patch)
treeab7e26fc805bca1ad78bc27e405c280dd5b396ba
parente53943c5af7da081fbc0fdb17667db513ce86f10 (diff)
downloadeclipse.platform.runtime-5ac37d109d815c15a42bf8b626b87870570533e1.zip
eclipse.platform.runtime-5ac37d109d815c15a42bf8b626b87870570533e1.tar.gz
eclipse.platform.runtime-5ac37d109d815c15a42bf8b626b87870570533e1.tar.bz2
Bug 317706 - [DI] OSGi services aren't injected if they weren't
registered when the context is created
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/EclipseContextFactory.java8
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java2
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java26
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ILookupStrategy.java52
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/ContextsActivator.java6
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java119
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/OSGiContextStrategy.java270
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/CoreTestsActivator.java18
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java2
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug304585Test.java92
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java3
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java150
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java2
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java8
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ContextExample.java2
-rw-r--r--tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java2
16 files changed, 230 insertions, 532 deletions
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/EclipseContextFactory.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/EclipseContextFactory.java
index 0188429..6a97cb9 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/EclipseContextFactory.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/EclipseContextFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,7 @@ package org.eclipse.e4.core.contexts;
import java.util.WeakHashMap;
import org.eclipse.e4.core.internal.contexts.EclipseContext;
-import org.eclipse.e4.core.internal.contexts.osgi.OSGiContextStrategy;
+import org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi;
import org.osgi.framework.BundleContext;
/**
@@ -26,7 +26,7 @@ public final class EclipseContextFactory {
* @return A new empty context.
*/
static public IEclipseContext create() {
- return new EclipseContext(null, null);
+ return new EclipseContext(null);
}
/**
@@ -53,7 +53,7 @@ public final class EclipseContextFactory {
synchronized (serviceContexts) {
IEclipseContext result = serviceContexts.get(bundleContext);
if (result == null) {
- result = new EclipseContext(null, new OSGiContextStrategy(bundleContext));
+ result = new EclipseContextOSGi(bundleContext);
result.set(EclipseContext.DEBUG_STRING, "OSGi context for bundle: " + bundleContext.getBundle().getSymbolicName()); //$NON-NLS-1$
serviceContexts.put(bundleContext, result);
}
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java
index 2e21e07..c40770c 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java
@@ -211,7 +211,7 @@ public class ContextObjectSupplier extends PrimaryObjectSupplier {
Stack<Computation> current = EclipseContext.getCalculatedComputations();
Computation plug = current.pop();
if (plug != null)
- throw new IllegalArgumentException("Internal error in nested computation processing");
+ throw new IllegalArgumentException("Internal error in nested computation processing"); //$NON-NLS-1$
}
static public ContextObjectSupplier getObjectSupplier(IEclipseContext context, IInjector injector) {
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
index 953d9ad..a312cb3 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
@@ -76,9 +76,7 @@ public class EclipseContext implements IEclipseContext {
private Map<String, ValueComputation> localValueComputations = Collections.synchronizedMap(new HashMap<String, ValueComputation>());
private Set<Computation> activeRATs = new HashSet<Computation>();
- final Map<String, Object> localValues = Collections.synchronizedMap(new HashMap<String, Object>());
-
- private final ILookupStrategy strategy;
+ final protected Map<String, Object> localValues = Collections.synchronizedMap(new HashMap<String, Object>());
private ArrayList<String> modifiable;
@@ -98,8 +96,7 @@ public class EclipseContext implements IEclipseContext {
static private final IEclipseContextDebugger debugAddOn = ContextDebugHelper.getDebugger();
- public EclipseContext(IEclipseContext parent, ILookupStrategy strategy) {
- this.strategy = strategy;
+ public EclipseContext(IEclipseContext parent) {
setParent(parent);
if (parent == null)
waiting = Collections.synchronizedList(new ArrayList<Computation>());
@@ -140,10 +137,6 @@ public class EclipseContext implements IEclipseContext {
IEclipseContext parent = getParent();
if (parent != null && parent.containsKey(name))
return true;
- if (strategy != null) {
- if (strategy.containsKey(name, this))
- return true;
- }
return false;
}
@@ -175,8 +168,6 @@ public class EclipseContext implements IEclipseContext {
}
}
- if (strategy != null)
- strategy.dispose();
localValueComputations.clear();
// if this was the parent's active child, deactivate it
@@ -218,8 +209,8 @@ public class EclipseContext implements IEclipseContext {
result = localValues.get(name);
if (result == null)
return null;
- } else if (strategy != null) // 2. try the local strategy
- result = strategy.lookup(name, originatingContext);
+ } else
+ result = lookup(name, originatingContext);
// if we found something, compute the concrete value and return
if (result != null) {
@@ -568,7 +559,7 @@ public class EclipseContext implements IEclipseContext {
}
public IEclipseContext createChild() {
- return new EclipseContext(this, null); // strategies are not inherited
+ return new EclipseContext(this); // strategies are not inherited
}
public IEclipseContext createChild(String name) {
@@ -695,4 +686,11 @@ public class EclipseContext implements IEclipseContext {
throw new IllegalArgumentException("Internal error: Invalid nested computation processing"); //$NON-NLS-1$
}
+ /**
+ * This method can be overriden to provide additional source for the requested data.
+ * The override is expected to take care of initiating dynamic updates.
+ */
+ protected Object lookup(String name, EclipseContext originatingContext) {
+ return null;
+ }
}
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ILookupStrategy.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ILookupStrategy.java
deleted file mode 100644
index 3277b4f..0000000
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ILookupStrategy.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.core.internal.contexts;
-
-import org.eclipse.e4.core.contexts.ContextFunction;
-import org.eclipse.e4.core.contexts.IEclipseContext;
-
-/**
- * A context strategy for looking up values that are not currently defined
- * in a context. The lookup strategy is consulted by the context after
- * looking for an already defined local value, but before delegating lookup
- * to a parent context.
- */
-public interface ILookupStrategy {
- /**
- * Looks up a value for the given name to be associated with the given context.
- * @param name The name of the context value to look up
- * @param context The context in which the lookup occurred
- * @return The value for the given name, or <code>null</code> if no
- * corresponding value could be found. The value may be an
- * {@link ContextFunction}.
- */
- public Object lookup(String name, IEclipseContext context);
-
- /**
- * Returns whether this strategy is able to return a value for the given name.
- * There is no guarantee that the result will predict a future invocation
- * of {@link #lookup(String, IEclipseContext)} on this same strategy,
- * due to the possibility of concurrent changes in this lookup strategy's
- * search scope.
- *
- * @param name The name of the context value to look up
- * @param context The context in which the lookup occurred
- * @return <code>true</code> if this strategy is able to return a
- * value for the given name, and <code>false</code> otherwise.
- */
- public boolean containsKey(String name, IEclipseContext context);
-
- /**
- * Disposes of this object. If this object is already disposed this method
- * will have no effect.
- */
- public void dispose();
-}
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/ContextsActivator.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/ContextsActivator.java
index a3b0da7..3594586 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/ContextsActivator.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/ContextsActivator.java
@@ -19,7 +19,7 @@ public class ContextsActivator implements BundleActivator {
static private ContextsActivator defaultInstance;
private BundleContext bundleContext;
- private ServiceTracker debugTracker = null;
+ private ServiceTracker<DebugOptions, DebugOptions> debugTracker = null;
public ContextsActivator() {
defaultInstance = this;
@@ -50,10 +50,10 @@ public class ContextsActivator implements BundleActivator {
if (myBundleContext == null)
return defaultValue;
if (getDefault().debugTracker == null) {
- getDefault().debugTracker = new ServiceTracker(getDefault().bundleContext, DebugOptions.class.getName(), null);
+ getDefault().debugTracker = new ServiceTracker<DebugOptions, DebugOptions>(getDefault().bundleContext, DebugOptions.class.getName(), null);
getDefault().debugTracker.open();
}
- DebugOptions options = (DebugOptions) getDefault().debugTracker.getService();
+ DebugOptions options = getDefault().debugTracker.getService();
if (options != null) {
String value = options.getOption(option);
if (value != null)
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java
new file mode 100644
index 0000000..4d1e7ec
--- /dev/null
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.e4.core.internal.contexts.osgi;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.e4.core.contexts.IContextFunction;
+import org.eclipse.e4.core.internal.contexts.EclipseContext;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+
+public class EclipseContextOSGi extends EclipseContext implements ServiceListener {
+
+ final private BundleContext bundleContext;
+
+ private Map<String, ServiceReference<?>> refs = Collections.synchronizedMap(new HashMap<String, ServiceReference<?>>());
+
+ public EclipseContextOSGi(BundleContext bundleContext) {
+ super(null);
+ this.bundleContext = bundleContext;
+ try {
+ // process all IContextFunction services already registered
+ ServiceReference<?>[] existing = bundleContext.getServiceReferences(IContextFunction.SERVICE_NAME, null);
+ if (existing != null) {
+ for (int i = 0; i < existing.length; i++) {
+ String name = (String) existing[i].getProperty(IContextFunction.SERVICE_CONTEXT_KEY);
+ refs.put(name, existing[i]);
+ localValues.put(name, bundleContext.getService(existing[i]));
+ }
+ }
+ } catch (InvalidSyntaxException e) {
+ // should never happen
+ }
+ this.bundleContext.addServiceListener(this);
+ }
+
+ public boolean containsKey(String name, boolean localOnly) {
+ if (super.containsKey(name, localOnly))
+ return true;
+ Object result = lookup(name, this);
+ return (result != null);
+ }
+
+ public Object lookup(String name, EclipseContext originatingContext) {
+ if (name == null)
+ return null;
+ if (refs.containsKey(name)) { // retrieve service again
+ // This could be reached, for instance, if previously stored service value is overridden or removed from the context.
+ ServiceReference<?> ref = refs.get(name);
+ if (ref == null)
+ return null;
+ Object service = bundleContext.getService(ref);
+ bundleContext.ungetService(ref);
+ localValues.put(name, service);
+ return service;
+ }
+ ServiceReference<?> ref = bundleContext.getServiceReference(name);
+ if (ref == null) {
+ refs.put(name, null);
+ return null;
+ }
+ refs.put(name, ref);
+ Object service = bundleContext.getService(ref);
+ localValues.put(name, service);
+ return service;
+ }
+
+ /**
+ * Returns the service name for a service reference
+ */
+ private String serviceName(ServiceReference<?> reference) {
+ return ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0];
+ }
+
+ public void dispose() {
+ for (ServiceReference<?> ref : refs.values()) {
+ if (ref != null)
+ bundleContext.ungetService(ref);
+ }
+ refs.clear();
+ bundleContext.removeServiceListener(this);
+ super.dispose();
+ }
+
+ public void serviceChanged(ServiceEvent event) {
+ ServiceReference<?> ref = event.getServiceReference();
+ String name = serviceName(ref);
+ if (IContextFunction.SERVICE_NAME.equals(name)) // those keep associated names
+ name = (String) ref.getProperty(IContextFunction.SERVICE_CONTEXT_KEY);
+
+ if (refs.containsKey(name)) {
+ ServiceReference<?> oldRef = refs.get(name);
+ if (oldRef != null)
+ bundleContext.ungetService(oldRef);
+ if (event.getType() == ServiceEvent.UNREGISTERING) {
+ refs.put(name, null);
+ remove(name);
+ } else {
+ Object service = bundleContext.getService(ref);
+ refs.put(name, ref);
+ set(name, service);
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/OSGiContextStrategy.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/OSGiContextStrategy.java
deleted file mode 100644
index 560de75..0000000
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/OSGiContextStrategy.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.core.internal.contexts.osgi;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.WeakHashMap;
-import org.eclipse.e4.core.contexts.IContextFunction;
-import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.e4.core.internal.contexts.EclipseContext;
-import org.eclipse.e4.core.internal.contexts.IContextDisposalListener;
-import org.eclipse.e4.core.internal.contexts.ILookupStrategy;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-/**
- * A context strategy that provides access to OSGi services.
- * <p>
- * OSGi services are looked up by service class name.
- */
-public class OSGiContextStrategy implements IContextDisposalListener, ILookupStrategy, ServiceTrackerCustomizer {
- class ServiceData {
- // the service name
- String name;
-
- ServiceTracker tracker;
- // the contexts using this service (IEclipseContext -> null)
- final Map<IEclipseContext, Object> users = Collections.synchronizedMap(new WeakHashMap<IEclipseContext, Object>());
-
- ServiceData(String name) {
- this.name = name;
- }
-
- public void addContext(IEclipseContext originatingContext) {
- users.put(originatingContext, null);
- }
-
- public IEclipseContext[] getUsingContexts() {
- return users.keySet().toArray(new IEclipseContext[users.size()]);
- }
- }
-
- /**
- * Maintains a cache of registered context functions, indexed by context function key.
- */
- class ContextFunctionCache implements ServiceListener {
- final Map<String, ServiceReference> functionKeys = Collections.synchronizedMap(new HashMap<String, ServiceReference>());
-
- public ContextFunctionCache() {
- try {
- String filter = "(" + Constants.OBJECTCLASS + '=' + IContextFunction.SERVICE_NAME //$NON-NLS-1$
- + ')';
- bundleContext.addServiceListener(this, filter);
- // process all services already registered
- ServiceReference[] existing = bundleContext.getServiceReferences(IContextFunction.SERVICE_NAME, null);
- if (existing != null) {
- for (int i = 0; i < existing.length; i++)
- add(existing[i]);
- }
- } catch (InvalidSyntaxException e) {
- // should never happen
- throw new RuntimeException(e);
- }
-
- }
-
- /**
- * Process an added service reference to a context function.
- */
- private void add(ServiceReference ref) {
- String key = (String) ref.getProperty(IContextFunction.SERVICE_CONTEXT_KEY);
- if (key != null)
- functionKeys.put(key, ref);
- }
-
- public ServiceReference lookup(String key) {
- return functionKeys.get(key);
- }
-
- public void dispose() {
- bundleContext.removeServiceListener(this);
- functionKeys.clear();
- }
-
- /**
- * Process a removed service reference from a context function.
- */
- private void remove(ServiceReference ref) {
- String key = (String) ref.getProperty(IContextFunction.SERVICE_CONTEXT_KEY);
- if (key != null)
- functionKeys.remove(key);
- }
-
- public void serviceChanged(ServiceEvent event) {
- switch (event.getType()) {
- case ServiceEvent.REGISTERED :
- add(event.getServiceReference());
- break;
- case ServiceEvent.UNREGISTERING :
- remove(event.getServiceReference());
- break;
- }
- }
- }
-
- final BundleContext bundleContext;
-
- private ContextFunctionCache functionCache;
- /**
- * Map of String (service name) -> ServiceData
- */
- private Map<String, ServiceData> services = Collections.synchronizedMap(new HashMap<String, ServiceData>());
-
- public OSGiContextStrategy(BundleContext bc) {
- super();
- this.bundleContext = bc;
- functionCache = new ContextFunctionCache();
- }
-
- public Object addingService(ServiceReference reference) {
- String name = serviceName(reference);
- Object newValue = bundleContext.getService(reference);
- if (newValue == null)
- return null;
- // for performance we store the concrete service object with each context that requested it
- ServiceData data = getServiceData(name);
- // may have been cleaned up concurrently
- if (data == null)
- return null;
- for (IEclipseContext user : data.getUsingContexts())
- user.set(name, newValue);
- return newValue;
- }
-
- public boolean containsKey(String name, IEclipseContext context) {
- // first look for a registered IContextFunction matching the name
- if (getContextFunction(name) != null)
- return true;
- // next, look for a matching service
- return bundleContext.getServiceReference(name) != null;
- }
-
- public void dispose() {
- synchronized (services) {
- for (Iterator<ServiceData> it = services.values().iterator(); it.hasNext();)
- it.next().tracker.close();
- services.clear();
- }
- functionCache.dispose();
- }
-
- /**
- * Returns the service data corresponding to the given name, or <code>null</code> if no such
- * data is available.
- */
- private ServiceData getServiceData(String name) {
- ServiceData data = services.get(name);
- if (data == null)
- return null;
- if (data.users.isEmpty()) {
- data.tracker.close();
- services.remove(name);
- return null;
- }
- return data;
- }
-
- public Object lookup(String name, IEclipseContext originatingContext) {
- if (name == null)
- return null;
- ServiceData data = getServiceData(name);
- if (data == null) {
- // first look for a registered IContextFunction matching the name
- ServiceReference ref = getContextFunction(name);
- if (ref != null)
- return bundleContext.getService(ref);
- // services must be fully qualified type names
- if (name.indexOf('.') == -1)
- return null;
- // create a tracker to retrieve the service with the given name
- data = new ServiceData(name);
- try {
- data.tracker = new ServiceTracker(bundleContext, name, this);
- } catch (IllegalArgumentException iae) {
- // we get these when the variables requested are not valid names
- return null;
- }
- // add the context immediately so cleanReferences doesn't remove it
- data.addContext(originatingContext);
-
- // link to this context so we can cleanup when the context is disposed
- ((EclipseContext) originatingContext).notifyOnDisposal(this);
-
- services.put(name, data);
- // just opening a tracker will cause values to be set by the tracker
- // callback methods
- data.tracker.open();
- } else {
- data.addContext(originatingContext);
- }
- return data.tracker.getService();
- }
-
- /**
- * Returns an IContextFunction service that computes values for the given name, or
- * <code>null</code> if there is no matching service.
- */
- private ServiceReference getContextFunction(String name) {
- return functionCache.lookup(name);
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- String name = serviceName(reference);
- ServiceData data = getServiceData(name);
- // may have been cleaned up concurrently
- if (data == null)
- return;
- for (IEclipseContext user : data.getUsingContexts())
- user.set(name, service);
- }
-
- public void removedService(ServiceReference reference, Object service) {
- String name = serviceName(reference);
- // must set to null rather than removing so injection continues to work
- ServiceData data = getServiceData(name);
- // may have been cleaned up concurrently
- if (data != null) {
- for (IEclipseContext user : data.getUsingContexts())
- user.set(name, null);
- }
- bundleContext.ungetService(reference);
- }
-
- /**
- * Returns the service name for a service reference
- */
- private String serviceName(ServiceReference reference) {
- return ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0];
- }
-
- public void disposed(IEclipseContext context) {
- synchronized (services) {
- for (Iterator<ServiceData> it = services.values().iterator(); it.hasNext();) {
- ServiceData data = it.next();
- data.users.remove(context);
- // if there are no more references, discard the service
- if (data.users.isEmpty()) {
- it.remove();
- data.tracker.close();
- }
- }
- }
- }
-}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/CoreTestsActivator.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/CoreTestsActivator.java
index d68f482..b04d6cc 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/CoreTestsActivator.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/CoreTestsActivator.java
@@ -21,9 +21,9 @@ public class CoreTestsActivator implements BundleActivator {
static private CoreTestsActivator defaultInstance;
private BundleContext bundleContext;
- private ServiceTracker debugTracker = null;
- private ServiceTracker preferencesTracker = null;
- private ServiceTracker eventAdminTracker;
+ private ServiceTracker<DebugOptions, DebugOptions> debugTracker = null;
+ private ServiceTracker<IPreferencesService, IPreferencesService> preferencesTracker = null;
+ private ServiceTracker<EventAdmin, EventAdmin> eventAdminTracker;
public CoreTestsActivator() {
defaultInstance = this;
@@ -60,18 +60,18 @@ public class CoreTestsActivator implements BundleActivator {
if (preferencesTracker == null) {
if (bundleContext == null)
return null;
- preferencesTracker = new ServiceTracker(bundleContext, IPreferencesService.class.getName(), null);
+ preferencesTracker = new ServiceTracker<IPreferencesService, IPreferencesService>(bundleContext, IPreferencesService.class.getName(), null);
preferencesTracker.open();
}
- return (IPreferencesService) preferencesTracker.getService();
+ return preferencesTracker.getService();
}
public boolean getBooleanDebugOption(String option, boolean defaultValue) {
if (debugTracker == null) {
- debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null);
+ debugTracker = new ServiceTracker<DebugOptions, DebugOptions>(bundleContext, DebugOptions.class.getName(), null);
debugTracker.open();
}
- DebugOptions options = (DebugOptions) debugTracker.getService();
+ DebugOptions options = debugTracker.getService();
if (options != null) {
String value = options.getOption(option);
if (value != null)
@@ -83,10 +83,10 @@ public class CoreTestsActivator implements BundleActivator {
if (eventAdminTracker == null) {
if (bundleContext == null)
return null;
- eventAdminTracker = new ServiceTracker(bundleContext, EventAdmin.class.getName(), null);
+ eventAdminTracker = new ServiceTracker<EventAdmin, EventAdmin>(bundleContext, EventAdmin.class.getName(), null);
eventAdminTracker.open();
}
- return (EventAdmin) eventAdminTracker.getService();
+ return eventAdminTracker.getService();
}
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
index 1630774..948700e 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/AnnotationsInjectionTest.java
@@ -90,7 +90,6 @@ public class AnnotationsInjectionTest extends TestCase {
int setMethodCalled = 0;
public TestData value;
- @SuppressWarnings("unused")
@PostConstruct
public void init() {
postConstructCalled++;
@@ -337,7 +336,6 @@ public class AnnotationsInjectionTest extends TestCase {
@Inject
public TestData directFieldInjection;
- @SuppressWarnings("unused")
@PreDestroy
public void aboutToClose() {
preDestoryCalled++;
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug304585Test.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug304585Test.java
deleted file mode 100644
index d849a89..0000000
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/Bug304585Test.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.e4.core.internal.tests.contexts.inject;
-
-import javax.inject.Inject;
-
-import junit.framework.TestCase;
-
-import org.eclipse.e4.core.contexts.ContextInjectionFactory;
-import org.eclipse.e4.core.contexts.EclipseContextFactory;
-import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.e4.core.internal.contexts.EclipseContext;
-import org.eclipse.e4.core.internal.contexts.ILookupStrategy;
-
-/**
- * Tests that a strategy is not still accessed after its context is disposed.
- */
-public class Bug304585Test extends TestCase {
-
- public static class InjectFieldTarget {
- @Inject
- PrintService printer;
- }
-
- public static class InjectMethodTarget {
- @Inject
- public void setPrinter(PrintService printer) {
- //
- }
- }
-
-
- public void testFieldInjection() throws Exception {
- IEclipseContext parent = EclipseContextFactory.create("ParentContext");
- Strategy strategy = new Strategy();
- IEclipseContext child = new EclipseContext(parent, strategy);
-
- ContextInjectionFactory.make(InjectFieldTarget.class, child);
-
- child.dispose();
- parent.dispose();
- assertFalse("Strategy used after context disposed", strategy.lookupAfterDisposed);
- }
-
- public void testMethodInjection() throws Exception {
- IEclipseContext parent = EclipseContextFactory.create("ParentContext");
- Strategy strategy = new Strategy();
- IEclipseContext child = new EclipseContext(parent, strategy);
-
- ContextInjectionFactory.make(InjectMethodTarget.class, child);
-
- child.dispose();
- parent.dispose();
- assertFalse("Strategy used after context disposed", strategy.lookupAfterDisposed);
- }
-
- public static class Strategy implements ILookupStrategy {
- private boolean disposed = false;
- boolean lookupAfterDisposed = false;
- private PrintService printer = new StringPrintService();
-
- public void dispose() {
- disposed = true;
- }
-
- public Object lookup(String name, IEclipseContext context) {
- if (disposed)
- lookupAfterDisposed = true;
- if (name != null && name.equals(PrintService.SERVICE_NAME)) {
- return printer;
- }
- return null;
- }
-
- public boolean containsKey(String name, IEclipseContext context) {
- if (disposed)
- lookupAfterDisposed = true;
- return name != null && name.equals(PrintService.SERVICE_NAME);
- }
-
- }
-
-}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java
index bb75144..a4677ee 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ContextInjectionDisposeTest.java
@@ -48,7 +48,6 @@ public class ContextInjectionDisposeTest extends TestCase {
@Inject
private String Field;
- @SuppressWarnings("unused")
@PreDestroy
public void dispose() {
disposeInvoked = true;
@@ -70,7 +69,6 @@ public class ContextInjectionDisposeTest extends TestCase {
Object Field;
String methodValue;
- @SuppressWarnings("unused")
@PreDestroy
public void dispose() {
disposeInvoked = true;
@@ -108,7 +106,6 @@ public class ContextInjectionDisposeTest extends TestCase {
Integer Field;
Object methodValue;
- @SuppressWarnings("unused")
@PreDestroy
public void dispose() {
disposeInvoked = true;
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java
index 02ba0de..e3fdeea 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/ServiceContextTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@ import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.contexts.RunAndTrack;
+import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.internal.tests.CoreTestsActivator;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.osgi.framework.BundleContext;
@@ -35,12 +36,14 @@ public class ServiceContextTest extends TestCase {
class Crayon {
@Inject
IPaletteService palette;
+
+ String msg;
public void draw() {
if (palette == null)
- System.out.println("I'm out of ink!");
+ msg = "I'm out of ink!";
else
- System.out.println("My ink is " + palette.getColor());
+ msg = "My ink is " + palette.getColor();
}
}
@@ -65,19 +68,17 @@ public class ServiceContextTest extends TestCase {
}
static class Printer {
- @Inject
+ @Inject @Optional
PrintService printer;
public void print(String message) {
if (printer != null)
printer.print(message);
- else
- System.out.println(message);
}
}
private IEclipseContext context;
- private final List<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>();
+ private final List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
protected void setUp() throws Exception {
super.setUp();
@@ -89,8 +90,9 @@ public class ServiceContextTest extends TestCase {
protected void tearDown() throws Exception {
super.tearDown();
- context.dispose();
- for (ServiceRegistration reg : registrations) {
+ // Consumers must not dispose OSGi context as it is reused
+ //context.dispose();
+ for (ServiceRegistration<?> reg : registrations) {
try {
reg.unregister();
} catch (IllegalStateException e) {
@@ -123,35 +125,70 @@ public class ServiceContextTest extends TestCase {
}
public void testServiceInjection() {
- Printer userObject = new Printer();
-
- StringPrintService stringPrint1 = new StringPrintService();
- BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
- ServiceRegistration reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint1, null);
-
- ContextInjectionFactory.inject(userObject, context);
- userObject.print("test");
- assertEquals("1.0", "test", stringPrint1.toString());
+ ServiceRegistration<?> reg1 = null;
+ ServiceRegistration<?> reg2 = null;
+ try {
+ Printer userObject = new Printer();
+
+ StringPrintService stringPrint1 = new StringPrintService();
+ BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
+ reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint1, null);
+
+ ContextInjectionFactory.inject(userObject, context);
+ userObject.print("test");
+ assertEquals("1.0", "test", stringPrint1.toString());
+
+ // now remove the service
+ reg1.unregister();
+ reg1 = null;
+ userObject.print("another test");
+ // the string should be unchanged
+ assertEquals("1.1", "test", stringPrint1.toString());
+ assertNull("1.2", userObject.printer);
+
+ // register a different service implementation
+ StringPrintService stringPrint2 = new StringPrintService();
+ reg2 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint2, null);
+ userObject.print("yet another test");
+ // the second string should have the value
+ assertEquals("2.0", "test", stringPrint1.toString());
+ assertEquals("2.1", "yet another test", stringPrint2.toString());
+ reg2.unregister();
+ reg2 = null;
+ assertNull("2.2", userObject.printer);
+ } finally {
+ if (reg1 != null) {
+ reg1.unregister();
+ reg1 = null;
+ }
+ if (reg2 != null) {
+ reg2.unregister();
+ reg2 = null;
+ }
+ }
+ }
- // now remove the service
- reg1.unregister();
- userObject.print("another test");
- // the string should be unchanged
- assertEquals("1.1", "test", stringPrint1.toString());
- assertNull("1.2", userObject.printer);
-
- // register a different service implementation
- StringPrintService stringPrint2 = new StringPrintService();
- ServiceRegistration reg2 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint2, null);
- userObject.print("yet another test");
- // the second string should have the value
- assertEquals("2.0", "test", stringPrint1.toString());
- assertEquals("2.1", "yet another test", stringPrint2.toString());
- reg2.unregister();
- assertNull("2.2", userObject.printer);
+ public void testServiceAddition() {
+ ServiceRegistration<?> reg1 = null;
+ try {
+ Printer userObject = new Printer();
+ ContextInjectionFactory.inject(userObject, context);
+
+ StringPrintService stringPrint1 = new StringPrintService();
+ BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
+ reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint1, null);
+
+ userObject.print("test");
+ assertEquals("1.0", "test", stringPrint1.toString());
+ } finally {
+ if (reg1 != null) {
+ reg1.unregister();
+ reg1 = null;
+ }
+ }
}
- protected void ensureUnregistered(ServiceRegistration reg) {
+ protected void ensureUnregistered(ServiceRegistration<?> reg) {
registrations.add(reg);
}
@@ -161,9 +198,9 @@ public class ServiceContextTest extends TestCase {
public void testServiceRemovalOnContextDispose() {
StringPrintService stringPrint1 = new StringPrintService();
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
- ServiceRegistration reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint1, null);
+ ServiceRegistration<?> reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint1, null);
try {
- ServiceReference ref = reg1.getReference();
+ ServiceReference<?> ref = reg1.getReference();
PrintService service = (PrintService) context.get(PrintService.SERVICE_NAME);
assertEquals("1.0", stringPrint1, service);
@@ -178,7 +215,7 @@ public class ServiceContextTest extends TestCase {
public void testRecursiveServiceRemoval() {
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
- ServiceRegistration reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, new StringPrintService(), null);
+ ServiceRegistration<?> reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, new StringPrintService(), null);
final IEclipseContext child = context.createChild();
final IEclipseContext child2 = context.createChild();
child.get(PrintService.SERVICE_NAME);
@@ -199,7 +236,7 @@ public class ServiceContextTest extends TestCase {
public void testServiceExample() {
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
- ServiceRegistration reg = bundleContext.registerService(IPaletteService.class.getName(), new PaletteImpl(Color.BLUE), null);
+ ServiceRegistration<?> reg = bundleContext.registerService(IPaletteService.class.getName(), new PaletteImpl(Color.BLUE), null);
IEclipseContext context = EclipseContextFactory.getServiceContext(bundleContext);
Crayon crayon = new Crayon();
ContextInjectionFactory.inject(crayon, context);
@@ -208,39 +245,4 @@ public class ServiceContextTest extends TestCase {
crayon.draw();
}
- /**
- * Tests that OSGi services are released when the context that requested the service is removed.
- */
- public void testServiceRemovalOnChildContextDispose() {
- StringPrintService stringPrint1 = new StringPrintService();
- BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
- ServiceRegistration reg1 = bundleContext.registerService(PrintService.SERVICE_NAME, stringPrint1, null);
- ServiceReference ref = reg1.getReference();
- assertNull("0.1", ref.getUsingBundles());
- IEclipseContext child = context.createChild("child");
-
- PrintService service = (PrintService) child.get(PrintService.SERVICE_NAME);
- assertEquals("1.0", stringPrint1, service);
- assertEquals("1.1", 1, ref.getUsingBundles().length);
- assertTrue("1.2", context.containsKey(PrintService.SERVICE_NAME));
- // when the child that used the service is gc'ed the parent should no longer contain the
- // service
- service = null;
- child = null;
- System.gc();
- System.runFinalization();
- System.gc();
- //create and dispose another child that uses the service
- child = context.createChild("child-2");
- service = (PrintService) child.get(PrintService.SERVICE_NAME);
- service = null;
- child.dispose();
- child = null;
-
- //now there should be no service references, even though child1 was never disposed
- assertNull("2.2", ref.getUsingBundles());
-
- reg1.unregister();
-
- }
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java
index 8c9149c..e6d36ef 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionMixedSuppliersTest.java
@@ -60,7 +60,7 @@ public class InjectionMixedSuppliersTest extends TestCase {
private void setPreference(String key, String value) throws BackingStoreException {
String nodePath = CoreTestsActivator.getDefault().getBundleContext().getBundle().getSymbolicName();
- IEclipsePreferences node = new InstanceScope().getNode(nodePath);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(nodePath);
node.put(key, value);
node.flush();
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
index 2bf9ebc..18eee05 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/InjectionPreferencesTest.java
@@ -167,7 +167,7 @@ public class InjectionPreferencesTest extends TestCase {
public void testBaseTypeConversion() throws BackingStoreException {
// setup preferences
String nodePath = CoreTestsActivator.getDefault().getBundleContext().getBundle().getSymbolicName();
- IEclipsePreferences node = new InstanceScope().getNode(nodePath);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(nodePath);
node.putInt(KEY_INT, 12);
node.putBoolean(KEY_BOOL, true);
node.putDouble(KEY_DOUBLE, 12.35345345345d);
@@ -208,7 +208,7 @@ public class InjectionPreferencesTest extends TestCase {
public void testAutoConversion() throws BackingStoreException {
// setup preferences
String nodePath = CoreTestsActivator.getDefault().getBundleContext().getBundle().getSymbolicName();
- IEclipsePreferences node = new InstanceScope().getNode(nodePath);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(nodePath);
node.putInt(KEY_INT, 12);
node.putBoolean(KEY_BOOL, true);
node.putDouble(KEY_DOUBLE, 12.35345345345d);
@@ -244,13 +244,13 @@ public class InjectionPreferencesTest extends TestCase {
private void setPreference(String key, String value) throws BackingStoreException {
String nodePath = CoreTestsActivator.getDefault().getBundleContext().getBundle().getSymbolicName();
- IEclipsePreferences node = new InstanceScope().getNode(nodePath);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(nodePath);
node.put(key, value);
node.flush();
}
private void setPreference(String key, String nodePath, String value) throws BackingStoreException {
- IEclipsePreferences node = new InstanceScope().getNode(nodePath);
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode(nodePath);
node.put(key, value);
node.flush();
}
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ContextExample.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ContextExample.java
index 6da35cb..7f2a148 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ContextExample.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/ContextExample.java
@@ -106,7 +106,7 @@ public class ContextExample {
public void runWithService() {
BundleContext bundleContext = CoreTestsActivator.getDefault().getBundleContext();
- ServiceRegistration reg = bundleContext.registerService(IPaletteService.class
+ ServiceRegistration<?> reg = bundleContext.registerService(IPaletteService.class
.getName(), new PaletteImpl(Color.BLUE), null);
IEclipseContext context = EclipseContextFactory.getServiceContext(bundleContext);
Crayon crayon = new Crayon();
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java
index a99e9ea..6d3f3d3 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/tests/CoreTestSuite.java
@@ -22,7 +22,6 @@ import org.eclipse.e4.core.internal.tests.contexts.ReparentingTest;
import org.eclipse.e4.core.internal.tests.contexts.RunAndTrackTest;
import org.eclipse.e4.core.internal.tests.contexts.inject.ActivationInjectionTest;
import org.eclipse.e4.core.internal.tests.contexts.inject.AnnotationsInjectionTest;
-import org.eclipse.e4.core.internal.tests.contexts.inject.Bug304585Test;
import org.eclipse.e4.core.internal.tests.contexts.inject.Bug317183Test;
import org.eclipse.e4.core.internal.tests.contexts.inject.ComplexDisposalTest;
import org.eclipse.e4.core.internal.tests.contexts.inject.ContextFunctionDynamicsTest;
@@ -92,7 +91,6 @@ public class CoreTestSuite extends TestSuite {
addTestSuite(DisposingReferencedContextTest.class);
addTestSuite(InjectionOrderTest.class);
addTestSuite(GroupedUpdatesTest.class);
- addTestSuite(Bug304585Test.class);
addTestSuite(ExtraDependenciesTest.class);
addTestSuite(ContextFunctionDynamicsTest.class);
addTestSuite(InjectArraysTest.class);