aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1204545 - 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/
Date Mon, 21 Nov 2011 15:41:23 GMT
Author: gnodet
Date: Mon Nov 21 15:41:22 2011
New Revision: 1204545

URL: http://svn.apache.org/viewvc?rev=1204545&view=rev
Log:
Do not use a singleton but put the ProxyManager interface available from the ExtendedBlueprintContainer

Modified:
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
    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/container/ServiceRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java?rev=1204545&r1=1204544&r2=1204545&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
Mon Nov 21 15:41:22 2011
@@ -18,13 +18,7 @@
  */
 package org.apache.aries.blueprint.container;
 
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -38,11 +32,11 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.aries.blueprint.BlueprintConstants;
-import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
 import org.apache.aries.blueprint.ExtendedServiceReferenceMetadata;
 import org.apache.aries.blueprint.di.AbstractRecipe;
 import org.apache.aries.blueprint.di.CollectionRecipe;
 import org.apache.aries.blueprint.di.Recipe;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -234,7 +228,7 @@ public abstract class AbstractServiceRef
         } else {
             //We don't use the #getBundleContextForServiceLookup() method here, the bundle
requesting the proxy is the 
             //blueprint client, not the context of the lookup
-            return BlueprintExtender.getProxyManager().createDelegatingProxy(blueprintContainer.getBundleContext().getBundle(),
interfaces, dispatcher, null);
+            return blueprintContainer.getProxyManager().createDelegatingProxy(blueprintContainer.getBundleContext().getBundle(),
interfaces, dispatcher, null);
         }
     }
 

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java?rev=1204545&r1=1204544&r2=1204545&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
Mon Nov 21 15:41:22 2011
@@ -18,8 +18,6 @@
  */
 package org.apache.aries.blueprint.container;
 
-import static org.apache.aries.blueprint.utils.ReflectionUtils.getRealCause;
-
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -33,16 +31,15 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Callable;
 
 import org.apache.aries.blueprint.BeanProcessor;
 import org.apache.aries.blueprint.ComponentDefinitionRegistry;
-import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
 import org.apache.aries.blueprint.Interceptor;
 import org.apache.aries.blueprint.di.AbstractRecipe;
 import org.apache.aries.blueprint.di.Recipe;
 import org.apache.aries.blueprint.proxy.Collaborator;
 import org.apache.aries.blueprint.proxy.ProxyUtils;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.apache.aries.blueprint.utils.ReflectionUtils.PropertyDescriptor;
 import org.osgi.framework.Bundle;
