You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2007/02/23 19:52:48 UTC

svn commit: r511048 [1/2] - in /incubator/tuscany/branches/sca-java-integration/sca/kernel/core: ./ src/main/java/org/apache/tuscany/core/databinding/javabeans/ src/main/java/org/apache/tuscany/core/implementation/processor/ src/main/java/org/apache/tu...

Author: svkrish
Date: Fri Feb 23 10:52:46 2007
New Revision: 511048

URL: http://svn.apache.org/viewvc?view=rev&rev=511048
Log:
Updates to support Multivalued Properties

Added:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIListObjectFactory.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonListObjectFactory.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ManyPropertyValueLoaderException.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/MissingTypePropertyLoaderException.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimpleMultivaluedPropertyObjectFactory.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/MultivaluePropertyLoadingTestCase.java
Modified:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/.checkstyle
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaMapperException.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/DefaultPropertyValueLoaderException.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoaderException.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyLoaderTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/PropertyParsingTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/StringParserPropertyFactoryTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/PropertyHelperTestCase.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/property/SimplePropertyObjectFactoryTestCase.java

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/.checkstyle
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/.checkstyle?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/.checkstyle (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/.checkstyle Fri Feb 23 10:52:46 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <fileset-config file-format-version="1.2.0" simple-config="true">
-    <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+    <fileset name="all" enabled="true" check-config-name="Tuscany" local="false">
         <file-match-pattern match-pattern="." include-pattern="true"/>
     </fileset>
 </fileset-config>

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaMapperException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaMapperException.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaMapperException.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/databinding/javabeans/XML2JavaMapperException.java Fri Feb 23 10:52:46 2007
@@ -66,4 +66,11 @@
         this.javaType = javaType;
     }
 
+    @Override
+    public String getMessage() {
+        return super.getMessage() + " <" + getJavaFieldName() + "> " + " in <" + getJavaType() + ">";
+    }
+    
+    
+
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java Fri Feb 23 10:52:46 2007
@@ -18,6 +18,12 @@
  */
 package org.apache.tuscany.core.implementation.processor;
 
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -32,9 +38,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.osoa.sca.annotations.Remotable;
-import org.osoa.sca.annotations.Service;
-
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
@@ -49,13 +52,8 @@
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
 import org.apache.tuscany.spi.implementation.java.ProcessingException;
-import org.apache.tuscany.spi.model.OverrideOptions;
-
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllInterfaces;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllPublicAndProtectedFields;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getAllUniquePublicProtectedMethods;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.toPropertyName;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
 
 /**
  * Heuristically evaluates an un-annotated Java implementation type to determine services, references, and properties
@@ -442,7 +440,7 @@
         JavaMappedProperty<T> property = new JavaMappedProperty<T>();
         property.setName(name);
         property.setMember(member);
-        property.setNoDefault(false);
+        property.setMustSupply(false);
         property.setJavaType(paramType);
         TypeInfo xmlType = typeMapper.getXMLType(paramType);
         if (xmlType != null) {

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ImplementationProcessorServiceImpl.java Fri Feb 23 10:52:46 2007
@@ -18,20 +18,18 @@
  */
 package org.apache.tuscany.core.implementation.processor;
 
+import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Member;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.Collection;
 import java.util.List;
-import javax.xml.namespace.QName;
 
-import org.osoa.sca.annotations.Callback;
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Remotable;
-import org.osoa.sca.annotations.Resource;
+import javax.xml.namespace.QName;
 
+import org.apache.tuscany.core.idl.java.IllegalCallbackException;
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
 import org.apache.tuscany.spi.idl.InvalidServiceContractException;
@@ -45,11 +43,12 @@
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
 import org.apache.tuscany.spi.implementation.java.ProcessingException;
 import org.apache.tuscany.spi.model.Multiplicity;
-import org.apache.tuscany.spi.model.OverrideOptions;
 import org.apache.tuscany.spi.model.ServiceContract;
-
-import org.apache.tuscany.core.idl.java.IllegalCallbackException;
-import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Resource;
 
 /**
  * The default implementation of an <code>ImplementationProcessorService</code>
@@ -312,7 +311,7 @@
             throw new DuplicatePropertyException(name);
         }
         property.setName(name);
-        property.setNoDefault(Boolean.parseBoolean(propAnnot.required()));
+        property.setMustSupply(Boolean.parseBoolean(propAnnot.required()));
 
         String xmlType = propAnnot.xmlType();
         if (xmlType != null && xmlType.length() != 0) {

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIListObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIListObjectFactory.java?view=auto&rev=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIListObjectFactory.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/JNDIListObjectFactory.java Fri Feb 23 10:52:46 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.core.injection;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * An implementation of ObjectFactory that creates instances by looking them up in a JNDI context.
+ *
+ * @version $Rev: 430937 $ $Date: 2006-08-12 06:47:56 +0530 (Sat, 12 Aug 2006) $
+ */
+public class JNDIListObjectFactory<T> implements ObjectFactory<List<T>> {
+    private final Context context;
+    private List<String> nameList;
+
+    public JNDIListObjectFactory(Context context, List<String> name) {
+        this.context = context;
+        this.nameList = Collections.unmodifiableList(name);
+    }
+
+
+    @SuppressWarnings("unchecked")
+    public List<T> getInstance() throws ObjectCreationException {
+        try {
+            List<T> instanceList = new ArrayList<T>();
+            for (int count = 0 ; count < instanceList.size() ; ++count) {
+                instanceList.add((T) context.lookup(nameList.get(count)));
+            }
+            return instanceList;
+        } catch (NamingException e) {
+            throw new ObjectCreationException(e);
+        }
+    }
+}

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonListObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonListObjectFactory.java?view=auto&rev=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonListObjectFactory.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/injection/SingletonListObjectFactory.java Fri Feb 23 10:52:46 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.core.injection;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * Implementation of ObjectFactory that returns a single instance, typically an immutable type.
+ *
+ * @version $Rev: 430937 $ $Date: 2006-08-12 06:47:56 +0530 (Sat, 12 Aug 2006) $
+ */
+public class SingletonListObjectFactory<T> implements ObjectFactory<List<T>> {
+    private List<T> instance;
+
+    public SingletonListObjectFactory(List<T> instance) {
+        this.instance = Collections.unmodifiableList(instance);
+    }
+
+    public List<T> getInstance() {
+        return instance;
+    }
+
+}

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ComponentLoader.java Fri Feb 23 10:52:46 2007
@@ -25,6 +25,7 @@
 import java.lang.reflect.Type;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
