geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r769258 - /geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java
Date Tue, 28 Apr 2009 06:09:54 GMT
Author: gnodet
Date: Tue Apr 28 06:09:53 2009
New Revision: 769258

URL: http://svn.apache.org/viewvc?rev=769258&view=rev
Log:
Extract method for parsing property-placeholder

Modified:
    geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java

Modified: geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java?rev=769258&r1=769257&r2=769258&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java
Tue Apr 28 06:09:53 2009
@@ -81,46 +81,50 @@
         ExtendedComponentDefinitionRegistry registry = (ExtendedComponentDefinitionRegistry)
context.getComponentDefinitionRegistry();
         createConfigAdminProxy(context, registry);
         if (nodeNameEquals(element, PROPERTY_PLACEHOLDER_ELEMENT)) {
-            MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
-            metadata.setId(getName(element));
-            metadata.setClassName(CmPropertyPlaceholder.class.getName());
-            metadata.addProperty("blueprintContext", createRef(context, "blueprintContext"));
-            metadata.addProperty("configAdmin", createRef(context, CONFIG_ADMIN_REFERENCE_NAME));
-            metadata.addProperty("persistentId", createValue(context, element.getAttribute(PERSISTENT_ID_ATTRIBUTE)));
-            String prefix = element.hasAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
-                                        ? element.getAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
-                                        : "${";
-            metadata.addProperty("placeholderPrefix", createValue(context, prefix));
-            String suffix = element.hasAttribute(PLACEHOLDER_SUFFIX_ATTRIBUTE)
-                                        ? element.getAttribute(PLACEHOLDER_SUFFIX_ATTRIBUTE)
-                                        : "}";
-            metadata.addProperty("placeholderSuffix", createValue(context, suffix));
-            String defaultsRef = element.hasAttribute(DEFAULTS_REF_ATTRIBUTE) ? element.getAttribute(DEFAULTS_REF_ATTRIBUTE)
: null;
-            if (defaultsRef != null) {
-                metadata.addProperty("defaultProperties", createRef(context, defaultsRef));
-            }
-            // Parse elements
-            NodeList nl = element.getChildNodes();
-            for (int i = 0; i < nl.getLength(); i++) {
-                Node node = nl.item(i);
-                if (node instanceof Element) {
-                    Element e = (Element) node;
-                    if (BLUEPRINT_CM_NAMESPACE.equals(e.getNamespaceURI())) {
-                        if (nodeNameEquals(e, DEFAULT_PROPERTIES_ELEMENT)) {
-                            if (defaultsRef != null) {
-                                throw new ComponentDefinitionException("Only one of " + DEFAULTS_REF_ATTRIBUTE
+ " attribute or " + DEFAULT_PROPERTIES_ELEMENT + " element is allowed");
-                            }
-                            Metadata props = parseDefaultProperties(context, metadata, e);
-                            metadata.addProperty("defaultProperties", props);
+            return parsePropertyPlaceholder(context, element);
+        } else {
+            // TODO: parse other compendium elements.
+            throw new ComponentDefinitionException("Unsupported element: " + element.getNodeName());
+        }
+    }
+
+    private ComponentMetadata parsePropertyPlaceholder(ExtendedParserContext context, Element
element) {
+        MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
+        metadata.setId(getName(element));
+        metadata.setClassName(CmPropertyPlaceholder.class.getName());
+        metadata.addProperty("blueprintContext", createRef(context, "blueprintContext"));
+        metadata.addProperty("configAdmin", createRef(context, CONFIG_ADMIN_REFERENCE_NAME));
+        metadata.addProperty("persistentId", createValue(context, element.getAttribute(PERSISTENT_ID_ATTRIBUTE)));
+        String prefix = element.hasAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
+                                    ? element.getAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
+                                    : "${";
+        metadata.addProperty("placeholderPrefix", createValue(context, prefix));
+        String suffix = element.hasAttribute(PLACEHOLDER_SUFFIX_ATTRIBUTE)
+                                    ? element.getAttribute(PLACEHOLDER_SUFFIX_ATTRIBUTE)
+                                    : "}";
+        metadata.addProperty("placeholderSuffix", createValue(context, suffix));
+        String defaultsRef = element.hasAttribute(DEFAULTS_REF_ATTRIBUTE) ? element.getAttribute(DEFAULTS_REF_ATTRIBUTE)
: null;
+        if (defaultsRef != null) {
+            metadata.addProperty("defaultProperties", createRef(context, defaultsRef));
+        }
+        // Parse elements
+        NodeList nl = element.getChildNodes();
+        for (int i = 0; i < nl.getLength(); i++) {
+            Node node = nl.item(i);
+            if (node instanceof Element) {
+                Element e = (Element) node;
+                if (BLUEPRINT_CM_NAMESPACE.equals(e.getNamespaceURI())) {
+                    if (nodeNameEquals(e, DEFAULT_PROPERTIES_ELEMENT)) {
+                        if (defaultsRef != null) {
+                            throw new ComponentDefinitionException("Only one of " + DEFAULTS_REF_ATTRIBUTE
+ " attribute or " + DEFAULT_PROPERTIES_ELEMENT + " element is allowed");
                         }
+                        Metadata props = parseDefaultProperties(context, metadata, e);
+                        metadata.addProperty("defaultProperties", props);
                     }
                 }
             }
-            return metadata;
-        } else {
-            // TODO: parse other compendium elements.
-            throw new ComponentDefinitionException("Unsupported element: " + element.getNodeName());
         }
+        return metadata;
     }
 
     private Metadata parseDefaultProperties(ExtendedParserContext context, MutableBeanMetadata
enclosingComponent, Element element) {



Mime
View raw message