geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r783038 - in /geronimo/sandbox/blueprint: blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ blueprint-core/src/main/java/org/apache/geronimo/bluepri...
Date Tue, 09 Jun 2009 15:29:40 GMT
Author: gnodet
Date: Tue Jun  9 15:29:37 2009
New Revision: 783038

URL: http://svn.apache.org/viewvc?rev=783038&view=rev
Log:
Fix findbug problems and tests

Modified:
    geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedServiceFactory.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/BundleDelegatingClassLoader.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java

Modified: geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedServiceFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedServiceFactory.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedServiceFactory.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedServiceFactory.java
Tue Jun  9 15:29:37 2009
@@ -272,7 +272,7 @@
         Method method = null;        
         if (componentDestroyMethod != null && componentDestroyMethod.length() >
0) {
             List<Method> methods = ReflectionUtils.findCompatibleMethods(clazz, componentDestroyMethod,
new Class [] { int.class });
-            if (methods != null & !methods.isEmpty()) {
+            if (methods != null && !methods.isEmpty()) {
                 method = methods.get(0);
             }
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
Tue Jun  9 15:29:37 2009
@@ -80,7 +80,7 @@
     private final AtomicBoolean started = new AtomicBoolean();
     private final AtomicBoolean satisfied = new AtomicBoolean();
     private SatisfactionListener satisfactionListener;
-    private ProxyFactory proxyFactory;
+    private volatile ProxyFactory proxyFactory;
 
     protected AbstractServiceReferenceRecipe(String name,
                                              ExtendedBlueprintContainer blueprintContainer,
@@ -95,6 +95,7 @@
         this.explicitDependencies = explicitDependencies;
         // Create a ClassLoader delegating to the bundle, but also being able to see our
bundle classes
         // so that the created proxy can access cglib classes.
+        // TODO: use a doPrivileged block 
         this.proxyClassLoader = new BundleDelegatingClassLoader(blueprintContainer.getBundleContext().getBundle(),
                                                                 getClass().getClassLoader());
         
@@ -191,32 +192,28 @@
         return getProxyFactory().createProxy(proxyClassLoader, toClassArray(loadAllClasses(interfaces)),
dispatcher);
     }
 
-    protected ProxyFactory getProxyFactory() throws ClassNotFoundException {
+    protected synchronized ProxyFactory getProxyFactory() throws ClassNotFoundException {
         if (proxyFactory == null) {
-            synchronized (this) {
-                if (proxyFactory == null) {
-                    boolean proxyClass = false;
-                    if (metadata instanceof ExtendedServiceReferenceMetadata) {
-                        proxyClass = (((ExtendedServiceReferenceMetadata) metadata).getProxyMethod()
& ExtendedServiceReferenceMetadata.PROXY_METHOD_CLASSES) != 0;
-                    }
-                    List<Class> classes = loadAllClasses(this.metadata.getInterfaceNames());
-                    if (!proxyClass) {
-                        for (Class cl : classes) {
-                            if (!cl.isInterface()) {
-                                throw new ComponentDefinitionException("A class " + cl.getName()
+ " was found in the interfaces list, but class proxying is not allowed by default. The ext:proxy-method='class'
attribute needs to be added to this service reference.");
-                            }
-                        }
-                    }
-                    try {
-                        proxyFactory = new CgLibProxyFactory();
-                    } catch (Throwable t) {
-                        if (proxyClass) {
-                            throw new ComponentDefinitionException("Class proxying has been
enabled but cglib can not be used", t);
-                        }
-                        proxyFactory = new JdkProxyFactory();
+            boolean proxyClass = false;
+            if (metadata instanceof ExtendedServiceReferenceMetadata) {
+                proxyClass = (((ExtendedServiceReferenceMetadata) metadata).getProxyMethod()
& ExtendedServiceReferenceMetadata.PROXY_METHOD_CLASSES) != 0;
+            }
+            List<Class> classes = loadAllClasses(this.metadata.getInterfaceNames());
+            if (!proxyClass) {
+                for (Class cl : classes) {
+                    if (!cl.isInterface()) {
+                        throw new ComponentDefinitionException("A class " + cl.getName()
+ " was found in the interfaces list, but class proxying is not allowed by default. The ext:proxy-method='class'
attribute needs to be added to this service reference.");
                     }
                 }
             }
+            try {
+                proxyFactory = new CgLibProxyFactory();
+            } catch (Throwable t) {
+                if (proxyClass) {
+                    throw new ComponentDefinitionException("Class proxying has been enabled
but cglib can not be used", t);
+                }
+                proxyFactory = new JdkProxyFactory();
+            }
         }
         return proxyFactory;
     }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
Tue Jun  9 15:29:37 2009
@@ -404,8 +404,8 @@
     private void trackServiceReferences() {
         Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
         Set<String> satisfiables = new HashSet<String>();
-        for (String name : dependencies.keySet()) {
-            for (SatisfiableRecipe satisfiable : dependencies.get(name)) {
+        for (List<SatisfiableRecipe> recipes : dependencies.values()) {
+            for (SatisfiableRecipe satisfiable : recipes) {
                 if (satisfiables.add(satisfiable.getName())) {
                     satisfiable.start(this);
                 }
@@ -418,8 +418,8 @@
         Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
         if (dependencies != null) {
             Set<String> satisfiables = new HashSet<String>();
-            for (String name : dependencies.keySet()) {
-                for (SatisfiableRecipe satisfiable : dependencies.get(name)) {
+            for (List<SatisfiableRecipe> recipes : dependencies.values()) {
+                for (SatisfiableRecipe satisfiable : recipes) {
                     if (satisfiables.add(satisfiable.getName())) {
                         satisfiable.stop();
                     }
@@ -430,8 +430,8 @@
 
     private boolean checkAllSatisfiables() {
         Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
-        for (String name : dependencies.keySet()) {
-            for (SatisfiableRecipe recipe : dependencies.get(name)) {
+        for (List<SatisfiableRecipe> recipes : dependencies.values()) {
+            for (SatisfiableRecipe recipe : recipes) {
                 if (!recipe.isSatisfied()) {
                     return false;
                 }
@@ -445,13 +445,14 @@
                 new Object[] { satisfiable.getName(), bundleContext.getBundle().getSymbolicName(),
satisfiable.isSatisfied() });
         if (state == State.Create || state == State.Created ) {
             Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
-            for (String name : dependencies.keySet()) {
+            for (Map.Entry<String, List<SatisfiableRecipe>> entry : dependencies.entrySet())
{
+                String name = entry.getKey();
                 ComponentMetadata metadata = componentDefinitionRegistry.getComponentDefinition(name);
                 if (metadata instanceof ServiceMetadata) {
                     ServiceRecipe reg = (ServiceRecipe) instantiator.getRepository().getRecipe(name);
                     synchronized (reg) {
                         boolean satisfied = true;
-                        for (SatisfiableRecipe recipe : dependencies.get(name)) {
+                        for (SatisfiableRecipe recipe : entry.getValue()) {
                             if (!recipe.isSatisfied()) {
                                 satisfied = false;
                                 break;
@@ -534,8 +535,8 @@
         List<String> missing = new ArrayList<String>();
         Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
         Set<SatisfiableRecipe> recipes = new HashSet<SatisfiableRecipe>();
-        for (String name : dependencies.keySet()) {
-            for (SatisfiableRecipe recipe : dependencies.get(name)) {
+        for (List<SatisfiableRecipe> deps : dependencies.values()) {
+            for (SatisfiableRecipe recipe : deps) {
                 if (!recipe.isSatisfied()) {
                     recipes.add(recipe);
                 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
Tue Jun  9 15:29:37 2009
@@ -197,7 +197,7 @@
      * The ServiceDispatcher is used when creating the cglib proxy.
      * Thic class is responsible for getting the actual service that will be used.
      */
-    public class ServiceDispatcher implements Callable<Object> {
+    public static class ServiceDispatcher implements Callable<Object> {
 
         public ServiceReference reference;
         public Object service;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
Tue Jun  9 15:29:37 2009
@@ -199,35 +199,33 @@
         return getService(blueprintContainer.getBundleContext().getBundle(), null);
     }
 
-    public Object getService(Bundle bundle, ServiceRegistration registration) {
+    public synchronized Object getService(Bundle bundle, ServiceRegistration registration)
{
         LOGGER.debug("Retrieving service for bundle {} and service registration {}", bundle,
registration);
         // Create initial service
-        synchronized (this) {
-            if (this.service == null) {
-                try {
-                    prototypeService = isPrototypeService(metadata.getServiceComponent());
-                    LOGGER.debug("Creating service instance");
-                    this.service = createInstance();
-                    LOGGER.debug("Service created: {}", this.service);
-                    // When the service is first requested, we need to create listeners and
call them
-                    if (listeners == null) {
-                        LOGGER.debug("Creating listeners");
-                        if (listenersRecipe != null) {
-                            listeners = (List) createSimpleRecipe(listenersRecipe);
-                        } else {
-                            listeners = Collections.emptyList();
-                        }
-                        LOGGER.debug("Listeners created: {}", listeners);
-                        LOGGER.debug("Calling listeners for service registration");
-                        for (ServiceListener listener : listeners) {
-                            listener.register(prototypeService || service instanceof ServiceFactory
? null : service,
-                                              registrationProperties);
-                        }
+        if (this.service == null) {
+            try {
+                prototypeService = isPrototypeService(metadata.getServiceComponent());
+                LOGGER.debug("Creating service instance");
+                this.service = createInstance();
+                LOGGER.debug("Service created: {}", this.service);
+                // When the service is first requested, we need to create listeners and call
them
+                if (listeners == null) {
+                    LOGGER.debug("Creating listeners");
+                    if (listenersRecipe != null) {
+                        listeners = (List) createSimpleRecipe(listenersRecipe);
+                    } else {
+                        listeners = Collections.emptyList();
+                    }
+                    LOGGER.debug("Listeners created: {}", listeners);
+                    LOGGER.debug("Calling listeners for service registration");
+                    for (ServiceListener listener : listeners) {
+                        listener.register(prototypeService || service instanceof ServiceFactory
? null : service,
+                                          registrationProperties);
                     }
-                } catch (RuntimeException e) {
-                    LOGGER.error("Error retrieving service from " + this, e);
-                    throw e;
                 }
+            } catch (RuntimeException e) {
+                LOGGER.error("Error retrieving service from " + this, e);
+                throw e;
             }
         }
         Object service = this.service;
@@ -243,7 +241,7 @@
         return service;
     }
 
-    public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
{
+    public synchronized void ungetService(Bundle bundle, ServiceRegistration registration,
Object service) {
         if (this.service instanceof ServiceFactory) {
             ((ServiceFactory) this.service).ungetService(bundle, registration, service);
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
Tue Jun  9 15:29:37 2009
@@ -21,6 +21,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.io.Serializable;
 
 import org.osgi.service.blueprint.reflect.BeanArgument;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
@@ -184,7 +185,7 @@
         return arguments;
     }
     
-    private static class BeanArgumentComparator implements Comparator<BeanArgument>
{
+    private static class BeanArgumentComparator implements Comparator<BeanArgument>,
Serializable {
         public int compare(BeanArgument object1, BeanArgument object2) {
             return object1.getIndex() - object2.getIndex();
         }        

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/BundleDelegatingClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/BundleDelegatingClassLoader.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/BundleDelegatingClassLoader.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/BundleDelegatingClassLoader.java
Tue Jun  9 15:29:37 2009
@@ -49,7 +49,7 @@
     }
 
     protected URL findResource(String name) {
-        URL resource = findResource(name);
+        URL resource = bundle.getResource(name);
         if (classLoader != null && resource == null) {
             resource = classLoader.getResource(name);
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java?rev=783038&r1=783037&r2=783038&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
Tue Jun  9 15:29:37 2009
@@ -133,7 +133,7 @@
     }
     
     public void testCompoundProperties() throws Exception {
-        ComponentDefinitionRegistryImpl registry = parse("/test-wiring-on.xml");
+        ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
         BlueprintObjectInstantiator graph = new TestBlueprintContainer(registry).getInstantiator();
         
         Object obj5 = graph.create("compound");



Mime
View raw message