incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mahrw...@apache.org
Subject svn commit: r953880 - in /incubator/aries/trunk: blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/
Date Fri, 11 Jun 2010 21:33:38 GMT
Author: mahrwald
Date: Fri Jun 11 21:33:37 2010
New Revision: 953880

URL: http://svn.apache.org/viewvc?rev=953880&view=rev
Log:
ARIES-322: Transaction interceptors (or any other interceptors) don't work with anonymous
inner beans

Modified:
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java
    incubator/aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml

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=953880&r1=953879&r2=953880&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
Fri Jun 11 21:33:37 2010
@@ -46,7 +46,6 @@ import org.apache.aries.blueprint.utils.
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.container.ReifiedType;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -73,7 +72,8 @@ public class BeanRecipe extends Abstract
     private List<String> argTypes;
     private boolean reorderArguments;
     private final boolean allowsFieldInjection;
-
+    private BeanMetadata interceptorLookupKey;
+    
 
     public BeanRecipe(String name, ExtendedBlueprintContainer blueprintContainer, Object
type, boolean allowsFieldInjection) {
         super(name);
@@ -138,6 +138,10 @@ public class BeanRecipe extends Abstract
         this.explicitDependencies = explicitDependencies;
     }
 
+    public void setInterceptorLookupKey(BeanMetadata metadata) {
+    	interceptorLookupKey = metadata;
+    }
+    
     @Override
     public List<Recipe> getConstructorDependencies() {
         List<Recipe> recipes = new ArrayList<Recipe>();
@@ -668,11 +672,9 @@ public class BeanRecipe extends Abstract
             throws ComponentDefinitionException {
 
         Object intercepted = null;
-        String beanName = getName();
         ComponentDefinitionRegistry reg = blueprintContainer
                 .getComponentDefinitionRegistry();
-        ComponentMetadata metaData = reg.getComponentDefinition(beanName);
-        List<Interceptor> interceptors = reg.getInterceptors(metaData);
+        List<Interceptor> interceptors = reg.getInterceptors(interceptorLookupKey);
         if (interceptors != null && interceptors.size() > 0) {
             boolean asmAvailable = false;
             try {
@@ -698,14 +700,14 @@ public class BeanRecipe extends Abstract
                 // if asm is available we can proxy the original object with the
                 // AsmInterceptorWrapper
                 intercepted = AsmInterceptorWrapper.createProxyObject(original
-                        .getClass().getClassLoader(), metaData, interceptors,
+                        .getClass().getClassLoader(), interceptorLookupKey, interceptors,
                         original, original.getClass());
             } else {
                 LOGGER.debug("cglib available for interceptors");
                 // otherwise we're using cglib and need to use the interfaces
                 // with the CgLibInterceptorWrapper
                 intercepted = CgLibInterceptorWrapper.createProxyObject(
-                        original.getClass().getClassLoader(), metaData,
+                        original.getClass().getClassLoader(), interceptorLookupKey,
                         interceptors, original, original.getClass()
                                 .getInterfaces());
             }

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java?rev=953880&r1=953879&r2=953880&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java
Fri Jun 11 21:33:37 2010
@@ -230,6 +230,7 @@ public class RecipeBuilder {
         recipe.setPrototype(MetadataUtil.isPrototypeScope(beanMetadata));
         recipe.setInitMethod(beanMetadata.getInitMethod());
         recipe.setDestroyMethod(beanMetadata.getDestroyMethod());
+        recipe.setInterceptorLookupKey(beanMetadata);
         List<BeanArgument> beanArguments = beanMetadata.getArguments();
         if (beanArguments != null && !beanArguments.isEmpty()) {
             boolean hasIndex = (beanArguments.get(0).getIndex() >= 0);

Modified: incubator/aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml?rev=953880&r1=953879&r2=953880&view=diff
==============================================================================
--- incubator/aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
(original)
+++ incubator/aries/trunk/transaction/transaction-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
Fri Jun 11 21:33:37 2010
@@ -69,19 +69,18 @@
        </service-properties>
    </service>
 
-   <bean id="requiresNewBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl"
init-method="initialize">
-       <tx:transaction method="insertRow throw*" value="RequiresNew"/>
-       <tx:transaction method="countRows" value="NotSupported"/>
-       <property name="enlistingDataSource" ref="enlistingDataSource"/>
-       <property name="dataSource" ref="dataSource"/>
-       <property name="user" value="user"/>
-       <property name="password" value="password"/>
-   </bean>
-   
-   <service id="requiresNewBean" ref="requiresNewBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
+   <service id="requiresNewBean" interface="org.apache.aries.transaction.test.TestBean">
        <service-properties>
            <entry key="tranStrategy" value="RequiresNew"/>
        </service-properties>
+       <bean class="org.apache.aries.transaction.test.impl.TestBeanImpl" init-method="initialize">
+           <tx:transaction method="insertRow throw*" value="RequiresNew"/>
+           <tx:transaction method="countRows" value="NotSupported"/>
+           <property name="enlistingDataSource" ref="enlistingDataSource"/>
+           <property name="dataSource" ref="dataSource"/>
+           <property name="user" value="user"/>
+           <property name="password" value="password"/>
+       </bean>
    </service>
 
    <bean id="mandatoryBeanImpl" class="org.apache.aries.transaction.test.impl.TestBeanImpl"
init-method="initialize">
@@ -92,7 +91,7 @@
        <property name="user" value="user"/>
        <property name="password" value="password"/>
    </bean>
-   
+
    <service id="mandatoryBean" ref="mandatoryBeanImpl" interface="org.apache.aries.transaction.test.TestBean">
        <service-properties>
            <entry key="tranStrategy" value="Mandatory"/>



Mime
View raw message