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/04/20 16:06:39 UTC

svn commit: r530817 - in /incubator/tuscany/java/sca/modules/implementation-script: ./ src/main/java/org/apache/tuscany/implementation/script/ src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/

Author: svkrish
Date: Fri Apr 20 07:06:38 2007
New Revision: 530817

URL: http://svn.apache.org/viewvc?view=rev&rev=530817
Log:
Extended a bit to support simple type properties

Added:
    incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java
Modified:
    incubator/tuscany/java/sca/modules/implementation-script/pom.xml
    incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
    incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
    incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
    incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java
    incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType
    incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js

Modified: incubator/tuscany/java/sca/modules/implementation-script/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/pom.xml?view=diff&rev=530817&r1=530816&r2=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/pom.xml Fri Apr 20 07:06:38 2007
@@ -115,6 +115,11 @@
             <version>1.0-incubating-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-databinding</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
 
 <!-- TODO: big hack to add script engine dependencies till extension dependencies fixed -->
 

Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java?view=diff&rev=530817&r1=530816&r2=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java Fri Apr 20 07:06:38 2007
@@ -33,6 +33,9 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.tuscany.assembly.ComponentType;
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.assembly.Reference;
+import org.apache.tuscany.assembly.Service;
 import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
 import org.apache.tuscany.assembly.xml.Constants;
 import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtension;
@@ -123,6 +126,15 @@
         ComponentType componentType = resolver.resolve(ComponentType.class, ct);
         if (componentType.isUnresolved()) {
             throw new ContributionResolveException("missing .componentType side file");
+        }
+        for (Reference reference : componentType.getReferences()) {
+            scriptImplementation.getReferences().add(reference);
+        }
+        for (Service service : componentType.getServices()) {
+            scriptImplementation.getServices().add(service);
+        }
+        for (Property property : componentType.getProperties()) {
+            scriptImplementation.getProperties().add(property);
         }
         scriptImplementation.setComponentType(componentType);
     }

Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java?view=diff&rev=530817&r1=530816&r2=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java Fri Apr 20 07:06:38 2007
@@ -29,11 +29,14 @@
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 
+import org.apache.tuscany.assembly.ComponentProperty;
 import org.apache.tuscany.core.component.ComponentContextImpl;
 import org.apache.tuscany.core.component.ComponentContextProvider;
 import org.apache.tuscany.core.component.scope.InstanceWrapperBase;
+import org.apache.tuscany.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.interfacedef.Operation;
 import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
 import org.apache.tuscany.spi.component.InstanceWrapper;
 import org.apache.tuscany.spi.component.TargetInvokerCreationException;
 import org.apache.tuscany.spi.component.TargetResolutionException;
@@ -49,16 +52,17 @@
     private ScriptImplementation impl;
     private ComponentContext componentContext;
     private Map<String, Object> references;
+    private Map<String, ObjectFactory<?>> propertyValueFactories;
+    
+    private ScriptPropertyValueObjectFactory propertyValueObjectFactory = null;
+    private DataBindingExtensionPoint dataBindingRegistry;
 
     public ScriptComponent(URI uri, URI groupId, ScriptImplementation impl) {
         super(uri, null, null, groupId, 50);
         this.impl = impl;
         componentContext = new ComponentContextImpl(this);
         references = new HashMap<String, Object>();
-    }
-
-    public void configureProperty(String propertyName) {
-       
+        propertyValueFactories = new HashMap<String, ObjectFactory<?>>();
     }
 
     public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean callback)
