geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r766716 - in /geronimo/sandbox/blueprint/blueprint-core/src: main/java/org/apache/geronimo/blueprint/context/Parser.java test/java/org/apache/geronimo/blueprint/ParserTest.java test/resources/test-simple-component.xml
Date Mon, 20 Apr 2009 14:54:11 GMT
Author: gawor
Date: Mon Apr 20 14:54:10 2009
New Revision: 766716

URL: http://svn.apache.org/viewvc?rev=766716&view=rev
Log:
fix init/destroy method parsing

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-simple-component.xml

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java?rev=766716&r1=766715&r2=766716&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
Mon Apr 20 14:54:10 2009
@@ -375,14 +375,20 @@
             metadata.setExplicitDependencies(parseListAsSet(element.getAttribute(DEPENDS_ON_ATTRIBUTE)));
         }
         if (element.hasAttribute(INIT_METHOD_ATTRIBUTE)) {
-            metadata.setInitMethodName(element.getAttribute(INIT_METHOD_ATTRIBUTE));
+            String method = element.getAttribute(INIT_METHOD_ATTRIBUTE);
+            if (method.trim().length() != 0) { 
+                metadata.setInitMethodName(method);
+            }
         } else {
             metadata.setInitMethodName(defaultInitMethod);
         }
         if (element.hasAttribute(DESTROY_METHOD_ATTRIBUTE)) {
-            metadata.setInitMethodName(element.getAttribute(DESTROY_METHOD_ATTRIBUTE));
+            String method = element.getAttribute(DESTROY_METHOD_ATTRIBUTE);
+            if (method.trim().length() != 0) {
+                metadata.setDestroyMethodName(method);
+            }
         } else {
-            metadata.setInitMethodName(defaultDestroyMethod);
+            metadata.setDestroyMethodName(defaultDestroyMethod);
         }
 
         // Parse elements

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java?rev=766716&r1=766715&r2=766716&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java
Mon Apr 20 14:54:10 2009
@@ -121,6 +121,18 @@
         assertNotNull(param.getValue());
         assertTrue(param.getValue() instanceof ReferenceValue);
         assertEquals("pojoB", ((ReferenceValue) param.getValue()).getComponentName());
+        
+        assertEquals("init", local.getInitMethodName());
+        assertEquals("destroy", local.getDestroyMethodName());
+                
+        // test pojoB
+        ComponentMetadata pojoB = registry.getComponentDefinition("pojoB");
+        assertNotNull(pojoB);
+        assertEquals("pojoB", pojoB.getName());
+        assertTrue(pojoB instanceof LocalComponentMetadata);
+        LocalComponentMetadata pojoBLocal = (LocalComponentMetadata) pojoB;
+        assertEquals("initPojo", pojoBLocal.getInitMethodName());
+        assertNull(pojoBLocal.getDestroyMethodName());
     }
 
     public void testParse() throws Exception {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-simple-component.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-simple-component.xml?rev=766716&r1=766715&r2=766716&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-simple-component.xml
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-simple-component.xml
Mon Apr 20 14:54:10 2009
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <components xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 ../../main/resources/org/apache/felix/blueprint/blueprint.xsd">
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 ../../main/resources/org/apache/felix/blueprint/blueprint.xsd"
+            default-init-method="init" default-destroy-method="destroy">
 
     <component id="pojoA" class="org.apache.geronimo.blueprint.pojos.PojoA" depends-on="
pojoB , pojoC ,">
         <constructor-arg value="val0"/>
@@ -30,5 +31,7 @@
             <value>val</value>
         </property>
     </component>
+    
+    <component id="pojoB" class="org.apache.geronimo.blueprint.pojos.PojoA" init-method="initPojo"
destroy-method="" />
 
 </components>
\ No newline at end of file



Mime
View raw message