532623 Treat application contexts in META-INF/spring/ like contexts in OSGI-INF/blueprint

Initial removal of Spring DM infrastructure - tests are still failing and their purpose has to be reverse-engineered.

Signed-off-by: ootto <olaf@x100.de>
diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractDelegatedExecutionApplicationContext.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractDelegatedExecutionApplicationContext.java
index 7a9e917..f3fbc68 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractDelegatedExecutionApplicationContext.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractDelegatedExecutionApplicationContext.java
@@ -219,10 +219,6 @@
 

 						public Object run() {

 							synchronized (startupShutdownMonitor) {

-

-								if (ObjectUtils.isEmpty(getConfigLocations())) {

-									setConfigLocations(getDefaultConfigLocations());

-								}

 								if (!OsgiBundleUtils.isBundleActive(getBundle())

 										&& !OsgiBundleUtils.isBundleLazyActivated(getBundle())) {

 									throw new ApplicationContextException(

diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java
index d3a567d..7276380 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/AbstractOsgiBundleApplicationContext.java
@@ -187,14 +187,12 @@
 	}

 

 	/**

-	 * Returns this application context configuration locations. The default implementation will check whether there are

-	 * any locations configured and, if not, will return the default locations.

-	 * 

+	 * Returns this application context configuration locations.

+	 *

 	 * @return application context configuration locations.

-	 * @see #getDefaultConfigLocations()

 	 */

 	public String[] getConfigLocations() {

-		return (this.configLocations != null ? this.configLocations : getDefaultConfigLocations());

+		return configLocations;

 	}

 

 	/**

@@ -219,17 +217,6 @@
 		}

 	}

 

-	/**

-	 * Returns the default configuration locations to use, for the case where no explicit configuration locations have

-	 * been specified. <p> Default implementation returns <code>null</code>, requiring explicit configuration locations.

-	 * 

-	 * @return application context default configuration locations

-	 * @see #setConfigLocations

-	 */

-	protected String[] getDefaultConfigLocations() {

-		return null;

-	}

-

 	protected void prepareRefresh() {

 		super.prepareRefresh();

 		// unpublish the service (if there is any) during the refresh

diff --git a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java
index 25b961d..3f4d804 100644
--- a/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java
+++ b/core/src/main/java/org/eclipse/gemini/blueprint/context/support/OsgiBundleXmlApplicationContext.java
@@ -15,10 +15,6 @@
 
 package org.eclipse.gemini.blueprint.context.support;
 
-import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
 import org.eclipse.gemini.blueprint.io.OsgiBundleResource;
 import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
 import org.eclipse.gemini.blueprint.util.internal.BundleUtils;
@@ -34,11 +30,14 @@
 import org.springframework.util.Assert;
 import org.xml.sax.EntityResolver;
 
+import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 /**
  * Stand-alone XML application context, backed by an OSGi bundle.
  * 
- * <p> The configuration location defaults can be overridden via {@link #getDefaultConfigLocations()}. Note that
- * locations can either denote concrete files like <code>/myfiles/context.xml</code> or <em>Ant-style</em> patterns like
+ * <p>Note that locations can either denote concrete files like <code>/myfiles/context.xml</code> or <em>Ant-style</em> patterns like
  * <code>/myfiles/*-context.xml</code> (see the {@link org.springframework.util.AntPathMatcher} javadoc for pattern
  * details). </p>
  * 
@@ -195,20 +194,6 @@
 	}
 
 	/**
-	 * Provide default locations for XML files. This implementation returns <code>META-INF/spring/*.xml</code> relying
-	 * on the default resource environment for actual localisation. By default, the bundle space will be used for
-	 * locating the resources.
-	 * 
-	 * <p/> <strong>Note:</strong> Instead of overriding this method, consider using the Spring-DM specific header
-	 * inside your manifest bundle.
-	 * 
-	 * @return default XML configuration locations
-	 */
-	protected String[] getDefaultConfigLocations() {
-		return new String[] { DEFAULT_CONFIG_LOCATION };
-	}
-
-	/**
 	 * Creates a special OSGi namespace handler resolver that first searches the bundle class path falling back to the
 	 * namespace service published by Spring-DM. This allows embedded libraries that provide namespace handlers take
 	 * priority over namespace provided by other bundles.
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/AbstractOsgiCollectionTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/AbstractOsgiCollectionTest.java
index 2f2c9e9..aa89099 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/AbstractOsgiCollectionTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/AbstractOsgiCollectionTest.java
@@ -134,7 +134,7 @@
 			clazzez[i++] = ((Class) iter.next()).getName();

 		}

 

-		ref = new MockServiceReference(null, properties, null, clazzez);

+		ref = new MockServiceReference(null, properties, clazzez);

 

 		event = new ServiceEvent(ServiceEvent.REGISTERED, ref);

 

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/ServiceReferenceComparatorTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/ServiceReferenceComparatorTest.java
index 9c100cb..837564d 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/ServiceReferenceComparatorTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/collection/ServiceReferenceComparatorTest.java
@@ -94,6 +94,6 @@
 		if (ranking != null)

 			dict.put(Constants.SERVICE_RANKING, ranking);

 

-		return new MockServiceReference(null, dict, null);

+		return new MockServiceReference(null, dict);

 	}

 }

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/interceptor/OsgiServiceDynamicInterceptorListenerTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/interceptor/OsgiServiceDynamicInterceptorListenerTest.java
index 52cb2fd..587801a 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/interceptor/OsgiServiceDynamicInterceptorListenerTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/internal/service/interceptor/OsgiServiceDynamicInterceptorListenerTest.java
@@ -115,7 +115,7 @@
 		// increase service ranking

 		props.put(Constants.SERVICE_RANKING, 10);

 

-		ServiceReference ref = new MockServiceReference(null, props, null);

+		ServiceReference ref = new MockServiceReference(null, props);

 

 		ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);

 

@@ -154,7 +154,7 @@
 		// increase service ranking

 		props.put(Constants.SERVICE_RANKING, 10);

 

-		ServiceReference ref = new MockServiceReference(null, props, null);

+		ServiceReference ref = new MockServiceReference(null, props);

 		ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, ref);

 

 		assertEquals(1, SimpleTargetSourceLifecycleListener.BIND);

@@ -176,7 +176,7 @@
 		// increase service ranking

 		props.put(Constants.SERVICE_RANKING, 10);

 

-		ServiceReference higherRankingRef = new MockServiceReference(null, props, null);

+		ServiceReference higherRankingRef = new MockServiceReference(null, props);

 		refs = new ServiceReference[] { new MockServiceReference(), higherRankingRef };

 

 		assertTrue(Arrays.equals(bundleContext.getServiceReferences((String)null, null), refs));

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java
index f38615f..1deadf3 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java
@@ -56,19 +56,19 @@
 		// lowest service reference

 		Dictionary dict1 = new Hashtable();

 		dict1.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);

-		ref1 = new MockServiceReference(null, dict1, null);

+		ref1 = new MockServiceReference(null, dict1);

 

 		// neutral service reference

 		Dictionary dict2 = new Hashtable();

 		dict2.put(Constants.SERVICE_ID, (long) 20);

 

-		ref2 = new MockServiceReference(null, dict2, null);

+		ref2 = new MockServiceReference(null, dict2);

 

 		// neutral service reference

 		Dictionary dict3 = new Hashtable();

 		dict3.put(Constants.SERVICE_ID, (long) 30);

 

-		ref3 = new MockServiceReference(null, dict3, null);

+		ref3 = new MockServiceReference(null, dict3);

 

 		ctrl = createStrictControl();

 		context = ctrl.createMock(BundleContext.class);

@@ -148,7 +148,7 @@
 		long id = 12345;

 		Dictionary dict = new Hashtable();

 		dict.put(Constants.SERVICE_ID, id);

-		ServiceReference ref = new MockServiceReference(null, dict, null);

+		ServiceReference ref = new MockServiceReference(null, dict);

 		assertEquals(id, OsgiServiceReferenceUtils.getServiceId(ref));

 	}

 

@@ -160,7 +160,7 @@
 		int ranking = 12345;

 		Dictionary dict = new Hashtable();

 		dict.put(Constants.SERVICE_RANKING, ranking);

-		ServiceReference ref = new MockServiceReference(null, dict, null);

+		ServiceReference ref = new MockServiceReference(null, dict);

 		assertEquals(ranking, OsgiServiceReferenceUtils.getServiceRanking(ref));

 	}

 

@@ -168,7 +168,7 @@
 		int ranking = 12345;

 		Dictionary dict = new Hashtable();

 		dict.put(Constants.SERVICE_RANKING, (long) ranking);

-		ServiceReference ref = new MockServiceReference(null, dict, null);

+		ServiceReference ref = new MockServiceReference(null, dict);

 		assertEquals(0, OsgiServiceReferenceUtils.getServiceRanking(ref));

 	}

 

@@ -182,7 +182,7 @@
 			}

 		};

 

-		ServiceReference ref = new MockServiceReference(null, dict, null);

+		ServiceReference ref = new MockServiceReference(null, dict);

 

 		assertNull(ref.getProperty(Constants.SERVICE_RANKING));

 		assertEquals(0, OsgiServiceReferenceUtils.getServiceRanking(ref));

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/util/OsgiStringUtilsTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/util/OsgiStringUtilsTest.java
index d08de6a..f0cbb88 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/util/OsgiStringUtilsTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/util/OsgiStringUtilsTest.java
@@ -18,7 +18,6 @@
 

 import junit.framework.TestCase;

 

-import org.eclipse.gemini.blueprint.util.OsgiStringUtils;

 import org.osgi.framework.Bundle;

 import org.osgi.framework.BundleEvent;

 import org.osgi.framework.FrameworkEvent;

@@ -134,7 +133,7 @@
 		String header = "HEADER";

 		String value = "VALUE";

 		props.put(header, value);

-		MockServiceReference ref = new MockServiceReference(bundle, props, null);

+		MockServiceReference ref = new MockServiceReference(bundle, props);

 		String out = OsgiStringUtils.nullSafeToString(ref);

 		assertTrue(out.indexOf(symName) > -1);

 		assertTrue(out.indexOf(header) > -1);

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMapTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMapTest.java
index a0f89ca..20c2b8d 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMapTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/util/internal/ServiceReferenceBasedMapTest.java
@@ -58,7 +58,7 @@
 	public void testContainsKeyObject() {

 		Properties prop = new Properties();

 		prop.setProperty("joe", "satriani");

-		reference = new MockServiceReference(new MockBundle(), prop, null);

+		reference = new MockServiceReference(new MockBundle(), prop);

 		createMap();

 		assertTrue(map.containsKey("joe"));

 	}

@@ -66,7 +66,7 @@
 	public void testContainsValueObject() {

 		Properties prop = new Properties();

 		prop.setProperty("joe", "satriani");

-		reference = new MockServiceReference(new MockBundle(), prop, null);

+		reference = new MockServiceReference(new MockBundle(), prop);

 		createMap();

 		assertTrue(map.containsValue("satriani"));

 	}

@@ -74,7 +74,7 @@
 	public void testEntrySet() {

 		Properties prop = new Properties();

 		prop.setProperty("joe", "satriani");

-		reference = new MockServiceReference(new MockBundle(), prop, null);

+		reference = new MockServiceReference(new MockBundle(), prop);

 		createMap();

 		Set entries = map.entrySet();

 		assertNotNull(entries);

@@ -89,7 +89,7 @@
 	public void testGetObject() {

 		Properties prop = new Properties();

 		prop.setProperty("joe", "satriani");

-		reference = new MockServiceReference(new MockBundle(), prop, null);

+		reference = new MockServiceReference(new MockBundle(), prop);

 		createMap();

 		assertEquals("satriani", map.get("joe"));

 	}

diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/OsgiBeanFactoryPostProcessor.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/OsgiBeanFactoryPostProcessor.java
index 9f0549d..d151259 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/OsgiBeanFactoryPostProcessor.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/OsgiBeanFactoryPostProcessor.java
@@ -1,16 +1,16 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

+/*

+ Copyright (c) 2006, 2010 VMware Inc.

+ All rights reserved. This program and the accompanying materials

+ are made available under the terms of the Eclipse Public License v1.0

+ and Apache License v2.0 which accompanies this distribution.

+ The Eclipse Public License is available at

+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

+ is available at http://www.opensource.org/licenses/apache2.0.php.

+ You may elect to redistribute this code under either of these licenses.

+

+ Contributors:

+ VMware Inc.

+ */

 

 package org.eclipse.gemini.blueprint.extender;

 

diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ContextLoaderListener.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ContextLoaderListener.java
index dec1c49..9cc1103 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ContextLoaderListener.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ContextLoaderListener.java
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
  * is available at http://www.opensource.org/licenses/apache2.0.php.
  * You may elect to redistribute this code under either of these licenses. 
- * 
+ *
  * Contributors:
  *   VMware Inc.
  *   Oracle Inc.
@@ -20,27 +20,30 @@
 import org.eclipse.gemini.blueprint.extender.OsgiApplicationContextCreator;
 import org.eclipse.gemini.blueprint.extender.internal.activator.listeners.BaseListener;
 import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration;
-import org.eclipse.gemini.blueprint.extender.support.DefaultOsgiApplicationContextCreator;
 import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;
 import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
 import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
-import org.osgi.framework.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Version;
 
 /**
  * Osgi Extender that bootstraps 'Spring powered bundles'.
- * 
+ * <p>
  * <p/> The class listens to bundle events and manages the creation and destruction of application contexts for bundles
  * that have one or both of: <ul> <li>A manifest header entry Spring-Context <li>XML files in META-INF/spring folder
  * </ul>
- * 
+ * <p>
  * <p/> The extender also discovers any Spring namespace/schema handlers in resolved bundles and makes them available
  * through a dedicated OSGi service.
- * 
+ * <p>
  * <p/> The extender behaviour can be customized by attaching fragments to the extender bundle. On startup, the extender
  * will look for <code>META-INF/spring/*.xml</code> files and merge them into an application context. From the resulting
  * context, the context will look for beans with predefined names to determine its configuration. The current version
  * recognises the following bean names:
- * 
+ * <p>
  * <table border="1"> <tr> <th>Bean Name</th> <th>Bean Type</th> <th>Description</th> </tr> <tr>
  * <td><code>taskExecutor</code></td> <td><code>org.springframework.core.task.TaskExecutor</code></td> <td>Task executor
  * used for creating the discovered application contexts.</td> </tr> <tr> <td><code>shutdownTaskExecutor</code></td>
@@ -48,9 +51,9 @@
  * application contexts.</td> </tr> <tr> <td><code>extenderProperties</code></td>
  * <td><code>java.util.Properties</code></td> <td>Various properties for configuring the extender behaviour (see
  * below)</td> </tr> </table>
- * 
+ * <p>
  * <p/> <code>extenderProperties</code> recognises the following properties:
- * 
+ * <p>
  * <table border="1"> <tr> <th>Name</th> <th>Type</th> <th>Description</th> </tr> <tr>
  * <td><code>shutdown.wait.time</code></td> <td>Number</td> <td>The amount of time the extender will wait for each
  * application context to shutdown gracefully. Expressed in milliseconds.</td> </tr> <tr>
@@ -58,185 +61,186 @@
  * </td> </tr> </table>
  * <p/> Note: The extender configuration context is created during the bundle activation (a synchronous OSGi lifecycle
  * callback) and should contain only simple bean definitions that will not delay context initialisation. </p>
- * 
+ *
  * @author Bill Gallagher
  * @author Andy Piper
  * @author Hal Hildebrand
  * @author Adrian Colyer
  * @author Costin Leau
  */
-public class ContextLoaderListener implements BundleActivator {
+public abstract class ContextLoaderListener implements BundleActivator {
 
     /**
-	 * Bundle listener used for context creation/destruction.
-	 */
-	private class ContextBundleListener extends BaseListener {
+     * Bundle listener used for context creation/destruction.
+     */
+    private class ContextBundleListener extends BaseListener {
 
-		protected void handleEvent(BundleEvent event) {
+        protected void handleEvent(BundleEvent event) {
 
-			Bundle bundle = event.getBundle();
+            Bundle bundle = event.getBundle();
 
-			// ignore current bundle for context creation
-			if (bundle.getBundleId() == bundleId) {
-				return;
-			}
+            // ignore current bundle for context creation
+            if (bundle.getBundleId() == bundleId) {
+                return;
+            }
 
-			switch (event.getType()) {
-			case BundleEvent.STARTED: {
-				lifecycleManager.maybeCreateApplicationContextFor(bundle);
-				break;
-			}
-			case BundleEvent.STOPPING: {
-				if (OsgiBundleUtils.isSystemBundle(bundle)) {
-					if (log.isDebugEnabled()) {
-						log.debug("System bundle stopping");
-					}
-					// System bundle is shutting down; Special handling for
-					// framework shutdown
-					shutdown();
-				} else {
-					lifecycleManager.maybeCloseApplicationContextFor(bundle);
-				}
-				break;
-			}
-			default:
-				break;
-			}
-		}
-	}
+            switch (event.getType()) {
+                case BundleEvent.STARTED: {
+                    lifecycleManager.maybeCreateApplicationContextFor(bundle);
+                    break;
+                }
+                case BundleEvent.STOPPING: {
+                    if (OsgiBundleUtils.isSystemBundle(bundle)) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("System bundle stopping");
+                        }
+                        // System bundle is shutting down; Special handling for
+                        // framework shutdown
+                        shutdown();
+                    } else {
+                        lifecycleManager.maybeCloseApplicationContextFor(bundle);
+                    }
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+    }
 
-	protected final Log log = LogFactory.getLog(getClass());
+    protected final Log log = LogFactory.getLog(getClass());
 
     private ExtenderConfiguration extenderConfiguration;
     private VersionMatcher versionMatcher;
-    private Version extenderVersion;
 
-    /** extender bundle id */
-	private long bundleId;
+    /**
+     * extender bundle id
+     */
+    private long bundleId;
 
-	/** The bundle's context */
-	private BundleContext bundleContext;
+    /**
+     * The bundle's context
+     */
+    private BundleContext bundleContext;
 
-	/** Bundle listener interested in context creation */
-	private BaseListener contextListener;
+    /**
+     * Bundle listener interested in context creation
+     */
+    private BaseListener contextListener;
 
-	/**
-	 * Monitor used for dealing with the bundle activator and synchronous bundle threads
-	 */
-	private final Object monitor = new Object();
+    /**
+     * Monitor used for dealing with the bundle activator and synchronous bundle threads
+     */
+    private final Object monitor = new Object();
 
-	/**
-	 * flag indicating whether the context is down or not - useful during shutdown
-	 */
-	private volatile boolean isClosed = false;
+    /**
+     * flag indicating whether the context is down or not - useful during shutdown
+     */
+    private volatile boolean isClosed = false;
 
-	private volatile LifecycleManager lifecycleManager;
-	private volatile OsgiContextProcessor processor;
+    private volatile LifecycleManager lifecycleManager;
 
     public ContextLoaderListener(ExtenderConfiguration extenderConfiguration) {
         this.extenderConfiguration = extenderConfiguration;
     }
 
     /**
-	 * <p/> Called by OSGi when this bundle is started. Finds all previously resolved bundles and adds namespace
-	 * handlers for them if necessary. </p> <p/> Creates application contexts for bundles started before the extender
-	 * was started. </p> <p/> Registers a namespace/entity resolving service for use by web app contexts. </p>
-	 * 
-	 * @see org.osgi.framework.BundleActivator#start
-	 */
-	public void start(BundleContext extenderBundleContext) throws Exception {
+     * <p/> Called by OSGi when this bundle is started. Finds all previously resolved bundles and adds namespace
+     * handlers for them if necessary. </p> <p/> Creates application contexts for bundles started before the extender
+     * was started. </p> <p/> Registers a namespace/entity resolving service for use by web app contexts. </p>
+     *
+     * @see org.osgi.framework.BundleActivator#start
+     */
+    public void start(BundleContext extenderBundleContext) throws Exception {
 
-		this.bundleContext = extenderBundleContext;
-		this.bundleId = extenderBundleContext.getBundle().getBundleId();
-        this.extenderVersion = OsgiBundleUtils.getBundleVersion(extenderBundleContext.getBundle());
-        this.versionMatcher = new DefaultVersionMatcher(getManagedBundleExtenderVersionHeader(), extenderVersion);
-        this.processor = createContextProcessor();
+        this.bundleContext = extenderBundleContext;
+        this.bundleId = extenderBundleContext.getBundle().getBundleId();
+        Version extenderVersion = OsgiBundleUtils.getBundleVersion(extenderBundleContext.getBundle());
+        this.versionMatcher = new VersionMatcher(getManagedBundleExtenderVersionHeader(), extenderVersion);
 
-		// initialize the configuration once namespace handlers have been detected
-		this.lifecycleManager =
-				new LifecycleManager(
+        // initialize the configuration once namespace handlers have been detected
+        this.lifecycleManager =
+                new LifecycleManager(
                         this.extenderConfiguration,
                         getVersionMatcher(),
                         createContextConfigFactory(),
                         getOsgiApplicationContextCreator(),
-						this.processor,
+                        createContextProcessor(),
                         getTypeCompatibilityChecker(),
                         bundleContext);
 
-		// Step 3: discover the bundles that are started
-		// and require context creation
-		initStartedBundles(bundleContext);
-	}
+        // Step 3: discover the bundles that are started
+        // and require context creation
+        initStartedBundles(bundleContext);
+    }
 
-	protected OsgiContextProcessor createContextProcessor() {
-		return new NoOpOsgiContextProcessor();
-	}
+    protected OsgiContextProcessor createContextProcessor() {
+        return new NoOpOsgiContextProcessor();
+    }
 
-	protected TypeCompatibilityChecker getTypeCompatibilityChecker() {
-		return null;
-	}
+    protected TypeCompatibilityChecker getTypeCompatibilityChecker() {
+        return null;
+    }
 
-	protected void initStartedBundles(BundleContext bundleContext) {
-		// register the context creation listener
-		contextListener = new ContextBundleListener();
-		// listen to any changes in bundles
-		bundleContext.addBundleListener(contextListener);
-		// get the bundles again to get an updated view
-		Bundle[] previousBundles = bundleContext.getBundles();
+    protected void initStartedBundles(BundleContext bundleContext) {
+        // register the context creation listener
+        contextListener = new ContextBundleListener();
+        // listen to any changes in bundles
+        bundleContext.addBundleListener(contextListener);
+        // get the bundles again to get an updated view
+        Bundle[] previousBundles = bundleContext.getBundles();
 
-		// Instantiate all previously resolved bundles which are Spring
-		// powered
-		for (int i = 0; i < previousBundles.length; i++) {
-			if (OsgiBundleUtils.isBundleActive(previousBundles[i])) {
-				try {
-					lifecycleManager.maybeCreateApplicationContextFor(previousBundles[i]);
-				} catch (Throwable e) {
-					log.warn("Cannot start bundle " + OsgiStringUtils.nullSafeSymbolicName(previousBundles[i])
-							+ " due to", e);
-				}
-			}
-		}
-	}
+        // Instantiate all previously resolved bundles which are Spring
+        // powered
+        for (Bundle previousBundle : previousBundles) {
+            if (OsgiBundleUtils.isBundleActive(previousBundle)) {
+                try {
+                    lifecycleManager.maybeCreateApplicationContextFor(previousBundle);
+                } catch (Throwable e) {
+                    log.warn("Cannot start bundle " + OsgiStringUtils.nullSafeSymbolicName(previousBundle)
+                            + " due to", e);
+                }
+            }
+        }
+    }
 
-	/**
-	 * Called by OSGi when this bundled is stopped. Unregister the namespace/entity resolving service and clear all
-	 * state. No further management of application contexts created by this extender prior to stopping the bundle occurs
-	 * after this point (even if the extender bundle is subsequently restarted).
-	 * 
-	 * @see org.osgi.framework.BundleActivator#stop
-	 */
-	public void stop(BundleContext context) throws Exception {
-		shutdown();
-	}
+    /**
+     * Called by OSGi when this bundled is stopped. Unregister the namespace/entity resolving service and clear all
+     * state. No further management of application contexts created by this extender prior to stopping the bundle occurs
+     * after this point (even if the extender bundle is subsequently restarted).
+     *
+     * @see org.osgi.framework.BundleActivator#stop
+     */
+    public void stop(BundleContext context) throws Exception {
+        shutdown();
+    }
 
-	/**
-	 * Shutdown the extender and all bundled managed by it. Shutdown of contexts is in the topological order of the
-	 * dependency graph formed by the service references.
-	 */
-	protected void shutdown() {
-		synchronized (monitor) {
-			// if already closed, bail out
-			if (isClosed)
-				return;
-			else
-				isClosed = true;
-		}
+    /**
+     * Shutdown the extender and all bundled managed by it. Shutdown of contexts is in the topological order of the
+     * dependency graph formed by the service references.
+     */
+    protected void shutdown() {
+        synchronized (monitor) {
+            // if already closed, bail out
+            if (isClosed)
+                return;
+            else
+                isClosed = true;
+        }
 
         this.contextListener.close();
 
-		// remove the bundle listeners (we are closing down)
-		if (contextListener != null) {
-			bundleContext.removeBundleListener(contextListener);
-			contextListener = null;
-		}
+        // remove the bundle listeners (we are closing down)
+        if (contextListener != null) {
+            bundleContext.removeBundleListener(contextListener);
+            contextListener = null;
+        }
 
-		// close managed bundles
-		lifecycleManager.destroy();
-	}
+        // close managed bundles
+        lifecycleManager.destroy();
+    }
 
-	protected ApplicationContextConfigurationFactory createContextConfigFactory() {
-		return new DefaultApplicationContextConfigurationFactory();
-	}
+    protected abstract ApplicationContextConfigurationFactory createContextConfigFactory();
 
     public VersionMatcher getVersionMatcher() {
         return versionMatcher;
@@ -246,15 +250,5 @@
         return ConfigUtils.EXTENDER_VERSION;
     }
 
-    protected OsgiApplicationContextCreator getOsgiApplicationContextCreator() {
-        OsgiApplicationContextCreator creator = this.extenderConfiguration.getContextCreator();
-        if (creator == null) {
-            creator = createDefaultOsgiApplicationContextCreator();
-        }
-        return creator;
-    }
-
-    protected OsgiApplicationContextCreator createDefaultOsgiApplicationContextCreator() {
-        return new DefaultOsgiApplicationContextCreator();
-    }
+    protected abstract OsgiApplicationContextCreator getOsgiApplicationContextCreator();
 }
\ No newline at end of file
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/DefaultApplicationContextConfigurationFactory.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/DefaultApplicationContextConfigurationFactory.java
deleted file mode 100644
index 6bf9ba7..0000000
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/DefaultApplicationContextConfigurationFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

-package org.eclipse.gemini.blueprint.extender.internal.activator;

-

-import org.eclipse.gemini.blueprint.extender.support.ApplicationContextConfiguration;

-import org.osgi.framework.Bundle;

-

-/**

- * @author Costin Leau

- */

-public class DefaultApplicationContextConfigurationFactory implements ApplicationContextConfigurationFactory {

-

-	public ApplicationContextConfiguration createConfiguration(Bundle bundle) {

-		return new ApplicationContextConfiguration(bundle);

-	}

-}

diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/DefaultVersionMatcher.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/DefaultVersionMatcher.java
deleted file mode 100644
index 51ba9a0..0000000
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/DefaultVersionMatcher.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

-package org.eclipse.gemini.blueprint.extender.internal.activator;

-

-import org.apache.commons.logging.Log;

-import org.apache.commons.logging.LogFactory;

-import org.osgi.framework.Bundle;

-import org.osgi.framework.Version;

-import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;

-import org.eclipse.gemini.blueprint.util.OsgiStringUtils;

-

-/**

- * @author Costin Leau

- */

-public class DefaultVersionMatcher implements VersionMatcher {

-

-	/** logger */

-	private static final Log log = LogFactory.getLog(LifecycleManager.class);

-

-	private final String versionHeader;

-	private final Version expectedVersion;

-

-

-	public DefaultVersionMatcher(String versionHeader, Version expectedVersion) {

-		this.versionHeader = versionHeader;

-		this.expectedVersion = expectedVersion;

-	}

-

-	public boolean matchVersion(Bundle bundle) {

-

-		if (!ConfigUtils.matchExtenderVersionRange(bundle, versionHeader, expectedVersion)) {

-			if (log.isDebugEnabled())

-				log.debug("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle)

-						+ "] expects an extender w/ version[" + bundle.getHeaders().get(versionHeader)

-						+ "] which does not match current extender w/ version[" + expectedVersion

-						+ "]; skipping bundle analysis...");

-			return false;

-		}

-

-		return true;

-	}

-}

diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java
index 406c298..f3601e9 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/LifecycleManager.java
@@ -26,7 +26,6 @@
 import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration;
 import org.eclipse.gemini.blueprint.extender.internal.support.OsgiBeanFactoryPostProcessorAdapter;
 import org.eclipse.gemini.blueprint.extender.internal.util.concurrent.Counter;
-import org.eclipse.gemini.blueprint.extender.internal.util.concurrent.RunnableTimedExecution;
 import org.eclipse.gemini.blueprint.extender.support.ApplicationContextConfiguration;
 import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
 import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
@@ -48,7 +47,7 @@
  * 
  * @author Costin Leau
  */
-class LifecycleManager implements DisposableBean {
+public class LifecycleManager implements DisposableBean {
 
 	/** logger */
 	private static final Log log = LogFactory.getLog(LifecycleManager.class);
@@ -97,8 +96,8 @@
 	private final TypeCompatibilityChecker typeChecker;
 
 	LifecycleManager(ExtenderConfiguration extenderConfiguration, VersionMatcher versionMatcher,
-                     ApplicationContextConfigurationFactory appCtxCfgFactory, OsgiApplicationContextCreator osgiApplicationContextCreator, OsgiContextProcessor processor,
-                     TypeCompatibilityChecker checker, BundleContext context) {
+					 ApplicationContextConfigurationFactory appCtxCfgFactory, OsgiApplicationContextCreator osgiApplicationContextCreator, OsgiContextProcessor processor,
+					 TypeCompatibilityChecker checker, BundleContext context) {
 
 		this.versionMatcher = versionMatcher;
 		this.extenderConfiguration = extenderConfiguration;
@@ -130,12 +129,12 @@
 	 * 
 	 * @param bundle
 	 */
-	protected void maybeCreateApplicationContextFor(Bundle bundle) {
+	public void maybeCreateApplicationContextFor(Bundle bundle) {
 
 		boolean debug = log.isDebugEnabled();
 		String bundleString = "[" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]";
 
-		final Long bundleId = new Long(bundle.getBundleId());
+		final Long bundleId = bundle.getBundleId();
 
 		if (managedContexts.containsKey(bundleId)) {
 			if (debug) {
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListenerServiceActivator.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListenerServiceActivator.java
index 1713da4..7df9a7b 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListenerServiceActivator.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListenerServiceActivator.java
@@ -47,12 +47,12 @@
         this.extenderConfiguration = extenderConfiguration;
     }
 
-    public void start(BundleContext extenderBundleContext) throws Exception {
+    public void start(BundleContext extenderBundleContext) {
         this.extenderBundleContext = extenderBundleContext;
         initListenerService();
     }
 
-    public void stop(BundleContext extenderBundleContext) throws Exception {
+    public void stop(BundleContext extenderBundleContext) {
         synchronized (monitor) {
             if (stopped) {
                 return;
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/NamespaceHandlerActivator.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/NamespaceHandlerActivator.java
index a53e439..ca82ace 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/NamespaceHandlerActivator.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/NamespaceHandlerActivator.java
@@ -46,14 +46,14 @@
     private BaseListener nsListener;
     private long bundleId;
     private BundleContext extenderBundleContext;
-    private DefaultVersionMatcher versionMatcher;
+    private VersionMatcher versionMatcher;
 
     public void start(BundleContext extenderBundleContext) {
         this.extenderBundleContext = extenderBundleContext;
         this.nsManager = new NamespaceManager(extenderBundleContext);
         this.bundleId = extenderBundleContext.getBundle().getBundleId();
         Version extenderVersion = OsgiBundleUtils.getBundleVersion(extenderBundleContext.getBundle());
-        this.versionMatcher = new DefaultVersionMatcher(getManagedBundleExtenderVersionHeader(), extenderVersion);
+        this.versionMatcher = new VersionMatcher(getManagedBundleExtenderVersionHeader(), extenderVersion);
 
         initNamespaceHandlers(extenderBundleContext);
     }
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/VersionMatcher.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/VersionMatcher.java
index 58de533..1761651 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/VersionMatcher.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/activator/VersionMatcher.java
@@ -14,12 +14,41 @@
 

 package org.eclipse.gemini.blueprint.extender.internal.activator;

 

+import org.apache.commons.logging.Log;

+import org.apache.commons.logging.LogFactory;

 import org.osgi.framework.Bundle;

+import org.osgi.framework.Version;

+import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;

+import org.eclipse.gemini.blueprint.util.OsgiStringUtils;

 

 /**

  * @author Costin Leau

  */

-interface VersionMatcher {

+public class VersionMatcher {

 

-	boolean matchVersion(Bundle bundle);

+	/** logger */

+	private static final Log log = LogFactory.getLog(LifecycleManager.class);

+

+	private final String versionHeader;

+	private final Version expectedVersion;

+

+

+	public VersionMatcher(String versionHeader, Version expectedVersion) {

+		this.versionHeader = versionHeader;

+		this.expectedVersion = expectedVersion;

+	}

+

+	public boolean matchVersion(Bundle bundle) {

+

+		if (!ConfigUtils.matchExtenderVersionRange(bundle, versionHeader, expectedVersion)) {

+			if (log.isDebugEnabled())

+				log.debug("Bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle)

+						+ "] expects an extender w/ version[" + bundle.getHeaders().get(versionHeader)

+						+ "] which does not match current extender w/ version[" + expectedVersion

+						+ "]; skipping bundle analysis...");

+			return false;

+		}

+

+		return true;

+	}

 }

diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/BlueprintLoaderListener.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/BlueprintLoaderListener.java
index 1e92751..1836f95 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/BlueprintLoaderListener.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/BlueprintLoaderListener.java
@@ -15,13 +15,16 @@
 package org.eclipse.gemini.blueprint.extender.internal.blueprint.activator;
 
 import org.eclipse.gemini.blueprint.extender.OsgiApplicationContextCreator;
-import org.eclipse.gemini.blueprint.extender.internal.activator.*;
+import org.eclipse.gemini.blueprint.extender.internal.activator.ApplicationContextConfigurationFactory;
+import org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener;
+import org.eclipse.gemini.blueprint.extender.internal.activator.ListenerServiceActivator;
+import org.eclipse.gemini.blueprint.extender.internal.activator.OsgiContextProcessor;
+import org.eclipse.gemini.blueprint.extender.internal.activator.TypeCompatibilityChecker;
 import org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.support.BlueprintConfigUtils;
 import org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.support.BlueprintContainerConfig;
 import org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.support.BlueprintContainerCreator;
 import org.eclipse.gemini.blueprint.extender.internal.blueprint.event.EventAdminDispatcher;
 import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration;
-import org.eclipse.gemini.blueprint.extender.support.ApplicationContextConfiguration;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
@@ -60,22 +63,17 @@
 
 	@Override
 	protected ApplicationContextConfigurationFactory createContextConfigFactory() {
-		return new ApplicationContextConfigurationFactory() {
-
-			public ApplicationContextConfiguration createConfiguration(Bundle bundle) {
-				return new BlueprintContainerConfig(bundle);
-			}
-		};
+		return BlueprintContainerConfig::new;
 	}
 
     /**
-     * Always use the {@link BlueprintContainerCreator}, never the configured creator.
-     * Rationale: Backwards compatibility. Both DM and Blueprint extenders are available simultaneously,
-     * however Blueprint extender support is new and must not be broken by existing configurations. Otherwise, existing
-     * users would have to make their creators aware of the difference between blueprint and dm containers.
+     * FIXME: For container configs residing in META-INF/spring (the old Spring DM location), use
+	 * 		  a user-provided context creator via {@link #extenderConfiguration#getOsgiApplicationContextCreator()}, if any,
+	 * 		  to keep supporting custom spring-dm creators for backwards compatibility.
      */
     @Override
     protected OsgiApplicationContextCreator getOsgiApplicationContextCreator() {
+    	// TODO: check config location (META-INF/spring or OSGI-INF/blueprint?) and provide respective context creator.
         return new BlueprintContainerCreator();
     }
 
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerConfig.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerConfig.java
index d5c1fb4..d03b759 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerConfig.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerConfig.java
@@ -1,102 +1,101 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

+/*

+ Copyright (c) 2006, 2010 VMware Inc.

+ All rights reserved. This program and the accompanying materials

+ are made available under the terms of the Eclipse Public License v1.0

+ and Apache License v2.0 which accompanies this distribution.

+ The Eclipse Public License is available at

+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

+ is available at http://www.opensource.org/licenses/apache2.0.php.

+ You may elect to redistribute this code under either of these licenses.

+

+ Contributors:

+ VMware Inc.

+ */

 

 package org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.support;

 

-import java.util.Dictionary;

-

 import org.apache.commons.logging.Log;

 import org.apache.commons.logging.LogFactory;

-import org.osgi.framework.Bundle;

 import org.eclipse.gemini.blueprint.extender.support.ApplicationContextConfiguration;

 import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;

 import org.eclipse.gemini.blueprint.util.OsgiStringUtils;

+import org.osgi.framework.Bundle;

+

+import java.util.Dictionary;

 

 /**

  * Extension to the default {@link ApplicationContextConfiguration} that overrides Spring DM settings with RFC 124.

- * 

+ *

  * @author Costin Leau

- * 

  */

 public class BlueprintContainerConfig extends ApplicationContextConfiguration {

 

-	/** logger */

-	private static final Log log = LogFactory.getLog(BlueprintContainerConfig.class);

+    /**

+     * logger

+     */

+    private static final Log LOG = LogFactory.getLog(BlueprintContainerConfig.class);

 

-	private final long timeout;

-	private final boolean createAsync;

-	private final boolean waitForDep;

-	private final boolean publishContext;

-	private final boolean hasTimeout;

-	private final String toString;

+    private final long timeout;

+    private final boolean createAsync;

+    private final boolean waitForDep;

+    private final boolean publishContext;

+    private final boolean hasTimeout;

+    private final String toString;

 

-	public BlueprintContainerConfig(Bundle bundle) {

-		super(bundle, new BlueprintConfigurationScanner());

+    public BlueprintContainerConfig(Bundle bundle) {

+        super(bundle, new BlueprintConfigurationScanner());

 

-		Dictionary headers = bundle.getHeaders();

+        Dictionary headers = bundle.getHeaders();

 

-		hasTimeout = BlueprintConfigUtils.hasTimeout(headers);

-		long option = BlueprintConfigUtils.getTimeOut(headers);

-		// no need to translate into ms

-		timeout = (option >= 0 ? option : ConfigUtils.DIRECTIVE_TIMEOUT_DEFAULT * 1000);

-		createAsync = BlueprintConfigUtils.getCreateAsync(headers);

-		waitForDep = BlueprintConfigUtils.getWaitForDependencies(headers);

-		publishContext = BlueprintConfigUtils.getPublishContext(headers);

+        this.hasTimeout = BlueprintConfigUtils.hasTimeout(headers);

+        long option = BlueprintConfigUtils.getTimeOut(headers);

+        // no need to translate into ms

+        this.timeout = (option >= 0 ? option : ConfigUtils.DIRECTIVE_TIMEOUT_DEFAULT * 1000);

+        this.createAsync = BlueprintConfigUtils.getCreateAsync(headers);

+        this.waitForDep = BlueprintConfigUtils.getWaitForDependencies(headers);

+        this.publishContext = BlueprintConfigUtils.getPublishContext(headers);

 

-		StringBuilder buf = new StringBuilder();

-		buf.append("Blueprint Config [Bundle=");

-		buf.append(OsgiStringUtils.nullSafeSymbolicName(bundle));

-		buf.append("]isBlueprintBundle=");

-		buf.append(isSpringPoweredBundle());

-		buf.append("|async=");

-		buf.append(createAsync);

-		buf.append("|graceperiod=");

-		buf.append(waitForDep);

-		buf.append("|publishCtx=");

-		buf.append(publishContext);

-		buf.append("|timeout=");

-		buf.append(timeout);

-		buf.append("ms");

-		toString = buf.toString();

+        this.toString = "Blueprint Config [Bundle=" +

+                OsgiStringUtils.nullSafeSymbolicName(bundle) +

+                "]isBlueprintBundle=" +

+                isBlueprintConfigurationPresent() +

+                "|async=" +

+                createAsync +

+                "|graceperiod=" +

+                waitForDep +

+                "|publishCtx=" +

+                publishContext +

+                "|timeout=" +

+                timeout +

+                "ms";

 

-		if (log.isTraceEnabled()) {

-			log.trace("Configuration: " + toString);

-		}

-	}

+        if (LOG.isTraceEnabled()) {

+            LOG.trace("Configuration: " + toString);

+        }

+    }

 

-	@Override

-	public boolean isTimeoutDeclared() {

-		return hasTimeout;

-	}

+    @Override

+    public boolean isTimeoutDeclared() {

+        return hasTimeout;

+    }

 

-	public long getTimeout() {

-		return timeout;

-	}

+    public long getTimeout() {

+        return timeout;

+    }

 

-	public boolean isCreateAsynchronously() {

-		return createAsync;

-	}

+    public boolean isCreateAsynchronously() {

+        return createAsync;

+    }

 

-	public boolean isWaitForDependencies() {

-		return waitForDep;

-	}

+    public boolean isWaitForDependencies() {

+        return waitForDep;

+    }

 

-	public boolean isPublishContextAsService() {

-		return publishContext;

-	}

+    public boolean isPublishContextAsService() {

+        return publishContext;

+    }

 

-	public String toString() {

-		return toString;

-	}

+    public String toString() {

+        return toString;

+    }

 }
\ No newline at end of file
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerCreator.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerCreator.java
index 9f9a09c..cfc13ab 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerCreator.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/blueprint/activator/support/BlueprintContainerCreator.java
@@ -45,7 +45,7 @@
 			log.trace("Created configuration " + config + " for bundle " + bundleName);

 

 		// it's not a spring bundle, ignore it

-		if (!config.isSpringPoweredBundle()) {

+		if (!config.isBlueprintConfigurationPresent()) {

 			if (log.isDebugEnabled())

 				log.debug("No blueprint configuration found in bundle " + bundleName + "; ignoring it...");

 			return null;

diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/boot/ChainActivator.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/boot/ChainActivator.java
index a51d46c..2935770 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/boot/ChainActivator.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/boot/ChainActivator.java
@@ -1,27 +1,31 @@
-/******************************************************************************
- * Copyright (c) 2006, 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Apache License v2.0 which accompanies this distribution. 
- * The Eclipse Public License is available at 
- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
- * is available at http://www.opensource.org/licenses/apache2.0.php.
- * You may elect to redistribute this code under either of these licenses. 
- * 
- * Contributors:
- *   VMware Inc.
- *****************************************************************************/
+/*
+ Copyright (c) 2006, 2010 VMware Inc.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Apache License v2.0 which accompanies this distribution.
+ The Eclipse Public License is available at
+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
+ is available at http://www.opensource.org/licenses/apache2.0.php.
+ You may elect to redistribute this code under either of these licenses.
+
+ Contributors:
+ VMware Inc.
+ */
 
 package org.eclipse.gemini.blueprint.extender.internal.boot;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.eclipse.gemini.blueprint.extender.internal.activator.*;
+import org.eclipse.gemini.blueprint.extender.internal.activator.BlueprintNamespaceHandlerActivator;
+import org.eclipse.gemini.blueprint.extender.internal.activator.JavaBeansCacheActivator;
+import org.eclipse.gemini.blueprint.extender.internal.activator.ListenerServiceActivator;
+import org.eclipse.gemini.blueprint.extender.internal.activator.LoggingActivator;
+import org.eclipse.gemini.blueprint.extender.internal.activator.NamespaceHandlerActivator;
+import org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.BlueprintLoaderListener;
 import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration;
+import org.eclipse.gemini.blueprint.util.OsgiPlatformDetector;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.BlueprintLoaderListener;
-import org.eclipse.gemini.blueprint.util.OsgiPlatformDetector;
 import org.springframework.util.ClassUtils;
 
 /**
@@ -31,12 +35,8 @@
  *
  */
 public class ChainActivator implements BundleActivator {
-
-	protected final Log log = LogFactory.getLog(getClass());
-
-	private static final boolean BLUEPRINT_AVAILABLE =
-			ClassUtils.isPresent("org.osgi.service.blueprint.container.BlueprintContainer", ChainActivator.class
-					.getClassLoader());
+	private static final String API_CLASS = "org.osgi.service.blueprint.container.BlueprintContainer";
+	private static final boolean BLUEPRINT_AVAILABLE = ClassUtils.isPresent(API_CLASS, ChainActivator.class.getClassLoader());
 
 	private final BundleActivator[] CHAIN;
 
@@ -44,53 +44,40 @@
         final LoggingActivator logStatus = new LoggingActivator();
         final JavaBeansCacheActivator activateJavaBeansCache = new JavaBeansCacheActivator();
         final NamespaceHandlerActivator activateCustomNamespaceHandling = new NamespaceHandlerActivator();
-        final NamespaceHandlerActivator activateBlueprintspecificNamespaceHandling = new BlueprintNamespaceHandlerActivator();
-        final ExtenderConfiguration initializeExtenderConfiguration = new ExtenderConfiguration();
-        final ListenerServiceActivator activateListeners = new ListenerServiceActivator(initializeExtenderConfiguration);
-        final ContextLoaderListener listenForSpringDmBundles = new ContextLoaderListener(initializeExtenderConfiguration);
-        final BlueprintLoaderListener listenForBlueprintBundles = new BlueprintLoaderListener(initializeExtenderConfiguration, activateListeners);
+        final NamespaceHandlerActivator activateBlueprintSpecificNamespaceHandling = new BlueprintNamespaceHandlerActivator();
+        final ExtenderConfiguration extenderConfiguration = new ExtenderConfiguration();
+        final ListenerServiceActivator activateListeners = new ListenerServiceActivator(extenderConfiguration);
+        final BlueprintLoaderListener listenForBlueprintBundles = new BlueprintLoaderListener(extenderConfiguration, activateListeners);
 
-        if (OsgiPlatformDetector.isR42()) {
-			if (BLUEPRINT_AVAILABLE) {
-				log.info("Blueprint API detected; enabling Blueprint Container functionality");
-				CHAIN = new BundleActivator[] {
-                        logStatus,
-                        activateJavaBeansCache,
-                        activateCustomNamespaceHandling,
-                        activateBlueprintspecificNamespaceHandling,
-                        initializeExtenderConfiguration,
-                        activateListeners,
-                        listenForSpringDmBundles,
-                        listenForBlueprintBundles
-                };
-			}
-			else {
-				log.warn("Blueprint API not found; disabling Blueprint Container functionality");
-				CHAIN = new BundleActivator[] {
-                        logStatus,
-                        activateJavaBeansCache,
-                        activateCustomNamespaceHandling,
-                        initializeExtenderConfiguration,
-                        activateListeners,
-                        listenForSpringDmBundles
-                };
-			}
-		} else {
-			log.warn("Pre-4.2 OSGi platform detected; disabling Blueprint Container functionality");
-            CHAIN = new BundleActivator[] {
-                    logStatus,
-                    activateJavaBeansCache,
-                    activateCustomNamespaceHandling,
-                    initializeExtenderConfiguration,
-                    activateListeners,
-                    listenForSpringDmBundles
-            };
-        }
+		Log log = LogFactory.getLog(getClass());
+
+		if (!OsgiPlatformDetector.isR42()) {
+			log.fatal("Pre-4.2 OSGi platform detected; disabling Blueprint Container functionality");
+			CHAIN = new BundleActivator[]{}; // NOOP chain
+			return;
+		}
+
+		if (!BLUEPRINT_AVAILABLE) {
+			log.fatal("Blueprint API " + API_CLASS + " not found; disabling Blueprint Container functionality");
+			CHAIN = new BundleActivator[]{}; // NOOP chain
+			return;
+		}
+
+		log.info("Blueprint API detected; enabling Blueprint Container functionality");
+		CHAIN = new BundleActivator[] {
+				logStatus,
+				activateJavaBeansCache,
+				activateCustomNamespaceHandling,
+				activateBlueprintSpecificNamespaceHandling,
+				extenderConfiguration,
+				activateListeners,
+				listenForBlueprintBundles
+		};
 	}
 
 	public void start(BundleContext context) throws Exception {
-		for (int i = 0; i < CHAIN.length; i++) {
-			CHAIN[i].start(context);
+		for (BundleActivator activator : CHAIN) {
+			activator.start(context);
 		}
 	}
 
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java
index ed93b3c..7b3461d 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/internal/support/ExtenderConfiguration.java
@@ -167,27 +167,27 @@
 				extenderConfiguration = extenderAppCtx;
 				// initialize beans
 				taskExecutor =
-						extenderConfiguration.containsBean(TASK_EXECUTOR_NAME) ? (TaskExecutor) extenderConfiguration
+						extenderConfiguration.containsBean(TASK_EXECUTOR_NAME) ? extenderConfiguration
 								.getBean(TASK_EXECUTOR_NAME, TaskExecutor.class) : createDefaultTaskExecutor();
 
 				shutdownTaskExecutor =
-						extenderConfiguration.containsBean(SHUTDOWN_TASK_EXECUTOR_NAME) ? (TaskExecutor) extenderConfiguration
+						extenderConfiguration.containsBean(SHUTDOWN_TASK_EXECUTOR_NAME) ? extenderConfiguration
 								.getBean(SHUTDOWN_TASK_EXECUTOR_NAME, TaskExecutor.class)
 								: createDefaultShutdownTaskExecutor();
 
 				eventMulticaster =
-						extenderConfiguration.containsBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME) ? (OsgiBundleApplicationContextEventMulticaster) extenderConfiguration
+						extenderConfiguration.containsBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME) ? extenderConfiguration
 								.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME,
 										OsgiBundleApplicationContextEventMulticaster.class)
 								: createDefaultEventMulticaster();
 
 				contextCreator =
-						extenderConfiguration.containsBean(CONTEXT_CREATOR_NAME) ? (OsgiApplicationContextCreator) extenderConfiguration
+						extenderConfiguration.containsBean(CONTEXT_CREATOR_NAME) ? extenderConfiguration
 								.getBean(CONTEXT_CREATOR_NAME, OsgiApplicationContextCreator.class)
 								: null;
 
 				contextEventListener =
-						extenderConfiguration.containsBean(CONTEXT_LISTENER_NAME) ? (OsgiBundleApplicationContextListener) extenderConfiguration
+						extenderConfiguration.containsBean(CONTEXT_LISTENER_NAME) ? extenderConfiguration
 								.getBean(CONTEXT_LISTENER_NAME, OsgiBundleApplicationContextListener.class)
 								: createDefaultApplicationContextListener();
 			}
@@ -203,7 +203,7 @@
 			// extender properties using the defaults as backup
 			if (extenderConfiguration.containsBean(PROPERTIES_NAME)) {
 				Properties customProperties =
-						(Properties) extenderConfiguration.getBean(PROPERTIES_NAME, Properties.class);
+						extenderConfiguration.getBean(PROPERTIES_NAME, Properties.class);
 				Enumeration<?> propertyKey = customProperties.propertyNames();
 				while (propertyKey.hasMoreElements()) {
 					String property = (String) propertyKey.nextElement();
@@ -302,7 +302,7 @@
 			}
 		}
 
-		return (String[]) urls.toArray(new String[urls.size()]);
+		return urls.toArray(new String[urls.size()]);
 	}
 
 	private Properties createDefaultProperties() {
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java
index 0f0a9cf..d5c5dc9 100644
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java
+++ b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ApplicationContextConfiguration.java
@@ -1,169 +1,155 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

+/*

+ Copyright (c) 2006, 2010 VMware Inc.

+ All rights reserved. This program and the accompanying materials

+ are made available under the terms of the Eclipse Public License v1.0

+ and Apache License v2.0 which accompanies this distribution.

+ The Eclipse Public License is available at

+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

+ is available at http://www.opensource.org/licenses/apache2.0.php.

+ You may elect to redistribute this code under either of these licenses.

+

+ Contributors:

+ VMware Inc.

+ */

 

 package org.eclipse.gemini.blueprint.extender.support;

 

-import java.util.Dictionary;

-

 import org.apache.commons.logging.Log;

 import org.apache.commons.logging.LogFactory;

-import org.osgi.framework.Bundle;

 import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;

 import org.eclipse.gemini.blueprint.extender.support.scanning.ConfigurationScanner;

-import org.eclipse.gemini.blueprint.extender.support.scanning.DefaultConfigurationScanner;

 import org.eclipse.gemini.blueprint.util.OsgiStringUtils;

-import org.springframework.util.Assert;

+import org.osgi.framework.Bundle;

 import org.springframework.util.ObjectUtils;

 

+import java.util.Dictionary;

+

+import static org.springframework.util.Assert.notNull;

+

 /**

- * Configuration class for Spring-DM application contexts.

- * 

+ * Configuration class for Blueprint application contexts.

+ * <p>

  * Determines the configuration information available in a bundle for constructing an application context. Reads all the

- * Spring-DM options present in the bundle header.

- * 

+ * Blueprint options present in the bundle header.

+ *

  * @author Adrian Colyer

  * @author Costin Leau

  */

-public class ApplicationContextConfiguration {

+public abstract class ApplicationContextConfiguration {

 

-	/** logger */

-	private static final Log log = LogFactory.getLog(ApplicationContextConfiguration.class);

+    /**

+     * logger

+     */

+    private static final Log LOG = LogFactory.getLog(ApplicationContextConfiguration.class);

 

-	private final Bundle bundle;

-	private final ConfigurationScanner configurationScanner;

-	private final boolean asyncCreation;

-	private final String[] configurationLocations;

-	private final boolean isSpringPoweredBundle;

-	private final boolean publishContextAsService;

-	private final boolean waitForDeps;

-	private final String toString;

-	private final long timeout;

-	private final boolean hasTimeout;

+    private final boolean asyncCreation;

+    private final String[] configurationLocations;

+    private final boolean isBlueprintConfigurationPresent;

+    private final boolean publishContextAsService;

+    private final boolean waitForDeps;

+    private final String toString;

+    private final long timeout;

+    private final boolean hasTimeout;

 

-	/**

-	 * Constructs a new <code>ApplicationContextConfiguration</code> instance from the given bundle. Uses the

-	 * {@link DefaultConfigurationScanner} internally for discovering Spring-powered bundles.

-	 * 

-	 * @param bundle bundle for which the application context configuration is created

-	 */

-	public ApplicationContextConfiguration(Bundle bundle) {

-		this(bundle, new DefaultConfigurationScanner());

-	}

+    public ApplicationContextConfiguration(Bundle bundle, ConfigurationScanner configurationScanner) {

+        notNull(bundle, "Constructor parameter bundle must not be null.");

+        notNull(configurationScanner, "Constructor parameter configurationScanner must not be null.");

 

-	public ApplicationContextConfiguration(Bundle bundle, ConfigurationScanner configurationScanner) {

-		Assert.notNull(bundle);

-		Assert.notNull(configurationScanner);

-		this.bundle = bundle;

-		this.configurationScanner = configurationScanner;

+        Dictionary headers = bundle.getHeaders();

 

-		Dictionary headers = this.bundle.getHeaders();

+        String[] configs = configurationScanner.getConfigurations(bundle);

 

-		String[] configs = this.configurationScanner.getConfigurations(bundle);

+        this.isBlueprintConfigurationPresent = !ObjectUtils.isEmpty(configs);

+        this.configurationLocations = configs;

 

-		this.isSpringPoweredBundle = !ObjectUtils.isEmpty(configs);

-		this.configurationLocations = configs;

+        this.hasTimeout = ConfigUtils.isDirectiveDefined(headers, ConfigUtils.DIRECTIVE_TIMEOUT);

 

-		hasTimeout = ConfigUtils.isDirectiveDefined(headers, ConfigUtils.DIRECTIVE_TIMEOUT);

+        long option = ConfigUtils.getTimeOut(headers);

+        // translate into ms

+        this.timeout = (option >= 0 ? option * 1000 : option);

+        this.publishContextAsService = ConfigUtils.getPublishContext(headers);

+        this.asyncCreation = ConfigUtils.getCreateAsync(headers);

+        this.waitForDeps = ConfigUtils.getWaitForDependencies(headers);

 

-		long option = ConfigUtils.getTimeOut(headers);

-		// translate into ms

-		this.timeout = (option >= 0 ? option * 1000 : option);

-		this.publishContextAsService = ConfigUtils.getPublishContext(headers);

-		this.asyncCreation = ConfigUtils.getCreateAsync(headers);

-		this.waitForDeps = ConfigUtils.getWaitForDependencies(headers);

+        // create toString

+        this.toString = "AppCtxCfg [Bundle=" +

+                OsgiStringUtils.nullSafeSymbolicName(bundle) +

+                "]isBlueprintConfigurationPresent=" +

+                isBlueprintConfigurationPresent() +

+                "|async=" +

+                isCreateAsynchronously() +

+                "|wait-for-deps=" +

+                isWaitForDependencies() +

+                "|publishCtx=" +

+                isPublishContextAsService() +

+                "|timeout=" +

+                getTimeout() / 1000 +

+                "s";

+        if (LOG.isTraceEnabled()) {

+            LOG.trace("Configuration: " + this.toString);

+        }

+    }

 

-		// create toString

-		StringBuilder buf = new StringBuilder();

-		buf.append("AppCtxCfg [Bundle=");

-		buf.append(OsgiStringUtils.nullSafeSymbolicName(bundle));

-		buf.append("]isSpringBundle=");

-		buf.append(isSpringPoweredBundle());

-		buf.append("|async=");

-		buf.append(isCreateAsynchronously());

-		buf.append("|wait-for-deps=");

-		buf.append(isWaitForDependencies());

-		buf.append("|publishCtx=");

-		buf.append(isPublishContextAsService());

-		buf.append("|timeout=");

-		buf.append(getTimeout() / 1000);

-		buf.append("s");

-		toString = buf.toString();

-		if (log.isTraceEnabled()) {

-			log.trace("Configuration: " + toString);

-		}

-	}

+    /**

+     * Indicates if the given bundle is "Spring-Powered" or not.

+     * <p>

+     * True if this bundle has at least one defined application context configuration file.

+     * <p>

+     * <p/> A bundle is "Spring-Powered" if it has at least one configuration resource.

+     */

+    public boolean isBlueprintConfigurationPresent() {

+        return this.isBlueprintConfigurationPresent;

+    }

 

-	/**

-	 * Indicates if the given bundle is "Spring-Powered" or not.

-	 * 

-	 * True if this bundle has at least one defined application context configuration file.

-	 * 

-	 * <p/> A bundle is "Spring-Powered" if it has at least one configuration resource.

-	 */

-	public boolean isSpringPoweredBundle() {

-		return this.isSpringPoweredBundle;

-	}

+    public boolean isTimeoutDeclared() {

+        return hasTimeout;

+    }

 

-	public boolean isTimeoutDeclared() {

-		return hasTimeout;

-	}

+    /**

+     * Returns the timeout (in milliseconds) an application context needs to wait for mandatory dependent services.

+     */

+    public long getTimeout() {

+        return this.timeout;

+    }

 

-	/**

-	 * Returns the timeout (in milliseconds) an application context needs to wait for mandatory dependent services.

-	 */

-	public long getTimeout() {

-		return this.timeout;

-	}

+    /**

+     * Indicates if an application context needs to be created asynchronously or not.

+     * <p>

+     * Should the application context wait for all non-optional service references to be satisfied before starting?

+     */

+    public boolean isCreateAsynchronously() {

+        return this.asyncCreation;

+    }

 

-	/**

-	 * Indicates if an application context needs to be created asynchronously or not.

-	 * 

-	 * Should the application context wait for all non-optional service references to be satisfied before starting?

-	 */

-	public boolean isCreateAsynchronously() {

-		return this.asyncCreation;

-	}

+    /**

+     * Indicates if the application context needs to be published as a service or not.

+     *

+     * @return Returns the publishContextAsService.

+     */

+    public boolean isPublishContextAsService() {

+        return publishContextAsService;

+    }

 

-	/**

-	 * Indicates if the application context needs to be published as a service or not.

-	 * 

-	 * @return Returns the publishContextAsService.

-	 */

-	public boolean isPublishContextAsService() {

-		return publishContextAsService;

-	}

+    /**

+     * Indicates if the configuration must wait for dependencies.

+     *

+     * @return true if the configuration indicates that dependencies should be waited for.

+     */

+    public boolean isWaitForDependencies() {

+        return waitForDeps;

+    }

 

-	/**

-	 * Indicates if the configuration must wait for dependencies.

-	 * 

-	 * @return true if the configuration indicates that dependencies should be waited for.

-	 */

-	public boolean isWaitForDependencies() {

-		return waitForDeps;

-	}

+    /**

+     * Returns the locations of the configuration resources used to build the application context (as Spring resource

+     * paths).

+     *

+     * @return configuration paths

+     */

+    public String[] getConfigurationLocations() {

+        return this.configurationLocations;

+    }

 

-	/**

-	 * Returns the locations of the configuration resources used to build the application context (as Spring resource

-	 * paths).

-	 * 

-	 * @return configuration paths

-	 */

-	public String[] getConfigurationLocations() {

-		return this.configurationLocations;

-	}

-

-	public String toString() {

-		return toString;

-	}

+    public String toString() {

+        return toString;

+    }

 }
\ No newline at end of file
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ConditionalApplicationContextCreator.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ConditionalApplicationContextCreator.java
deleted file mode 100644
index 9d16717..0000000
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/ConditionalApplicationContextCreator.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

-package org.eclipse.gemini.blueprint.extender.support;

-

-import org.osgi.framework.BundleContext;

-import org.springframework.beans.factory.InitializingBean;

-import org.eclipse.gemini.blueprint.context.DelegatedExecutionOsgiBundleApplicationContext;

-import org.eclipse.gemini.blueprint.extender.OsgiApplicationContextCreator;

-import org.springframework.util.Assert;

-

-/**

- * Useful {@link OsgiApplicationContextCreator} implementation that dictates

- * whether the default application context used by the Spring-DM extender should

- * be created (or not) based on a <code>boolean</code> value. This allows

- * clients to handle only the bundleContext filtering while being decoupled from

- * the context creation process:

- * 

- * <pre class="code">

- * 

- * ConditionalApplicationContextCreator creator = new ConditionalApplicationContextCreator();

- * 

- * creator.setFilter(new ConditionalApplicationContextCreator.BundleContextFilter() {

- * 	// filter bundles with no copyright

- * 	public boolean matches(BundleContext bundleContext) {

- * 		return bundleContext.getBundle().getHeaders().get(Constants.BUNDLE_COPYRIGHT) != null)

- * 	}

- * }

- * 

- * creator.createApplicationContext(bundleContext); 

- * </pre>

- * 

- * @see OsgiApplicationContextCreator

- * @author Costin Leau

- */

-public class ConditionalApplicationContextCreator implements OsgiApplicationContextCreator, InitializingBean {

-

-	/**

-	 * Callback used to filter the bundle contexts for which the default

-	 * application contexts are created.

-	 * 

-	 * @author Costin Leau

-	 * 

-	 */

-	public static interface BundleContextFilter {

-

-		/**

-		 * Determines if the given bundle context matches the filter criteria.

-		 * 

-		 * @param bundleContext the OSGi bundle context to check

-		 * @return true if the bundle context matches, false otherwise.

-		 */

-		boolean matches(BundleContext bundleContext);

-	}

-

-

-	private BundleContextFilter filter;

-

-	private OsgiApplicationContextCreator delegatedContextCreator;

-

-

-	public void afterPropertiesSet() throws Exception {

-		Assert.notNull(filter, "filter property is required");

-		if (delegatedContextCreator == null)

-			delegatedContextCreator = new DefaultOsgiApplicationContextCreator();

-	}

-

-	public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(BundleContext bundleContext)

-			throws Exception {

-		if (filter.matches(bundleContext))

-			return delegatedContextCreator.createApplicationContext(bundleContext);

-		else

-			return null;

-	}

-

-	/**

-	 * Sets the {@link BundleContextFilter} used by this context creator.

-	 * 

-	 * @param filter The bundle context filter to set.

-	 */

-	public void setFilter(BundleContextFilter filter) {

-		this.filter = filter;

-	}

-

-	/**

-	 * Sets the {@link OsgiApplicationContextCreator} used by this context

-	 * creator for the actual creation. If none is specified,

-	 * {@link DefaultOsgiApplicationContextCreator} is used.

-	 * 

-	 * @param delegatedContextCreator the instance used for creating the

-	 * application context

-	 */

-	public void setDelegatedApplicationContextCreator(OsgiApplicationContextCreator delegatedContextCreator) {

-		this.delegatedContextCreator = delegatedContextCreator;

-	}

-}

diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/DefaultOsgiApplicationContextCreator.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/DefaultOsgiApplicationContextCreator.java
deleted file mode 100644
index 5234349..0000000
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/DefaultOsgiApplicationContextCreator.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

-package org.eclipse.gemini.blueprint.extender.support;

-

-import org.apache.commons.logging.Log;

-import org.apache.commons.logging.LogFactory;

-import org.osgi.framework.Bundle;

-import org.osgi.framework.BundleContext;

-import org.eclipse.gemini.blueprint.context.DelegatedExecutionOsgiBundleApplicationContext;

-import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;

-import org.eclipse.gemini.blueprint.extender.OsgiApplicationContextCreator;

-import org.eclipse.gemini.blueprint.extender.support.scanning.ConfigurationScanner;

-import org.eclipse.gemini.blueprint.extender.support.scanning.DefaultConfigurationScanner;

-import org.eclipse.gemini.blueprint.util.OsgiStringUtils;

-import org.springframework.util.Assert;

-import org.springframework.util.ObjectUtils;

-

-/**

- * Default {@link OsgiApplicationContextCreator} implementation.

- * 

- * <p/> Creates an {@link OsgiBundleXmlApplicationContext} instance using the

- * default locations (<tt>Spring-Context</tt> manifest header or

- * <tt>META-INF/spring/*.xml</tt>) if available, null otherwise.

- * 

- * <p/> Additionally, this implementation allows custom locations to be

- * specified through {@link ConfigurationScanner} interface.

- * 

- * @see ConfigurationScanner

- * @author Costin Leau

- * 

- */

-public class DefaultOsgiApplicationContextCreator implements OsgiApplicationContextCreator {

-

-	/** logger */

-	private static final Log log = LogFactory.getLog(DefaultOsgiApplicationContextCreator.class);

-

-	private ConfigurationScanner configurationScanner = new DefaultConfigurationScanner();

-

-

-	public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(BundleContext bundleContext)

-			throws Exception {

-		Bundle bundle = bundleContext.getBundle();

-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(bundle, configurationScanner);

-		if (log.isTraceEnabled())

-			log.trace("Created configuration " + config + " for bundle "

-					+ OsgiStringUtils.nullSafeNameAndSymName(bundle));

-

-		// it's not a spring bundle, ignore it

-		if (!config.isSpringPoweredBundle()) {

-			return null;

-		}

-

-		log.info("Discovered configurations " + ObjectUtils.nullSafeToString(config.getConfigurationLocations())

-				+ " in bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]");

-

-		DelegatedExecutionOsgiBundleApplicationContext sdoac = new OsgiBundleXmlApplicationContext(

-			config.getConfigurationLocations());

-		sdoac.setBundleContext(bundleContext);

-		sdoac.setPublishContextAsService(config.isPublishContextAsService());

-

-		return sdoac;

-	}

-

-	/**

-	 * Sets the configurationScanner used by this creator.

-	 * 

-	 * @param configurationScanner The configurationScanner to set.

-	 */

-	public void setConfigurationScanner(ConfigurationScanner configurationScanner) {

-		Assert.notNull(configurationScanner);

-		this.configurationScanner = configurationScanner;

-	}

-}
\ No newline at end of file
diff --git a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/scanning/DefaultConfigurationScanner.java b/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/scanning/DefaultConfigurationScanner.java
deleted file mode 100644
index 74cd24d..0000000
--- a/extender/src/main/java/org/eclipse/gemini/blueprint/extender/support/scanning/DefaultConfigurationScanner.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

-package org.eclipse.gemini.blueprint.extender.support.scanning;

-

-import java.util.Enumeration;

-

-import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;

-import org.eclipse.gemini.blueprint.io.OsgiBundleResource;

-import org.osgi.framework.Bundle;

-import org.springframework.util.ObjectUtils;

-

-/**

- * Default implementation of {@link ConfigurationScanner} interface.

- * 

- * <p/>Supports <tt>Spring-Context</tt> manifest header and

- * <tt>META-INF/spring/*.xml</tt>.

- * 

- * @author Costin Leau

- * 

- */

-public class DefaultConfigurationScanner implements ConfigurationScanner {

-

-	private static final String CONTEXT_DIR = "/META-INF/spring/";

-

-	private static final String CONTEXT_FILES = "*.xml";

-

-	/** Default configuration location */

-	public static final String DEFAULT_CONFIG = OsgiBundleResource.BUNDLE_URL_PREFIX + CONTEXT_DIR + CONTEXT_FILES;

-

-

-	public String[] getConfigurations(Bundle bundle) {

-		String[] locations = ConfigUtils.getHeaderLocations(bundle.getHeaders());

-

-		// if no location is specified in the header, try the defaults

-		if (ObjectUtils.isEmpty(locations)) {

-			// check the default locations if the manifest doesn't provide any info

-			Enumeration defaultConfig = bundle.findEntries(CONTEXT_DIR, CONTEXT_FILES, false);

-			if (defaultConfig != null && defaultConfig.hasMoreElements()) {

-				return new String[] { DEFAULT_CONFIG };

-			}

-			else {

-				return new String[0];

-			}

-		}

-		else {

-			return locations;

-		}

-	}

-}

diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/BlueprintLoaderListenerTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/BlueprintLoaderListenerTest.java
new file mode 100644
index 0000000..79c1216
--- /dev/null
+++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/BlueprintLoaderListenerTest.java
@@ -0,0 +1,119 @@
+/*
+ Copyright (c) 2006, 2010 VMware Inc.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Apache License v2.0 which accompanies this distribution.
+ The Eclipse Public License is available at
+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
+ is available at http://www.opensource.org/licenses/apache2.0.php.
+ You may elect to redistribute this code under either of these licenses.
+
+ Contributors:
+ VMware Inc.
+ */
+
+package org.eclipse.gemini.blueprint.extender.internal;
+
+import junit.framework.TestCase;
+import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEventMulticaster;
+import org.eclipse.gemini.blueprint.extender.internal.activator.ListenerServiceActivator;
+import org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.BlueprintLoaderListener;
+import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration;
+import org.eclipse.gemini.blueprint.extender.internal.support.TestTaskExecutor;
+import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;
+import org.eclipse.gemini.blueprint.mock.EntryLookupControllingMockBundle;
+import org.eclipse.gemini.blueprint.mock.MockBundle;
+import org.eclipse.gemini.blueprint.mock.MockBundleContext;
+import org.eclipse.gemini.blueprint.mock.MockServiceRegistration;
+import org.mockito.Mockito;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
+import org.springframework.core.io.ClassPathResource;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * @author Adrian Colyer
+ * 
+ */
+public class BlueprintLoaderListenerTest extends TestCase {
+	private BlueprintLoaderListener listener;
+    private ExtenderConfiguration configuration = mock(ExtenderConfiguration.class);
+    private OsgiBundleApplicationContextEventMulticaster multicaster = mock(OsgiBundleApplicationContextEventMulticaster.class);
+	private ListenerServiceActivator listenerServiceActivator;
+	private BundleContext context;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		doReturn(multicaster).when(this.configuration).getEventMulticaster();
+		this.context = mock(BundleContext.class);
+		this.listenerServiceActivator = new ListenerServiceActivator(this.configuration);
+		this.listener = new BlueprintLoaderListener(this.configuration, listenerServiceActivator);
+		this.listenerServiceActivator.start(this.context);
+	}
+
+	public void testStart() throws Exception {
+		BundleContext context = Mockito.mock(BundleContext.class);
+		// look for existing resolved bundles
+		when(context.getBundles()).thenReturn(new Bundle[0]);
+
+		// register context service
+		when(context.registerService((String[]) null, null, null)).thenReturn(null);
+
+		// create task executor
+		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
+		aBundle.setEntryReturnOnNextCallToGetEntry(null);
+		when(context.getBundle()).thenReturn(aBundle);
+
+		// listen for bundle events
+		context.addBundleListener(null);
+
+		when(context.registerService(isA(String[].class), any(), isA(Dictionary.class))).thenReturn(new MockServiceRegistration<>());
+
+		this.listener.start(context);
+
+		verify(context).registerService(isA(String[].class), any(), isA(Dictionary.class));
+	}
+
+	public void ignoredTestTaskExecutor() throws Exception {
+		Dictionary<String, String> headers = new Hashtable<>();
+		headers.put(Constants.BUNDLE_NAME, "Extender mock bundle");
+		final EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
+		aBundle.setEntryReturnOnNextCallToGetEntry(new ClassPathResource("META-INF/spring/moved-extender.xml").getURL());
+
+		MockBundleContext ctx = new MockBundleContext() {
+
+			public Bundle getBundle() {
+				return aBundle;
+			}
+		};
+
+		this.listener.start(ctx);
+
+		Dictionary<String, String> hdrs = new Hashtable<>();
+		hdrs.put(ConfigUtils.SPRING_CONTEXT_HEADER, "bla bla");
+		MockBundle anotherBundle = new MockBundle(hdrs);
+		anotherBundle.setBundleId(1);
+
+		BundleEvent event = new BundleEvent(BundleEvent.STARTED, anotherBundle);
+
+		BundleListener listener = ctx.getBundleListeners().iterator().next();
+
+		TestTaskExecutor.called = false;
+
+		listener.bundleChanged(event);
+		assertTrue("task executor should have been called if configured properly", TestTaskExecutor.called);
+	}
+
+}
diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/ContextLoaderListenerTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/ContextLoaderListenerTest.java
deleted file mode 100644
index 8e33852..0000000
--- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/ContextLoaderListenerTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/******************************************************************************
- * Copyright (c) 2006, 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Apache License v2.0 which accompanies this distribution. 
- * The Eclipse Public License is available at 
- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
- * is available at http://www.opensource.org/licenses/apache2.0.php.
- * You may elect to redistribute this code under either of these licenses. 
- * 
- * Contributors:
- *   VMware Inc.
- *****************************************************************************/
-
-package org.eclipse.gemini.blueprint.extender.internal;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import static org.easymock.EasyMock.*;
-import org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener;
-import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration;
-import org.eclipse.gemini.blueprint.extender.internal.support.TestTaskExecutor;
-import org.eclipse.gemini.blueprint.extender.support.internal.ConfigUtils;
-import org.eclipse.gemini.blueprint.mock.EntryLookupControllingMockBundle;
-import org.eclipse.gemini.blueprint.mock.MockBundle;
-import org.eclipse.gemini.blueprint.mock.MockBundleContext;
-import org.eclipse.gemini.blueprint.mock.MockServiceRegistration;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Constants;
-import org.springframework.core.io.ClassPathResource;
-
-/**
- * @author Adrian Colyer
- * 
- */
-public abstract class ContextLoaderListenerTest extends TestCase {
-	private ContextLoaderListener listener;
-    // TODO: mock & train once there are any applications of this base class.
-    private ExtenderConfiguration configuration;
-
-    protected void setUp() throws Exception {
-		super.setUp();
-		this.listener = new ContextLoaderListener(this.configuration);
-	}
-
-	public void testStart() throws Exception {
-		BundleContext context = createMock(BundleContext.class);
-		// platform determination
-
-		// extracting bundle id from bundle
-		expect(context.getBundle()).andReturn(new MockBundle());
-
-		// look for existing resolved bundles
-		expect(context.getBundles()).andReturn(new Bundle[0]).times(2);
-
-		// register context service
-		expect(context.registerService((String[]) null, null, null)).andReturn(null).atLeastOnce();
-
-		// create task executor
-		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
-		aBundle.setEntryReturnOnNextCallToGetEntry(null);
-		expect(context.getBundle()).andReturn(aBundle).atLeastOnce();
-
-		// listen for bundle events
-		context.addBundleListener(null);
-        expectLastCall().times(2);
-
-		expect(context.registerService(new String[0], null, new Hashtable<String, Object>())).andReturn(new MockServiceRegistration()).atLeastOnce();
-		replay(context);
-
-		this.listener.start(context);
-		verify(context);
-	}
-
-	public void tstTaskExecutor() throws Exception {
-		Dictionary headers = new Hashtable();
-		headers.put(Constants.BUNDLE_NAME, "Extender mock bundle");
-		final EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
-		aBundle.setEntryReturnOnNextCallToGetEntry(new ClassPathResource("META-INF/spring/moved-extender.xml").getURL());
-
-		MockBundleContext ctx = new MockBundleContext() {
-
-			public Bundle getBundle() {
-				return aBundle;
-			}
-		};
-
-		this.listener.start(ctx);
-
-		Dictionary hdrs = new Hashtable();
-		hdrs.put(ConfigUtils.SPRING_CONTEXT_HEADER, "bla bla");
-		MockBundle anotherBundle = new MockBundle(hdrs);
-		anotherBundle.setBundleId(1);
-
-		BundleEvent event = new BundleEvent(BundleEvent.STARTED, anotherBundle);
-
-		BundleListener listener = (BundleListener) ctx.getBundleListeners().iterator().next();
-
-		TestTaskExecutor.called = false;
-
-		listener.bundleChanged(event);
-		assertTrue("task executor should have been called if configured properly", TestTaskExecutor.called);
-	}
-
-}
diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/DependencyMockBundle.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/DependencyMockBundle.java
index e977f4f..61acc63 100644
--- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/DependencyMockBundle.java
+++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/DependencyMockBundle.java
@@ -104,7 +104,7 @@
 

 		for (int i = 0; i < dependents.length; i++) {

 			registeredServices.put(dependents[i], new MockServiceReference(DependencyMockBundle.this, createProps(i,

-					serviceRanking, serviceId), null) {

+					serviceRanking, serviceId)) {

 

 				public Bundle[] getUsingBundles() {

 					return DependencyMockBundle.this.dependentOn.toArray(new Bundle[dependentOn.size()]);

diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListListenerAdapterTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListListenerAdapterTest.java
index 5410ce0..33c5dcf 100644
--- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListListenerAdapterTest.java
+++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/activator/ListListenerAdapterTest.java
@@ -63,7 +63,7 @@
         public ServiceRegistration registerService(String[] clazzes, final Object service, Dictionary properties) {

             MockServiceRegistration reg = new MockServiceRegistration(properties);

 

-            MockServiceReference ref = new MockServiceReference(getBundle(), properties, reg, clazzes) {

+            MockServiceReference ref = new MockServiceReference(getBundle(), properties, clazzes) {

 

                 @Override

                 public Object getProperty(String key) {

diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ApplicationContextConfigurationTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ApplicationContextConfigurationTest.java
index f1d51d5..5d3b94b 100644
--- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ApplicationContextConfigurationTest.java
+++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/support/ApplicationContextConfigurationTest.java
@@ -1,30 +1,30 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

+/*
+ Copyright (c) 2006, 2010 VMware Inc.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Apache License v2.0 which accompanies this distribution.
+ The Eclipse Public License is available at
+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
+ is available at http://www.opensource.org/licenses/apache2.0.php.
+ You may elect to redistribute this code under either of these licenses.
+
+ Contributors:
+ VMware Inc.
+ */
+
 package org.eclipse.gemini.blueprint.extender.internal.support;
 
+import junit.framework.TestCase;
+import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;
+import org.eclipse.gemini.blueprint.extender.internal.blueprint.activator.support.BlueprintContainerConfig;
+import org.eclipse.gemini.blueprint.extender.support.ApplicationContextConfiguration;
+import org.eclipse.gemini.blueprint.mock.EntryLookupControllingMockBundle;
+
 import java.net.URL;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
 
-import junit.framework.TestCase;
-
-import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;
-import org.eclipse.gemini.blueprint.extender.support.ApplicationContextConfiguration;

-import org.eclipse.gemini.blueprint.mock.EntryLookupControllingMockBundle;

-
 /**
  * Test that given a bundle, we can correctly determine the spring configuration
  * required for it.
@@ -39,59 +39,59 @@
 	public void testBundleWithNoHeaderAndNoMetaInfSpringResourcesIsNotSpringPowered() {
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(null);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertFalse("bundle is not spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertFalse("bundle is not spring powered", config.isBlueprintConfigurationPresent());
 	}
 
 	public void testBundleWithSpringResourcesAndNoHeaderIsSpringPowered() {
 		EntryLookupControllingMockBundle aBundle = new RepeatingEntryLookupControllingMockBundle(null);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertTrue("bundle is spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertTrue("bundle is spring powered", config.isBlueprintConfigurationPresent());
 	}
 
 	public void testBundleWithHeaderAndNoMetaInfResourcesIsSpringPowered() throws Exception {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "META-INF/spring/context.xml");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(null);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL("file://META-INF/spring/context.xml"));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertTrue("bundle is spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertTrue("bundle is spring powered", config.isBlueprintConfigurationPresent());
 	}
 
 	public void testBundleWithNoHeaderShouldWaitFiveMinutes() {
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		assertEquals("bundle should timeout in five minutes", new Long(5 * 60 * 1000), new Long(config.getTimeout()));
 	}
 
 	public void testBundleWithWaitFiveSecondWaitForTimeout() {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "*;timeout:=5");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertEquals("bundle should timeout in 5 s", new Long(5 * 1000), new Long(config.getTimeout()));
 	}
 
 	public void testBundleWithWaitForEver() {
 		// *;flavour
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "*;timeout:=none");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertEquals("bundle should timeout -2 (indicates forever)", new Long(-2), new Long(config.getTimeout()));
 	}
 
 	public void tstConfigLocationsInMetaInfNoHeader() {
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		String[] configFiles = config.getConfigurationLocations();
 		assertEquals("0 config files", 0, configFiles.length);
 		// assertEquals("bundle-url:file://META-INF/spring/context.xml",
@@ -101,137 +101,137 @@
 	}
 
 	public void tstConfigLocationsInMetaInfWithHeader() throws Exception {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "META-INF/spring/context.xml");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL("file://META-INF/spring/context.xml"));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		String[] configFiles = config.getConfigurationLocations();
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertEquals("osgibundle:META-INF/spring/context.xml", configFiles[0]);
 	}
 
 	public void tstConfigLocationsInMetaInfWithWildcardHeader() throws Exception {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "*;wait-for-dependencies:=false");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		String[] configFiles = config.getConfigurationLocations();
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertEquals("1 config files", 1, configFiles.length);
 		assertEquals(OsgiBundleXmlApplicationContext.DEFAULT_CONFIG_LOCATION, configFiles[0]);
 	}
 
 	public void tstEmptyConfigLocationsInMetaInf() throws Exception {
 		System.out.println("tsst");
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", ";wait-for-dependencies:=false");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		String[] configFiles = config.getConfigurationLocations();
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertEquals("1 config files", 1, configFiles.length);
 		assertEquals(OsgiBundleXmlApplicationContext.DEFAULT_CONFIG_LOCATION, configFiles[0]);
 	}
 
 	public void tstConfigLocationsInMetaInfWithHeaderAndDependencies() throws Exception {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "META-INF/spring/context.xml;wait-for-dependencies:=false");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		String[] configFiles = config.getConfigurationLocations();
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertEquals("2 config files", 1, configFiles.length);
 		assertEquals("osgibundle:META-INF/spring/context.xml", configFiles[0]);
 	}
 
 	public void tstBundleWithHeaderWithBadEntriesAndNoMetaInfResourcesIsNotSpringPowered() {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "META-INF/splurge/context.xml");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(null);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertFalse("bundle is not spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertFalse("bundle is not spring powered", config.isBlueprintConfigurationPresent());
 	}
 
 	public void tstHeaderWithWildcardEntryAndNoMetaInfResources() {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "*;wait-for-dependencies:=false");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(null);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertFalse("not spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertFalse("not spring powered", config.isBlueprintConfigurationPresent());
 	}
 
 	public void tstHeaderWithBadEntry() throws Exception {
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "META-INF/spring/context-two.xml,META-INF/splurge/context.xml,");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL("file://META-INF/spring/context-two.xml"));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertFalse("bundle is not spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertFalse("bundle is not spring powered", config.isBlueprintConfigurationPresent());
 		String[] configFiles = config.getConfigurationLocations();
 		assertEquals("0 config file", 0, configFiles.length);
 	}
 
 	public void testCreateAsynchronouslyDefaultTrue() throws Exception {
 		// *;flavour
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "*;timeout:=none");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertTrue("bundle should have create-asynchronously = true", config.isCreateAsynchronously());
 	}
 
 	public void testSetCreateAsynchronouslyTrue() {
 		// *;flavour
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "*;create-asynchronously:=true");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertTrue("bundle should have create-asynchronously = true", config.isCreateAsynchronously());
 	}
 
 	public void testSetCreateAsynchronouslyFalse() throws Exception {
 		// *;flavour
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "META-INF/spring/context.xml;create-asynchronously:=false");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
 		aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
-		assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
+		assertTrue("bundle should be Spring powered", config.isBlueprintConfigurationPresent());
 		assertFalse("bundle should have create-asynchronously = false", config.isCreateAsynchronously());
 	}
 
 	public void testCreateAsynchronouslyDefaultTrueIfAbsent() {
 		// *;flavour
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		assertTrue("bundle should have create-asynchronously = true", config.isCreateAsynchronously());
 	}
 
 	public void testCreateAsynchronouslyDefaultTrueIfGarbage() {
 		// *;flavour
-		Dictionary headers = new Hashtable();
+		Dictionary<String, Object> headers = new Hashtable<>();
 		headers.put("Spring-Context", "*;favour:=false");
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
 		aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
-		ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
+		ApplicationContextConfiguration config = new BlueprintContainerConfig(aBundle);
 		assertTrue("bundle should have create-asynchronously = true", config.isCreateAsynchronously());
 	}
 
diff --git a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java
index 33bacdf..df26a57 100644
--- a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java
+++ b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceReference.java
@@ -1,247 +1,235 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

+/*

+ Copyright (c) 2006, 2010 VMware Inc.

+ All rights reserved. This program and the accompanying materials

+ are made available under the terms of the Eclipse Public License v1.0

+ and Apache License v2.0 which accompanies this distribution.

+ The Eclipse Public License is available at

+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

+ is available at http://www.opensource.org/licenses/apache2.0.php.

+ You may elect to redistribute this code under either of these licenses.

+

+ Contributors:

+ VMware Inc.

+ */

 

 package org.eclipse.gemini.blueprint.mock;

 

+import org.osgi.framework.Bundle;

+import org.osgi.framework.Constants;

+import org.osgi.framework.ServiceReference;

+

 import java.util.Dictionary;

 import java.util.Enumeration;

 import java.util.Hashtable;

 

-import org.osgi.framework.Bundle;

-import org.osgi.framework.Constants;

-import org.osgi.framework.ServiceReference;

-import org.osgi.framework.ServiceRegistration;

+import static org.osgi.framework.Constants.OBJECTCLASS;

+import static org.osgi.framework.Constants.SERVICE_ID;

+import static org.osgi.framework.Constants.SERVICE_RANKING;

 

 /**

  * ServiceReference mock.

- * 

+ * <p>

  * <p/> This mock tries to adhere to the OSGi spec as much as possible by

  * providing the mandatory serviceId properties such as

  * {@link Constants#SERVICE_ID}, {@link Constants#OBJECTCLASS} and

  * {@link Constants#SERVICE_RANKING}.

- * 

+ *

  * @author Costin Leau

- * 

  */

-public class MockServiceReference implements ServiceReference {

+public class MockServiceReference<T> implements ServiceReference<T> {

 

-	private Bundle bundle;

+    private Bundle bundle;

+    private static long GLOBAL_SERVICE_ID = System.currentTimeMillis();

 

-	private static long GLOBAL_SERVICE_ID = System.currentTimeMillis();

+    private long serviceId;

 

-	private long serviceId;

+    // private ServiceRegistration registration;

+    private Dictionary<String, Object> properties;

 

-	// private ServiceRegistration registration;

-	private Dictionary properties;

-

-	private String[] objectClass = new String[] { Object.class.getName() };

+    private String[] objectClass = new String[]{Object.class.getName()};

 

 

-	/**

-	 * Constructs a new <code>MockServiceReference</code> instance using

-	 * defaults.

-	 */

-	public MockServiceReference() {

-		this(null, null, null);

-	}

+    /**

+     * Constructs a new <code>MockServiceReference</code> instance associated

+     * with the given bundle.

+     *

+     * @param bundle associated reference bundle

+     */

+    public MockServiceReference(Bundle bundle) {

+        this(bundle, null, null);

+    }

 

-	/**

-	 * Constructs a new <code>MockServiceReference</code> instance associated

-	 * with the given bundle.

-	 * 

-	 * @param bundle associated reference bundle

-	 */

-	public MockServiceReference(Bundle bundle) {

-		this(bundle, null, null);

-	}

+    /**

+     * Constructs a new <code>MockServiceReference</code> instance matching

+     * the given class namess.

+     *

+     * @param classes associated class names

+     */

+    public MockServiceReference(String[] classes) {

+        this(null, null, classes);

+    }

 

-	/**

-	 * Constructs a new <code>MockServiceReference</code> instance matching

-	 * the given class namess.

-	 * 

-	 * @param classes associated class names

-	 */

-	public MockServiceReference(String[] classes) {

-		this(null, null, null, classes);

+    /**

+     * Constructs a new <code>MockServiceReference</code> instance associated

+     * with the given bundle and matching the given class names.

+     *

+     * @param bundle  associated bundle

+     * @param classes matching class names

+     */

+    public MockServiceReference(Bundle bundle, String[] classes) {

+        this(bundle, null, classes);

+    }

 

-	}

+    /**

+     * Constructs a new <code>MockServiceReference</code> instance associated

+     * with the given service registration.

+     */

+    public MockServiceReference() {

+        this(null, null, null);

+    }

 

-	/**

-	 * Constructs a new <code>MockServiceReference</code> instance associated

-	 * with the given bundle and matching the given class names.

-	 * 

-	 * @param bundle associated bundle

-	 * @param classes matching class names

-	 */

-	public MockServiceReference(Bundle bundle, String[] classes) {

-		this(bundle, null, null, classes);

-	}

+    /**

+     * Constructs a new <code>MockServiceReference</code> instance associated

+     * with the given bundle, service registration and having the given service

+     * properties.

+     *

+     * @param bundle     associated bundle

+     * @param properties reference properties

+     */

+    public MockServiceReference(Bundle bundle, Dictionary properties) {

+        this(bundle, properties, null);

+    }

 

-	/**

-	 * Constructs a new <code>MockServiceReference</code> instance associated

-	 * with the given service registration.

-	 * 

-	 * @param registration service registration

-	 */

-	public MockServiceReference(ServiceRegistration registration) {

-		this(null, null, registration);

-	}

+    /**

+     * Constructs a new <code>MockServiceReference</code> instance. This

+     * constructor gives access to all the parameters of the mock service

+     * reference such as associated bundle, reference properties, service

+     * registration and reference class names.

+     *

+     * @param bundle     associated bundle

+     * @param properties reference properties

+     * @param classes    reference class names

+     */

+    public MockServiceReference(Bundle bundle, Dictionary properties, String[] classes) {

+        this.bundle = (bundle == null ? new MockBundle() : bundle);

+        // this.registration = (registration == null ? new

+        // MockServiceRegistration() :

+        // registration);

+        this.properties = (properties == null ? new Hashtable() : properties);

+        if (classes != null && classes.length > 0)

+            this.objectClass = classes;

+        addMandatoryProperties(this.properties);

+    }

 

-	/**

-	 * Constructs a new <code>MockServiceReference</code> instance associated

-	 * with the given bundle, service registration and having the given service

-	 * properties.

-	 * 

-	 * @param bundle associated bundle

-	 * @param properties reference properties

-	 * @param registration associated service registrations

-	 */

-	public MockServiceReference(Bundle bundle, Dictionary properties, ServiceRegistration registration) {

-		this(bundle, properties, registration, null);

-	}

+    private void addMandatoryProperties(Dictionary<String, Object> dict) {

+        // add mandatory properties

+        Object id = dict.get(SERVICE_ID);

+        if (id == null || !(id instanceof Long))

+            dict.put(SERVICE_ID, GLOBAL_SERVICE_ID++);

 

-	/**

-	 * Constructs a new <code>MockServiceReference</code> instance. This

-	 * constructor gives access to all the parameters of the mock service

-	 * reference such as associated bundle, reference properties, service

-	 * registration and reference class names.

-	 * 

-	 * @param bundle associated bundle

-	 * @param properties reference properties

-	 * @param registration service registration

-	 * @param classes reference class names

-	 */

-	public MockServiceReference(Bundle bundle, Dictionary properties, ServiceRegistration registration, String[] classes) {

-		this.bundle = (bundle == null ? new MockBundle() : bundle);

-		// this.registration = (registration == null ? new

-		// MockServiceRegistration() :

-		// registration);

-		this.properties = (properties == null ? new Hashtable() : properties);

-		if (classes != null && classes.length > 0)

-			this.objectClass = classes;

-		addMandatoryProperties(this.properties);

-	}

+        if (dict.get(OBJECTCLASS) == null)

+            dict.put(OBJECTCLASS, objectClass);

 

-	private void addMandatoryProperties(Dictionary dict) {

-		// add mandatory properties

-		Object id = dict.get(Constants.SERVICE_ID);

-		if (id == null || !(id instanceof Long))

-			dict.put(Constants.SERVICE_ID, new Long(GLOBAL_SERVICE_ID++));

+        Object ranking = dict.get(SERVICE_RANKING);

+        if (ranking == null || !(ranking instanceof Integer))

+            dict.put(SERVICE_RANKING, 0);

 

-		if (dict.get(Constants.OBJECTCLASS) == null)

-			dict.put(Constants.OBJECTCLASS, objectClass);

+        serviceId = (Long) dict.get(SERVICE_ID);

+    }

 

-		Object ranking = dict.get(Constants.SERVICE_RANKING);

-		if (ranking == null || !(ranking instanceof Integer))

-			dict.put(Constants.SERVICE_RANKING, new Integer(0));

+    public Bundle getBundle() {

+        return bundle;

+    }

 

-		serviceId = ((Long) dict.get(Constants.SERVICE_ID)).longValue();

-	}

+    public Object getProperty(String key) {

+        return properties.get(key);

+    }

 

-	public Bundle getBundle() {

-		return bundle;

-	}

+    public String[] getPropertyKeys() {

+        String[] keys = new String[this.properties.size()];

+        Enumeration ks = this.properties.keys();

 

-	public Object getProperty(String key) {

-		return properties.get(key);

-	}

+        for (int i = 0; i < keys.length && ks.hasMoreElements(); i++) {

+            keys[i] = (String) ks.nextElement();

+        }

 

-	public String[] getPropertyKeys() {

-		String[] keys = new String[this.properties.size()];

-		Enumeration ks = this.properties.keys();

+        return keys;

+    }

 

-		for (int i = 0; i < keys.length && ks.hasMoreElements(); i++) {

-			keys[i] = (String) ks.nextElement();

-		}

+    public Bundle[] getUsingBundles() {

+        return new Bundle[]{};

+    }

 

-		return keys;

-	}

+    public boolean isAssignableTo(Bundle bundle, String className) {

+        return false;

+    }

 

-	public Bundle[] getUsingBundles() {

-		return new Bundle[] {};

-	}

+    /**

+     * Sets the properties associated with this reference.

+     */

+    public void setProperties(Dictionary<String, ?> properties) {

+        if (properties != null) {

+            Dictionary<String, Object> copy = new Hashtable<>();

+            Enumeration<String> keys = properties.keys();

+            while (keys.hasMoreElements()) {

+                String key = keys.nextElement();

+                copy.put(key, properties.get(key));

+            }

 

-	public boolean isAssignableTo(Bundle bundle, String className) {

-		return false;

-	}

+            // copy mandatory properties

+            copy.put(SERVICE_ID, this.properties.get(SERVICE_ID));

+            copy.put(OBJECTCLASS, this.properties.get(OBJECTCLASS));

+            // optional property

+            if (copy.get(SERVICE_RANKING) == null)

+                copy.put(SERVICE_RANKING, this.properties.get(SERVICE_RANKING));

 

-	/**

-	 * Sets the properties associated with this reference.

-	 * 

-	 * @param properties

-	 */

-	public void setProperties(Dictionary properties) {

-		if (properties != null) {

-			// copy mandatory properties

-			properties.put(Constants.SERVICE_ID, this.properties.get(Constants.SERVICE_ID));

-			properties.put(Constants.OBJECTCLASS, this.properties.get(Constants.OBJECTCLASS));

-			// optional property

-			if (properties.get(Constants.SERVICE_RANKING) == null)

-				properties.put(Constants.SERVICE_RANKING, this.properties.get(Constants.SERVICE_RANKING));

+            this.properties = copy;

+        }

+    }

 

-			this.properties = properties;

-		}

-	}

+    /**

+     * Two mock service references are equal if they contain the same service

+     * id.

+     */

+    public boolean equals(Object obj) {

+        return this == obj || obj instanceof MockServiceReference && this.hashCode() == obj.hashCode();

+    }

 

-	/**

-	 * Two mock service references are equal if they contain the same service

-	 * id.

-	 */

-	public boolean equals(Object obj) {

-		if (this == obj)

-			return true;

-		if (obj instanceof MockServiceReference) {

-			return this.hashCode() == ((MockServiceReference) obj).hashCode();

-		}

-		return false;

-	}

+    /**

+     * {@inheritDoc}

+     * <p>

+     * Returns a hash code based on the class and service id.

+     */

+    public int hashCode() {

+        return MockServiceReference.class.hashCode() * 13 + (int) serviceId;

+    }

 

-	/**

-	 * {@inheritDoc}

-	 * 

-	 * Returns a hash code based on the class and service id.

-	 */

-	public int hashCode() {

-		return MockServiceReference.class.hashCode() * 13 + (int) serviceId;

-	}

+    public String toString() {

+        return "mock service reference [owning bundle id=" + bundle.hashCode() + "|props : " + properties + "]";

+    }

 

-	public String toString() {

-		return "mock service reference [owning bundle id=" + bundle.hashCode() + "|props : " + properties + "]";

-	}

+    public int compareTo(Object reference) {

+        ServiceReference other = (ServiceReference) reference;

 

-	public int compareTo(Object reference) {

-		ServiceReference other = (ServiceReference) reference;

+        // compare based on service ranking

 

-		// compare based on service ranking

+        Object ranking = this.getProperty(SERVICE_RANKING);

+        // if the property is not supplied or of incorrect type, use the default

+        int rank1 = ((ranking != null && ranking instanceof Integer) ? (Integer) ranking : 0);

+        ranking = other.getProperty(SERVICE_RANKING);

+        int rank2 = ((ranking != null && ranking instanceof Integer) ? (Integer) ranking : 0);

 

-		Object ranking = this.getProperty(Constants.SERVICE_RANKING);

-		// if the property is not supplied or of incorrect type, use the default

-		int rank1 = ((ranking != null && ranking instanceof Integer) ? ((Integer) ranking).intValue() : 0);

-		ranking = other.getProperty(Constants.SERVICE_RANKING);

-		int rank2 = ((ranking != null && ranking instanceof Integer) ? ((Integer) ranking).intValue() : 0);

+        int result = rank1 - rank2;

 

-		int result = rank1 - rank2;

+        if (result == 0) {

+            long id1 = serviceId;

+            long id2 = (Long) other.getProperty(SERVICE_ID);

 

-		if (result == 0) {

-			long id1 = serviceId;

-			long id2 = ((Long) other.getProperty(Constants.SERVICE_ID)).longValue();

+            // when comparing IDs, make sure to return inverse results (i.e. lower

+            // id, means higher service)

+            return (int) (id2 - id1);

+        }

 

-			// when comparing IDs, make sure to return inverse results (i.e. lower

-			// id, means higher service)

-			return (int) (id2 - id1);

-		}

-

-		return result;

-	}

+        return result;

+    }

 }
\ No newline at end of file
diff --git a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistration.java b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistration.java
index 0408879..964a576 100644
--- a/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistration.java
+++ b/mock/src/main/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistration.java
@@ -1,24 +1,24 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

+/*

+ Copyright (c) 2006, 2010 VMware Inc.

+ All rights reserved. This program and the accompanying materials

+ are made available under the terms of the Eclipse Public License v1.0

+ and Apache License v2.0 which accompanies this distribution.

+ The Eclipse Public License is available at

+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

+ is available at http://www.opensource.org/licenses/apache2.0.php.

+ You may elect to redistribute this code under either of these licenses.

+

+ Contributors:

+ VMware Inc.

+ */

 

 package org.eclipse.gemini.blueprint.mock;

 

-import java.util.Dictionary;

-

 import org.osgi.framework.ServiceReference;

 import org.osgi.framework.ServiceRegistration;

 

+import java.util.Dictionary;

+

 /**

  * ServiceRegistration mock.

  * 

@@ -29,9 +29,9 @@
  * @author Costin Leau

  * 

  */

-public class MockServiceRegistration implements ServiceRegistration {

+public class MockServiceRegistration<T> implements ServiceRegistration<T> {

 

-	private ServiceReference reference;

+	private ServiceReference<T> reference;

 

 

 	/**

@@ -56,15 +56,12 @@
 	/**

 	 * Constructs a new <code>MockServiceRegistration</code> instance using

 	 * the given class names and properties.

-	 * 

-	 * @param clazz

-	 * @param props

 	 */

 	public MockServiceRegistration(String[] clazz, Dictionary props) {

-		reference = new MockServiceReference(null, props, this, clazz);

+		reference = new MockServiceReference<T>(null, props, clazz);

 	}

 

-	public ServiceReference getReference() {

+	public ServiceReference<T> getReference() {

 		return reference;

 	}

 

@@ -73,13 +70,14 @@
 	 * 

 	 * @param reference service reference

 	 */

-	public void setReference(ServiceReference reference) {

+	public void setReference(ServiceReference<T> reference) {

 		this.reference = reference;

 	}

 

-	public void setProperties(Dictionary props) {

+	@Override

+	public void setProperties(Dictionary<String, ?> props) {

 		if (reference instanceof MockServiceReference)

-			((MockServiceReference) reference).setProperties(props);

+			((MockServiceReference<T>) reference).setProperties(props);

 		else

 			throw new IllegalArgumentException("cannot update properties - service reference is not a "

 					+ MockServiceReference.class.getName());

diff --git a/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceReferenceTest.java b/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceReferenceTest.java
index bf92c3f..b8cf3a8 100644
--- a/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceReferenceTest.java
+++ b/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceReferenceTest.java
@@ -1,200 +1,194 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

+/*

+ Copyright (c) 2006, 2010 VMware Inc.

+ All rights reserved. This program and the accompanying materials

+ are made available under the terms of the Eclipse Public License v1.0

+ and Apache License v2.0 which accompanies this distribution.

+ The Eclipse Public License is available at

+ http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

+ is available at http://www.opensource.org/licenses/apache2.0.php.

+ You may elect to redistribute this code under either of these licenses.

+

+ Contributors:

+ VMware Inc.

+ */

 

 package org.eclipse.gemini.blueprint.mock;

 

+import junit.framework.TestCase;

+import org.osgi.framework.Bundle;

+import org.osgi.framework.Constants;

+

 import java.util.Date;

 import java.util.Dictionary;

 import java.util.Hashtable;

-import java.util.Properties;

-

-import junit.framework.TestCase;

-

-import org.eclipse.gemini.blueprint.mock.MockBundle;

-import org.eclipse.gemini.blueprint.mock.MockServiceReference;

-import org.osgi.framework.Bundle;

-import org.osgi.framework.Constants;

 

 /**

  * @author Costin Leau

- * 

  */

 public class MockServiceReferenceTest extends TestCase {

+    MockServiceReference<?> mock;

 

-	MockServiceReference mock;

+    protected void setUp() throws Exception {

+        super.setUp();

+        mock = new MockServiceReference();

+    }

 

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#MockServiceReference()}.

+     */

+    public void testMockServiceReference() {

+        assertNotNull(mock.getBundle());

+        assertNotNull(mock.getPropertyKeys());

+    }

 

-	protected void setUp() throws Exception {

-		mock = new MockServiceReference();

-	}

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#MockServiceReference(org.osgi.framework.Bundle)}.

+     */

+    public void testMockServiceReferenceBundle() {

+        Bundle bundle = new MockBundle();

+        mock = new MockServiceReference(bundle);

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#MockServiceReference()}.

-	 */

-	public void testMockServiceReference() {

-		assertNotNull(mock.getBundle());

-		assertNotNull(mock.getPropertyKeys());

-	}

+        assertSame(bundle, mock.getBundle());

+        assertNotNull(mock.getPropertyKeys());

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#MockServiceReference(org.osgi.framework.Bundle)}.

-	 */

-	public void testMockServiceReferenceBundle() {

-		Bundle bundle = new MockBundle();

-		mock = new MockServiceReference(bundle);

+    }

 

-		assertSame(bundle, mock.getBundle());

-		assertNotNull(mock.getPropertyKeys());

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#MockServiceReference()}.

+     */

+    public void testMockServiceReferenceBundleHashtable() {

+        mock = new MockServiceReference();

+        assertNotNull(mock.getBundle());

+        assertNotNull(mock.getPropertyKeys());

+    }

 

-	}

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getBundle()}.

+     */

+    public void testGetBundle() {

+        assertNotNull(mock.getBundle());

+    }

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#MockServiceReference(org.osgi.framework.Bundle, java.util.Hashtable, org.osgi.framework.ServiceRegistration)}.

-	 */

-	public void testMockServiceReferenceBundleHashtable() {

-		mock = new MockServiceReference(null, null, null);

-		assertNotNull(mock.getBundle());

-		assertNotNull(mock.getPropertyKeys());

-	}

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getProperty(java.lang.String)}.

+     */

+    public void testGetProperty() {

+        assertNull(mock.getProperty("foo"));

+    }

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getBundle()}.

-	 */

-	public void testGetBundle() {

-		assertNotNull(mock.getBundle());

-	}

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getPropertyKeys()}.

+     */

+    public void testGetPropertyKeys() {

+        assertNotNull(mock.getPropertyKeys());

+    }

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getProperty(java.lang.String)}.

-	 */

-	public void testGetProperty() {

-		assertNull(mock.getProperty("foo"));

-	}

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getUsingBundles()}.

+     */

+    public void testGetUsingBundles() {

+        assertNotNull(mock.getUsingBundles());

+    }

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getPropertyKeys()}.

-	 */

-	public void testGetPropertyKeys() {

-		assertNotNull(mock.getPropertyKeys());

-	}

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#isAssignableTo(org.osgi.framework.Bundle, java.lang.String)}.

+     */

+    public void testIsAssignableTo() {

+        assertFalse(mock.isAssignableTo(new MockBundle(), "foo"));

+    }

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#getUsingBundles()}.

-	 */

-	public void testGetUsingBundles() {

-		assertNotNull(mock.getUsingBundles());

-	}

+    /**

+     * Test method for

+     * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#setProperties(java.util.Dictionary)}.

+     */

+    public void testSetProperties() {

+        Dictionary<String, Object> props = new Hashtable<>();

+        String key = "foo";

+        Object value = new Object();

+        props.put(key, value);

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#isAssignableTo(org.osgi.framework.Bundle, java.lang.String)}.

-	 */

-	public void testIsAssignableTo() {

-		assertFalse(mock.isAssignableTo(new MockBundle(), "foo"));

-	}

+        assertNull(mock.getProperty(key));

+        mock.setProperties(props);

+        assertSame(value, mock.getProperty(key));

+    }

 

-	/**

-	 * Test method for

-	 * {@link org.eclipse.gemini.blueprint.mock.MockServiceReference#setProperties(java.util.Dictionary)}.

-	 */

-	public void testSetProperties() {

-		Dictionary props = new Hashtable();

-		String key = "foo";

-		Object value = new Object();

-		props.put(key, value);

+    public void testMandatoryProperties() {

+        Object serviceId = mock.getProperty(Constants.SERVICE_ID);

+        assertNotNull(serviceId);

+        assertTrue(serviceId instanceof Long);

+        Object objectClass = mock.getProperty(Constants.OBJECTCLASS);

+        assertNotNull(objectClass);

+        assertTrue(objectClass instanceof String[]);

+    }

 

-		assertNull(mock.getProperty(key));

-		mock.setProperties(props);

-		assertSame(value, mock.getProperty(key));

-	}

+    public void testMandatoryPropertiesDontChange() {

+        Object serviceId = mock.getProperty(Constants.SERVICE_ID);

+        Object objectClass = mock.getProperty(Constants.OBJECTCLASS);

 

-	public void testMandatoryProperties() {

-		Object serviceId = mock.getProperty(Constants.SERVICE_ID);

-		assertNotNull(serviceId);

-		assertTrue(serviceId instanceof Long);

-		Object objectClass = mock.getProperty(Constants.OBJECTCLASS);

-		assertNotNull(objectClass);

-		assertTrue(objectClass instanceof String[]);

-	}

+        mock.setProperties(new Hashtable<>());

+        assertSame(serviceId, mock.getProperty(Constants.SERVICE_ID));

+        assertSame(objectClass, mock.getProperty(Constants.OBJECTCLASS));

 

-	public void testMandatoryPropertiesDontChange() {

-		Object serviceId = mock.getProperty(Constants.SERVICE_ID);

-		Object objectClass = mock.getProperty(Constants.OBJECTCLASS);

+        Dictionary<String, Object> anotherDict = new Hashtable<>();

+        anotherDict.put(Constants.SERVICE_ID, 1234L);

+        anotherDict.put(Constants.OBJECTCLASS, new String[]{Date.class.getName()});

+        mock.setProperties(anotherDict);

 

-		mock.setProperties(new Hashtable());

-		assertSame(serviceId, mock.getProperty(Constants.SERVICE_ID));

-		assertSame(objectClass, mock.getProperty(Constants.OBJECTCLASS));

+        assertSame(serviceId, mock.getProperty(Constants.SERVICE_ID));

+        assertSame(objectClass, mock.getProperty(Constants.OBJECTCLASS));

+    }

 

-		Dictionary anotherDict = new Hashtable();

-		anotherDict.put(Constants.SERVICE_ID, new Long(1234));

-		anotherDict.put(Constants.OBJECTCLASS, new String[] { Date.class.getName() });

-		mock.setProperties(anotherDict);

+    public void testCompareReferencesWithTheSameId() throws Exception {

+        MockServiceReference refA = createReference(1L, null);

+        MockServiceReference refB = createReference(1L, null);

 

-		assertSame(serviceId, mock.getProperty(Constants.SERVICE_ID));

-		assertSame(objectClass, mock.getProperty(Constants.OBJECTCLASS));

-	}

+        // refA is higher then refB

+        assertEquals(0, refA.compareTo(refB));

+        assertEquals(0, refB.compareTo(refA));

+    }

 

-	public void testCompareReferencesWithTheSameId() throws Exception {

-		MockServiceReference refA = createReference(new Long(1), null);

-		MockServiceReference refB = createReference(new Long(1), null);

+    public void testServiceRefsWithDifferentIdAndNoRanking() throws Exception {

+        MockServiceReference refA = createReference(1L, null);

+        MockServiceReference refB = createReference(2L, null);

 

-		// refA is higher then refB

-		assertEquals(0, refA.compareTo(refB));

-		assertEquals(0, refB.compareTo(refA));

-	}

+        // refA is higher then refB

+        // default ranking is equal

+        assertTrue(refA.compareTo(refB) > 0);

+        assertTrue(refB.compareTo(refA) < 0);

+    }

 

-	public void testServiceRefsWithDifferentIdAndNoRanking() throws Exception {

-		MockServiceReference refA = createReference(new Long(1), null);

-		MockServiceReference refB = createReference(new Long(2), null);

+    public void testServiceRefsWithDifferentIdAndDifferentRanking() throws Exception {

+        MockServiceReference refA = createReference(1L, 0);

+        MockServiceReference refB = createReference(2L, 1);

 

-		// refA is higher then refB

-		// default ranking is equal

-		assertTrue(refA.compareTo(refB) > 0);

-		assertTrue(refB.compareTo(refA) < 0);

-	}

+        // refB is higher then refA (due to ranking)

+        assertTrue(refA.compareTo(refB) < 0);

+        assertTrue(refB.compareTo(refA) > 0);

+    }

 

-	public void testServiceRefsWithDifferentIdAndDifferentRanking() throws Exception {

-		MockServiceReference refA = createReference(new Long(1), new Integer(0));

-		MockServiceReference refB = createReference(new Long(2), new Integer(1));

+    public void testServiceRefsWithSameRankAndDifId() throws Exception {

+        MockServiceReference refA = createReference(1L, 5);

+        MockServiceReference refB = createReference(2L, 5);

 

-		// refB is higher then refA (due to ranking)

-		assertTrue(refA.compareTo(refB) < 0);

-		assertTrue(refB.compareTo(refA) > 0);

-	}

+        // same ranking, means id equality applies

+        assertTrue(refA.compareTo(refB) > 0);

+        assertTrue(refB.compareTo(refA) < 0);

+    }

 

-	public void testServiceRefsWithSameRankAndDifId() throws Exception {

-		MockServiceReference refA = createReference(new Long(1), new Integer(5));

-		MockServiceReference refB = createReference(new Long(2), new Integer(5));

+    private MockServiceReference createReference(Long id, Integer ranking) {

+        Dictionary<String, Object> dict = new Hashtable<>();

+        dict.put(Constants.SERVICE_ID, id);

+        if (ranking != null)

+            dict.put(Constants.SERVICE_RANKING, ranking);

 

-		// same ranking, means id equality applies

-		assertTrue(refA.compareTo(refB) > 0);

-		assertTrue(refB.compareTo(refA) < 0);

-	}

-

-	private MockServiceReference createReference(Long id, Integer ranking) {

-		Dictionary dict = new Properties();

-		dict.put(Constants.SERVICE_ID, id);

-		if (ranking != null)

-			dict.put(Constants.SERVICE_RANKING, ranking);

-

-		return new MockServiceReference(null, dict, null);

-	}

+        return new MockServiceReference(null, dict);

+    }

 }