@@ -80,7 +84,7 @@
 
     public Object createInstance() throws ObjectCreationException {
         try {
-
+            ObjectFactory<?> propertyValueFactory = null;
             ScriptEngineManager manager = new ScriptEngineManager();
             
             for (String referenceName : references.keySet()) {
@@ -88,6 +92,13 @@
                 manager.put(referenceName, reference);
             }
             
+            for (String propertyName : propertyValueFactories.keySet()) {
+                propertyValueFactory = propertyValueFactories.get(propertyName);
+                if ( propertyValueFactory != null) {
+                    manager.put(propertyName, propertyValueFactory.getInstance());
+                }
+            }
+            
             ScriptEngine engine = manager.getEngineByExtension(impl.getScriptLanguage());
             if (engine == null) {
                 throw new ObjectCreationException("no script engine found for language: " + impl.getScriptLanguage());
@@ -149,5 +160,24 @@
     public <B> ServiceReference<B> getServiceReference(Class<B> arg0, String arg1) {
         // TODO Auto-generated method stub
         return null;
+    }
+
+    public void setDataBindingRegistry(DataBindingExtensionPoint dataBindingRegistry) {
+        this.dataBindingRegistry = dataBindingRegistry;
+    }
+
+    public void setPropertyValueObjectFactory(ScriptPropertyValueObjectFactory propertyValueObjectFactory) {
+        this.propertyValueObjectFactory = propertyValueObjectFactory;
+    }
+    
+    public void initializePropertyValueFactories(List<ComponentProperty> properties) {
+        ObjectFactory<?> propertyObjectFactory = null;
+        
+        for (ComponentProperty aProperty : properties) {
+            if (aProperty.getValue() != null) {
+                propertyObjectFactory = propertyValueObjectFactory.createValueFactory(aProperty);
+                propertyValueFactories.put(aProperty.getName(), propertyObjectFactory);
+            }
+        }
     }
 }

Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java?view=diff&rev=530817&r1=530816&r2=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java Fri Apr 20 07:06:38 2007
@@ -22,13 +22,16 @@
 import java.net.URI;
 
 import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.spi.builder.BuilderConfigException;
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
 
 public class ScriptComponentBuilder extends ComponentBuilderExtension<ScriptImplementation> {
-
+    private ScriptPropertyValueObjectFactory propertyValueObjectFactory = null;
+    private DataBindingExtensionPoint dataBindingRegistry;
+    
     public ScriptComponentBuilder() {
     }
 
@@ -36,12 +39,25 @@
         URI id = URI.create(context.getComponentId() + assemblyComponent.getName());
         ScriptImplementation scriptImplementation = (ScriptImplementation)assemblyComponent.getImplementation();
         ScriptComponent scriptComponent = new ScriptComponent(id, context.getGroupId(), scriptImplementation);
+        scriptComponent.setPropertyValueObjectFactory(propertyValueObjectFactory);
+        scriptComponent.setDataBindingRegistry(dataBindingRegistry);
+        
+        scriptComponent.initializePropertyValueFactories(assemblyComponent.getProperties());
+        
         return scriptComponent;
     }
 
     @Override
     protected Class<ScriptImplementation> getImplementationType() {
         return ScriptImplementation.class;
+    }
+
+    public void setPropertyValueObjectFactory(ScriptPropertyValueObjectFactory propertyValueObjectFactory) {
+        this.propertyValueObjectFactory = propertyValueObjectFactory;
+    }
+
+    public void setDataBindingRegistry(DataBindingExtensionPoint dataBindingRegistry) {
+        this.dataBindingRegistry = dataBindingRegistry;
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java?view=diff&rev=530817&r1=530816&r2=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java Fri Apr 20 07:06:38 2007
@@ -24,6 +24,8 @@
 import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.core.ExtensionPointRegistry;
 import org.apache.tuscany.core.ModuleActivator;
+import org.apache.tuscany.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.databinding.Mediator;
 import org.apache.tuscany.spi.builder.BuilderRegistry;
 
 public class ScriptModuleActivator implements ModuleActivator {
@@ -40,6 +42,14 @@
 
         builder = new ScriptComponentBuilder();
         builder.setBuilderRegistry(builderRegistry);
+        
+        Mediator mediator = registry.getExtensionPoint(Mediator.class);
+        ScriptPropertyValueObjectFactory factory = new ScriptPropertyValueObjectFactory(mediator);
+        builder.setPropertyValueObjectFactory(factory);
+
+        DataBindingExtensionPoint dataBindingRegistry = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+        builder.setDataBindingRegistry(dataBindingRegistry);
+        
         builder.init();
     }
 

Added: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java?view=auto&rev=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java Fri Apr 20 07:06:38 2007
@@ -0,0 +1,234 @@
+/*
+ * 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.implementation.script;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.databinding.DefaultTransformerExtensionPoint;
+import org.apache.tuscany.databinding.Mediator;
+import org.apache.tuscany.databinding.SimpleTypeMapper;
+import org.apache.tuscany.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.databinding.extension.SimpleTypeMapperExtension;
+import org.apache.tuscany.databinding.impl.MediatorImpl;
+import org.apache.tuscany.databinding.javabeans.DOMNode2JavaBeanTransformer;
+import org.apache.tuscany.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.interfacedef.DataType;
+import org.apache.tuscany.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.interfacedef.util.TypeInfo;
+import org.apache.tuscany.interfacedef.util.XMLType;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class ScriptPropertyValueObjectFactory {
+    // protected DataBindingRegistry dbRegistry = new DataBindingRegistryImpl();
+    protected Mediator mediator = null;
+    protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperExtension();
+    boolean isSimpleType;
+    
+    public ScriptPropertyValueObjectFactory(Mediator mediator) {
+        this.mediator = mediator;
+    }
+    
+    public ObjectFactory createValueFactory(Property property) {
+        isSimpleType = isSimpleType(property);
+        Document doc = (Document)property.getValue();
+        Element rootElement = doc.getDocumentElement();
+        
+        //FIXME : since scripts use dynamic types we need to generate a dynamic java type using the 
+        //xml structure of the property value.  Should this be done in the JavaBeansDataBinding... 
+        Class javaType = null;
+        
+        if (property.isMany()) {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                List<String> values = 
+                    getSimplePropertyValues(value, javaType);
+                return new ListObjectFactoryImpl(property, 
+                                                 values,
+                                                 isSimpleType,
+                                                 javaType);
+            } else {
+                return new ListObjectFactoryImpl(property,
+                                                 getComplexPropertyValues(doc),
+                                                 isSimpleType,
+                                                 javaType);
+            }
+        } else {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                return new ObjectFactoryImpl(property,
+                                             value,
+                                             isSimpleType,
+                                             javaType);
+            } else {
+                Object value = getComplexPropertyValues(doc).get(0);
+                return new ObjectFactoryImpl(property,
+                                             value,
+                                             isSimpleType,
+                                             javaType);
+            }
+            
+        }
+    }
+    
+    private boolean isSimpleType(Property property) {
+        if (property.getXSDType() != null) {
+            return SimpleTypeMapperExtension.isSimpleXSDType(property.getXSDType());
+        } else {
+            if (property instanceof Document) {
+                Document doc = (Document)property;
+                Element element = doc.getDocumentElement(); 
+                if (element.getChildNodes().getLength() == 1 && 
+                    element.getChildNodes().item(0).getNodeType() == Element.TEXT_NODE) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    private List<String> getSimplePropertyValues(String concatenatedValue, Class javaType) {
+        List<String> propValues = new ArrayList<String>();
+        StringTokenizer st = null;
+        if ( javaType.getName().equals("java.lang.String")) {
+            st = new StringTokenizer(concatenatedValue, "\"");
+        } else {
+            st = new StringTokenizer(concatenatedValue);
+        }
+        String aToken = null;
+        while (st.hasMoreTokens()) {
+            aToken = st.nextToken();
+            if (aToken.trim().length() > 0) {
+                propValues.add(aToken);
+            }
+        }
+        return propValues;
+    }
+    
+    private List<Node> getComplexPropertyValues(Document document) {
+        Element rootElement = document.getDocumentElement();
+        List<Node> propValues = new ArrayList<Node>();
+        for (int count = 0 ; count < rootElement.getChildNodes().getLength() ; ++count) {
+            if (rootElement.getChildNodes().item(count).getNodeType() == Document.ELEMENT_NODE) {
+                propValues.add(rootElement.getChildNodes().item(count));
+            }
+        }
+        return propValues;
+    }
+    
+    public abstract class ObjectFactoryImplBase  implements ObjectFactory {
+        protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperExtension();
+        protected Property property;
+        protected Object propertyValue;
+        protected Class javaType;
+        protected DataType<XMLType> sourceDataType;
+        protected DataType<?> targetDataType;
+        boolean isSimpleType;
+
+        public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class javaType)  {
+            
+            this.isSimpleType = isSimpleType;
+            this.property = property;
+            this.propertyValue = propertyValue;
+            this.javaType = javaType;
+            //FIXME : fix this when we have managed to generate dynamic java types
+            /*sourceDataType =
+                new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, 
+                    new XMLType(null, this.property.getXSDType()));
+            TypeInfo typeInfo = null;
+            if (this.property.getXSDType() != null) {
+                if (SimpleTypeMapperExtension.isSimpleXSDType(this.property.getXSDType())) {
+                    typeInfo = new TypeInfo(property.getXSDType(), true, null);
+                } else {
+                    typeInfo = new TypeInfo(property.getXSDType(), false, null);
+                }
+            } else {
+                typeInfo = new TypeInfo(property.getXSDType(), false, null);
+            }
+
+            XMLType xmlType = new XMLType(typeInfo);
+            String dataBinding = null; //(String)property.getExtensions().get(DataBinding.class.getName());
+            if (dataBinding != null) {
+                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+            } else {
+                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+                mediator.getDataBindingRegistry().introspectType(targetDataType, null);  
+            }*/
+        }
+    }
+    
+    public class ObjectFactoryImpl extends ObjectFactoryImplBase {
+        public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class javaType) {
+            super(property, propertyValue, isSimpleType, javaType);
+        }
+
+        @SuppressWarnings("unchecked")
+        public Object getInstance() throws ObjectCreationException {
+            if (isSimpleType) {
+                return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+            } else {
+                return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
+                //return null;
+            }
+        }
+    }
+
+    public class ListObjectFactoryImpl extends ObjectFactoryImplBase  {
+        public ListObjectFactoryImpl(Property property, List<?>propertyValues, boolean isSimpleType, Class javaType) {
+            super(property, propertyValues, isSimpleType, javaType);
+        }
+
+        @SuppressWarnings("unchecked")
+        public List<?> getInstance() throws ObjectCreationException {
+            if (isSimpleType) {
+                List<Object> values = new ArrayList<Object>();
+                for (String aValue : (List<String>)propertyValue) {
+                    values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                }
+                return values;
+            } else {
+                List instances = new ArrayList();
+                for (Node aValue : (List<Node>)propertyValue) {
+                    instances.add(mediator.mediate(aValue,
+                                                      sourceDataType,
+                                                      targetDataType,
+                                                      null));
+                }
+                return instances;
+            }
+        }
+    }
+}
+      
\ No newline at end of file