@@ -54,6 +51,8 @@ import org.osgi.service.blueprint.reflec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.aries.blueprint.utils.ReflectionUtils.getRealCause;
+
 /**
  * A <code>Recipe</code> to create POJOs.
  *
@@ -687,7 +686,7 @@ public class BeanRecipe extends Abstract
                 // we have a class from the framework parent, so use our bundle for proxying.
                 b = blueprintContainer.getBundleContext().getBundle();
               }
-              intercepted = BlueprintExtender.getProxyManager().createInterceptingProxy(b,

+              intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
                   ProxyUtils.asList(original.getClass()), original, 
                   new Collaborator(interceptorLookupKey, interceptors));
             } catch (org.apache.aries.proxy.UnableToProxyException e) {

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=1204545&r1=1204544&r2=1204545&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
Mon Nov 21 15:41:22 2011
@@ -64,6 +64,7 @@ import org.apache.aries.blueprint.reflec
 import org.apache.aries.blueprint.utils.HeaderParser;
 import org.apache.aries.blueprint.utils.JavaUtils;
 import org.apache.aries.blueprint.utils.HeaderParser.PathElement;
+import org.apache.aries.proxy.ProxyManager;
 import org.apache.aries.util.AriesFrameworkUtil;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -146,8 +147,10 @@ public class BlueprintContainerImpl 
     private List<ServiceRecipe> services;
     private AccessControlContext accessControlContext;
     private final IdSpace tempRecipeIdSpace = new IdSpace();
-    
-    public BlueprintContainerImpl(BundleContext bundleContext, Bundle extenderBundle, BlueprintListener
eventDispatcher, NamespaceHandlerRegistry handlers, ScheduledExecutorService executors, List<Object>
pathList) {
+    private ProxyManager proxyManager;
+
+    public BlueprintContainerImpl(BundleContext bundleContext, Bundle extenderBundle, BlueprintListener
eventDispatcher,
+                                  NamespaceHandlerRegistry handlers, ScheduledExecutorService
executors, List<Object> pathList, ProxyManager proxyManager) {
         this.bundleContext = bundleContext;
         this.extenderBundle = extenderBundle;
         this.eventDispatcher = eventDispatcher;
@@ -160,12 +163,17 @@ public class BlueprintContainerImpl 
         if (System.getSecurityManager() != null) {
             this.accessControlContext = createAccessControlContext();
         }
+        this.proxyManager = proxyManager;
     }
 
     public Bundle getExtenderBundle() {
         return extenderBundle;
     }
 
+    public ProxyManager getProxyManager() {
+        return proxyManager;
+    }
+
     public <T extends Processor> List<T> getProcessors(Class<T> clazz)
{
         List<T> p = new ArrayList<T>();
         for (Processor processor : processors) {

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=1204545&r1=1204544&r2=1204545&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 Nov 21 15:41:22 2011
@@ -78,7 +78,7 @@ public class BlueprintExtender implement
     private RecursiveBundleTracker bt;
     private ServiceRegistration parserServiceReg;
     private ServiceRegistration quiesceParticipantReg;
-    private static SingleServiceTracker<ProxyManager> proxyManager;
+    private SingleServiceTracker<ProxyManager> proxyManager;
     
     public void start(BundleContext ctx) {
         LOGGER.debug("Starting blueprint extender...");
@@ -178,14 +178,6 @@ public class BlueprintExtender implement
         LOGGER.debug("Blueprint extender stopped");
     }
     
-    /**
-     * @return the proxy manager. This will return null if the blueprint is not yet managing
bundles.
-     */
-    public static ProxyManager getProxyManager()
-    {
-      return proxyManager.getService();
-    }
-
     private List<Bundle> getBundlesToDestroy() {
         List<Bundle> bundlesToDestroy = new ArrayList<Bundle>();
         for (Bundle bundle : containers.keySet()) {
@@ -315,7 +307,7 @@ public class BlueprintExtender implement
                 // ServiceReference, or just not do this check, which could be quite harmful.
                 boolean compatible = isCompatible(bundle);
                 if (compatible) {
-                    final BlueprintContainerImpl blueprintContainer = new BlueprintContainerImpl(bundle.getBundleContext(),
context.getBundle(), eventDispatcher, handlers, executors, pathList);
+                    final BlueprintContainerImpl blueprintContainer = new BlueprintContainerImpl(bundle.getBundleContext(),
context.getBundle(), eventDispatcher, handlers, executors, pathList, proxyManager.getService());
                     containers.put(bundle, blueprintContainer);
                     String val = context.getProperty("org.apache.aries.blueprint.synchronous");
                     if (Boolean.parseBoolean(val)) {

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java?rev=1204545&r1=1204544&r2=1204545&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
Mon Nov 21 15:41:22 2011
@@ -45,7 +45,6 @@ import org.apache.aries.blueprint.utils.
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.apache.aries.blueprint.utils.ServiceListener;
 import org.apache.aries.proxy.InvocationListener;
-import org.apache.aries.proxy.UnableToProxyException;
 import org.apache.aries.util.AriesFrameworkUtil;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -491,7 +490,7 @@ public class ServiceRecipe extends Abstr
                 }
                 InvocationListener collaborator = new Collaborator(cm, interceptors);
 
-                intercepted = BlueprintExtender.getProxyManager().createInterceptingProxy(b,

+                intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
                         getClassesForProxying(), original, collaborator);
             } catch (Exception u) {
                 Bundle b = blueprintContainer.getBundleContext().getBundle();

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java?rev=1204545&r1=1204544&r2=1204545&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/services/ExtendedBlueprintContainer.java
Mon Nov 21 15:41:22 2011
@@ -22,8 +22,8 @@ import java.util.List;
 
 import org.apache.aries.blueprint.ComponentDefinitionRegistry;
 import org.apache.aries.blueprint.Processor;
-import org.apache.aries.blueprint.container.ServiceRecipe;
 import org.apache.aries.blueprint.di.Repository;
+import org.apache.aries.proxy.ProxyManager;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -62,5 +62,7 @@ public interface ExtendedBlueprintContai
     AccessControlContext getAccessControlContext();
 
     void reload();
+
+    ProxyManager getProxyManager();
             
 }

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=1204545&r1=1204544&r2=1204545&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
Mon Nov 21 15:41:22 2011
@@ -27,7 +27,7 @@ public class TestBlueprintContainer exte
     private ComponentDefinitionRegistryImpl registry;
     
     public TestBlueprintContainer(ComponentDefinitionRegistryImpl registry) {
-        super(new TestBundleContext(), null, null, null, null, null);
+        super(new TestBundleContext(), null, null, null, null, null, null);
         this.registry = registry;
         if (registry != null) {
             registry.registerComponentDefinition(new PassThroughMetadataImpl("blueprintContainer",
this));



Mime
View raw message