You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by th...@apache.org on 2007/03/16 13:49:39 UTC

svn commit: r518956 [1/2] - in /webservices/axis2/trunk/java/modules/scripting: ./ src/ src/META-INF/ src/org/ src/org/apache/ src/org/apache/axis2/ src/org/apache/axis2/scripting/ src/org/apache/axis2/scripting/convertors/ test-resources/ test-resourc...

Author: thilina
Date: Fri Mar 16 05:49:37 2007
New Revision: 518956

URL: http://svn.apache.org/viewvc?view=rev&rev=518956
Log:
commiting the patch given at 
https://issues.apache.org/jira/browse/AXIS2-2211

Thanx Ant.. 

Added:
    webservices/axis2/trunk/java/modules/scripting/
    webservices/axis2/trunk/java/modules/scripting/maven.xml
    webservices/axis2/trunk/java/modules/scripting/project.properties
    webservices/axis2/trunk/java/modules/scripting/project.xml
    webservices/axis2/trunk/java/modules/scripting/src/
    webservices/axis2/trunk/java/modules/scripting/src/META-INF/
    webservices/axis2/trunk/java/modules/scripting/src/META-INF/module.xml
    webservices/axis2/trunk/java/modules/scripting/src/org/
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptDeploymentEngine.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptInvoker.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptMessageContext.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptModule.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptReceiver.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptRepositoryListener.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/ConvertorFactory.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/DefaultOMElementConvertor.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/JSOMElementConvertor.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/OMElementConvertor.java
    webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/RBOMElementConvertor.java
    webservices/axis2/trunk/java/modules/scripting/test/
    webservices/axis2/trunk/java/modules/scripting/test-resources/
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.js
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.wsdl
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.js
    webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.wsdl
    webservices/axis2/trunk/java/modules/scripting/test/org/
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptDeploymentEngineTest.java
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptModuleTest.java
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptReceiverTest.java
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/TestUtils.java
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/convertors/
    webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/convertors/JSOMElementConvertorTest.java

Added: webservices/axis2/trunk/java/modules/scripting/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/maven.xml?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/maven.xml (added)
+++ webservices/axis2/trunk/java/modules/scripting/maven.xml Fri Mar 16 05:49:37 2007
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Copyright 2006 The Apache Software Foundation.
+ !
+ ! Licensed 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.
+ !-->
+
+<!-- $Revision$ $Date$ -->
+
+<project default="jar"
+    xmlns:j="jelly:core"
+    xmlns:u="jelly:util"
+    xmlns:maven="jelly:maven"
+    xmlns:deploy="deploy"
+    xmlns:ant="jelly:ant">
+    <postGoal name="test:compile">
+        <mkdir dir="target/tempmar/META-INF"/>
+        <copy file="src/META-INF/module.xml"
+            tofile="target/tempmar/META-INF/module.xml"/>
+        <copy file="../../LICENSE.txt"
+            tofile="target/tempmar/META-INF/LICENSE.txt" overwrite="true"/>
+
+    	<mkdir dir="target/tempmar/lib"/>
+        <copy file="${maven.repo.local}/bsf/jars/bsf-${bsf.version}.jar" 
+            tofile="target/tempmar/lib/bsf-${bsf.version}.jar"/>
+        <copy file="${maven.repo.local}/rhino/jars/js-${js.version}.jar" 
+            tofile="target/tempmar/lib/js-${js.version}.jar"/>
+        <copy file="${maven.repo.local}/xmlbeans/jars/xbean-${xbean.version}.jar" 
+            tofile="target/tempmar/lib/xbean-${xbean.version}.jar"/>
+
+        <copy todir="target/tempmar">
+            <fileset dir="target/classes">
+                <include name="**/org/apache/*/**/*.class"/>
+            </fileset>
+        </copy>
+
+    	<mkdir dir="target/modules"/>
+        <jar jarfile="target/axis2-scripting-${scripting_version}.mar" basedir="target/tempmar">
+            <include name="**"/>
+        </jar>
+        <copy file="target/axis2-scripting-${scripting_version}.mar"
+            tofile="target/modules/axis2-scripting-${scripting_version}.mar"/>
+        <copy file="target/axis2-scripting-${scripting_version}.mar" 
+            tofile="${maven.repo.local}/org.apache.axis2/mars/axis2-scripting-${scripting_version}.mar"/>
+    </postGoal>
+    <preGoal name="itest:compile">
+        <u:file var="file" name="${maven.itest.src}"/>
+        <j:if test="${!file.exists()}">
+            <j:expr value="${context.setVariable('maven.itest.skip', 'true')}"/>
+        </j:if>
+    </preGoal>
+</project>

Added: webservices/axis2/trunk/java/modules/scripting/project.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/project.properties?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/project.properties (added)
+++ webservices/axis2/trunk/java/modules/scripting/project.properties Fri Mar 16 05:49:37 2007
@@ -0,0 +1,21 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2004 The Apache Software Foundation.
+#
+# Licensed 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.
+# -------------------------------------------------------------------
+
+maven.multiproject.type=jar
+scripting_version=1.2-SNAPSHOT
+js.version=1.6R5
+xbean.version=2.2.0
+bsf.version=2.4.0