Modified: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType?view=diff&rev=530817&r1=530816&r2=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType Fri Apr 20 07:06:38 2007
@@ -17,11 +17,15 @@
  * specific language governing permissions and limitations
  * under the License.
 -->
-<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance">
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" 
+	xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
   <service name="HelloWorldService">
         <interface.java interface="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorld" />
   </service>
+  <property name="greeter" type="xsd:string">Tuscany</property>
 
 </componentType>              
        

Modified: incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js?view=diff&rev=530817&r1=530816&r2=530817
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js Fri Apr 20 07:06:38 2007
@@ -16,7 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.    
  */
- 
+
 function sayHello(s) {
+   
    return "Hello " + s;
 }



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


Re: svn commit: r530817 - in /incubator/tuscany/java/sca/modules/implementation-script: ./ src/main/java/org/apache/tuscany/implementation/script/ src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/

Posted by ant elder <an...@gmail.com>.
This is great, the script container now supports properties! I took the
liberty of adding some property itests, see the
org.apache.tuscany.implementation.script.itests.properties folder. Probably
what we should do is extend those to also test other types like ints and
arrays etc. The JRuby tests don't work, it looks like a bug in the JRuby
script engine, but right now the way the script implementation does
references and properties is by setting them as global variables, changing
to use script instance variables may fix the problem and could be more
correct anyway.

   ...ant

