geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r784005 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
Date Fri, 12 Jun 2009 06:45:48 GMT
Author: gnodet
Date: Fri Jun 12 06:45:48 2009
New Revision: 784005

URL: http://svn.apache.org/viewvc?rev=784005&view=rev
Log:
Put back support for <interfaces/> on service

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java?rev=784005&r1=784004&r2=784005&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
Fri Jun 12 06:45:48 2009
@@ -125,6 +125,7 @@
     public static final String SERVICE_ELEMENT = "service";
     public static final String REFERENCE_ELEMENT = "reference";
     public static final String REFLIST_ELEMENT = "ref-list";
+    public static final String INTERFACES_ELEMENT = "interfaces";
     public static final String LISTENER_ELEMENT = "listener";
     public static final String SERVICE_PROPERTIES_ELEMENT = "service-properties";
     public static final String REGISTRATION_LISTENER_ELEMENT = "registration-listener";
@@ -594,7 +595,12 @@
             if (node instanceof Element) {
                 Element e = (Element) node;
                 if (isBlueprintNamespace(e.getNamespaceURI())) {
-                    if (nodeNameEquals(e, SERVICE_PROPERTIES_ELEMENT)) {
+                    if (nodeNameEquals(e, INTERFACES_ELEMENT)) {
+                        if (hasInterfaceNameAttribute) {
+                            throw new ComponentDefinitionException("Only one of " + INTERFACE_ATTRIBUTE
+ " attribute or " + INTERFACES_ELEMENT + " element must be used");
+                        }
+                        service.setInterfaceNames(parseInterfaceNames(e));
+                    } else if (nodeNameEquals(e, SERVICE_PROPERTIES_ELEMENT)) {
                         List<MapEntry> entries = parseServiceProperties(e, service).getEntries();
                         service.setServiceProperties(entries); 
                     } else if (nodeNameEquals(e, REGISTRATION_LISTENER_ELEMENT)) {
@@ -1011,6 +1017,27 @@
         return listener;
     }
 
+    public List<String> parseInterfaceNames(Element element) {
+        List<String> interfaceNames = new ArrayList<String>();
+        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 (nodeNameEquals(e, VALUE_ELEMENT)) {
+                    String v = getTextValue(e).trim();
+                    if (interfaceNames.contains(v)) {
+                        throw new ComponentDefinitionException("The element " + INTERFACES_ELEMENT
+ " should not contain the same interface twice");
+                    }
+                    interfaceNames.add(getTextValue(e));
+                } else {
+                    throw new ComponentDefinitionException("Unsupported element " + e.getNodeName()
+ " inside an " + INTERFACES_ELEMENT + " element");
+                }
+            }
+        }
+        return interfaceNames;
+    }
+
     private Metadata parseArgumentOrPropertyValue(Element element, ComponentMetadata enclosingComponent)
{
         // TODO: we should ensure there is only a single element or ref attribute defined
here
         if (element.hasAttribute(REF_ATTRIBUTE)) {



Mime
View raw message