aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1723022 - in /aries/trunk/blueprint/blueprint-core/src: main/java/org/apache/aries/blueprint/container/ main/java/org/apache/aries/blueprint/services/ test/java/org/apache/aries/blueprint/ test/java/org/apache/aries/blueprint/container/
Date Tue, 05 Jan 2016 09:30:44 GMT
Author: gnodet
Date: Tue Jan  5 09:30:44 2016
New Revision: 1723022

URL: http://svn.apache.org/viewvc?rev=1723022&view=rev
Log:
[ARIES-1482] Support programmatic creation of blueprint container with specific additional
namespaces

Modified:
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java?rev=1723022&r1=1723021&r2=1723022&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
Tue Jan  5 09:30:44 2016
@@ -140,6 +140,7 @@ public class BlueprintContainerImpl
     private final AggregateConverter converter;
     private final ExecutorService executors;
     private final ScheduledExecutorService timer;
+    private final Collection<URI> additionalNamespaces;
     private Set<URI> namespaces;
     private State state = State.Unknown;
     private NamespaceHandlerSet handlerSet;
@@ -162,7 +163,7 @@ public class BlueprintContainerImpl
 
     public BlueprintContainerImpl(Bundle bundle, BundleContext bundleContext, Bundle extenderBundle,
BlueprintListener eventDispatcher,
                                   NamespaceHandlerRegistry handlers, ExecutorService executor,
ScheduledExecutorService timer,
-                                  List<Object> pathList, ProxyManager proxyManager)
{
+                                  List<Object> pathList, ProxyManager proxyManager,
Collection<URI> namespaces) {
         this.bundle = bundle;
         this.bundleContext = bundleContext;
         this.extenderBundle = extenderBundle;
@@ -180,6 +181,7 @@ public class BlueprintContainerImpl
             this.accessControlContext = null;
         }
         this.proxyManager = proxyManager;
+        this.additionalNamespaces = namespaces;
     }
 
     public ExecutorService getExecutors() {
@@ -301,6 +303,9 @@ public class BlueprintContainerImpl
                         parser = new Parser();
                         parser.parse(getResources());
                         namespaces = parser.getNamespaces();
+                        if (additionalNamespaces != null) {
+                            namespaces.addAll(additionalNamespaces);
+                        }
                         handlerSet = handlers.getNamespaceHandlers(namespaces, getBundle());
                         handlerSet.addListener(this);
                         state = State.WaitForNamespaceHandlers;

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=1723022&r1=1723021&r2=1723022&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
Tue Jan  5 09:30:44 2016
@@ -20,8 +20,10 @@ package org.apache.aries.blueprint.conta
 
 import java.io.File;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Enumeration;
@@ -264,7 +266,11 @@ public class BlueprintExtender implement
     }
 
     private boolean createContainer(Bundle bundle, List<Object> paths) {
-    try {
+        return createContainer(bundle, paths, null);
+    }
+
+    private boolean createContainer(Bundle bundle, List<Object> paths, Collection<URI>
namespaces) {
+        try {
             if (paths == null || paths.isEmpty()) {
                 // This bundle is not a blueprint bundle, so ignore it
                 return false;
@@ -282,7 +288,7 @@ public class BlueprintExtender implement
             BlueprintContainerImpl blueprintContainer = new BlueprintContainerImpl(bundle,
bundleContext,
                                                                 context.getBundle(), eventDispatcher,
                                                                 handlers, getExecutorService(bundle),
-                                                                executors, paths, pm);
+                                                                executors, paths, pm, namespaces);
             synchronized (containers) {
                 if (containers.putIfAbsent(bundle, blueprintContainer) != null) {
                     return false;
@@ -597,6 +603,14 @@ public class BlueprintExtender implement
                 return getContainer(bundle);
             } else {
                 return null;
+            }
+        }
+
+        public BlueprintContainer createContainer(Bundle bundle, List<Object> blueprintPaths,
Collection<URI> namespaces) {
+            if (BlueprintExtender.this.createContainer(bundle, blueprintPaths, namespaces))
{
+                return getContainer(bundle);
+            } else {
+                return null;
             }
         }
 

Modified: 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=1723022&r1=1723021&r2=1723022&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/BlueprintExtenderService.java
Tue Jan  5 09:30:44 2016
@@ -16,6 +16,8 @@
  */
 package org.apache.aries.blueprint.services;
 
+import java.net.URI;
+import java.util.Collection;
 import java.util.List;
 
 import org.osgi.framework.Bundle;
@@ -35,10 +37,19 @@ public interface BlueprintExtenderServic
      * @param bundle the application bundle
      * @param blueprintPaths the application blueprint resources
      * @return container
-     */    
+     */
     BlueprintContainer createContainer(Bundle bundle, List<Object> blueprintPaths);
 
     /**
+     * Create Blueprint container for the application bundle using a list of Blueprint resources
+     * @param bundle the application bundle
+     * @param blueprintPaths the application blueprint resources
+     * @param namespaces additional namespaces to force reference to
+     * @return container
+     */
+    BlueprintContainer createContainer(Bundle bundle, List<Object> blueprintPaths,
Collection<URI> namespaces);
+
+    /**
      * Get an existing container for the application bundle
      * @param bundle the application bundle
      * @return container

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java?rev=1723022&r1=1723021&r2=1723022&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java
Tue Jan  5 09:30:44 2016
@@ -44,7 +44,7 @@ public class TestBlueprintContainer exte
     }
 
     public TestBlueprintContainer(ComponentDefinitionRegistryImpl registry, ProxyManager
proxyManager) throws Exception {
-        super(null, new TestBundleContext(), null, null, null, null, null, null, proxyManager);
+        super(null, new TestBundleContext(), null, null, null, null, null, null, proxyManager,
null);
         this.registry = registry;
         if (registry != null) {
             registry.registerComponentDefinition(new PassThroughMetadataImpl("blueprintContainer",
this));

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java?rev=1723022&r1=1723021&r2=1723022&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java
Tue Jan  5 09:30:44 2016
@@ -120,7 +120,7 @@ public class BeanRecipeTest {
 
     @Test
     public void parameterWithGenerics() throws Exception {
-        BlueprintContainerImpl container = new BlueprintContainerImpl(null, null, null, null,
null, null, null, null, null);
+        BlueprintContainerImpl container = new BlueprintContainerImpl(null, null, null, null,
null, null, null, null, null, null);
         BeanRecipe recipe = new BeanRecipe("example", container, ExampleService.class, false);
         recipe.setArguments(Arrays.<Object>asList(new ExampleImpl()));
         recipe.setArgTypes(Arrays.<String>asList((String) null));
@@ -195,7 +195,7 @@ public class BeanRecipeTest {
 
     @Test
     public void protectedClassAccess() throws Exception {
-        BlueprintContainerImpl container = new BlueprintContainerImpl(null, null, null, null,
null, null, null, null, null);
+        BlueprintContainerImpl container = new BlueprintContainerImpl(null, null, null, null,
null, null, null, null, null, null);
         BeanRecipe recipe = new BeanRecipe("a", container, null, false);
         recipe.setFactoryComponent(new PassThroughRecipe("factory", new Factory().create()));
         recipe.setFactoryMethod("getA");



Mime
View raw message