On 4/20/07, svkrish@apache.org <sv...@apache.org> wrote:
>
> Author: svkrish
> Date: Fri Apr 20 07:06:38 2007
> New Revision: 530817
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=530817
> Log:
> Extended a bit to support simple type properties
>
> Added:
>
>     incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java
> Modified:
>     incubator/tuscany/java/sca/modules/implementation-script/pom.xml
>
>     incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
>
>     incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
>
>     incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
>
>     incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java
>
>     incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType
>
>     incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js
>
> Modified: incubator/tuscany/java/sca/modules/implementation-script/pom.xml
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/pom.xml?view=diff&rev=530817&r1=530816&r2=530817
>
> ==============================================================================
> --- incubator/tuscany/java/sca/modules/implementation-script/pom.xml
> (original)
> +++ incubator/tuscany/java/sca/modules/implementation-script/pom.xml Fri
> Apr 20 07:06:38 2007
> @@ -115,6 +115,11 @@
>              <version>1.0-incubating-SNAPSHOT</version>
>              <scope>test</scope>
>          </dependency>
> +        <dependency>
> +            <groupId>org.apache.tuscany.sca</groupId>
> +            <artifactId>tuscany-databinding</artifactId>
> +            <version>1.0-incubating-SNAPSHOT</version>
> +        </dependency>
>
> <!-- TODO: big hack to add script engine dependencies till extension
> dependencies fixed -->
>
>
> Modified:
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java?view=diff&rev=530817&r1=530816&r2=530817
>
> ==============================================================================
> ---
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
> (original)
> +++
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptArtifactProcessor.java
> Fri Apr 20 07:06:38 2007
> @@ -33,6 +33,9 @@
> import javax.xml.stream.XMLStreamWriter;
>
> import org.apache.tuscany.assembly.ComponentType;
> +import org.apache.tuscany.assembly.Property;
> +import org.apache.tuscany.assembly.Reference;
> +import org.apache.tuscany.assembly.Service;
> import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
> import org.apache.tuscany.assembly.xml.Constants;
> import
> org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtension;
> @@ -123,6 +126,15 @@
>          ComponentType componentType = resolver.resolve(
> ComponentType.class, ct);
>          if (componentType.isUnresolved()) {
>              throw new ContributionResolveException("missing
> .componentType side file");
> +        }
> +        for (Reference reference : componentType.getReferences()) {
> +            scriptImplementation.getReferences().add(reference);
> +        }
> +        for (Service service : componentType.getServices()) {
> +            scriptImplementation.getServices().add(service);
> +        }
> +        for (Property property : componentType.getProperties()) {
> +            scriptImplementation.getProperties().add(property);
>          }
>          scriptImplementation.setComponentType(componentType);
>      }
>
> Modified:
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java?view=diff&rev=530817&r1=530816&r2=530817
>
> ==============================================================================
> ---
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
> (original)
> +++
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponent.java
> Fri Apr 20 07:06:38 2007
> @@ -29,11 +29,14 @@
> import javax.script.ScriptEngineManager;
> import javax.script.ScriptException;
>
> +import org.apache.tuscany.assembly.ComponentProperty;
> import org.apache.tuscany.core.component.ComponentContextImpl;
> import org.apache.tuscany.core.component.ComponentContextProvider;
> import org.apache.tuscany.core.component.scope.InstanceWrapperBase;
> +import org.apache.tuscany.databinding.DataBindingExtensionPoint;
> import org.apache.tuscany.interfacedef.Operation;
> import org.apache.tuscany.spi.ObjectCreationException;
> +import org.apache.tuscany.spi.ObjectFactory;
> import org.apache.tuscany.spi.component.InstanceWrapper;
> import org.apache.tuscany.spi.component.TargetInvokerCreationException;
> import org.apache.tuscany.spi.component.TargetResolutionException;
> @@ -49,16 +52,17 @@
>      private ScriptImplementation impl;
>      private ComponentContext componentContext;
>      private Map<String, Object> references;
> +    private Map<String, ObjectFactory<?>> propertyValueFactories;
> +
> +    private ScriptPropertyValueObjectFactory propertyValueObjectFactory =
> null;
> +    private DataBindingExtensionPoint dataBindingRegistry;
>
>      public ScriptComponent(URI uri, URI groupId, ScriptImplementation
> impl) {
>          super(uri, null, null, groupId, 50);
>          this.impl = impl;
>          componentContext = new ComponentContextImpl(this);
>          references = new HashMap<String, Object>();
> -    }
> -
> -    public void configureProperty(String propertyName) {
> -
> +        propertyValueFactories = new HashMap<String, ObjectFactory<?>>();
>      }
>
>      public TargetInvoker createTargetInvoker(String targetName, Operation
> operation, boolean callback)
> @@ -80,7 +84,7 @@
>
>      public Object createInstance() throws ObjectCreationException {
>          try {
> -
> +            ObjectFactory<?> propertyValueFactory = null;
>              ScriptEngineManager manager = new ScriptEngineManager();
>
>              for (String referenceName : references.keySet()) {
> @@ -88,6 +92,13 @@
>                  manager.put(referenceName, reference);
>              }
>
> +            for (String propertyName : propertyValueFactories.keySet()) {
> +                propertyValueFactory = propertyValueFactories.get
> (propertyName);
> +                if ( propertyValueFactory != null) {
> +                    manager.put(propertyName,
> propertyValueFactory.getInstance());
> +                }
> +            }
> +
>              ScriptEngine engine = manager.getEngineByExtension(
> impl.getScriptLanguage());
>              if (engine == null) {
>                  throw new ObjectCreationException("no script engine found
> for language: " + impl.getScriptLanguage());
> @@ -149,5 +160,24 @@
>      public <B> ServiceReference<B> getServiceReference(Class<B> arg0,
> String arg1) {
>          // TODO Auto-generated method stub
>          return null;
> +    }
> +
> +    public void setDataBindingRegistry(DataBindingExtensionPoint
> dataBindingRegistry) {
> +        this.dataBindingRegistry = dataBindingRegistry;
> +    }
> +
> +    public void
> setPropertyValueObjectFactory(ScriptPropertyValueObjectFactory
> propertyValueObjectFactory) {
> +        this.propertyValueObjectFactory = propertyValueObjectFactory;
> +    }
> +
> +    public void initializePropertyValueFactories(List<ComponentProperty>
> properties) {
> +        ObjectFactory<?> propertyObjectFactory = null;
> +
> +        for (ComponentProperty aProperty : properties) {
> +            if (aProperty.getValue() != null) {
> +                propertyObjectFactory =
> propertyValueObjectFactory.createValueFactory(aProperty);
> +                propertyValueFactories.put(aProperty.getName(),
> propertyObjectFactory);
> +            }
> +        }
>      }
> }
>
> Modified:
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java?view=diff&rev=530817&r1=530816&r2=530817
>
> ==============================================================================
> ---
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
> (original)
> +++
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptComponentBuilder.java
> Fri Apr 20 07:06:38 2007
> @@ -22,13 +22,16 @@
> import java.net.URI;
>
> import org.apache.tuscany.assembly.Component;
> +import org.apache.tuscany.databinding.DataBindingExtensionPoint;
> import org.apache.tuscany.spi.builder.BuilderConfigException;
> import org.apache.tuscany.spi.component.AtomicComponent;
> import org.apache.tuscany.spi.deployer.DeploymentContext;
> import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
>
> public class ScriptComponentBuilder extends
> ComponentBuilderExtension<ScriptImplementation> {
> -
> +    private ScriptPropertyValueObjectFactory propertyValueObjectFactory =
> null;
> +    private DataBindingExtensionPoint dataBindingRegistry;
> +
>      public ScriptComponentBuilder() {
>      }
>
> @@ -36,12 +39,25 @@
>          URI id = URI.create(context.getComponentId() +
> assemblyComponent.getName());
>          ScriptImplementation scriptImplementation =
> (ScriptImplementation)assemblyComponent.getImplementation();
>          ScriptComponent scriptComponent = new ScriptComponent(id,
> context.getGroupId(), scriptImplementation);
> +        scriptComponent.setPropertyValueObjectFactory
> (propertyValueObjectFactory);
> +        scriptComponent.setDataBindingRegistry(dataBindingRegistry);
> +
> +        scriptComponent.initializePropertyValueFactories(
> assemblyComponent.getProperties());
> +
>          return scriptComponent;
>      }
>
>      @Override
>      protected Class<ScriptImplementation> getImplementationType() {
>          return ScriptImplementation.class;
> +    }
> +
> +    public void
> setPropertyValueObjectFactory(ScriptPropertyValueObjectFactory
> propertyValueObjectFactory) {
> +        this.propertyValueObjectFactory = propertyValueObjectFactory;
> +    }
> +
> +    public void setDataBindingRegistry(DataBindingExtensionPoint
> dataBindingRegistry) {
> +        this.dataBindingRegistry = dataBindingRegistry;
>      }
>
> }
>
> Modified:
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java?view=diff&rev=530817&r1=530816&r2=530817
>
> ==============================================================================
> ---
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java
> (original)
> +++
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptModuleActivator.java
> Fri Apr 20 07:06:38 2007
> @@ -24,6 +24,8 @@
> import
> org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtensionPoint
> ;
> import org.apache.tuscany.core.ExtensionPointRegistry;
> import org.apache.tuscany.core.ModuleActivator;
> +import org.apache.tuscany.databinding.DataBindingExtensionPoint;
> +import org.apache.tuscany.databinding.Mediator;
> import org.apache.tuscany.spi.builder.BuilderRegistry;
>
> public class ScriptModuleActivator implements ModuleActivator {
> @@ -40,6 +42,14 @@
>
>          builder = new ScriptComponentBuilder();
>          builder.setBuilderRegistry(builderRegistry);
> +
> +        Mediator mediator = registry.getExtensionPoint(Mediator.class);
> +        ScriptPropertyValueObjectFactory factory = new
> ScriptPropertyValueObjectFactory(mediator);
> +        builder.setPropertyValueObjectFactory(factory);
> +
> +        DataBindingExtensionPoint dataBindingRegistry =
> registry.getExtensionPoint(DataBindingExtensionPoint.class);
> +        builder.setDataBindingRegistry(dataBindingRegistry);
> +
>          builder.init();
>      }
>
>
> Added:
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java?view=auto&rev=530817
>
> ==============================================================================
> ---
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java
> (added)
> +++
> incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptPropertyValueObjectFactory.java
> Fri Apr 20 07:06:38 2007
> @@ -0,0 +1,234 @@
> +/*
> + * 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.implementation.script;
> +
> +
> +import java.util.ArrayList;
> +import java.util.List;
> +import java.util.StringTokenizer;
> +
> +import org.apache.tuscany.assembly.Property;
> +import org.apache.tuscany.databinding.DataBindingExtensionPoint;
> +import org.apache.tuscany.databinding.DefaultDataBindingExtensionPoint;
> +import org.apache.tuscany.databinding.DefaultTransformerExtensionPoint;
> +import org.apache.tuscany.databinding.Mediator;
> +import org.apache.tuscany.databinding.SimpleTypeMapper;
> +import org.apache.tuscany.databinding.TransformerExtensionPoint;
> +import org.apache.tuscany.databinding.extension.SimpleTypeMapperExtension
> ;
> +import org.apache.tuscany.databinding.impl.MediatorImpl;
> +import
> org.apache.tuscany.databinding.javabeans.DOMNode2JavaBeanTransformer;
> +import org.apache.tuscany.databinding.javabeans.JavaBeansDataBinding;
> +import org.apache.tuscany.databinding.xml.DOMDataBinding;
> +import org.apache.tuscany.interfacedef.DataType;
> +import org.apache.tuscany.interfacedef.impl.DataTypeImpl;
> +import org.apache.tuscany.interfacedef.util.TypeInfo;
> +import org.apache.tuscany.interfacedef.util.XMLType;
> +import org.apache.tuscany.spi.ObjectCreationException;
> +import org.apache.tuscany.spi.ObjectFactory;
> +import org.w3c.dom.Document;
> +import org.w3c.dom.Element;
> +import org.w3c.dom.Node;
> +
> +public class ScriptPropertyValueObjectFactory {
> +    // protected DataBindingRegistry dbRegistry = new
> DataBindingRegistryImpl();
> +    protected Mediator mediator = null;
> +    protected SimpleTypeMapper simpleTypeMapper = new
> SimpleTypeMapperExtension();
> +    boolean isSimpleType;
> +
> +    public ScriptPropertyValueObjectFactory(Mediator mediator) {
> +        this.mediator = mediator;
> +    }
> +
> +    public ObjectFactory createValueFactory(Property property) {
> +        isSimpleType = isSimpleType(property);
> +        Document doc = (Document)property.getValue();
> +        Element rootElement = doc.getDocumentElement();
> +
> +        //FIXME : since scripts use dynamic types we need to generate a
> dynamic java type using the
> +        //xml structure of the property value.  Should this be done in
> the JavaBeansDataBinding...
> +        Class javaType = null;
> +
> +        if (property.isMany()) {
> +            if (isSimpleType) {
> +                String value = "";
> +                if (rootElement.getChildNodes().getLength() > 0) {
> +                    value = rootElement.getChildNodes
> ().item(0).getTextContent();
> +                }
> +                List<String> values =
> +                    getSimplePropertyValues(value, javaType);
> +                return new ListObjectFactoryImpl(property,
> +                                                 values,
> +                                                 isSimpleType,
> +                                                 javaType);
> +            } else {
> +                return new ListObjectFactoryImpl(property,
> +
> getComplexPropertyValues(doc),
> +                                                 isSimpleType,
> +                                                 javaType);
> +            }
> +        } else {
> +            if (isSimpleType) {
> +                String value = "";
> +                if (rootElement.getChildNodes().getLength() > 0) {
> +                    value = rootElement.getChildNodes
> ().item(0).getTextContent();
> +                }
> +                return new ObjectFactoryImpl(property,
> +                                             value,
> +                                             isSimpleType,
> +                                             javaType);
> +            } else {
> +                Object value = getComplexPropertyValues(doc).get(0);
> +                return new ObjectFactoryImpl(property,
> +                                             value,
> +                                             isSimpleType,
> +                                             javaType);
> +            }
> +
> +        }
> +    }
> +
> +    private boolean isSimpleType(Property property) {
> +        if (property.getXSDType() != null) {
> +            return SimpleTypeMapperExtension.isSimpleXSDType(
> property.getXSDType());
> +        } else {
> +            if (property instanceof Document) {
> +                Document doc = (Document)property;
> +                Element element = doc.getDocumentElement();
> +                if (element.getChildNodes().getLength() == 1 &&
> +                    element.getChildNodes().item(0).getNodeType() ==
> Element.TEXT_NODE) {
> +                    return true;
> +                }
> +            }
> +        }
> +        return false;
> +    }
> +
> +    private List<String> getSimplePropertyValues(String
> concatenatedValue, Class javaType) {
> +        List<String> propValues = new ArrayList<String>();
> +        StringTokenizer st = null;
> +        if ( javaType.getName().equals("java.lang.String")) {
> +            st = new StringTokenizer(concatenatedValue, "\"");
> +        } else {
> +            st = new StringTokenizer(concatenatedValue);
> +        }
> +        String aToken = null;
> +        while (st.hasMoreTokens()) {
> +            aToken = st.nextToken();
> +            if (aToken.trim().length() > 0) {
> +                propValues.add(aToken);
> +            }
> +        }
> +        return propValues;
> +    }
> +
> +    private List<Node> getComplexPropertyValues(Document document) {
> +        Element rootElement = document.getDocumentElement();
> +        List<Node> propValues = new ArrayList<Node>();
> +        for (int count = 0 ; count < rootElement.getChildNodes().getLength()
> ; ++count) {
> +            if (rootElement.getChildNodes().item(count).getNodeType() ==
> Document.ELEMENT_NODE) {
> +                propValues.add(rootElement.getChildNodes().item(count));
> +            }
> +        }
> +        return propValues;
> +    }
> +
> +    public abstract class ObjectFactoryImplBase  implements ObjectFactory
> {
> +        protected SimpleTypeMapper simpleTypeMapper = new
> SimpleTypeMapperExtension();
> +        protected Property property;
> +        protected Object propertyValue;
> +        protected Class javaType;
> +        protected DataType<XMLType> sourceDataType;
> +        protected DataType<?> targetDataType;
> +        boolean isSimpleType;
> +
> +        public ObjectFactoryImplBase(Property property, Object
> propertyValue, boolean isSimpleType, Class javaType)  {
> +
> +            this.isSimpleType = isSimpleType;
> +            this.property = property;
> +            this.propertyValue = propertyValue;
> +            this.javaType = javaType;
> +            //FIXME : fix this when we have managed to generate dynamic
> java types
> +            /*sourceDataType =
> +                new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class
> ,
> +                    new XMLType(null, this.property.getXSDType()));
> +            TypeInfo typeInfo = null;
> +            if (this.property.getXSDType() != null) {
> +                if (SimpleTypeMapperExtension.isSimpleXSDType(
> this.property.getXSDType())) {
> +                    typeInfo = new TypeInfo(property.getXSDType(), true,
> null);
> +                } else {
> +                    typeInfo = new TypeInfo(property.getXSDType(), false,
> null);
> +                }
> +            } else {
> +                typeInfo = new TypeInfo(property.getXSDType(), false,
> null);
> +            }
> +
> +            XMLType xmlType = new XMLType(typeInfo);
> +            String dataBinding = null;
> //(String)property.getExtensions().get(DataBinding.class.getName());
> +            if (dataBinding != null) {
> +                targetDataType = new DataTypeImpl<XMLType>(dataBinding,
> javaType, xmlType);
> +            } else {
> +                targetDataType = new DataTypeImpl<XMLType>(dataBinding,
> javaType, xmlType);
> +                mediator.getDataBindingRegistry().introspectType(targetDataType,
> null);
> +            }*/
> +        }
> +    }
> +
> +    public class ObjectFactoryImpl extends ObjectFactoryImplBase {
> +        public ObjectFactoryImpl(Property property, Object propertyValue,
> boolean isSimpleType, Class javaType) {
> +            super(property, propertyValue, isSimpleType, javaType);
> +        }
> +
> +        @SuppressWarnings("unchecked")
> +        public Object getInstance() throws ObjectCreationException {
> +            if (isSimpleType) {
> +                return simpleTypeMapper.toJavaObject(property.getXSDType(),
> (String)propertyValue, null);
> +            } else {
> +                return mediator.mediate(propertyValue, sourceDataType,
> targetDataType, null);
> +                //return null;
> +            }
> +        }
> +    }
> +
> +    public class ListObjectFactoryImpl extends ObjectFactoryImplBase  {
> +        public ListObjectFactoryImpl(Property property,
> List<?>propertyValues, boolean isSimpleType, Class javaType) {
> +            super(property, propertyValues, isSimpleType, javaType);
> +        }
> +
> +        @SuppressWarnings("unchecked")
> +        public List<?> getInstance() throws ObjectCreationException {
> +            if (isSimpleType) {
> +                List<Object> values = new ArrayList<Object>();
> +                for (String aValue : (List<String>)propertyValue) {
> +                    values.add(simpleTypeMapper.toJavaObject(
> property.getXSDType(), aValue, null));
> +                }
> +                return values;
> +            } else {
> +                List instances = new ArrayList();
> +                for (Node aValue : (List<Node>)propertyValue) {
> +                    instances.add(mediator.mediate(aValue,
> +                                                      sourceDataType,
> +                                                      targetDataType,
> +                                                      null));
> +                }
> +                return instances;
> +            }
> +        }
> +    }
> +}
> +
> \ No newline at end of file
>
> Modified:
> incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType?view=diff&rev=530817&r1=530816&r2=530817
>
> ==============================================================================
> ---
> incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType
> (original)
> +++
> incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType
> Fri Apr 20 07:06:38 2007
> @@ -17,11 +17,15 @@
>   * specific language governing permissions and limitations
>   * under the License.
> -->
> -<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="
> http://www.w3.org/2006/01/wsdl-instance">
> +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0"
> +       xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
> +       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> +       xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
>    <service name="HelloWorldService">
>          <interface.java interface="
> org.apache.tuscany.implementation.script.itests.helloworld.HelloWorld" />
>    </service>
> +  <property name="greeter" type="xsd:string">Tuscany</property>
>
> </componentType>
>
>
> Modified:
> incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js
> URL:
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js?view=diff&rev=530817&r1=530816&r2=530817
>
> ==============================================================================
> ---
> incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js
> (original)
> +++
> incubator/tuscany/java/sca/modules/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js
> Fri Apr 20 07:06:38 2007
> @@ -16,7 +16,8 @@
>   * specific language governing permissions and limitations
>   * under the License.
>   */
> -
> +
> function sayHello(s) {
> +
>     return "Hello " + s;
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-commits-help@ws.apache.org
>
>