geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r775871 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache: geronimo/blueprint/ geronimo/blueprint/context/ xbean/recipe/
Date Mon, 18 May 2009 09:25:20 GMT
Author: gnodet
Date: Mon May 18 09:25:18 2009
New Revision: 775871

URL: http://svn.apache.org/viewvc?rev=775871&view=rev
Log:
Remove dependency from BlueprintContextEventSender to BundleContext (switch to Bundle instead)
Make ConstructionException inherit from ComponentDefinitionException
Check ref / idref before after recipe creation
Tweak signature disambiguation to adhere more to the TCK

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultBlueprintContextEventSender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ConstructionException.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintContextEventSender.java
Mon May 18 09:25:18 2009
@@ -18,7 +18,7 @@
  */
 package org.apache.geronimo.blueprint;
 
-import org.osgi.service.blueprint.context.BlueprintContext;
+import org.osgi.framework.Bundle;
 
 /**
  * Interface used to send events related to blueprint context life cycle.
@@ -28,12 +28,12 @@
  */
 public interface BlueprintContextEventSender extends Destroyable {
 
-    void sendCreating(BlueprintContext blueprintContext);
-    void sendCreated(BlueprintContext blueprintContext);
-    void sendDestroying(BlueprintContext blueprintContext);
-    void sendDestroyed(BlueprintContext blueprintContext);
-    void sendWaiting(BlueprintContext blueprintContext, String[] serviceObjectClass, String
serviceFilter);
-    void sendFailure(BlueprintContext blueprintContext, Throwable cause);
-    void sendFailure(BlueprintContext blueprintContext, Throwable cause, String[] serviceObjectClass,
String serviceFilter);
+    void sendCreating(Bundle bundle);
+    void sendCreated(Bundle bundle);
+    void sendDestroying(Bundle bundle);
+    void sendDestroyed(Bundle bundle);
+    void sendWaiting(Bundle bundle, String[] serviceObjectClass, String serviceFilter);
+    void sendFailure(Bundle bundle, Throwable cause);
+    void sendFailure(Bundle bundle, Throwable cause, String[] serviceObjectClass, String
serviceFilter);
 
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java
Mon May 18 09:25:18 2009
@@ -117,46 +117,51 @@
     
     private void checkBundle(Bundle bundle, boolean lazyActivation) {
         LOGGER.debug("Scanning bundle {} for blueprint application (lazy: {})", bundle.getSymbolicName(),
lazyActivation);
-
-        List<URL> urls = new ArrayList<URL>();
-        Dictionary headers = bundle.getHeaders();
-        String blueprintHeader = (String)headers.get(BlueprintConstants.BUNDLE_BLUEPRINT_HEADER);
-        if (blueprintHeader != null) {
-            List<PathElement> paths = HeaderParser.parseHeader(blueprintHeader);
-            for (PathElement path : paths) {
-                URL url = bundle.getEntry(path.getName());
-                if (url != null) {
-                    urls.add(url);
+        try {
+            List<URL> urls = new ArrayList<URL>();
+            Dictionary headers = bundle.getHeaders();
+            String blueprintHeader = (String)headers.get(BlueprintConstants.BUNDLE_BLUEPRINT_HEADER);
+            if (blueprintHeader != null) {
+                List<PathElement> paths = HeaderParser.parseHeader(blueprintHeader);
+                for (PathElement path : paths) {
+                    URL url = bundle.getEntry(path.getName());
+                    if (url != null) {
+                        urls.add(url);
+                    } else {
+                        throw new IllegalArgumentException("Unable to find bundle entry for
config file " + path.getName());
+                    }
                 }
             }
-        }
-        if (urls.isEmpty()) {
-            Enumeration e = bundle.findEntries("OSGI-INF/blueprint", "*.xml", false);
-            if (e != null) {
-                while (e.hasMoreElements()) {
-                    URL u = (URL) e.nextElement();
-                    urls.add(u);
+            if (urls.isEmpty()) {
+                Enumeration e = bundle.findEntries("OSGI-INF/blueprint", "*.xml", false);
+                if (e != null) {
+                    while (e.hasMoreElements()) {
+                        URL u = (URL) e.nextElement();
+                        urls.add(u);
+                    }
                 }
             }
-        }
-        if (!urls.isEmpty()) {
-            LOGGER.debug("Found blueprint application in bundle {} with urls: {}", bundle.getSymbolicName(),
urls);
+            if (!urls.isEmpty()) {
+                LOGGER.debug("Found blueprint application in bundle {} with urls: {}", bundle.getSymbolicName(),
urls);
+
+                // Check compatibility
+                // XXX: we can't check compatibility when dealing with lazy activated bundles
since that will trigger
+                // the bundle to be fully started
+                boolean compatible = lazyActivation || isCompatible(bundle);
+                if (compatible) {
+                    final BlueprintContextImpl blueprintContext = new BlueprintContextImpl(bundle.getBundleContext(),
sender, handlers, executors, urls, lazyActivation);
+                    contextMap.put(bundle, blueprintContext);
+                    // run synchronous when bundle is lazy activated
+                    blueprintContext.run(lazyActivation ? false: true);
+                } else {
+                    LOGGER.info("Bundle {} is not compatible with this blueprint extender",
bundle.getSymbolicName());
+                }
 
-            // Check compatibility 
-            // XXX: we can't check compatibility when dealing with lazy activated bundles
since that will trigger
-            // the bundle to be fully started
-            boolean compatible = lazyActivation || isCompatible(bundle);
-            if (compatible) {
-                final BlueprintContextImpl blueprintContext = new BlueprintContextImpl(bundle.getBundleContext(),
sender, handlers, executors, urls, lazyActivation);
-                contextMap.put(bundle, blueprintContext);
-                // run synchronous when bundle is lazy activated 
-                blueprintContext.run(lazyActivation ? false: true);
             } else {
-                LOGGER.info("Bundle {} is not compatible with this blueprint extender", bundle.getSymbolicName());
+                LOGGER.debug("No blueprint application found in bundle {}", bundle.getSymbolicName());
             }
-
-        } else {
-            LOGGER.debug("No blueprint application found in bundle {}", bundle.getSymbolicName());
+        } catch (Throwable t) {
+            sender.sendFailure(bundle, t);
         }
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
Mon May 18 09:25:18 2009
@@ -49,6 +49,7 @@
 import org.apache.xbean.recipe.ExecutionContext;
 import org.apache.xbean.recipe.DefaultExecutionContext;
 import org.apache.xbean.recipe.ConstructionException;
+import org.apache.xbean.recipe.ReferenceNameRecipe;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -183,7 +184,7 @@
                 switch (state) {
                     case Unknown:
                         checkDirectives();
-                        sender.sendCreating(this);
+                        sender.sendCreating(getBundleContext().getBundle());
                         parser = new Parser();
                         parser.parse(urls);
                         namespaces = parser.getNamespaces();
@@ -196,7 +197,7 @@
                         for (URI ns : namespaces) {
                             if (handlers.getNamespaceHandler(ns) == null) {
                                 if (!waitForNamespaceHandlersEventSent) {
-                                    sender.sendWaiting(this, new String[] {NamespaceHandler.class.getName()
}, null);
+                                    sender.sendWaiting(getBundleContext().getBundle(), new
String[] {NamespaceHandler.class.getName() }, null);
                                     waitForNamespaceHandlersEventSent = true;
                                 }
                                 return;
@@ -207,6 +208,7 @@
                         break;
                     case Populated:
                         instantiator = new BlueprintObjectInstantiator(new RecipeBuilder(this).createRepository());
+                        checkReferences();
                         trackServiceReferences();
                         if (checkAllSatisfiables() || !waitForDependencies) {
                             state = State.InitialReferencesSatisfied;
@@ -214,7 +216,7 @@
                             // TODO: pass correct parameters
                             // TODO: do we need to send one event for each missing reference
?
                             // TODO: create a timer, then fail after it elapsed
-                            sender.sendWaiting(this, null, null);
+                            sender.sendWaiting(getBundleContext().getBundle(), null, null);
                             state = State.WaitForInitialReferences;
                         }
                         break;
@@ -252,7 +254,7 @@
                             // TODO: pass correct parameters
                             // TODO: do we need to send one event for each missing reference
?
                             // TODO: create a timer, then fail after it elapsed
-                            sender.sendWaiting(this, null, null);
+                            sender.sendWaiting(getBundleContext().getBundle(), null, null);
                             state = State.WaitForInitialReferences2;
                         }
                         break;
@@ -294,7 +296,7 @@
                             //    BlueprintContext.getComponent(String) is called directly
                             registration = bundleContext.registerService(BlueprintContext.class.getName(),
this, props);
 
-                            sender.sendCreated(this);
+                            sender.sendCreated(getBundleContext().getBundle());
                             state = State.Created;
                         }
                         break;
@@ -308,7 +310,48 @@
             state = State.Failed;
             // TODO: clean up
             LOGGER.error("Unable to start blueprint context for bundle " + bundleContext.getBundle().getSymbolicName(),
t);
-            sender.sendFailure(this, t);
+            sender.sendFailure(getBundleContext().getBundle(), t);
+        }
+    }
+
+    private void checkReferences() throws Exception {
+        BlueprintObjectRepository repository = (BlueprintObjectRepository) instantiator.getRepository();
+        List<Recipe> recipes = new ArrayList<Recipe>();
+        boolean createNewContext = !ExecutionContext.isContextSet();
+        if (createNewContext) {
+            ExecutionContext.setContext(new DefaultExecutionContext(instantiator.getRepository()));
+        }
+        try {
+            for (String name : repository.getNames()) {
+                Recipe recipe = repository.getRecipe(name);
+                if (recipe != null) {
+                    getAllRecipes(recipe, recipes);
+                }
+            }
+        } finally {
+            if (createNewContext) {
+                ExecutionContext.setContext(null);
+            }
+        }
+        for (Recipe recipe : recipes) {
+            String ref = null;
+            if (recipe instanceof ReferenceRecipe) {
+                ref = ((ReferenceRecipe) recipe).getReferenceName();
+            } else if (recipe instanceof ReferenceNameRecipe) {
+                ref = ((ReferenceNameRecipe) recipe).getReferenceName();
+            }
+            if (ref != null && repository.get(ref) == null) {
+                throw new ComponentDefinitionException("Unresolved ref/idref to component:
" + ref);
+            }
+        }
+    }
+
+    private void getAllRecipes(Recipe recipe, List<Recipe> recipes) {
+        if (!recipes.contains(recipe)) {
+            recipes.add(recipe);
+            for (Recipe r : recipe.getNestedRecipes()) {
+                getAllRecipes(r, recipes);
+            }
         }
     }
 
@@ -479,8 +522,10 @@
         LOGGER.debug("Instantiating components: {}", components);
         try {
             instantiator.createAll(components);
-        } catch (ConstructionException e) {
-            throw (ComponentDefinitionException) new ComponentDefinitionException("Unable
to instantiate components").initCause(e);
+        } catch (ComponentDefinitionException e) {
+            throw e;
+        } catch (Throwable t) {
+            throw (ComponentDefinitionException) new ComponentDefinitionException("Unable
to instantiate components").initCause(t);
         }
     }
 
@@ -565,8 +610,10 @@
             return instantiator.create(name);
         } catch (org.apache.xbean.recipe.NoSuchObjectException e) {
             throw new NoSuchComponentException(name);
-        } catch (ConstructionException e) {
-            throw (ComponentDefinitionException) new ComponentDefinitionException("Cound
not create component instance for " + name).initCause(e);
+        } catch (ComponentDefinitionException e) {
+            throw e;
+        } catch (Throwable t) {
+            throw (ComponentDefinitionException) new ComponentDefinitionException("Cound
not create component instance for " + name).initCause(t);
         }
     }
 
@@ -621,7 +668,7 @@
     
     public synchronized void destroy() {
         state = State.Destroyed;
-        sender.sendDestroying(this);
+        sender.sendDestroying(getBundleContext().getBundle());
         
         if (registration != null) {
             registration.unregister();
@@ -632,7 +679,7 @@
         unregisterTriggerServices();
         destroyComponents();
         
-        sender.sendDestroyed(this);
+        sender.sendDestroyed(getBundleContext().getBundle());
         LOGGER.debug("Module context destroyed: " + this.bundleContext);
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
Mon May 18 09:25:18 2009
@@ -49,6 +49,7 @@
 import org.apache.xbean.recipe.Recipe;
 import org.apache.xbean.recipe.RecipeHelper;
 import org.apache.xbean.recipe.ReferenceRecipe;
+import static org.apache.xbean.recipe.RecipeHelper.toClass;
 import org.osgi.service.blueprint.convert.ConversionService;
 import org.osgi.service.blueprint.reflect.BeanArgument;
 
@@ -241,7 +242,7 @@
             // look for instance method on factory object
             Object factoryObj = factory.create(Object.class, false);
             // Map of matching methods
-            Map<Method, List<Object>> matches = findMatchingMethods(factoryObj.getClass(),
factoryMethod, true, args, types, arguments);
+            Map<Method, List<Object>> matches = findMatchingMethods(factoryObj.getClass(),
factoryMethod, true, args, types);
             if (matches.size() == 1) {
                 try {
                     Map.Entry<Method, List<Object>> match = matches.entrySet().iterator().next();
@@ -259,7 +260,7 @@
             }
         } else if (factoryMethod != null) {
             // Map of matching methods
-            Map<Method, List<Object>> matches = findMatchingMethods(getType(),
factoryMethod, false, args, types, arguments);
+            Map<Method, List<Object>> matches = findMatchingMethods(getType(),
factoryMethod, false, args, types);
             if (matches.size() == 1) {
                 try {
                     Map.Entry<Method, List<Object>> match = matches.entrySet().iterator().next();
@@ -277,7 +278,7 @@
             }
         } else {
             // Map of matching constructors
-            Map<Constructor, List<Object>> matches = findMatchingConstructors(args,
types, args);
+            Map<Constructor, List<Object>> matches = findMatchingConstructors(getType(),
args, types);
             if (matches.size() == 1) {
                 try {
                     Map.Entry<Constructor, List<Object>> match = matches.entrySet().iterator().next();
@@ -302,7 +303,9 @@
         return ConversionUtils.convert(obj, type, blueprintContext.getConversionService());
     }
 
-    private Map<Method, List<Object>> findMatchingMethods(Class type, String
name, boolean instance, List<Object> args, List<Class> types, List<Object>
arguments) {
+    public static final boolean TCK_COMPLIANCE = true;
+
+    private Map<Method, List<Object>> findMatchingMethods(Class type, String
name, boolean instance, List<Object> args, List<Class> types) {
         Map<Method, List<Object>> matches = new HashMap<Method, List<Object>>();
         // Get constructors
         List<Method> methods = new ArrayList<Method>(Arrays.asList(type.getMethods()));
@@ -313,33 +316,73 @@
                 it.remove();
             } else if (mth.getParameterTypes().length != args.size()) {
                 it.remove();
-            } else if (!instance ^ Modifier.isStatic(mth.getModifiers())) {
+            } else if (instance ^ !Modifier.isStatic(mth.getModifiers())) {
                 it.remove();
             }
         }
+        // Find a direct match with no conversion
+        if (TCK_COMPLIANCE && matches.size() != 1) {
+            Map<Method, List<Object>> nmatches = new HashMap<Method, List<Object>>();
+            for (Method mth : methods) {
+                boolean found = true;
+                List<Object> match = new ArrayList<Object>();
+                for (int i = 0; i < args.size(); i++) {
+                    if (types.get(i) != null) {
+                        if (!toClass(mth.getParameterTypes()[i]).isAssignableFrom(types.get(i)))
{
+                            found = false;
+                            break;
+                        }
+                    } else {
+                        if (!mth.getParameterTypes()[i].isInstance(args.get(i))) {
+                            found = false;
+                            break;
+                        }
+                    }
+                    try {
+                        Object val = convert(args.get(i), mth.getGenericParameterTypes()[i]);
+                        match.add(val);
+                    } catch (Throwable t) {
+                        found = false;
+                        break;
+                    }
+                }
+                if (found) {
+                    nmatches.put(mth, match);
+                }
+            }
+            if (nmatches.size() > 0) {
+                matches = nmatches;
+            }
+        }
         // Find a direct match
-        for (Method mth : methods) {
-            boolean found = true;
-            List<Object> match = new ArrayList<Object>();
-            for (int i = 0; i < args.size(); i++) {
-                if (types.get(i) != null && types.get(i) != mth.getParameterTypes()[i])
{
-                    found = false;
-                    break;
+        if (matches.size() != 1) {
+            Map<Method, List<Object>> nmatches = new HashMap<Method, List<Object>>();
+            for (Method mth : methods) {
+                boolean found = true;
+                List<Object> match = new ArrayList<Object>();
+                for (int i = 0; i < args.size(); i++) {
+                    if (types.get(i) != null && types.get(i) != mth.getParameterTypes()[i])
{
+                        found = false;
+                        break;
+                    }
+                    try {
+                        Object val = convert(args.get(i), mth.getGenericParameterTypes()[i]);
+                        match.add(val);
+                    } catch (Throwable t) {
+                        found = false;
+                        break;
+                    }
                 }
-                try {
-                    Object val = convert(args.get(i), mth.getGenericParameterTypes()[i]);
-                    match.add(val);
-                } catch (Throwable t) {
-                    found = false;
-                    break;
+                if (found) {
+                    nmatches.put(mth, match);
                 }
             }
-            if (found) {
-                matches.put(mth, match);
+            if (nmatches.size() > 0) {
+                matches = nmatches;
             }
         }
         // Start reordering
-        if (matches.size() != 1 && reorderArguments && arguments.size() >
1) {
+        if (matches.size() != 1 && reorderArguments && args.size() > 1)
{
             Map<Method, List<Object>> nmatches = new HashMap<Method, List<Object>>();
             for (Method mth : methods) {
                 ArgumentMatcher matcher = new ArgumentMatcher(mth.getGenericParameterTypes());
@@ -355,35 +398,75 @@
         return matches;
     }
 
-    private Map<Constructor, List<Object>> findMatchingConstructors(List<Object>
args, List<Class> types, List<Object> arguments) {
+    private Map<Constructor, List<Object>> findMatchingConstructors(Class type,
List<Object> args, List<Class> types) {
         Map<Constructor, List<Object>> matches = new HashMap<Constructor,
List<Object>>();
         // Get constructors
-        List<Constructor> constructors = new ArrayList<Constructor>(Arrays.asList(getType().getConstructors()));
+        List<Constructor> constructors = new ArrayList<Constructor>(Arrays.asList(type.getConstructors()));
         // Discard any signature with wrong cardinality
         for (Iterator<Constructor> it = constructors.iterator(); it.hasNext();) {
             if (it.next().getParameterTypes().length != args.size()) {
                 it.remove();
             }
         }
+        // Find a direct match with no conversion
+        if (TCK_COMPLIANCE && matches.size() != 1) {
+            Map<Constructor, List<Object>> nmatches = new HashMap<Constructor,
List<Object>>();
+            for (Constructor cns : constructors) {
+                boolean found = true;
+                List<Object> match = new ArrayList<Object>();
+                for (int i = 0; i < args.size(); i++) {
+                    if (types.get(i) != null) {
+                        if (!toClass(cns.getParameterTypes()[i]).isAssignableFrom(types.get(i)))
{
+                            found = false;
+                            break;
+                        }
+                    } else {
+                        if (!cns.getParameterTypes()[i].isInstance(args.get(i))) {
+                            found = false;
+                            break;
+                        }
+                    }
+                    try {
+                        Object val = convert(args.get(i), cns.getGenericParameterTypes()[i]);
+                        match.add(val);
+                    } catch (Throwable t) {
+                        found = false;
+                        break;
+                    }
+                }
+                if (found) {
+                    nmatches.put(cns, match);
+                }
+            }
+            if (nmatches.size() > 0) {
+                matches = nmatches;
+            }
+        }
         // Find a direct match
-        for (Constructor cns : constructors) {
-            boolean found = true;
-            List<Object> match = new ArrayList<Object>();
-            for (int i = 0; i < args.size(); i++) {
-                if (types.get(i) != null && types.get(i) != cns.getParameterTypes()[i])
{
-                    found = false;
-                    break;
+        if (matches.size() != 1) {
+            Map<Constructor, List<Object>> nmatches = new HashMap<Constructor,
List<Object>>();
+            for (Constructor cns : constructors) {
+                boolean found = true;
+                List<Object> match = new ArrayList<Object>();
+                for (int i = 0; i < args.size(); i++) {
+                    if (types.get(i) != null && types.get(i) != cns.getParameterTypes()[i])
{
+                        found = false;
+                        break;
+                    }
+                    try {
+                        Object val = convert(args.get(i), cns.getGenericParameterTypes()[i]);
+                        match.add(val);
+                    } catch (Throwable t) {
+                        found = false;
+                        break;
+                    }
                 }
-                try {
-                    Object val = convert(args.get(i), cns.getGenericParameterTypes()[i]);
-                    match.add(val);
-                } catch (Throwable t) {
-                    found = false;
-                    break;
+                if (found) {
+                    nmatches.put(cns, match);
                 }
             }
-            if (found) {
-                matches.put(cns, match);
+            if (nmatches.size() > 0) {
+                matches = nmatches;
             }
         }
         // Start reordering
@@ -559,7 +642,7 @@
                     throw new ConstructionException("Error getting property: " + names[i]
+ " on bean " + getName() + " when setting property " + propertyName + " on class " + clazz.getName(),
t);
                 }
             } else {
-                throw new ConstructionException("No getter for " + names[i] + " property");
+                throw new ConstructionException("No getter for " + names[i] + " property
on bean " + getName() + " when setting property " + propertyName + " on class " + clazz.getName());
             }
         }
         Method setter = getPropertyDescriptor(clazz, names[names.length - 1]).getWriteMethod();
@@ -618,7 +701,6 @@
 
     private class ArgumentMatcher {
 
-        private ConversionService converter;
         private List<TypeEntry> entries;
 
         public ArgumentMatcher(Type[] types) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
Mon May 18 09:25:18 2009
@@ -116,6 +116,8 @@
             retrack();
             
             return collection;
+        } catch (ConstructionException t) {
+            throw t;
         } catch (Throwable t) {
             throw new ConstructionException(t);
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultBlueprintContextEventSender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultBlueprintContextEventSender.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultBlueprintContextEventSender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultBlueprintContextEventSender.java
Mon May 18 09:25:18 2009
@@ -23,20 +23,19 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.osgi.framework.BundleContext;
+import org.apache.geronimo.blueprint.BlueprintConstants;
+import org.apache.geronimo.blueprint.BlueprintContextEventSender;
+import org.apache.geronimo.blueprint.BlueprintStateManager;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.event.Event;
-import org.osgi.service.blueprint.context.EventConstants;
-import org.osgi.service.blueprint.context.BlueprintContext;
+import org.osgi.framework.Version;
 import org.osgi.service.blueprint.context.BlueprintContextListener;
-import org.apache.geronimo.blueprint.BlueprintConstants;
-import org.apache.geronimo.blueprint.BlueprintContextEventSender;
-import org.apache.geronimo.blueprint.BlueprintStateManager;
+import org.osgi.service.blueprint.context.EventConstants;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -86,48 +85,46 @@
         }
     }
 
-    public void sendCreating(BlueprintContext blueprintContext) {
-        states.put(blueprintContext.getBundleContext().getBundle(),  CREATING);
-        sendEvent(blueprintContext, TOPIC_CREATING, null, null, null);
+    public void sendCreating(Bundle bundle) {
+        states.put(bundle,  CREATING);
+        sendEvent(bundle, TOPIC_CREATING, null, null, null);
     }
 
-    public void sendCreated(BlueprintContext blueprintContext) {
-        states.put(blueprintContext.getBundleContext().getBundle(),  CREATED);
-        sendEvent(blueprintContext, TOPIC_CREATED, null, null, null);
+    public void sendCreated(Bundle bundle) {
+        states.put(bundle,  CREATED);
+        sendEvent(bundle, TOPIC_CREATED, null, null, null);
     }
 
-    public void sendDestroying(BlueprintContext blueprintContext) {
-        states.put(blueprintContext.getBundleContext().getBundle(),  DESTROYING);
-        sendEvent(blueprintContext, TOPIC_DESTROYING, null, null, null);
+    public void sendDestroying(Bundle bundle) {
+        states.put(bundle,  DESTROYING);
+        sendEvent(bundle, TOPIC_DESTROYING, null, null, null);
     }
 
-    public void sendDestroyed(BlueprintContext blueprintContext) {
-        states.put(blueprintContext.getBundleContext().getBundle(),  DESTROYED);
-        sendEvent(blueprintContext, TOPIC_DESTROYED, null, null, null);
+    public void sendDestroyed(Bundle bundle) {
+        states.put(bundle,  DESTROYED);
+        sendEvent(bundle, TOPIC_DESTROYED, null, null, null);
     }
 
-    public void sendWaiting(BlueprintContext blueprintContext, String[] serviceObjectClass,
String serviceFilter) {
-        states.put(blueprintContext.getBundleContext().getBundle(),  WAITING);
-        sendEvent(blueprintContext, TOPIC_WAITING, null, serviceObjectClass, serviceFilter);
+    public void sendWaiting(Bundle bundle, String[] serviceObjectClass, String serviceFilter)
{
+        states.put(bundle,  WAITING);
+        sendEvent(bundle, TOPIC_WAITING, null, serviceObjectClass, serviceFilter);
     }
 
-    public void sendFailure(BlueprintContext blueprintContext, Throwable cause) {
-        states.put(blueprintContext.getBundleContext().getBundle(),  cause != null ? cause
: FAILED);
-        sendEvent(blueprintContext, TOPIC_FAILURE, cause, null, null);
+    public void sendFailure(Bundle bundle, Throwable cause) {
+        states.put(bundle,  cause != null ? cause : FAILED);
+        sendEvent(bundle, TOPIC_FAILURE, cause, null, null);
     }
 
-    public void sendFailure(BlueprintContext blueprintContext, Throwable cause, String[]
serviceObjectClass, String serviceFilter) {
-        states.put(blueprintContext.getBundleContext().getBundle(),  cause != null ? cause
: FAILED);
-        sendEvent(blueprintContext, TOPIC_FAILURE, cause, serviceObjectClass, serviceFilter);
+    public void sendFailure(Bundle bundle, Throwable cause, String[] serviceObjectClass,
String serviceFilter) {
+        states.put(bundle,  cause != null ? cause : FAILED);
+        sendEvent(bundle, TOPIC_FAILURE, cause, serviceObjectClass, serviceFilter);
     }
 
-    public void sendEvent(BlueprintContext blueprintContext, String topic, Throwable cause,
String[] serviceObjectClass, String serviceFilter) {
-
-        Bundle bundle = blueprintContext.getBundleContext().getBundle();
+    public void sendEvent(Bundle bundle, String topic, Throwable cause, String[] serviceObjectClass,
String serviceFilter) {
 
         LOGGER.debug("Sending blueprint context event {} for bundle {}", topic, bundle.getSymbolicName());
 
-        callListeners(blueprintContext, topic, cause);
+        callListeners(bundle, topic, cause);
 
         EventAdmin eventAdmin = getEventAdmin();
         if (eventAdmin == null) {
@@ -161,7 +158,7 @@
         eventAdmin.postEvent(event);
     }
 
-    private void callListeners(BlueprintContext blueprintContext, String topic, Throwable
cause) {
+    private void callListeners(Bundle bundle, String topic, Throwable cause) {
         boolean created = TOPIC_CREATED.equals(topic);
         boolean failure = TOPIC_FAILURE.equals(topic);
         if (created || failure) {
@@ -170,9 +167,9 @@
                 for (Object listener : listeners) {
                     try {
                         if (created) {
-                            ((BlueprintContextListener) listener).contextCreated(blueprintContext.getBundleContext().getBundle());
+                            ((BlueprintContextListener) listener).contextCreated(bundle);
                         } else {
-                            ((BlueprintContextListener) listener).contextCreationFailed(blueprintContext.getBundleContext().getBundle(),
cause);
+                            ((BlueprintContextListener) listener).contextCreationFailed(bundle,
cause);
                         }
                     } catch (Throwable t) {
                         LOGGER.info("Error calling blueprint context listener", t);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
Mon May 18 09:25:18 2009
@@ -190,7 +190,7 @@
         synchronized (monitor) {
             if (tracker.isStarted() && trackedServiceReference == null &&
metadata.getTimeout() > 0) {
                 Set<String> interfaces = new HashSet<String>(metadata.getInterfaceNames());
-                sender.sendWaiting(blueprintContext, interfaces.toArray(new String[interfaces.size()]),
getOsgiFilter());
+                sender.sendWaiting(blueprintContext.getBundleContext().getBundle(), interfaces.toArray(new
String[interfaces.size()]), getOsgiFilter());
                 monitor.wait(metadata.getTimeout());
             }
             if (trackedServiceReference == null) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ConstructionException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ConstructionException.java?rev=775871&r1=775870&r2=775871&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ConstructionException.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/xbean/recipe/ConstructionException.java
Mon May 18 09:25:18 2009
@@ -16,27 +16,27 @@
  */
 package org.apache.xbean.recipe;
 
+import org.osgi.service.blueprint.context.ComponentDefinitionException;
+
 /**
  * @version $Rev: 6680 $ $Date: 2005-12-24T04:38:27.427468Z $
  */
-public class ConstructionException extends RuntimeException {
+public class ConstructionException extends ComponentDefinitionException {
 
     private String className;
     private String attributeName;
 
-    public ConstructionException() {
-    }
-
     public ConstructionException(String message) {
         super(message);
     }
 
     public ConstructionException(String message, Throwable cause) {
-        super(message, cause);
+        super(message);
+        initCause(cause);
     }
 
     public ConstructionException(Throwable cause) {
-        super(cause);
+        this("", cause);
     }
 
     public String getClassName() {
@@ -55,9 +55,6 @@
         this.attributeName = attributeName;
     }
 
-    public void setPrependAttributeName(String attributeName) {
-    }
-
     public String getMessage() {
         if (className == null) {
             return super.getMessage();



Mime
View raw message