Author: gnodet
Date: Fri Jan 27 10:04:53 2017
New Revision: 1780532

URL: http://svn.apache.org/viewvc?rev=1780532&view=rev
Log:
[ARIES-1673] Spring beans not destroyed

Modified:
    
aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java

Modified: 
aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java?rev=1780532&r1=1780531&r2=1780532&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java
 (original)
+++ 
aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java
 Fri Jan 27 10:04:53 2017
@@ -139,7 +139,7 @@ public class BlueprintNamespaceHandler i
         if (applicationContext == null) {
             applicationContext = new SpringApplicationContext(container);
             
registry.registerComponentDefinition(createPassThrough(parserContext,
-                    SPRING_APPLICATION_CONTEXT_ID, applicationContext
+                    SPRING_APPLICATION_CONTEXT_ID, applicationContext, 
"destroy"
             ));
         }
         // Create registry
@@ -186,6 +186,30 @@ public class BlueprintNamespaceHandler i
         return pt;
     }
 
+    private ComponentMetadata createPassThrough(ParserContext parserContext, 
String id, Object o, String destroy) {
+        MutablePassThroughMetadata pt = 
parserContext.createMetadata(MutablePassThroughMetadata.class);
+        pt.setId(id + ".factory");
+        pt.setObject(new Holder(o));
+        MutableBeanMetadata b = 
parserContext.createMetadata(MutableBeanMetadata.class);
+        b.setId(id);
+        b.setFactoryComponent(pt);
+        b.setFactoryMethod("getObject");
+        b.setDestroyMethod(destroy);
+        return b;
+    }
+
+    public static class Holder {
+        private final Object object;
+
+        public Holder(Object object) {
+            this.object = object;
+        }
+
+        public Object getObject() {
+            return object;
+        }
+    }
+
     private Metadata createRef(ParserContext parserContext, String id) {
         MutableRefMetadata ref = 
parserContext.createMetadata(MutableRefMetadata.class);
         ref.setComponentId(id);


Reply via email to