Author: sergeyb
Date: Mon Oct 21 16:07:54 2013
New Revision: 1534260
URL: http://svn.apache.org/r1534260
Log:
[ARIES-1121] Initial code for BlueprintExtenderService
Added:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
(with props)
Modified:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
Modified:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
URL:
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java?rev=1534260&r1=1534259&r2=1534260&view=diff
==============================================================================
---
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
(original)
+++
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
Mon Oct 21 16:07:54 2013
@@ -32,6 +32,7 @@ import java.util.concurrent.*;
import org.apache.aries.blueprint.BlueprintConstants;
import
org.apache.aries.blueprint.annotation.service.BlueprintAnnotationScanner;
import org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl;
+import org.apache.aries.blueprint.services.BlueprintExtenderService;
import org.apache.aries.blueprint.services.ParserService;
import org.apache.aries.blueprint.utils.HeaderParser;
import org.apache.aries.blueprint.utils.HeaderParser.PathElement;
@@ -75,6 +76,7 @@ public class BlueprintExtender implement
private NamespaceHandlerRegistry handlers;
private RecursiveBundleTracker bt;
private ServiceRegistration parserServiceReg;
+ private ServiceRegistration blueprintServiceReg;
private ServiceRegistration quiesceParticipantReg;
private SingleServiceTracker<ProxyManager> proxyManager;
private ExecutorServiceFinder executorServiceFinder;
@@ -125,6 +127,12 @@ public class BlueprintExtender implement
new ParserServiceImpl (handlers),
new Hashtable<String, Object>());
+ // Create and publish a BlueprintContainerService
+ blueprintServiceReg = ctx.registerService(
+ BlueprintExtenderService.class.getName(),
+ new BlueprintContainerServiceImpl(),
+ new Hashtable<String, Object>());
+
try{
ctx.getBundle().loadClass(QUIESCE_PARTICIPANT_CLASS);
//Class was loaded, register
@@ -147,7 +155,7 @@ public class BlueprintExtender implement
stopping = true;
AriesFrameworkUtil.safeUnregisterService(parserServiceReg);
-
+ AriesFrameworkUtil.safeUnregisterService(blueprintServiceReg);
AriesFrameworkUtil.safeUnregisterService(quiesceParticipantReg);
// Orderly shutdown of containers
@@ -233,9 +241,13 @@ public class BlueprintExtender implement
}
private boolean createContainer(Bundle bundle) {
- try {
- List<Object> paths = getBlueprintPaths(bundle);
- if (paths == null) {
+ List<Object> paths = getBlueprintPaths(bundle);
+ return createContainer(bundle, paths);
+ }
+
+ private boolean createContainer(Bundle bundle, List<Object> paths) {
+ try {
+ if (paths == null || paths.isEmpty()) {
// This bundle is not a blueprint bundle, so ignore it
return false;
}
@@ -532,5 +544,39 @@ public class BlueprintExtender implement
{
return containers.get(bundle);
}
+
+ private class BlueprintContainerServiceImpl implements
BlueprintExtenderService {
+
+ public BlueprintContainer createContainer(Bundle bundle) {
+ if (BlueprintExtender.this.createContainer(bundle)) {
+ return getContainer(bundle);
+ } else {
+ return null;
+ }
+ }
+
+ public BlueprintContainer createContainer(Bundle bundle, List<Object>
blueprintPaths) {
+ if (BlueprintExtender.this.createContainer(bundle,
blueprintPaths)) {
+ return getContainer(bundle);
+ } else {
+ return null;
+ }
+ }
+
+ public void destroyContainer(Bundle bundle, BlueprintContainer
container) {
+ BlueprintContainer bundleContainer = getContainer(bundle);
+ if (bundleContainer != container) {
+ String error = "Unexpected Blueprint Container";
+ LOGGER.error(error);
+ throw new IllegalArgumentException(error);
+ }
+ BlueprintExtender.this.destroyContainer(bundle);
+ }
+
+ public BlueprintContainer getContainer(Bundle bundle) {
+ return BlueprintExtender.this.getBlueprintContainerImpl(bundle);
+ }
+
+ }
}
Added:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
URL:
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java?rev=1534260&view=auto
==============================================================================
---
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
(added)
+++
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
Mon Oct 21 16:07:54 2013
@@ -0,0 +1,39 @@
+package org.apache.aries.blueprint.services;
+
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+
+public interface BlueprintExtenderService {
+
+ /**
+ * Create Blueprint container for the application bundle
+ * @param bundle the application bundle
+ * @return container
+ */
+ BlueprintContainer createContainer(Bundle bundle);
+
+ /**
+ * Create Blueprint container for the application bundle using a list of
Blueprint resources
+ * @param bundle the application bundle
+ * @param blueprintPaths the application blueprint resources
+ * @return container
+ */
+ BlueprintContainer createContainer(Bundle bundle, List<Object>
blueprintPaths);
+
+ /**
+ * Get an existing container for the application bundle
+ * @param bundle the application bundle
+ * @return container
+ */
+ BlueprintContainer getContainer(Bundle bundle);
+
+ /**
+ * Destroy Blueprint container for the application bundle
+ * @param bundle the application bundle
+ * @param container the container
+ */
+ void destroyContainer(Bundle bundle, BlueprintContainer container);
+}
+
Propchange:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date