aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1716138 - in /aries/trunk/blueprint: blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/ blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/ blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbun...
Date Tue, 24 Nov 2015 13:57:22 GMT
Author: gnodet
Date: Tue Nov 24 13:57:22 2015
New Revision: 1716138

URL: http://svn.apache.org/viewvc?rev=1716138&view=rev
Log:
[ARIES-1456] Support for @PostConstruct and @PreDestroy

Modified:
    aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java
    aries/trunk/blueprint/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanC.java
    aries/trunk/blueprint/blueprint-testbundles/src/main/resources/OSGI-INF/blueprint/config.xml

Modified: aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java?rev=1716138&r1=1716137&r2=1716138&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
(original)
+++ aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/SpringTest.java
Tue Nov 24 13:57:22 2015
@@ -20,12 +20,14 @@ package org.apache.aries.blueprint.itest
 
 import java.util.List;
 
+import org.apache.aries.blueprint.testbundles.BeanC;
 import org.junit.Test;
 import org.ops4j.pax.exam.Option;
 import org.osgi.framework.Bundle;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 
 import static org.apache.aries.blueprint.itests.Helper.mvnBundle;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 public class SpringTest extends AbstractBlueprintIntegrationTest {
@@ -39,6 +41,9 @@ public class SpringTest extends Abstract
         BlueprintContainer container = startBundleBlueprint("org.apache.aries.blueprint.testbundles");
         List list = (List) container.getComponentInstance("springList");
         System.out.println(list);
+
+        BeanC beanC = (BeanC) list.get(4);
+        assertEquals(1, beanC.getInitialized());
     }
 
     @org.ops4j.pax.exam.Configuration

Modified: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java?rev=1716138&r1=1716137&r2=1716138&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java
(original)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java
Tue Nov 24 13:57:22 2015
@@ -24,6 +24,7 @@ import org.apache.aries.blueprint.Compon
 import org.apache.aries.blueprint.ComponentDefinitionRegistryProcessor;
 import org.apache.aries.blueprint.ExtendedBeanMetadata;
 import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.apache.aries.blueprint.spring.BlueprintBeanFactory.SpringMetadata;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
@@ -57,6 +58,9 @@ public class SpringBeanProcessor impleme
 
     @Override
     public Object beforeInit(Object o, String s, BeanCreator beanCreator, BeanMetadata beanMetadata)
{
+        if (beanMetadata instanceof SpringMetadata) {
+            return o;
+        }
         if (o instanceof Aware) {
             if (o instanceof BeanNameAware) {
                 ((BeanNameAware) o).setBeanName(s);

Modified: aries/trunk/blueprint/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanC.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanC.java?rev=1716138&r1=1716137&r2=1716138&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanC.java
(original)
+++ aries/trunk/blueprint/blueprint-testbundles/src/main/java/org/apache/aries/blueprint/testbundles/BeanC.java
Tue Nov 24 13:57:22 2015
@@ -21,7 +21,7 @@ import javax.annotation.PostConstruct;
 public class BeanC {
 
     private final BeanA beanA;
-    private boolean initialized;
+    private int initialized;
 
     public BeanC(BeanA beanA) {
         this.beanA = beanA;
@@ -29,10 +29,10 @@ public class BeanC {
 
     @PostConstruct
     public void start() {
-        this.initialized = true;
+        this.initialized++;
     }
 
-    public boolean isInitialized() {
+    public int getInitialized() {
         return initialized;
     }
 }

Modified: aries/trunk/blueprint/blueprint-testbundles/src/main/resources/OSGI-INF/blueprint/config.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-testbundles/src/main/resources/OSGI-INF/blueprint/config.xml?rev=1716138&r1=1716137&r2=1716138&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-testbundles/src/main/resources/OSGI-INF/blueprint/config.xml
(original)
+++ aries/trunk/blueprint/blueprint-testbundles/src/main/resources/OSGI-INF/blueprint/config.xml
Tue Nov 24 13:57:22 2015
@@ -20,9 +20,11 @@
            xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:bean="http://www.springframework.org/schema/beans"
            xmlns:util="http://www.springframework.org/schema/util"
+           xmlns:context="http://www.springframework.org/schema/context"
            xsi:schemaLocation="
              http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
              http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
+             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
              http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
 
@@ -30,6 +32,8 @@
 
     <bean:beans default-autowire="constructor">
 
+        <context:annotation-config />
+
         <bean:bean id="beanC" class="org.apache.aries.blueprint.testbundles.BeanC"/>
 
     </bean:beans>



Mime
View raw message