Added: webservices/axis2/trunk/java/modules/scripting/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/project.xml?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/project.xml (added)
+++ webservices/axis2/trunk/java/modules/scripting/project.xml Fri Mar 16 05:49:37 2007
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+ -->
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+    <name>Apache Axis 2.0 - Scrpting</name>
+    <id>axis2-scripting</id>
+    <groupId>org.apache.axis2</groupId>
+    <description>Axis2 scripting support for services implemented with scripting languages</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-kernel</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.neethi</groupId>
+            <artifactId>neethi</artifactId>
+            <version>${neethi.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-java2wsdl</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>${axiom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>${axiom.version}</version>
+        </dependency>
+         <dependency>
+            <groupId>org.apache.ws.commons.schema</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons.logging.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>${stax.api.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${stax.impl.groupid}</groupId>
+            <artifactId>${stax.impl.artifactid}</artifactId>
+            <version>${stax.impl.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>${javamail.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>activation</artifactId>
+            <version>${activation.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>wsdl4j</groupId>
+            <artifactId>wsdl4j</artifactId>
+            <version>${wsdl4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>rhino</groupId>
+            <artifactId>js</artifactId>
+            <version>${js.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>xmlbeans</groupId>
+            <artifactId>xbean</artifactId>
+            <version>${xbean.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>bsf</groupId>
+            <artifactId>bsf</artifactId>
+            <version>${bsf.version}</version>
+        </dependency>
+    </dependencies>
+
+    <reports/>
+</project>

Added: webservices/axis2/trunk/java/modules/scripting/src/META-INF/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/META-INF/module.xml?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/META-INF/module.xml (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/META-INF/module.xml Fri Mar 16 05:49:37 2007
@@ -0,0 +1,3 @@
+<module name="script" 
+        class="org.apache.axis2.scripting.ScriptModule">
+</module>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptDeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptDeploymentEngine.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptDeploymentEngine.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptDeploymentEngine.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,263 @@
+/*
+ *  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.axis2.scripting;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.DeploymentErrorMsgs;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.repository.util.DeploymentFileData;
+import org.apache.axis2.deployment.repository.util.WSInfo;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * An Axis2 DeploymentEngine subclass for deploying script services 
+ * supporting hot deploy and hot update.
+ */
+public class ScriptDeploymentEngine extends DeploymentEngine {
+
+    private static final Log log = LogFactory.getLog(ScriptModule.class);
+
+    public static final String SCRIPT_HOT_UPDATE_ = "scripts.hotupdate";
+
+    private AxisConfiguration realAxisConfig;
+
+    public ScriptDeploymentEngine(AxisConfiguration realAxisConfig) {
+        this.axisConfig = new AxisConfiguration();
+        this.realAxisConfig = realAxisConfig;
+    }
+
+    public void loadRepository(File scriptsRepoFile) throws DeploymentException {
+        this.repoListener = new ScriptRepositoryListener(this);
+        this.servicesDir = scriptsRepoFile;
+
+        Parameter scriptsHotUpdateParameter = axisConfig.getParameter(SCRIPT_HOT_UPDATE_);
+        this.hotUpdate = scriptsHotUpdateParameter == null || "true".equals(scriptsHotUpdateParameter.getValue());
+    }
+
+    public void doDeploy() {
+        List alreadyDeployed = new ArrayList();
+        for (int i = 0; i < wsToDeploy.size(); i++) {
+            try {
+
+            	DeploymentFileData archiveFileData = (DeploymentFileData)wsToDeploy.get(i);
+                deployService(alreadyDeployed, archiveFileData);
+
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.warn("Exception deploying script service: " + ((DeploymentFileData)wsToDeploy.get(i)).getName());
+            }
+        }
+        wsToDeploy.clear();
+    }
+
+    private void deployService(List alreadyDeployed, DeploymentFileData archiveFileData) throws AxisFault {
+        File file = archiveFileData.getFile();
+
+        File wsdlFile;
+        File scriptFile;
+        if (file.toString().endsWith(".wsdl")) {
+            wsdlFile = file;
+            scriptFile = getScriptForWSDL(wsdlFile);
+        } else {
+            scriptFile = file;
+            wsdlFile = getWSDLForScript(scriptFile);
+        }
+
+        if (scriptFile != null && wsdlFile != null && !alreadyDeployed.contains(scriptFile.toURI()) && scriptFile.exists() && wsdlFile.exists()) {
+            AxisService axisService = createService(wsdlFile, scriptFile);
+            AxisServiceGroup axisServiceGroup = new AxisServiceGroup(axisConfig);
+            axisServiceGroup.setServiceGroupClassLoader(axisService.getClassLoader());
+            axisServiceGroup.setServiceGroupName(axisService.getName());
+            axisServiceGroup.addService(axisService);
+            realAxisConfig.addServiceGroup(axisServiceGroup);
+            alreadyDeployed.add(scriptFile.toURI());
+            log.info("Deployed script service '" + axisService.getName() + "' for script: " + scriptFile.getName());
+        }
+    }
+
+    public void unDeploy() {
+        String serviceName = null;
+        List undeployed = new ArrayList();
+        for (int i = 0; i < wsToUnDeploy.size(); i++) {
+            try {
+                WSInfo wsInfo = (WSInfo)wsToUnDeploy.get(i);
+//                if (wsInfo.getType() == TYPE_SERVICE) {
+                    if (isHotUpdate()) {
+                        try {
+                            serviceName = getAxisServiceName(wsInfo.getFileName());
+                            if (!undeployed.contains(serviceName)) {
+                                realAxisConfig.removeServiceGroup(serviceName);
+                                undeployed.add(serviceName);
+                                // TODO: need a way to also remove the ServiceGroup from the ConfigContext.applicationSessionServiceGroupContextTable
+                                log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED, serviceName));
+                            }
+                        } catch (AxisFault axisFault) {
+                            // May be a faulty service
+                            realAxisConfig.removeFaultyService(serviceName);
+                            log.debug("removeFaultyService: " + wsInfo.getFileName());
+                        }
+                    } else {
+                        realAxisConfig.removeFaultyService(serviceName);
+                        log.debug("not hotUpdate, removeFaultyService: " + wsInfo.getFileName());
+                    }
+//                }
+            } catch (Exception e) {
+                log.warn(e);
+            }
+        }
+        wsToUnDeploy.clear();
+    }
+
+    /*
+     * Override the DeploymentEngine method return an empty modules directory as
+     * its not required for script services
+     */
+    public File getModulesDir() {
+        return new File("");
+    }
+
+    /**
+     * Gets the script associated with the wsdl. The associated script is the
+     * file with the same name as the wsdl file excluding the file suffix, for
+     * example, stockquote.js and stockquote.wsdl.
+     */
+    protected File getScriptForWSDL(File wsdlFile) {
+        String wsdlFileName = wsdlFile.getName();
+        String fileSuffix = wsdlFileName.substring(0, wsdlFileName.lastIndexOf('.') );
+        File wsdlFileDir = wsdlFile.getParentFile();
+        String[] files = wsdlFileDir.list();
+        for (int i = 0; i < files.length; i++) {
+            if (!files[i].equals(wsdlFileName) && files[i].startsWith(fileSuffix)) {
+                File scriptFile = new File(wsdlFileDir, files[i]);
+                return scriptFile;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Gets the WSDL associated with the script. The associated WSDL is the file
+     * with the same name as the script file excluding the file suffix, for
+     * example, stockquote.js and stockquote.wsdl.
+     */
+    protected File getWSDLForScript(File scriptFile) {
+        String scriptFileName = scriptFile.getName();
+        String fileSuffix = scriptFileName.substring(0, scriptFileName.lastIndexOf('.'));
+        File scriptFileDir = scriptFile.getParentFile();
+        File wsdlFile = new File(scriptFileDir, fileSuffix + ".wsdl");
+        return wsdlFile;
+    }
+
+    /**
+     * Creates an Axis2 service for the script
+     */
+    protected AxisService createService(File wsdlFile, File scriptFile) {
+        AxisService axisService = null;
+        try {
+
+            InputStream definition;
+            try {
+                definition = wsdlFile.toURL().openStream();
+            } catch (Exception e) {
+                throw new AxisFault("exception opening wsdl", e);
+            }
+
+            WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(definition);
+            builder.setServerSide(true);
+            axisService = builder.populateService();
+
+            //axisService.setScope(Constants.SCOPE_APPLICATION);
+            Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
+            axisService.addParameter(userWSDL);
+
+            Parameter scriptSrc = new Parameter(ScriptReceiver.SCRIPT_SRC_PROP, readScriptSource(scriptFile));
+            axisService.addParameter(scriptSrc);
+
+            ScriptReceiver scriptReceiver = new ScriptReceiver();
+            axisService.addMessageReceiver("http://www.w3.org/2004/08/wsdl/in-out", scriptReceiver);
+
+            // TODO: Shouldn't this be done by WSDLToAxisServiceBuilder.populateService?
+            for (Iterator it = axisService.getOperations(); it.hasNext();) {
+                AxisOperation operation = (AxisOperation)it.next();
+                operation.setMessageReceiver(scriptReceiver);
+            }
+
+            Parameter scriptParam = new Parameter(ScriptReceiver.SCRIPT_ATTR, scriptFile.toString());
+            axisService.addParameter(scriptParam);
+
+            axisService.setName(scriptFile.getName().substring(0, scriptFile.getName().lastIndexOf('.')));
+
+        } catch (Throwable e) {
+            log.warn("AxisFault creating script service", e);
+            e.printStackTrace();
+        }
+
+        return axisService;
+    }
+
+    /**
+     * Reads the complete script source code into a String
+     */
+    protected String readScriptSource(File scriptFile) throws AxisFault {
+        InputStream is;
+        try {
+            is = scriptFile.toURL().openStream();
+        } catch (IOException e) {
+            throw new AxisFault("IOException opening script: " + scriptFile, e);
+        }
+        try {
+            Reader reader = new InputStreamReader(is, "UTF-8");
+            char[] buffer = new char[1024];
+            StringBuilder source = new StringBuilder();
+            int count;
+            while ((count = reader.read(buffer)) > 0) {
+                source.append(buffer, 0, count);
+            }
+            return source.toString();
+        } catch (IOException e) {
+            throw new AxisFault("IOException reading script: " + scriptFile, e);
+        } finally {
+            try {
+                is.close();
+            } catch (IOException e) {
+                throw new AxisFault("IOException closing script: " + scriptFile, e);
+            }
+        }
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptInvoker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptInvoker.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptInvoker.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptInvoker.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,128 @@
+/*
+ *  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.axis2.scripting;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+
+import org.apache.bsf.BSFEngine;
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+
+public class ScriptInvoker {
+
+	protected File scriptFile;
+
+	protected long lastModified;
+
+	protected long lastCheckTime;
+
+	protected int hotUpdateInterval;
+
+	protected BSFEngine engine;
+
+	private String scriptName;
+
+	public ScriptInvoker(File scriptFile, int hotUpdateInterval) {
+		this.scriptFile = scriptFile;
+		this.hotUpdateInterval = hotUpdateInterval;
+		this.scriptName = scriptFile.getName();
+		initEngine();
+	}
+
+	public Object invoke(String functionName, Object[] args) {
+
+		if (hotUpdateInterval > 0) {
+			checkUpdate();
+		}
+
+		try {
+			engine.call(null, functionName, args);
+		} catch (BSFException e) {
+			throw new RuntimeException(e);
+		}
+
+		return null;
+	}
+
+	protected synchronized void checkUpdate() {
+		long now = System.currentTimeMillis();
+		if (now - lastCheckTime > hotUpdateInterval) {
+			lastCheckTime = now;
+			long lm = scriptFile.lastModified();
+			if (lm != lastModified) {
+				lastModified = lm;
+				initEngine();
+			}
+		}
+	}
+
+	protected void initEngine() {
+		try {
+
+			String scriptLanguage = BSFManager.getLangFromFilename(scriptName);
+			BSFManager bsfManager = new BSFManager();
+			bsfManager.setClassLoader(BSFManager.class.getClassLoader());
+			// bsfManager.declareBean("_AxisService", axisService,
+			// AxisService.class);
+
+			BSFEngine bsfEngine = bsfManager
+					.loadScriptingEngine(scriptLanguage);
+			Object scriptSrc = readScript();
+			bsfEngine.exec(scriptName, 0, 0, scriptSrc);
+
+		} catch (BSFException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * Reads the complete script source code into a String
+	 */
+	protected String readScript() {
+		Reader reader = null;
+		try {
+
+			reader = new FileReader(scriptFile);
+			char[] buffer = new char[1024];
+			StringBuilder source = new StringBuilder();
+			int count;
+			while ((count = reader.read(buffer)) > 0) {
+				source.append(buffer, 0, count);
+			}
+
+			return source.toString();
+
+		} catch (IOException e) {
+			throw new RuntimeException("IOException reading script: "
+					+ scriptName, e);
+		} finally {
+			try {
+				if (reader != null) {
+					reader.close();
+				}
+			} catch (IOException e) {
+				throw new RuntimeException("IOException closing script: "
+						+ scriptName, e);
+			}
+		}
+	}
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptMessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptMessageContext.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptMessageContext.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptMessageContext.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,89 @@
+/*
+ *  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.axis2.scripting;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.scripting.convertors.OMElementConvertor;
+
+/**
+ * ScriptMessageContext decorates the Axis2 MessageContext adding methods to use
+ * the message payload XML in a way natural to the scripting language.
+ */
+public class ScriptMessageContext extends MessageContext {
+
+	private static final long serialVersionUID = 1L;
+
+	private MessageContext mc;
+
+    private OMElementConvertor convertor;
+
+    public ScriptMessageContext(MessageContext mc, OMElementConvertor convertor) {
+        this.mc = mc;
+        this.convertor = convertor;
+    }
+
+    /**
+     * Get the XML representation of SOAP Body payload. The payload is the first
+     * element inside the SOAP <Body> tags
+     * 
+     * @return the XML SOAP Body
+     */
+    public Object getPayloadXML() {
+        return convertor.toScript(mc.getEnvelope().getBody().getFirstElement());
+    }
+
+    /**
+     * Set the SOAP body payload from XML
+     * 
+     * @param payload
+     * @throws XMLStreamException
+     */
+    public void setPayloadXML(Object payload) {
+        mc.getEnvelope().getBody().setFirstChild(convertor.fromScript(payload));
+    }
+
+    /**
+     * Get the XML representation of the complete SOAP envelope
+     */
+    public Object getEnvelopeXML() {
+        return convertor.toScript(mc.getEnvelope());
+    }
+
+    // helpers to set EPRs from a script string
+
+    public void setTo(String reference) {
+        mc.setTo(new EndpointReference(reference));
+    }
+
+    public void setFaultTo(String reference) {
+        mc.setFaultTo(new EndpointReference(reference));
+    }
+
+    public void setFrom(String reference) {
+        mc.setFrom(new EndpointReference(reference));
+    }
+
+    public void setReplyTo(String reference) {
+        mc.setReplyTo(new EndpointReference(reference));
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptModule.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptModule.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptModule.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptModule.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,99 @@
+/*
+ *  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.axis2.scripting;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.modules.Module;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+/**
+ * Axis2 module to initialize script services. Uses a ScriptDeploymentEngine to
+ * find all the scripts in the scriptServices directory and deploy them as Axis2
+ * services.
+ */
+public class ScriptModule implements Module {
+
+    private static final Log log = LogFactory.getLog(ScriptModule.class);
+
+    /**
+     * Init by creating and deploying AxisServices for each script
+     */
+    public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault {
+
+        log.debug("script services init");
+
+        AxisConfiguration axisConfig = configContext.getAxisConfiguration();
+
+        File scriptServicesDirectory = getScriptServicesDirectory(axisConfig);
+        ScriptDeploymentEngine deploymentEngine = new ScriptDeploymentEngine(axisConfig);
+        deploymentEngine.loadRepository(scriptServicesDirectory);
+        deploymentEngine.loadServices();
+
+        log.info("script module activated");
+    }
+
+    /**
+     * Gets the repo directory for the scripts. The scripts directory is a
+     * sub-directory of the Axis2 repository directory. Its name may be defined
+     * by a 'scriptServicesDir' property in the axis2.xml otherwise it defaults
+     * a to a directory named 'scriptServices'.
+     */
+    protected File getScriptServicesDirectory(AxisConfiguration axisConfig) throws DeploymentException {
+        try {
+
+            URL axis2Repository = axisConfig.getRepository();
+            Parameter scriptsDirParam = axisConfig.getParameter("scriptServicesDir");
+            String scriptsDir = scriptsDirParam == null ? "scriptServices" : (String)scriptsDirParam.getValue();
+            File scriptsDirFile = new File(new File(axis2Repository.toURI()), scriptsDir);
+            return scriptsDirFile;
+
+        } catch (URISyntaxException e) {
+            throw new DeploymentException("URISyntaxException getting script service directory", e);
+        }
+    }
+
+    // --- the following are unused methods on the Module interface ---
+
+    public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+    }
+
+    public boolean canSupportAssertion(Assertion assertion) {
+        return false;
+    }
+
+    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+    }
+
+    public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptReceiver.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptReceiver.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,233 @@
+/*
+ *  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.axis2.scripting;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.axis2.scripting.convertors.ConvertorFactory;
+import org.apache.axis2.scripting.convertors.OMElementConvertor;
+import org.apache.bsf.BSFEngine;
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * An Axis2 MessageReceiver for invoking script language functions.
+ * 
+ * The scripting support uses the Apache Bean Scripting Framework (BSF) 
+ * so the script may be written in any language supported by BSF. 
+ * 
+ * There are two ways of defining the script, either in a seperate file
+ * or embedded in-line within the services.xml file.
+ * 
+ * This example shows a services.xml using a seperate script file:
+ * <code>
+ *   <serviceGroup>
+ *     <service ...>
+ *       ...
+ *       <parameter name="script">scripts/myScript.js</parameter>
+ *     </service>
+ *   </serviceGroup>
+ * </code>
+ * 
+ * This example shows a JavaScript function embedded within a services.xml file:
+ * <code>
+ *   <serviceGroup>
+ *     <service ...>
+ *       ...
+ *       <parameter name="script.js"><![CDATA[
+ *          function invoke(inMC, outMC) {
+ *             ...
+ *          }
+ *        ]]></parameter>
+ *     </service>
+ *   </serviceGroup>
+ * </code>
+ * 
+ * The script language is determined by the file name suffix when using scripts
+ * in seperate files or the script parameter name suffix when using inline scripts.
+ */
+public class ScriptReceiver extends AbstractInOutSyncMessageReceiver {
+
+    public static final String SCRIPT_ATTR = "script";
+    public static final String FUNCTION_ATTR = "function";
+    public static final String DEFAULT_FUNCTION = "invoke";
+    public static final String CONVERTOR_ATTR = "convertor";
+
+    protected static final String BSFENGINE_PROP = ScriptReceiver.class.getName() + "BSFEngine";
+    protected static final String CONVERTOR_PROP = ScriptReceiver.class.getName() + "OMElementConvertor";
+    public static final String SCRIPT_SRC_PROP = ScriptReceiver.class.getName() + "ScriptSrc";
+
+    private static final Log log = LogFactory.getLog(ScriptModule.class);
+
+    public ScriptReceiver() {
+    }
+
+    /**
+     * Invokes the service by calling the script function
+     */
+    public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault {
+        try {
+
+            log.debug("invoking script service");
+
+            outMC.setEnvelope(getSOAPFactory(inMC).getDefaultEnvelope());
+
+            BSFEngine engine = getBSFEngine(inMC);
+            OMElementConvertor convertor = (OMElementConvertor) inMC.getServiceContext().getProperty(CONVERTOR_PROP);
+
+            Parameter scriptFunctionParam = inMC.getAxisService().getParameter(FUNCTION_ATTR);
+            String scriptFunction = scriptFunctionParam == null ? DEFAULT_FUNCTION : (String) scriptFunctionParam.getValue();
+
+            ScriptMessageContext inScriptMC = new ScriptMessageContext(inMC, convertor);
+            ScriptMessageContext outScriptMC = new ScriptMessageContext(outMC, convertor);
+            Object[] args = new Object[] { inScriptMC, outScriptMC };
+
+            engine.call(null, scriptFunction, args);
+
+        } catch (BSFException e) {
+            throw new AxisFault(e);
+        }
+    }
+
+    /**
+     * Gets the BSFEngine for the script service.
+     * 
+     * The first service invocation creates the BSFEngine and caches
+     * it in the Axis2 ServiceContext for reuse by subsequent requests.
+     */
+    protected BSFEngine getBSFEngine(MessageContext mc) throws AxisFault {
+        BSFEngine bsfEngine;
+        ServiceContext serviceContext = mc.getServiceContext();
+        synchronized (serviceContext) {
+            bsfEngine = (BSFEngine) serviceContext.getProperty(BSFENGINE_PROP);
+            if (bsfEngine == null) {
+                bsfEngine = initScript(mc);
+            }
+        }
+        return bsfEngine;
+    }
+
+    /**
+     * Initializes the script service by finding the script source code,
+     * compiling it in a BSFEngine, and creating an OMElementConvertor
+     * for the script.
+     */
+    protected BSFEngine initScript(MessageContext mc) throws AxisFault {
+        log.debug("initializing script service");
+
+        AxisService axisService = mc.getAxisService();
+
+        String scriptName = null;
+        String scriptSrc = null;
+        Parameter scriptFileParam = axisService.getParameter(SCRIPT_ATTR);
+        if (scriptFileParam != null) {
+            // the script is defined in a seperate file
+            scriptName = ((String) scriptFileParam.getValue()).trim();
+            Parameter scriptSrcParam = axisService.getParameter(SCRIPT_SRC_PROP);
+            if (scriptSrcParam != null) {
+                scriptSrc = (String) scriptSrcParam.getValue();
+            } else {
+                scriptSrc = readScript(axisService.getClassLoader(), scriptName);
+            }
+        } else {
+            // the script is defined inline within the services.xml
+            ArrayList parameters = axisService.getParameters();
+            for (int i=0; scriptFileParam == null && i<parameters.size(); i++) {
+                Parameter p = (Parameter) parameters.get(i);
+                if (p.getName().startsWith("script.")) {
+                    scriptFileParam = p;
+                    scriptName = p.getName();
+                    scriptSrc = (String) p.getValue();
+                }
+            }
+        }
+        if (scriptName == null) {
+            throw new AxisFault("Missing script parameter");
+        }
+        
+        try {
+
+            String scriptLanguage = BSFManager.getLangFromFilename(scriptName);
+            BSFManager bsfManager = new BSFManager();
+            bsfManager.setClassLoader(BSFManager.class.getClassLoader());
+            bsfManager.declareBean("_AxisService", axisService, AxisService.class);
+
+            BSFEngine bsfEngine = bsfManager.loadScriptingEngine(scriptLanguage);
+            bsfEngine.exec(scriptName, 0, 0, scriptSrc);
+
+            ServiceContext serviceContext = mc.getServiceContext();
+            serviceContext.setProperty(BSFENGINE_PROP, bsfEngine);
+
+            OMElementConvertor convertor = ConvertorFactory.createOMElementConvertor(axisService, scriptName);
+            serviceContext.setProperty(CONVERTOR_PROP, convertor);
+
+            return bsfEngine;
+
+        } catch (BSFException e) {
+            throw new AxisFault(e);
+        }
+    }
+
+    /**
+     * Reads the complete script source code into a String
+     */
+    protected String readScript(ClassLoader cl, String scriptName) throws AxisFault {
+        URL url = cl.getResource(scriptName);
+        if (url == null) {
+            throw new AxisFault("Script not found: " + scriptName);
+        }
+        InputStream is;
+        try {
+            is = url.openStream();
+        } catch (IOException e) {
+            throw new AxisFault("IOException opening script: " + scriptName, e);
+        }
+        try {
+            Reader reader = new InputStreamReader(is, "UTF-8");
+            char[] buffer = new char[1024];
+            StringBuilder source = new StringBuilder();
+            int count;
+            while ((count = reader.read(buffer)) > 0) {
+                source.append(buffer, 0, count);
+            }
+            return source.toString();
+        } catch (IOException e) {
+            throw new AxisFault("IOException reading script: " + scriptName, e);
+        } finally {
+            try {
+                is.close();
+            } catch (IOException e) {
+                throw new AxisFault("IOException closing script: " + scriptName, e);
+            }
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptRepositoryListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptRepositoryListener.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptRepositoryListener.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/ScriptRepositoryListener.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,65 @@
+/*
+ *  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.axis2.scripting;
+
+import java.io.File;
+
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.RepositoryListener;
+
+/**
+ * An Axis2 RepositoryListener subclass for dealing with script services
+ */
+public class ScriptRepositoryListener extends RepositoryListener {
+
+    public ScriptRepositoryListener(DeploymentEngine deploymentEngine) {
+        super(deploymentEngine, false);
+    }
+
+    /**
+     * Searches a given folder for script services and adds them to a list in
+     * the WSInfolist class.
+     */
+    protected void findServicesInDirectory() {
+
+        File[] files = deploymentEngine.getServicesDir().listFiles();
+
+        if (files != null && files.length > 0) {
+            for (int i = 0; i < files.length; i++) {
+                wsInfoList.addWSInfoItem(files[i], TYPE_SERVICE);
+            }
+        }
+
+        wsInfoList.addWSInfoItem(null, TYPE_DEFAULT);
+    }
+
+    /*
+     * Override the RepositoryListener method to do nothing as not required for
+     * script services
+     */
+    public void checkModules() {
+    }
+
+    /*
+     * Override the RepositoryListener method to do nothing as not required for
+     * script services
+     */
+    protected void loadClassPathModules() {
+    }
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/ConvertorFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/ConvertorFactory.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/ConvertorFactory.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/ConvertorFactory.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,110 @@
+package org.apache.axis2.scripting.convertors;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.scripting.ScriptReceiver;
+
+public class ConvertorFactory {
+
+    /**
+     * Creates an OMElementConvertor for the script.
+     * 
+     * The OMElementConvertor impl class name is either:
+     * - the convertor class name attribute from the script element in the sevices.xml
+     * - the value of the parameter name XXOMElementConvertor in the axis2.xml
+     *   where XX is the script language suffix upper cased, eg. JS or RB
+     * - org.apache.axis2.receivers.scripting.convertors.XXOMElementConvertor where
+     *   where XX is the script language suffix upper cased, eg. JS or RB
+     * - org.apache.axis2.receivers.scripting.convertors.DefaultOMElementConvertor
+     */
+    public static OMElementConvertor createOMElementConvertor(AxisService axisService, String scriptName) throws AxisFault {
+        OMElementConvertor oc = getScriptConvertor(axisService);
+        if (oc == null) {
+            oc = getAxis2Convertor(axisService, scriptName);
+        } 
+        if (oc == null) {
+            try {
+                oc = getDefaultScriptConvertor(axisService, scriptName);
+            } catch (Exception e) {
+                throw new AxisFault(e);
+            }
+        } 
+        if (oc == null) {
+            oc = new DefaultOMElementConvertor();
+        } 
+        return oc;
+    }
+
+    /**
+     * 
+     */
+    protected static OMElementConvertor getScriptConvertor(AxisService axisService) {
+        OMElementConvertor oc = null;
+        Parameter convertorParam = axisService.getParameter(ScriptReceiver.CONVERTOR_ATTR);
+        if (convertorParam != null) {
+            String convertorClassName = (String) convertorParam.getValue(); 
+            try {
+                oc = (OMElementConvertor) Class.forName(convertorClassName, true, axisService.getClassLoader()).newInstance();
+            } catch (Exception e) {
+                // ignore
+            }
+        }
+        return oc;
+    }
+
+    protected static OMElementConvertor getAxis2Convertor(AxisService axisService, String scriptName) {
+        OMElementConvertor oc = null;
+        int lastDot = scriptName.lastIndexOf('.');
+        String suffix = scriptName.substring(lastDot + 1).toUpperCase();
+        String className = OMElementConvertor.class.getName();
+        int i = className.lastIndexOf('.');
+        String convertorClassNameProp = suffix.toUpperCase() + className.substring(i + 1);
+        AxisConfiguration axisConfig = axisService.getAxisConfiguration();
+        Parameter convertorParam = axisConfig.getParameter(convertorClassNameProp);
+        if (convertorParam != null) {
+            String convertorClassName = (String) convertorParam.getValue();
+            try {
+                oc = (OMElementConvertor) Class.forName(convertorClassName, true, axisService.getClassLoader()).newInstance();
+            } catch (Exception e) {
+                // ignore
+            }
+        }
+        return oc;
+    }
+
+    protected static OMElementConvertor getDefaultScriptConvertor(AxisService axisService, String scriptName) throws InstantiationException, IllegalAccessException {
+        OMElementConvertor oc = null;
+        int lastDot = scriptName.lastIndexOf('.');
+        String suffix = scriptName.substring(lastDot + 1).toUpperCase();
+        String className = OMElementConvertor.class.getName();
+        int i = className.lastIndexOf('.');
+        String convertorClassName = suffix.toUpperCase() + className.substring(i + 1);
+        AxisConfiguration axisConfig = axisService.getAxisConfiguration();
+        Parameter convertorParam = axisConfig.getParameter(convertorClassName);
+        if (convertorParam != null) {
+            try {
+                oc = (OMElementConvertor) Class.forName((String) convertorParam.getValue(), true, axisService.getClassLoader()).newInstance();
+            } catch (ClassNotFoundException e) {
+                // ignore
+            }
+        } else {
+            String fqConvertorClassName = className.substring(0, i + 1) + convertorClassName;
+            try {
+                oc = (OMElementConvertor) Class.forName(fqConvertorClassName, true, axisService.getClassLoader()).newInstance();
+            } catch (ClassNotFoundException e) {
+                // ignore
+            }
+            if (oc == null) {
+                try {
+                    oc = (OMElementConvertor) Class.forName(fqConvertorClassName, true, ConvertorFactory.class.getClassLoader()).newInstance();
+                } catch (ClassNotFoundException e) {
+                    // ignore
+                }
+            }
+        }
+        return oc;
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/DefaultOMElementConvertor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/DefaultOMElementConvertor.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/DefaultOMElementConvertor.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/DefaultOMElementConvertor.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,55 @@
+/*
+ *  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.axis2.scripting.convertors;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.bsf.BSFEngine;
+
+/**
+ * The DefaultOMElementConvertor converts between Synapse OMElements and Strings
+ */
+public class DefaultOMElementConvertor implements OMElementConvertor {
+
+    public OMElement fromScript(Object o) {
+        try {
+
+            byte[] xmlBytes = o.toString().getBytes();
+            StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(xmlBytes));
+            OMElement omElement = builder.getDocumentElement();
+            return omElement;
+
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public Object toScript(OMElement omElement) {
+        return omElement.toString();
+    }
+
+    public void setEngine(BSFEngine e) {
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/JSOMElementConvertor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/JSOMElementConvertor.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/JSOMElementConvertor.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/JSOMElementConvertor.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,91 @@
+/*
+ *  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.axis2.scripting.convertors;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.xmlbeans.XmlObject;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Wrapper;
+import org.mozilla.javascript.xml.XMLObject;
+
+/**
+ * JSObjectConvertor converts between OMElements and JavaScript E4X XML objects
+ */
+public class JSOMElementConvertor extends DefaultOMElementConvertor {
+
+    protected Scriptable scope;
+
+    public JSOMElementConvertor() {
+        Context cx = Context.enter();
+        try {
+            this.scope = cx.initStandardObjects();
+        } finally {
+            Context.exit();
+        }
+    }
+
+    public Object toScript(OMElement o) {
+        XmlObject xml;
+        try {
+            xml = XmlObject.Factory.parse(o.getXMLStreamReader());
+        } catch (Exception e) {
+            throw new RuntimeException("exception getting message XML: " + e);
+        }
+
+        Context cx = Context.enter();
+        try {
+
+            Object wrappedXML = cx.getWrapFactory().wrap(cx, scope, xml, XmlObject.class);
+            Scriptable jsXML = cx.newObject(scope, "XML", new Object[] { wrappedXML });
+
+            return jsXML;
+
+        } finally {
+            Context.exit();
+        }
+    }
+
+    public OMElement fromScript(Object o) {
+        if (!(o instanceof XMLObject)) {
+            return super.fromScript(o);
+        }
+
+        // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost. See Mozilla bugzilla 361722
+        Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) o, "copy", new Object[0]);
+        Wrapper wrapper = (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new Object[0]);
+        XmlObject xmlObject = (XmlObject)wrapper.unwrap();
+        try {
+
+            StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
+            OMElement omElement = builder.getDocumentElement();
+
+            return omElement;
+
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/OMElementConvertor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/OMElementConvertor.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/OMElementConvertor.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/OMElementConvertor.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,47 @@
+/*
+ *  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.axis2.scripting.convertors;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.bsf.BSFEngine;
+
+/**
+ * The OMElementConvertor interface enables customizing the conversion of 
+ * XML between Synapse and a script language. Some script languages have their
+ * own ways of using XML, such as E4X in JavaScript or REXML in Ruby. But BSF
+ * has no support for those so Synapse needs to handle this itself, which is what
+ * the OMElementConvertor does.
+ * 
+ * Which OMElementConvertor type to use is discovered based on the file name suffix of 
+ * the mediator script. The suffix is converted to uppercase and used as the prefix to 
+ * the OMElementConvertor classname. For example, with a JavaScript script named myscript.js
+ * the .js suffix is taken to make the convertor class name 
+ * "org.apache.synapse.mediators.bsf.convertors.JSOMElementConvertor"
+ * If the convertor class is not found then a default convertor is used which converts
+ * XML to a String representation.
+ */
+public interface OMElementConvertor {
+    
+    public void setEngine(BSFEngine e);
+    public Object toScript(OMElement omElement);
+    
+    public OMElement fromScript(Object o);
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/RBOMElementConvertor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/RBOMElementConvertor.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/RBOMElementConvertor.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/src/org/apache/axis2/scripting/convertors/RBOMElementConvertor.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,77 @@
+/*
+ *  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.axis2.scripting.convertors;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.bsf.BSFEngine;
+import org.apache.bsf.BSFException;
+
+/**
+ * OMElementConvertor for Ruby scripts
+ * 
+ * TODO: Right now this goes via Strings and likely isn't very fast
+ * There could well be much better ways to do this :)
+ */
+public class RBOMElementConvertor implements OMElementConvertor {
+
+    protected BSFEngine bsfEngine;
+
+    public RBOMElementConvertor() {
+    }
+
+    public Object toScript(OMElement omElement) {
+        try {
+
+            StringBuffer srcFragment = new StringBuffer("Document.new(<<EOF\n");
+            srcFragment.append(omElement.toString());
+            srcFragment.append("\nEOF\n");
+            srcFragment.append(")");
+            
+            Object o = bsfEngine.eval("RBOMElementConvertor", 0, 0, srcFragment.toString());
+            return o;
+
+        } catch (BSFException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public OMElement fromScript(Object o) {
+        try {
+
+            byte[] xmlBytes = o.toString().getBytes();
+            StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(xmlBytes));
+            OMElement omElement = builder.getDocumentElement();
+
+            return omElement;
+
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void setEngine(BSFEngine e) {
+        this.bsfEngine = e;
+    }
+}

Added: webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.js
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy%20of%20test.js?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.js (added)
+++ webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.js Fri Mar 16 05:49:37 2007
@@ -0,0 +1 @@
+petra
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy%20of%20test.wsdl?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.wsdl (added)
+++ webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/Copy of test.wsdl Fri Mar 16 05:49:37 2007
@@ -0,0 +1,121 @@
+<!--
+  ~  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.
+  -->
+
+<wsdl:definitions xmlns:axis2="http://services.samples" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="http://services.samples/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://services.samples">
+	<wsdl:types>
+		<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax21="http://services.samples/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://services.samples/xsd">
+			<xs:element name="getQuote">
+				<xs:complexType>
+					<xs:sequence>
+						<xs:element name="request" type="ax21:GetQuote"/>
+					</xs:sequence>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="GetQuote" type="ax21:GetQuote"/>
+			<xs:complexType name="GetQuote">
+				<xs:sequence>
+					<xs:element name="symbol" type="xs:string"/>
+				</xs:sequence>
+			</xs:complexType>
+			<xs:element name="getQuoteResponse">
+				<xs:complexType>
+					<xs:sequence>
+						<xs:element name="return" type="ax21:GetQuoteResponse"/>
+					</xs:sequence>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="GetQuoteResponse" type="ax21:GetQuoteResponse"/>
+			<xs:complexType name="GetQuoteResponse">
+				<xs:sequence>
+					<xs:element name="change" type="xs:double"/>
+					<xs:element name="earnings" type="xs:double"/>
+					<xs:element name="high" type="xs:double"/>
+					<xs:element name="last" type="xs:double"/>
+					<xs:element name="lastTradeTimestamp" type="xs:string"/>
+					<xs:element name="low" type="xs:double"/>
+					<xs:element name="marketCap" type="xs:double"/>
+					<xs:element name="name" type="xs:string"/>
+					<xs:element name="open" type="xs:double"/>
+					<xs:element name="peRatio" type="xs:double"/>
+					<xs:element name="percentageChange" type="xs:double"/>
+					<xs:element name="prevClose" type="xs:double"/>
+					<xs:element name="symbol" type="xs:string"/>
+					<xs:element name="volume" type="xs:int"/>
+				</xs:sequence>
+			</xs:complexType>
+			<xs:element name="placeOrder">
+				<xs:complexType>
+					<xs:sequence>
+						<xs:element name="order" type="ax21:PlaceOrder"/>
+					</xs:sequence>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="PlaceOrder" type="ax21:PlaceOrder"/>
+			<xs:complexType name="PlaceOrder">
+				<xs:sequence>
+					<xs:element name="price" type="xs:double"/>
+					<xs:element name="quantity" type="xs:int"/>
+					<xs:element name="symbol" type="xs:string"/>
+				</xs:sequence>
+			</xs:complexType>
+		</xs:schema>
+	</wsdl:types>
+	<wsdl:message name="getQuoteMessage">
+		<wsdl:part name="part1" element="ns1:getQuote"/>
+	</wsdl:message>
+	<wsdl:message name="getQuoteResponseMessage">
+		<wsdl:part name="part1" element="ns1:getQuoteResponse"/>
+	</wsdl:message>
+	<wsdl:message name="placeOrderMessage">
+		<wsdl:part name="part1" element="ns1:placeOrder"/>
+	</wsdl:message>
+	<wsdl:portType name="SimpleStockQuoteServicePortType">
+		<wsdl:operation name="getQuote">
+			<wsdl:input message="axis2:getQuoteMessage"/>
+			<wsdl:output message="axis2:getQuoteResponseMessage"/>
+		</wsdl:operation>
+		<wsdl:operation name="placeOrder">
+			<wsdl:input message="axis2:placeOrderMessage"/>
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:binding name="SimpleStockQuoteServiceSOAP11Binding" type="axis2:SimpleStockQuoteServicePortType">
+		<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+		<wsdl:operation name="getQuote">
+			<soap:operation soapAction="urn:getQuote" style="document"/>
+			<wsdl:input>
+				<soap:body use="literal" namespace="http://services.samples"/>
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" namespace="http://services.samples"/>
+			</wsdl:output>
+		</wsdl:operation>
+		<wsdl:operation name="placeOrder">
+			<soap:operation soapAction="urn:placeOrder" style="document"/>
+			<wsdl:input>
+				<soap:body use="literal" namespace="http://services.samples"/>
+			</wsdl:input>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:service name="SimpleStockQuoteService">
+		<wsdl:port name="SimpleStockQuoteServiceSOAP11port" binding="axis2:SimpleStockQuoteServiceSOAP11Binding">
+			<soap:address location="http://localhost:8080/axis2/services/SimpleStockQuoteService"/>
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>
+

Added: webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.js
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.js?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.js (added)
+++ webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.js Fri Mar 16 05:49:37 2007
@@ -0,0 +1 @@
+petra
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.wsdl?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.wsdl (added)
+++ webservices/axis2/trunk/java/modules/scripting/test-resources/org/apache/axis2/scripting/testrepo/test.wsdl Fri Mar 16 05:49:37 2007
@@ -0,0 +1,121 @@
+<!--
+  ~  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.
+  -->
+
+<wsdl:definitions xmlns:axis2="http://services.samples" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns1="http://services.samples/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://services.samples">
+	<wsdl:types>
+		<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax21="http://services.samples/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://services.samples/xsd">
+			<xs:element name="getQuote">
+				<xs:complexType>
+					<xs:sequence>
+						<xs:element name="request" type="ax21:GetQuote"/>
+					</xs:sequence>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="GetQuote" type="ax21:GetQuote"/>
+			<xs:complexType name="GetQuote">
+				<xs:sequence>
+					<xs:element name="symbol" type="xs:string"/>
+				</xs:sequence>
+			</xs:complexType>
+			<xs:element name="getQuoteResponse">
+				<xs:complexType>
+					<xs:sequence>
+						<xs:element name="return" type="ax21:GetQuoteResponse"/>
+					</xs:sequence>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="GetQuoteResponse" type="ax21:GetQuoteResponse"/>
+			<xs:complexType name="GetQuoteResponse">
+				<xs:sequence>
+					<xs:element name="change" type="xs:double"/>
+					<xs:element name="earnings" type="xs:double"/>
+					<xs:element name="high" type="xs:double"/>
+					<xs:element name="last" type="xs:double"/>
+					<xs:element name="lastTradeTimestamp" type="xs:string"/>
+					<xs:element name="low" type="xs:double"/>
+					<xs:element name="marketCap" type="xs:double"/>
+					<xs:element name="name" type="xs:string"/>
+					<xs:element name="open" type="xs:double"/>
+					<xs:element name="peRatio" type="xs:double"/>
+					<xs:element name="percentageChange" type="xs:double"/>
+					<xs:element name="prevClose" type="xs:double"/>
+					<xs:element name="symbol" type="xs:string"/>
+					<xs:element name="volume" type="xs:int"/>
+				</xs:sequence>
+			</xs:complexType>
+			<xs:element name="placeOrder">
+				<xs:complexType>
+					<xs:sequence>
+						<xs:element name="order" type="ax21:PlaceOrder"/>
+					</xs:sequence>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="PlaceOrder" type="ax21:PlaceOrder"/>
+			<xs:complexType name="PlaceOrder">
+				<xs:sequence>
+					<xs:element name="price" type="xs:double"/>
+					<xs:element name="quantity" type="xs:int"/>
+					<xs:element name="symbol" type="xs:string"/>
+				</xs:sequence>
+			</xs:complexType>
+		</xs:schema>
+	</wsdl:types>
+	<wsdl:message name="getQuoteMessage">
+		<wsdl:part name="part1" element="ns1:getQuote"/>
+	</wsdl:message>
+	<wsdl:message name="getQuoteResponseMessage">
+		<wsdl:part name="part1" element="ns1:getQuoteResponse"/>
+	</wsdl:message>
+	<wsdl:message name="placeOrderMessage">
+		<wsdl:part name="part1" element="ns1:placeOrder"/>
+	</wsdl:message>
+	<wsdl:portType name="SimpleStockQuoteServicePortType">
+		<wsdl:operation name="getQuote">
+			<wsdl:input message="axis2:getQuoteMessage"/>
+			<wsdl:output message="axis2:getQuoteResponseMessage"/>
+		</wsdl:operation>
+		<wsdl:operation name="placeOrder">
+			<wsdl:input message="axis2:placeOrderMessage"/>
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:binding name="SimpleStockQuoteServiceSOAP11Binding" type="axis2:SimpleStockQuoteServicePortType">
+		<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+		<wsdl:operation name="getQuote">
+			<soap:operation soapAction="urn:getQuote" style="document"/>
+			<wsdl:input>
+				<soap:body use="literal" namespace="http://services.samples"/>
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" namespace="http://services.samples"/>
+			</wsdl:output>
+		</wsdl:operation>
+		<wsdl:operation name="placeOrder">
+			<soap:operation soapAction="urn:placeOrder" style="document"/>
+			<wsdl:input>
+				<soap:body use="literal" namespace="http://services.samples"/>
+			</wsdl:input>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:service name="SimpleStockQuoteService">
+		<wsdl:port name="SimpleStockQuoteServiceSOAP11port" binding="axis2:SimpleStockQuoteServiceSOAP11Binding">
+			<soap:address location="http://localhost:8080/axis2/services/SimpleStockQuoteService"/>
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>
+

Added: webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptDeploymentEngineTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptDeploymentEngineTest.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptDeploymentEngineTest.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptDeploymentEngineTest.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,25 @@
+package org.apache.axis2.scripting;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
+
+public class ScriptDeploymentEngineTest extends TestCase {
+    
+    public void test1() throws URISyntaxException, InterruptedException, MalformedURLException, AxisFault {
+        AxisConfiguration axisConfig = new AxisConfiguration();
+        ScriptDeploymentEngine sde = new ScriptDeploymentEngine(axisConfig);
+        URL testScript = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.js");
+        File scriptsDir = new File(testScript.toURI()).getParentFile();
+        sde.loadRepository(scriptsDir);
+        sde.loadServices();
+        assertNotNull(axisConfig.getService("test"));
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptModuleTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptModuleTest.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptModuleTest.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptModuleTest.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,74 @@
+package org.apache.axis2.scripting;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+
+public class ScriptModuleTest extends TestCase {
+
+//    public void testGetScriptForWSDL() throws MalformedURLException, URISyntaxException {
+//        ScriptModule module = new ScriptModule();
+//        URL wsdlURL = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.wsdl");
+//        URL scriptURL = module.getScriptForWSDL(wsdlURL);
+//        assertTrue(scriptURL.toString().endsWith("test.js"));
+//    }
+//
+//    public void testGetWSDLsInDir() throws MalformedURLException, URISyntaxException {
+//        ScriptModule module = new ScriptModule();
+//        URL wsdlURL = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.wsdl");
+//        URL scriptsDir = new File(wsdlURL.toURI()).getParentFile().toURL();
+//        List wsdls = module.getWSDLsInDir(scriptsDir);
+//        assertEquals(2, wsdls.size());
+//        assertTrue(wsdls.get(0).toString().endsWith("test.wsdl"));
+//    }
+//
+//    public void testReadScriptSource() throws AxisFault {
+//        ScriptModule module = new ScriptModule();
+//        URL url = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.js");
+//        String s = module.readScriptSource(url);
+//        assertEquals("petra", s);
+//    }
+
+    public void testGetScriptServicesDirectory() throws AxisFault, MalformedURLException, URISyntaxException {
+        ScriptModule module = new ScriptModule();
+        AxisConfiguration axisConfig = new AxisConfiguration();
+        URL url = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.js");
+        File dir = new File(url.toURI()).getParentFile();
+        axisConfig.setRepository(dir.getParentFile().toURL());
+        axisConfig.addParameter(new Parameter("scriptServicesDir", dir.getName()));
+        assertEquals(dir.toURL(), module.getScriptServicesDirectory(axisConfig).toURL());
+    }
+
+//    public void testCreateService() throws AxisFault {
+//        URL wsdlURL = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.wsdl");
+//        URL scriptURL = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.js");
+//        ScriptModule module = new ScriptModule();
+//        AxisService axisService = module.createService(wsdlURL, scriptURL);
+//        assertEquals("petra", axisService.getParameterValue(ScriptReceiver.SCRIPT_SRC_PROP));
+//    }
+
+    public void testInit() throws AxisFault, MalformedURLException, URISyntaxException, InterruptedException {
+        ScriptModule module = new ScriptModule();
+        AxisConfiguration axisConfig = new AxisConfiguration();
+        URL url = getClass().getClassLoader().getResource("org/apache/axis2/scripting/testrepo/test.js");
+        File dir = new File(url.toURI()).getParentFile();
+        axisConfig.setRepository(dir.getParentFile().toURL());
+        axisConfig.addParameter(new Parameter("scriptServicesDir", dir.getName()));
+        ConfigurationContext configContext = new ConfigurationContext(axisConfig);
+
+        module.init(configContext, null);
+        
+        Thread.sleep(500);
+        
+        assertNotNull(axisConfig.getService("test"));
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptReceiverTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptReceiverTest.java?view=auto&rev=518956
==============================================================================
--- webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptReceiverTest.java (added)
+++ webservices/axis2/trunk/java/modules/scripting/test/org/apache/axis2/scripting/ScriptReceiverTest.java Fri Mar 16 05:49:37 2007
@@ -0,0 +1,45 @@
+package org.apache.axis2.scripting;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+
+public class ScriptReceiverTest extends TestCase {
+    
+    public void testInvokeBusinessLogic() throws AxisFault {
+        ScriptReceiver scriptReceiver = new ScriptReceiver();
+        MessageContext inMC = TestUtils.createMockMessageContext("<a>petra</a>");
+        AxisService axisServce = new AxisService();
+        axisServce.setParent(new AxisServiceGroup(new AxisConfiguration()));
+        axisServce.addParameter(new Parameter(ScriptReceiver.SCRIPT_ATTR, "foo.js"));
+        axisServce.addParameter(new Parameter(ScriptReceiver.SCRIPT_SRC_PROP, "function invoke(inMC,outMC) {outMC.setPayloadXML(<a>petra</a>) }"));
+        inMC.setAxisService(axisServce);
+        scriptReceiver.invokeBusinessLogic(inMC, inMC);
+        Iterator iterator = inMC.getEnvelope().getChildElements();
+        iterator.next();
+        assertEquals("<a>petra</a>", ((OMElement) iterator.next()).getFirstElement().toString());
+    }
+
+    public void testAxisService() throws AxisFault {
+        ScriptReceiver scriptReceiver = new ScriptReceiver();
+        MessageContext inMC = TestUtils.createMockMessageContext("<a>petra</a>");
+        AxisService axisServce = new AxisService();
+        axisServce.setParent(new AxisServiceGroup(new AxisConfiguration()));
+        axisServce.addParameter(new Parameter(ScriptReceiver.SCRIPT_ATTR, "foo.js"));
+        axisServce.addParameter(new Parameter(ScriptReceiver.SCRIPT_SRC_PROP, "var scope = _AxisService.getScope();function invoke(inMC,outMC) {outMC.setPayloadXML(<a>{scope}</a>) }"));
+        inMC.setAxisService(axisServce);
+        scriptReceiver.invokeBusinessLogic(inMC, inMC);
+        Iterator iterator = inMC.getEnvelope().getChildElements();
+        iterator.next();
+        assertEquals("<a>request</a>", ((OMElement) iterator.next()).getFirstElement().toString());
+    }
+
+}



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