Return-Path: Delivered-To: apmail-incubator-aries-commits-archive@minotaur.apache.org Received: (qmail 30999 invoked from network); 30 Nov 2009 12:18:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Nov 2009 12:18:06 -0000 Received: (qmail 92818 invoked by uid 500); 30 Nov 2009 12:18:06 -0000 Delivered-To: apmail-incubator-aries-commits-archive@incubator.apache.org Received: (qmail 92739 invoked by uid 500); 30 Nov 2009 12:18:05 -0000 Mailing-List: contact aries-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: aries-dev@incubator.apache.org Delivered-To: mailing list aries-commits@incubator.apache.org Delivered-To: moderator for aries-commits@incubator.apache.org Received: (qmail 2360 invoked by uid 99); 30 Nov 2009 10:49:50 -0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r885371 - /incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java Date: Mon, 30 Nov 2009 10:49:27 -0000 To: aries-commits@incubator.apache.org From: mahrwald@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091130104928.1B1FD23888FE@eris.apache.org> Author: mahrwald Date: Mon Nov 30 10:49:27 2009 New Revision: 885371 URL: http://svn.apache.org/viewvc?rev=885371&view=rev Log: ARIES-56 Unwrap ServiceProxyWrapper for factory-ref bean creation Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java?rev=885371&r1=885370&r2=885371&view=diff ============================================================================== --- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java (original) +++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java Mon Nov 30 10:49:27 2009 @@ -206,6 +206,16 @@ if (factory != null) { // look for instance method on factory object Object factoryObj = factory.create(); + + // If the factory is a service reference, we need to get hold of the actual proxy for the service + if (factoryObj instanceof ReferenceRecipe.ServiceProxyWrapper) { + try { + factoryObj = ((ReferenceRecipe.ServiceProxyWrapper) factoryObj).convert(new ReifiedType(Object.class)); + } catch (Exception e) { + throw new ComponentDefinitionException("Error when instantiating bean " + getName() + " of class " + getType(), getRealCause(e)); + } + } + // Map of matching methods Map> matches = findMatchingMethods(factoryObj.getClass(), factoryMethod, true, args, argTypes); if (matches.size() == 1) { @@ -213,7 +223,7 @@ Map.Entry> match = matches.entrySet().iterator().next(); instance = invoke(match.getKey(), factoryObj, match.getValue().toArray()); } catch (Throwable e) { - throw new ComponentDefinitionException("Error when instanciating bean " + getName() + " of class " + getType(), getRealCause(e)); + throw new ComponentDefinitionException("Error when instantiating bean " + getName() + " of class " + getType(), getRealCause(e)); } } else if (matches.size() == 0) { throw new ComponentDefinitionException("Unable to find a matching factory method " + factoryMethod + " on class " + factoryObj.getClass().getName() + " for arguments " + args + " when instanciating bean " + getName());