@@ -71,8 +72,8 @@
 import org.w3c.dom.Document;
 
 /**
- * Loads a component definition from an XML-based assembly file
- *
+ * Loads a component definition from an XML-based assembly file 
+ * 
  * @version $Rev$ $Date$
  */
 public class ComponentLoader extends LoaderExtension<ComponentDefinition<?>> {
@@ -81,13 +82,18 @@
     private static final QName REFERENCE = new QName(XML_NAMESPACE_1_0, "reference");
 
     private static final String PROPERTY_FILE_ATTR = "file";
-    private static final String PROPERTY_NAME_ATTR = "name";
     private static final String PROPERTY_SOURCE_ATTR = "source";
+    private static final String PROPERTY_NAME_ATTR = "name";
+    private static final String PROPERTY_TYPE_ATTR = "type";
+    private static final String PROPERTY_ELEMENT_ATTR = "element";
+    public static final char COLON = ':';
 
     private PropertyObjectFactory propertyFactory;
 
     @Constructor
-    public ComponentLoader(@Autowire LoaderRegistry registry, @Autowire PropertyObjectFactory propertyFactory) {
+    public ComponentLoader(@Autowire
+    LoaderRegistry registry, @Autowire
+    PropertyObjectFactory propertyFactory) {
         super(registry);
         this.propertyFactory = propertyFactory;
     }
@@ -100,7 +106,8 @@
     public ComponentDefinition<?> load(CompositeComponent parent,
                                        ModelObject object,
                                        XMLStreamReader reader,
-                                       DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+                                       DeploymentContext deploymentContext) throws XMLStreamException,
+                                                                           LoaderException {
         assert COMPONENT.equals(reader.getName());
         String name = reader.getAttributeValue(null, "name");
         String initLevel = reader.getAttributeValue(null, "initLevel");
@@ -140,12 +147,11 @@
                     case END_ELEMENT:
                         if (reader.getName().equals(COMPONENT)) {
                             // hack to leave alone SystemImplementation
-                            if (!((Implementation) componentDefinition
-                                .getImplementation() instanceof SystemImplementation)) {
+                            if (!((Implementation)componentDefinition.getImplementation() instanceof SystemImplementation)) {
                                 populatePropertyValues(componentDefinition);
                             }
                             ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> type =
-                                (ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>>) componentDefinition
+                                (ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>>)componentDefinition
                                     .getImplementation().getComponentType();
                             for (ReferenceDefinition ref : type.getReferences().values()) {
                                 if (ref.isAutowire()) {
@@ -168,14 +174,14 @@
 
     protected Implementation<?> loadImplementation(CompositeComponent parent,
                                                    XMLStreamReader reader,
-                                                   DeploymentContext deploymentContext)
-        throws XMLStreamException, LoaderException {
+                                                   DeploymentContext deploymentContext) throws XMLStreamException,
+                                                                                       LoaderException {
         reader.nextTag();
         ModelObject o = registry.load(parent, null, reader, deploymentContext);
         if (!(o instanceof Implementation)) {
             throw new MissingImplementationException();
         }
-        return (Implementation<?>) o;
+        return (Implementation<?>)o;
     }
 
     @SuppressWarnings("unchecked")
@@ -192,23 +198,40 @@
         }
         
         PropertyValue<Type> propertyValue;
+        readPropertyType(reader, property);
+        
         String source = reader.getAttributeValue(null, PROPERTY_SOURCE_ATTR);
         String file = reader.getAttributeValue(null, PROPERTY_FILE_ATTR);
+        
         if (source != null || file != null) {
             propertyValue = new PropertyValue<Type>(name, source, file);
-            propertyValue.setValue(property.getDefaultValue());
+            propertyValue.setValue(property.getDefaultValues());
             LoaderUtil.skipToEndElement(reader);
         } else {
             try {
                 DocumentBuilder documentBuilder = DOMHelper.newDocumentBuilder();
-                Document value = StaxUtil.createPropertyValue(reader, property.getXmlType(), documentBuilder);
-                propertyValue = new PropertyValue<Type>(name, value);
+                List<Document> values = loadPropertyValues(reader, documentBuilder, property.getXmlType(), property.getXmlElement());
+                propertyValue = new PropertyValue<Type>(name, values);
+                if (!property.isMany() && values.size() > 1) {
+                    ManyPropertyValueLoaderException ex = new ManyPropertyValueLoaderException();
+                    ex.setPropertyName(name);
+                    ex.setLine(reader.getLocation().getLineNumber());
+                    ex.setColumn(reader.getLocation().getColumnNumber());
+                    throw ex;
+                }
             } catch (ParserConfigurationException e) {
                 throw new LoaderException(e);
             }
         }
-        ObjectFactory<Type> objectFactory = propertyFactory.createObjectFactory(property, propertyValue);
-        // propertyValue.setValueFactory(new SimplePropertyObjectFactory(property, propertyValue.getValue()));
+        
+        ObjectFactory<?> objectFactory = null;
+        if (property.isMany()) {
+            objectFactory = propertyFactory.createListObjectFactory(property, propertyValue);
+        } else {
+            objectFactory = propertyFactory.createObjectFactory(property, propertyValue);
+        }
+        // propertyValue.setValueFactory(new
+        // SimplePropertyObjectFactory(property, propertyValue.getValue()));
         propertyValue.setValueFactory(objectFactory);
         componentDefinition.add(propertyValue);
     }
@@ -216,12 +239,11 @@
     protected void loadReference(XMLStreamReader reader,
                                  DeploymentContext deploymentContext,
                                  ComponentDefinition<?> componentDefinition) throws XMLStreamException,
-                                                                                    LoaderException {
+                                                                            LoaderException {
         String name = reader.getAttributeValue(null, "name");
         String text = reader.getElementText();
         String target = text != null ? text.trim() : null;
 
-
         if (name == null) {
             throw new InvalidReferenceException("No name specified");
         } else if (target == null) {
@@ -245,7 +267,8 @@
             } else {
                 for (BindingDefinition binding : definition.getBindings()) {
                     try {
-                        // FIXME this is bad - clarify in the spec how URIs are overriden
+                        // FIXME this is bad - clarify in the spec how URIs are
+                        // overriden
                         binding.setTargetUri(new URI(target));
                     } catch (URISyntaxException e) {
                         throw new LoaderException(e);
@@ -268,8 +291,8 @@
     }
 
     @SuppressWarnings("unchecked")
-    protected void populatePropertyValues(ComponentDefinition<Implementation<?>> componentDefinition)
-        throws LoaderException, MissingPropertyValueException {
+    protected void populatePropertyValues(ComponentDefinition<Implementation<?>> componentDefinition) throws LoaderException,
+                                                                                                     MissingPropertyValueException {
         ComponentType componentType = componentDefinition.getImplementation().getComponentType();
         if (componentType != null) {
             Map<String, Property<?>> properties = componentType.getProperties();
@@ -277,16 +300,19 @@
 
             for (Property<?> aProperty : properties.values()) {
                 if (propertyValues.get(aProperty.getName()) == null) {
-                    if (aProperty.isNoDefault()) {
+                    if (aProperty.isMustSupply()) {
                         throw new MissingPropertyValueException(aProperty.getName());
-                    } else if (aProperty.getDefaultValue() != null) {
+                    } else if (aProperty.getDefaultValues() != null) {
                         PropertyValue propertyValue = new PropertyValue();
                         propertyValue.setName(aProperty.getName());
-                        propertyValue.setValue(aProperty.getDefaultValue());
-                        propertyValue.setValueFactory(
-                          propertyFactory.createObjectFactory(aProperty, propertyValue));
-                        /*propertyValue.setValueFactory(new SimplePropertyObjectFactory(aProperty,
-                            propertyValue.getValue()));*/
+                        propertyValue.setValue(aProperty.getDefaultValues());
+                        propertyValue.setValueFactory(propertyFactory
+                            .createObjectFactory(aProperty, propertyValue));
+                        /*
+                         * propertyValue.setValueFactory(new
+                         * SimplePropertyObjectFactory(aProperty,
+                         * propertyValue.getValue()));
+                         */
                         propertyValues.put(aProperty.getName(), propertyValue);
                     }
                 }
@@ -295,7 +321,8 @@
     }
 
     /**
-     * Validates a component definition, ensuring all component type configuration elements are satisfied
+     * Validates a component definition, ensuring all component type
+     * configuration elements are satisfied
      */
     protected void validate(ComponentDefinition<Implementation<?>> definition) throws LoaderException {
         // validate refererences
@@ -337,4 +364,61 @@
 
         }
     }
-}
+
+    private void readPropertyType(XMLStreamReader reader, Property property) throws MissingTypePropertyLoaderException{
+
+        String typeName = reader.getAttributeValue(null, PROPERTY_TYPE_ATTR);
+        String elementName = reader.getAttributeValue(null, PROPERTY_ELEMENT_ATTR);
+        QName xmlElement = null;
+        QName xmlType = null;
+
+        if (typeName != null) {
+            int index = typeName.indexOf(COLON);
+            if (index != -1) {
+                String prefix = typeName.substring(0, index);
+                String localName = typeName.substring(index + 1);
+                String ns = reader.getNamespaceURI(prefix);
+                xmlType = new QName(ns, localName, prefix);
+            }
+        } else if (elementName != null) {
+            int index = elementName.indexOf(COLON);
+            if (index != -1) {
+                String prefix = elementName.substring(0, index);
+                String localName = elementName.substring(index + 1);
+                String ns = reader.getNamespaceURI(prefix);
+                xmlElement = new QName(ns, localName, prefix);
+                // FIXME :
+                // need to figure out how to determine the xmltype from this
+                // xmlelement
+                // this need access to the global xml element thro
+                // schemalocation or thro
+                // artifact repository
+                xmlType = null;
+            }
+        }
+
+        if (xmlType != null) {
+            property.setXmlType(xmlType);
+        }
+
+        if (xmlElement != null) {
+            property.setXmlElement(xmlElement);
+        }
+        
+        /*if (property.getXmlType() == null && property.getXmlElement() == null) {
+            MissingTypePropertyLoaderException ex = new MissingTypePropertyLoaderException();
+            ex.setPropertyName(property.getName());
+            ex.setLine(reader.getLocation().getLineNumber());
+            ex.setColumn(reader.getLocation().getColumnNumber());
+            throw ex; 
+        }*/
+    }
+
+    private List<Document> loadPropertyValues(XMLStreamReader reader,
+                                    DocumentBuilder documentBuilder,
+                                    QName xmlType,
+                                    QName xmlElement) throws XMLStreamException {
+        return StaxUtil.createPropertyValues(reader, xmlType, xmlElement, documentBuilder);
+    }
+    
+ }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/DefaultPropertyValueLoaderException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/DefaultPropertyValueLoaderException.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/DefaultPropertyValueLoaderException.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/DefaultPropertyValueLoaderException.java Fri Feb 23 10:52:46 2007
@@ -27,6 +27,6 @@
 public class DefaultPropertyValueLoaderException extends PropertyLoaderException {
 
     public DefaultPropertyValueLoaderException() {
-        super("Default Property Value must be supplied only when 'noDefault' attribute is set to 'false'");
+        super("Default Property Value must be supplied only when 'mustSupply' attribute is set to 'false'");
     }
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/JNDIPropertyFactory.java Fri Feb 23 10:52:46 2007
@@ -18,6 +18,9 @@
  */
 package org.apache.tuscany.core.loader;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -28,6 +31,7 @@
 import org.apache.tuscany.spi.model.Property;
 import org.apache.tuscany.spi.model.PropertyValue;
 
+import org.apache.tuscany.core.injection.JNDIListObjectFactory;
 import org.apache.tuscany.core.injection.JNDIObjectFactory;
 
 /**
@@ -41,10 +45,25 @@
 public class JNDIPropertyFactory implements PropertyObjectFactory {
     public <T> ObjectFactory<T> createObjectFactory(Property<T> property, PropertyValue<T> value)
         throws LoaderException {
-        String text = value.getValue().getDocumentElement().getTextContent();
+        String text = value.getValue().get(0).getDocumentElement().getTextContent();
         try {
             Context context = new InitialContext();
             return new JNDIObjectFactory<T>(context, text);
+        } catch (NamingException e) {
+            throw new LoaderException(e);
+        }
+    }
+    
+    public <T> ObjectFactory<List<T>> createListObjectFactory(Property<T> property, PropertyValue<T> value)
+    throws LoaderException {
+        try {
+            List<T> instances = new ArrayList<T>();
+            Context context = new InitialContext();
+            List<String> text = new ArrayList<String>();
+            for (int count = 0 ; count < instances.size() ; ++count) {
+                text.add(value.getValue().get(count).getDocumentElement().getTextContent());
+            }
+            return new JNDIListObjectFactory<T>(context, text);
         } catch (NamingException e) {
             throw new LoaderException(e);
         }

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ManyPropertyValueLoaderException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ManyPropertyValueLoaderException.java?view=auto&rev=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ManyPropertyValueLoaderException.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/ManyPropertyValueLoaderException.java Fri Feb 23 10:52:46 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.core.loader;
+
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev: 487057 $ $Date: 2006-12-14 12:50:44 +0530 (Thu, 14 Dec 2006) $
+ */
+public class ManyPropertyValueLoaderException extends PropertyLoaderException {
+
+    public ManyPropertyValueLoaderException() {
+        super("Multiple property values may be supplied only if 'many' attribute is set to  'true'");
+    }
+}

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/MissingTypePropertyLoaderException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/MissingTypePropertyLoaderException.java?view=auto&rev=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/MissingTypePropertyLoaderException.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/MissingTypePropertyLoaderException.java Fri Feb 23 10:52:46 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.core.loader;
+
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev: 487057 $ $Date: 2006-12-14 12:50:44 +0530 (Thu, 14 Dec 2006) $
+ */
+public class MissingTypePropertyLoaderException extends PropertyLoaderException {
+
+    public MissingTypePropertyLoaderException() {
+        super("Property type missing - either one of 'type' or 'element' must be specified ");
+    }
+}

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoader.java Fri Feb 23 10:52:46 2007
@@ -20,6 +20,8 @@
 
 import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
 
+import java.util.List;
+
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -29,6 +31,7 @@
 
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.extension.DOMHelper;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.LoaderExtension;
 import org.apache.tuscany.spi.loader.LoaderRegistry;
@@ -36,12 +39,10 @@
 import org.apache.tuscany.spi.model.Property;
 import org.apache.tuscany.spi.util.stax.StaxUtil;
 import org.osoa.sca.annotations.Constructor;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
 
 /**
  * Loads a property from an XML-based assembly file
- *
+ * 
  * @version $Rev$ $Date$
  */
 public class PropertyLoader extends LoaderExtension<Property> {
@@ -49,14 +50,17 @@
     public static final String PROPERTY_TYPE_ATTR = "type";
     public static final String PROPERTY_ELEMENT_ATTR = "element";
     public static final String PROPERTY_MANY_ATTR = "many";
-    public static final String PROPERTY_NO_DEFAULT_ATTR = "noDefault";
+    public static final String PROPERTY_NO_DEFAULT_ATTR = "mustSupply";
+    public static final String DEFAULT_PREFIX = "xs";
+    public static final String DEFAULT_SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
     public static final char COLON = ':';
-    
+
     public static final QName PROPERTY = new QName(XML_NAMESPACE_1_0, "property");
     private final DocumentBuilder documentBuilder;
 
-    @Constructor({"registry"})
-    public PropertyLoader(@Autowire LoaderRegistry registry) {
+    @Constructor( {"registry"})
+    public PropertyLoader(@Autowire
+    LoaderRegistry registry) {
         super(registry);
         try {
             documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
@@ -70,56 +74,75 @@
         return PROPERTY;
     }
 
-    public Property<?> load(CompositeComponent parent, ModelObject object, XMLStreamReader reader,
-                            DeploymentContext ctx)
-        throws XMLStreamException, PropertyLoaderException {
+    public Property<?> load(CompositeComponent parent,
+                            ModelObject object,
+                            XMLStreamReader reader,
+                            DeploymentContext ctx) throws XMLStreamException,
+                                                  PropertyLoaderException {
         assert PROPERTY.equals(reader.getName());
         String name = reader.getAttributeValue(null, PROPERTY_NAME_ATTR);
         String typeName = reader.getAttributeValue(null, PROPERTY_TYPE_ATTR);
         String elementName = reader.getAttributeValue(null, PROPERTY_ELEMENT_ATTR);
-        
+        QName xmlElement = null;
         QName xmlType = null;
+        
         if (typeName != null) {
             int index = typeName.indexOf(COLON);
             if (index != -1) {
                 String prefix = typeName.substring(0, index);
+                if (prefix == null || prefix.length() == 0) {
+                    prefix = DEFAULT_PREFIX;
+                }
+                
                 String localName = typeName.substring(index + 1);
                 String ns = reader.getNamespaceURI(prefix);
+                if (ns == null || ns.length() == 0) {
+                    ns = DEFAULT_SCHEMA_NS;
+                }
                 xmlType = new QName(ns, localName, prefix);
             }
         } else if (elementName != null) {
-            QName xmlElement = null;
-            int index = typeName.indexOf(COLON);
+            int index = elementName.indexOf(COLON);
             if (index != -1) {
-                String prefix = typeName.substring(0, index);
-                String localName = typeName.substring(index + 1);
+                String prefix = elementName.substring(0, index);
+                String localName = elementName.substring(index + 1);
                 String ns = reader.getNamespaceURI(prefix);
                 xmlElement = new QName(ns, localName, prefix);
-                //FIXME :
-                //need to figure out how to determine the xmltype from this xmlelement 
-                //this need access to the global xml element thro schemalocation or thro 
-                //artifact repository
+                // FIXME :
+                // need to figure out how to determine the xmltype from this
+                // xmlelement
+                // this need access to the global xml element thro
+                // schemalocation or thro
+                // artifact repository
                 xmlType = null;
             }
         }
         
-        
+        if (xmlType == null && xmlElement == null) {
+            MissingTypePropertyLoaderException ex = new MissingTypePropertyLoaderException();
+            ex.setPropertyName(name);
+            ex.setLine(reader.getLocation().getLineNumber());
+            ex.setColumn(reader.getLocation().getColumnNumber());
+            throw ex; 
+        }
+
         boolean many = false;
-        boolean noDefault = false;
+        boolean mustSupply = false;
         String attrValue = null;
         attrValue = reader.getAttributeValue(null, PROPERTY_MANY_ATTR);
         if (attrValue != null) {
-            many = Boolean.parseBoolean(attrValue); 
+            many = Boolean.parseBoolean(attrValue);
         }
-        
+
         attrValue = reader.getAttributeValue(null, PROPERTY_NO_DEFAULT_ATTR);
         if (attrValue != null) {
-            noDefault = Boolean.parseBoolean(attrValue); 
+            mustSupply = Boolean.parseBoolean(attrValue);
         }
-        
-        Document value = StaxUtil.createPropertyValue(reader, xmlType, documentBuilder);
- 
-        if (noDefault && isDefaultValueDefined(value) ) { 
+
+        List defaultValues =
+            StaxUtil.createPropertyValues(reader, xmlType, xmlElement, documentBuilder);
+
+        if (mustSupply && defaultValues.size() > 0) {
             DefaultPropertyValueLoaderException ex = new DefaultPropertyValueLoaderException();
             ex.setPropertyName(name);
             ex.setLine(reader.getLocation().getLineNumber());
@@ -127,23 +150,21 @@
             throw ex;
         }
 
+        if (!many && defaultValues.size() > 1) {
+            ManyPropertyValueLoaderException ex = new ManyPropertyValueLoaderException();
+            ex.setPropertyName(name);
+            ex.setLine(reader.getLocation().getLineNumber());
+            ex.setColumn(reader.getLocation().getColumnNumber());
+            throw ex;
+        }
+
         Property<?> property = new Property();
         property.setName(name);
         property.setXmlType(xmlType);
+        property.setXmlElement(xmlElement);
         property.setMany(many);
-        property.setNoDefault(noDefault);
-        property.setDefaultValue(value);
+        property.setMustSupply(mustSupply);
+        property.setDefaultValues(defaultValues);
         return property;
-    }
-    
-    private boolean isDefaultValueDefined(Document value) {
-        if ( value.getFirstChild().hasChildNodes() ) {
-            Node childNode = value.getFirstChild().getFirstChild();
-            if ( childNode.getNodeType() == Document.ELEMENT_NODE ||
-                    (childNode.getNodeType() == Document.TEXT_NODE && 
-                            childNode.getTextContent().trim().length() > 0) )
-                return true;
-        }
-        return false;
     }
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoaderException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoaderException.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoaderException.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/PropertyLoaderException.java Fri Feb 23 10:52:46 2007
@@ -61,5 +61,9 @@
     public void setPropertyName(String propertyName) {
         this.propertyName = propertyName;
     }
+    
+    public String getMessage() {
+        return super.getMessage() + " in " + getPropertyName();
+    }
 
 }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/loader/StringParserPropertyFactory.java Fri Feb 23 10:52:46 2007
@@ -24,16 +24,19 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.stream.XMLStreamException;
 
+import org.apache.tuscany.core.injection.SingletonListObjectFactory;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
 import org.apache.tuscany.spi.ObjectFactory;
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.PropertyObjectFactory;
 import org.apache.tuscany.spi.model.Property;
 import org.apache.tuscany.spi.model.PropertyValue;
 
-import org.apache.tuscany.core.injection.SingletonObjectFactory;
-
 /**
  * Implementation of StAXPropertyFactory that interprets the XML as
  *
@@ -43,8 +46,19 @@
 
     public <T> ObjectFactory<T> createObjectFactory(Property<T> property, PropertyValue<T> value)
         throws LoaderException {
-        String text = value.getValue().getDocumentElement().getTextContent();
+        String text = value.getValue().get(0).getDocumentElement().getTextContent();
         return new SingletonObjectFactory<T>(createInstance(text, property.getJavaType()));
+    }
+    
+    public <T> ObjectFactory<List<T>> createListObjectFactory(Property<T> property, PropertyValue<T> value)
+    throws LoaderException {
+        String text = null;
+        List<T> instances = new ArrayList<T>();
+        for (int count = 0 ; count < value.getValue().size() ; ++count) {
+            text = value.getValue().get(count).getDocumentElement().getTextContent();
+            instances.add(createInstance(text, property.getJavaType()));
+        }
+        return new SingletonListObjectFactory<T>(instances);
     }
 
     @SuppressWarnings("unchecked")

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyHelper.java Fri Feb 23 10:52:46 2007
@@ -20,19 +20,28 @@
 package org.apache.tuscany.core.property;
 
 import java.io.InputStream;
+import java.io.StringWriter;
 import java.net.URI;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
+import org.apache.tuscany.core.databinding.javabeans.JavaBean2DOMNodeTransformer;
 import org.apache.tuscany.core.databinding.xml.InputStream2Node;
 import org.apache.tuscany.spi.databinding.extension.DOMHelper;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
@@ -73,7 +82,7 @@
         // TODO: How to wrap the result into a Document?
         Document document = DOMHelper.newDocument();
         if (result instanceof Document) {
-            return document;
+            return (Document)result;
         } else {
             document.appendChild(document.importNode(result, true));
             return document;
@@ -109,7 +118,6 @@
         Map<String, PropertyValue<?>> propertyValues = componentDefinition.getPropertyValues();
         
         for (PropertyValue propValue : propertyValues.values()) {
-            Document node = propValue.getValue();
             String source = propValue.getSource();
             String file = propValue.getFile();
             if (source != null) {
@@ -131,27 +139,41 @@
                             ex.addContextName(source);
                             throw ex;
                         }
-                        Document document = compositeProp.getDefaultValue();
+                        
+                        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+                        Document compositePropDefValues = builder.newDocument();
+                        
+                        boolean prependValue = false;
+                        for (int count = 0 ; count < compositeProp.getDefaultValues().size() ; ++count) {
+                            Node clone = compositeProp.getDefaultValues().get(count).getFirstChild().cloneNode(true);
+                            prependValue = clone.getNodeName().equals("value");
+                            clone = compositePropDefValues.adoptNode(clone);
+                            compositePropDefValues.appendChild(clone);
+                            //compositePropDefValues.appendChild(compositeProp.getDefaultValues().get(count).getFirstChild().cloneNode(true));
+                        }
                         // Adding /value because the document root is "value"
                         String path = source.substring(index);
                         String xpath = null;
-                        if ("/".equals(path)) {
-                            // trailing / is not legal for xpath
-                            xpath = "/value";
+                        Property<?> componentProperty = (Property<?>) 
+                            componentDefinition.getImplementation().getComponentType().getProperties().get(propValue.getName());
+                        if (prependValue) {
+                            if ("/".equals(path)) {
+                                // trailing / is not legal for xpath
+                                xpath = "/value";
+                            } else {
+                                xpath = "/value" + path;
+                            }
                         } else {
-                            xpath = "/value" + path;
+                            xpath = path;
                         }
-
+                            
                         // FIXME: How to deal with namespaces?
-                        node = evaluate(null, document, xpath);
+                        Document node = evaluate(null, compositePropDefValues, xpath);
                         if (node != null) {
-                            propValue.setValue(node);
+                            List<Document> values = new ArrayList<Document>();
+                            values.add(node);
+                            propValue.setValue(values);
                         } 
-                        /*Property<?> prop =
-                            (Property<?>)componentDefinition.getImplementation().getComponentType()
-                                .getProperties().get(propValue.getName());
-                        propValue
-                            .setValueFactory(new SimplePropertyObjectFactory(prop, propValue.getValue()));*/
                     } else {
                         InvalidValueException ex =
                             new InvalidValueException("The 'source' has an invalid value");
@@ -162,16 +184,22 @@
                     throw new LoaderException(e);
                 }
             } else if (file != null) {
-                node = loadFromFile(propValue.getFile(), deploymentContext);
-                propValue.setValue(node);
+                Document node = loadFromFile(propValue.getFile(), deploymentContext);
+                List<Document> values = new ArrayList<Document>();
+                values.add(node);
+                propValue.setValue(values);
                 Property<?> prop =
                     (Property<?>)componentDefinition.getImplementation().getComponentType().getProperties()
                         .get(propValue.getName());
-                propValue.setValueFactory(new SimplePropertyObjectFactory(prop, propValue.getValue()));
+                if (prop.isMany()) {
+                    propValue.setValueFactory(new SimpleMultivaluedPropertyObjectFactory(prop, propValue.getValue()));
+                } else {
+                    propValue.setValueFactory(new SimplePropertyObjectFactory(prop, (Document)propValue.getValue().get(0)));
+                }
             }
         }
     }
-
+    
     private static class DOMNamespeceContext implements NamespaceContext {
         private Node node;
 
@@ -184,10 +212,12 @@
         }
 
         public String getNamespaceURI(String prefix) {
+            //return "http://foo";
             return node.lookupNamespaceURI(prefix);
         }
 
         public String getPrefix(String namespaceURI) {
+            //return "foo";
             return node.lookupPrefix(namespaceURI);
         }
 

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/PropertyObjectFactoryImpl.java Fri Feb 23 10:52:46 2007
@@ -19,6 +19,9 @@
 
 package org.apache.tuscany.core.property;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.namespace.QName;
 
 import org.apache.tuscany.core.databinding.xml.DOMDataBinding;
@@ -31,6 +34,7 @@
 import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
 import org.apache.tuscany.spi.idl.ElementInfo;
 import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.PropertyObjectFactory;
 import org.apache.tuscany.spi.model.DataType;
 import org.apache.tuscany.spi.model.Property;
@@ -58,18 +62,26 @@
 
     public <T> ObjectFactory<T> createObjectFactory(Property<T> property, PropertyValue<T> value) {
         if (mediator == null) {
-            return new SimplePropertyObjectFactory<T>(property, value.getValue());
+            return new SimplePropertyObjectFactory<T>(property, value.getValue().get(0));
         }
         return new ObjectFactoryImpl<T>(property, value);
     }
+    
+    public <T> ObjectFactory<List<T>> createListObjectFactory(Property<T> property, PropertyValue<T> value) throws LoaderException {
+        if (mediator == null) {
+            return new SimpleMultivaluedPropertyObjectFactory<T>(property, value.getValue());
+        }
+        return new ListObjectFactoryImpl<T>(property, value);
+    }
 
-    public class ObjectFactoryImpl<P> implements ObjectFactory<P> {
-        private Property<P> property;
-        private PropertyValue<P> propertyValue;
-        private DataType<QName> sourceDataType;
-        private DataType<?> targetDataType;
+    
+    public class ObjectFactoryImplBase<P> {
+        protected Property<P> property;
+        protected PropertyValue<P> propertyValue;
+        protected DataType<QName> sourceDataType;
+        protected DataType<?> targetDataType;
 
-        public ObjectFactoryImpl(Property<P> property, PropertyValue<P> propertyValue) {
+        public ObjectFactoryImplBase(Property<P> property, PropertyValue<P> propertyValue) {
             this.property = property;
             this.propertyValue = propertyValue;
             sourceDataType = new DataType<QName>(DOMDataBinding.NAME, Node.class, this.property.getXmlType());
@@ -95,11 +107,33 @@
                 registry.introspectType(targetDataType, null);
             }
         }
+    }
 
+    public class ObjectFactoryImpl<P> extends ObjectFactoryImplBase<P> implements ObjectFactory<P> {
+        
+        public ObjectFactoryImpl(Property<P> property, PropertyValue<P> propertyValue) {
+            super(property, propertyValue);
+        }
+    
         @SuppressWarnings("unchecked")
         public P getInstance() throws ObjectCreationException {
-            return (P)mediator.mediate(propertyValue.getValue(), sourceDataType, targetDataType, null);
+            return (P)mediator.mediate(propertyValue.getValue().get(0), sourceDataType, targetDataType, null);
+        }
+    }
+        
+    public class ListObjectFactoryImpl<P> extends ObjectFactoryImplBase<P> implements ObjectFactory<List<P>> {
+        
+        public ListObjectFactoryImpl(Property<P> property, PropertyValue<P> propertyValue) {
+            super(property, propertyValue);
+        }
+    
+        @SuppressWarnings("unchecked")
+        public List<P> getInstance() throws ObjectCreationException {
+            List<P> instances = new ArrayList<P>();
+            for (int count = 0; count < propertyValue.getValue().size() ; ++count) {
+                instances.add((P)mediator.mediate(propertyValue.getValue().get(count), sourceDataType, targetDataType, null));
+            }
+            return instances;
         }
     }
-
 }

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimpleMultivaluedPropertyObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimpleMultivaluedPropertyObjectFactory.java?view=auto&rev=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimpleMultivaluedPropertyObjectFactory.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimpleMultivaluedPropertyObjectFactory.java Fri Feb 23 10:52:46 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.core.property;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.apache.tuscany.spi.model.Property;
+import org.w3c.dom.Document;
+
+public class SimpleMultivaluedPropertyObjectFactory<P> implements ObjectFactory<List<P>> {
+    private SimpleTypeMapperExtension typeMapper;
+    private Property<P> property;
+    private List<Document> values;
+    private List<P> instance;
+
+    public SimpleMultivaluedPropertyObjectFactory(Property<P> property, List<Document> value) {
+        super();
+        
+        this.property = property;
+        this.values = (value == null) ? property.getDefaultValues() : value;
+        this.typeMapper = new SimpleTypeMapperExtension();
+    }
+
+    @SuppressWarnings("unchecked")
+    public List<P> getInstance() throws ObjectCreationException {
+        if (values == null) {
+            return null;
+        }
+        
+        TypeInfo xmlType = null;
+        String text = null;
+        
+        if (instance == null) {
+            instance = new ArrayList<P>();
+            for (int count = 0 ; count < values.size() ; ++count) {
+                text = values.get(count).getDocumentElement().getTextContent();
+            
+                if (property.getJavaType() == null) {
+                    xmlType = new TypeInfo(property.getXmlType(), true, null);
+                } else {
+                    xmlType = typeMapper.getXMLType(property.getJavaType());
+                }
+                if (xmlType == null) {
+                    throw new IllegalArgumentException("Complex property is not supported.");
+                }
+                instance.add((P)typeMapper.toJavaObject(xmlType.getQName(), text, null));
+            }
+        }
+        return instance;
+    }
+
+}

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/property/SimplePropertyObjectFactory.java Fri Feb 23 10:52:46 2007
@@ -36,7 +36,7 @@
         super();
         
         this.property = property;
-        this.value = (value == null) ? property.getDefaultValue() : value;
+        this.value = (value == null) ? property.getDefaultValues().get(0) : value;
         this.typeMapper = new SimpleTypeMapperExtension();
     }
 

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java Fri Feb 23 10:52:46 2007
@@ -75,7 +75,7 @@
         if (!this.registry.containsKey(contentType)) {
             throw new UnsupportedContentTypeException(contentType, sourceURL.getPath());
         }
-
+ 
         this.registry.get(contentType).processContent(contribution, source, inputStream);
 
     }

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java Fri Feb 23 10:52:46 2007
@@ -83,8 +83,9 @@
         type.setImplementationScope(Scope.STATELESS);
         JavaImplementation impl = new JavaImplementation(Foo.class, type);
         ComponentDefinition<JavaImplementation> definition = new ComponentDefinition<JavaImplementation>(impl);
-        ObjectFactory<Integer> defaultValueFactory = property.getDefaultValueFactory();
-        PropertyValue<Integer> propertyValue = new PropertyValue<Integer>(property.getName(), defaultValueFactory);
+        ObjectFactory<?> defaultValueFactory = property.getDefaultValueFactory();
+        PropertyValue<Integer> propertyValue = 
+            new PropertyValue<Integer>(property.getName(), defaultValueFactory);
         definition.getPropertyValues().put(property.getName(), propertyValue);
         AtomicComponent component = builder.build(parent, definition, deploymentContext);
         FooInt foo = (FooInt) component.createInstance();

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java Fri Feb 23 10:52:46 2007
@@ -45,7 +45,7 @@
         Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
         processor.visitConstructor(null, ctor, type, null);
         JavaMappedProperty<?> property = type.getProperties().get("myProp");
-        assertEquals(property.isNoDefault(), true);
+        assertEquals(property.isMustSupply(), true);
         assertEquals("myProp", property.getName());
     }
 

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderPropertyTestCase.java Fri Feb 23 10:52:46 2007
@@ -51,7 +51,7 @@
             new PojoComponentType<ServiceDefinition, ReferenceDefinition, Property<?>>();
         Property property = new Property();
         property.setName("name");
-        property.setNoDefault(true);
+        property.setMustSupply(true);
         type.add(property);
         
         JavaImplementation impl = new JavaImplementation(null, type);

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/ComponentLoaderTestCase.java Fri Feb 23 10:52:46 2007
@@ -142,6 +142,8 @@
         XMLStreamReader reader = createMock(XMLStreamReader.class);
         expect(reader.getAttributeValue(null, "name")).andReturn("name");
         expect(reader.getAttributeValue(null, "source")).andReturn("$source");
+        expect(reader.getAttributeValue(null, "type")).andReturn(null).anyTimes();
+        expect(reader.getAttributeValue(null, "element")).andReturn(null).anyTimes();
         expect(reader.getAttributeValue(null, "file")).andReturn(null);
         expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
         replay(reader);

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java?view=diff&rev=511048&r1=511047&r2=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/JNDIPropertyFactoryTestCase.java Fri Feb 23 10:52:46 2007
@@ -1,19 +1,21 @@
 package org.apache.tuscany.core.loader;
 
 import java.lang.reflect.Type;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
+
 import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.naming.spi.InitialContextFactory;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.tuscany.spi.model.PropertyValue;
-
 import junit.framework.TestCase;
+
 import org.apache.tuscany.core.injection.JNDIObjectFactory;
+import org.apache.tuscany.spi.model.PropertyValue;
 import org.easymock.EasyMock;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 /**
  * @version $Rev$ $Date$
@@ -32,7 +34,9 @@
             EasyMock.expect(doc.getDocumentElement()).andReturn(element);
             EasyMock.replay(doc);
             PropertyValue<?> value = new MockPropertyValue<Type>();
-            value.setValue(doc);
+            List<Document> docList = new ArrayList<Document>();
+            docList.add(doc);
+            value.setValue(docList);
             JNDIObjectFactory<?> jndiFactory = (JNDIObjectFactory<?>) factory.createObjectFactory(null, value);
             assertEquals("bar", jndiFactory.getInstance());
         } finally {

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/MultivaluePropertyLoadingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/MultivaluePropertyLoadingTestCase.java?view=auto&rev=511048
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/MultivaluePropertyLoadingTestCase.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/loader/MultivaluePropertyLoadingTestCase.java Fri Feb 23 10:52:46 2007
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.core.loader;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.databinding.javabeans.JavaBean2DOMNodeTransformer;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.util.stax.StaxUtil;
+import org.easymock.EasyMock;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * @version $Rev: 502055 $ $Date: 2007-02-01 05:37:32 +0530 (Thu, 01 Feb 2007) $
+ */
+public class MultivaluePropertyLoadingTestCase extends TestCase {
+    private PropertyLoader propertyLoader;
+    private XMLInputFactory xmlFactory;
+    
+    
+    public void testPropertyLoading_SimpleType() throws Exception {
+        String xml = "<tus:property xmlns:foo='http://foo.com' "
+                + "xmlns:tus='http://www.osoa.org/xmlns/sca/1.0'"
+            + " name='TestProperty' many='true' type='foo:TestType'>"
+            + "<foo:TestValue>"
+            + "TestPropertyValue"
+            + "</foo:TestValue>"
+            + "</tus:property>";
+
+        XMLStreamReader reader = getReader(xml);
+        Property<?> aProperty = propertyLoader.load(null, null, reader, null);
+        //printNode(aProperty.getDefaultValue());
+        
+        assertEquals("TestProperty", aProperty.getName());
+        assertEquals(new QName("http://foo.com", "TestType", "foo"), aProperty.getXmlType());
+        assertEquals(false, aProperty.isMustSupply());
+        assertEquals(true, aProperty.isMany());
+        
+        Element root = aProperty.getDefaultValues().get(0).getDocumentElement();
+        
+        NodeList childNodes = root.getChildNodes();
+        assertEquals(1, childNodes.getLength());
+
+        Text t = (Text) childNodes.item(0);
+        assertEquals("TestPropertyValue", t.getTextContent());
+    }
+    
+    public void testPropertyLoading_Type() throws Exception {
+        String xml = "<tus:property xmlns:foo='http://foo.com' "
+                	+ "xmlns:tus='http://www.osoa.org/xmlns/sca/1.0' " 
+                        + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
+                        + " name='complexFoo' many='true' type='foo:MyComplexType'>"
+                        + "<MyComplexPropertyValue1 xsi:type='foo:MyComplexType' attr='bar'>"
+                            + "<foo:a>AValue</foo:a>" 
+                            + "<foo:b>InterestingURI</foo:b>"
+                        + "</MyComplexPropertyValue1>" 
+                        + "<MyComplexPropertyValue2 xsi:type='foo:MyComplexType' attr='zing'>"
+                            + "<foo:a>BValue</foo:a>"
+                            + "<foo:b>BoringURI</foo:b>"
+                        + "</MyComplexPropertyValue2>"
+                        + "</tus:property>";
+
+        
+
+        XMLStreamReader reader = getReader(xml);
+        Property<?> aProperty = propertyLoader.load(null, null, reader, null);
+        
+        assertEquals("complexFoo", aProperty.getName());
+        assertEquals(new QName("http://foo.com", "MyComplexType", "foo"), aProperty.getXmlType());
+        assertEquals(false, aProperty.isMustSupply());
+        assertEquals(true, aProperty.isMany());
+        
+        Element secondValue = aProperty.getDefaultValues().get(1).getDocumentElement();
+        
+        NodeList childNodes = secondValue.getChildNodes();
+        assertEquals(2, childNodes.getLength());
+
+        Element e = (Element) childNodes.item(0);
+        assertEquals("http://foo.com", e.getNamespaceURI());
+        assertEquals("a", e.getLocalName());
+        assertEquals("BValue", e.getTextContent());
+        e = (Element) childNodes.item(1);
+        assertEquals("http://foo.com", e.getNamespaceURI());
+        assertEquals("b", e.getLocalName());
+        assertEquals("BoringURI", e.getTextContent());
+    }
+  
+    public void testPropertyLoading_Element() throws Exception {
+        String xml = 
+            "<tus:property xmlns:foo='http://foo.com' "
+                + "xmlns:tus='http://www.osoa.org/xmlns/sca/1.0'"
+                + " name='TestProperty' many='true' element='foo:TestElement'>\n"
+                + "<foo:TestElement>"
+                    + "<foo:a>aValue1</foo:a>"
+                    + "<foo:b>InterestingURI1</foo:b>"
+                + "</foo:TestElement>"
+                + "<foo:TestElement>"
+                    + "<foo:a>aValue2</foo:a>"
+                    + "<foo:b>InterestingURI2</foo:b>"
+            + "</foo:TestElement>"
+            + "</tus:property>";
+        XMLStreamReader reader = getReader(xml);
+        Property<?> aProperty = propertyLoader.load(null, null, reader, null);
+        
+        Element secondElement = aProperty.getDefaultValues().get(1).getDocumentElement();
+        
+        assertEquals(2, aProperty.getDefaultValues().size());
+        assertEquals("TestProperty", aProperty.getName());
+        assertEquals(new QName("http://foo.com", "TestElement", "foo"), aProperty.getXmlElement());
+        assertEquals(false, aProperty.isMustSupply());
+        assertEquals(true, aProperty.isMany());
+        
+        NodeList childNodes = secondElement.getChildNodes();
+        assertEquals(2, childNodes.getLength());
+
+        Element e = (Element) childNodes.item(0);
+        assertEquals("http://foo.com", e.getNamespaceURI());
+        assertEquals("a", e.getLocalName());
+        assertEquals("aValue2", e.getTextContent());
+        e = (Element) childNodes.item(1);
+        assertEquals("http://foo.com", e.getNamespaceURI());
+        assertEquals("b", e.getLocalName());
+        assertEquals("InterestingURI2", e.getTextContent());
+    }
+    
+    public void testManyValueException() throws Exception {
+        String xml = 
+            "<tus:property xmlns:foo='http://foo.com' "
+            + "xmlns:tus='http://www.osoa.org/xmlns/sca/1.0'"
+            + " name='TestProperty' element='foo:TestElement'>\n"
+            + "<foo:TestElement>"
+                + "<foo:a>aValue1</foo:a>"
+                + "<foo:b>InterestingURI1</foo:b>"
+            + "</foo:TestElement>"
+            + "<foo:TestElement>"
+                + "<foo:a>aValue2</foo:a>"
+                + "<foo:b>InterestingURI2</foo:b>"
+        + "</foo:TestElement>"
+        + "</tus:property>";
+
+        XMLStreamReader reader = getReader(xml);
+        
+        try {
+            propertyLoader.load(null, null, reader, null);
+        } catch (Exception e) {
+            assertTrue(e instanceof ManyPropertyValueLoaderException);
+        }
+    }
+
+    public XMLStreamReader getReader(String xml) throws XMLStreamException {
+        XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(xml));
+        reader.next();
+        return reader;
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        xmlFactory = XMLInputFactory.newInstance();
+        propertyLoader = new PropertyLoader(EasyMock.createMock(LoaderRegistry.class));
+    }
+    
+    private void printNode(Node node) throws Exception {
+        javax.xml.transform.Transformer transformer =
+            TransformerFactory.newInstance().newTransformer();
+        JavaBean2DOMNodeTransformer java2DomTransformer = new JavaBean2DOMNodeTransformer();
+        StringWriter sw = new StringWriter();
+        transformer.transform(new DOMSource(node), new StreamResult(sw));
+        
+        System.out.println(sw.toString());
+    }
+}



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