tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r428470 - in /incubator/tuscany/java/sca: core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java spi/src/main/java/org/apache/tuscany/spi/model/Property.java
Date Thu, 03 Aug 2006 18:43:02 GMT
Author: jboynes
Date: Thu Aug  3 11:43:02 2006
New Revision: 428470

URL: http://svn.apache.org/viewvc?rev=428470&view=rev
Log:
load default property value as a DOM so that we can support complex properties

Modified:
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
    incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Property.java

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java?rev=428470&r1=428469&r2=428470&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
(original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
Thu Aug  3 11:43:02 2006
@@ -19,16 +19,19 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 
 import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
 import org.osoa.sca.annotations.Constructor;
+import org.w3c.dom.Document;
 
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.LoaderExtension;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.LoaderRegistry;
-import org.apache.tuscany.spi.loader.LoaderUtil;
 import org.apache.tuscany.spi.model.Property;
 import org.apache.tuscany.spi.annotation.Autowire;
 
@@ -39,10 +42,17 @@
  */
 public class PropertyLoader extends LoaderExtension<Property> {
     public static final QName PROPERTY = new QName(XML_NAMESPACE_1_0, "property");
+    private final DocumentBuilder documentBuilder;
 
     @Constructor({"registry"})
     public PropertyLoader(@Autowire LoaderRegistry registry) {
         super(registry);
+        try {
+            documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        } catch (ParserConfigurationException e) {
+            // we should be able to construct the default DocumentBuilder
+            throw new AssertionError(e);
+        }
     }
 
     public QName getXMLType() {
@@ -52,8 +62,7 @@
     public Property<?> load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext
ctx)
         throws XMLStreamException, LoaderException {
         assert PROPERTY.equals(reader.getName());
-        Property<?> property = new Property();
-        property.setName(reader.getAttributeValue(null, "name"));
+        String name = reader.getAttributeValue(null, "name");
         String typeName = reader.getAttributeValue(null, "type");
         QName xmlType;
         int index = typeName.indexOf(':');
@@ -67,13 +76,16 @@
             String namespaceURI = reader.getNamespaceURI();
             xmlType = new QName(namespaceURI, typeName);
         }
-        property.setXmlType(xmlType);
-        property.setMany(Boolean.parseBoolean(reader.getAttributeValue(null, "many")));
-        property.setRequired(Boolean.parseBoolean(reader.getAttributeValue(null, "required")));
+        boolean many = Boolean.parseBoolean(reader.getAttributeValue(null, "many"));
+        boolean required = Boolean.parseBoolean(reader.getAttributeValue(null, "required"));
+        Document value = StAXUtil.createPropertyValue(reader, xmlType, documentBuilder);
 
-        // TODO support default values
-
-        LoaderUtil.skipToEndElement(reader);
+        Property<?> property = new Property();
+        property.setName(name);
+        property.setXmlType(xmlType);
+        property.setMany(many);
+        property.setRequired(required);
+        property.setDefaultValue(value);
         return property;
     }
 }

Modified: incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Property.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Property.java?rev=428470&r1=428469&r2=428470&view=diff
==============================================================================
--- incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Property.java
(original)
+++ incubator/tuscany/java/sca/spi/src/main/java/org/apache/tuscany/spi/model/Property.java
Thu Aug  3 11:43:02 2006
@@ -18,6 +18,8 @@
 
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Document;
+
 import org.apache.tuscany.spi.ObjectFactory;
 
 /**
@@ -32,6 +34,7 @@
     private Class<T> javaType;
     private boolean many;
     private boolean required;
+    private Document defaultValue;
 
     public Property() {
     }
@@ -88,5 +91,13 @@
 
     public void setRequired(boolean required) {
         this.required = required;
+    }
+
+    public Document getDefaultValue() {
+        return defaultValue;
+    }
+
+    public void setDefaultValue(Document defaultValue) {
+        this.defaultValue = defaultValue;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message