[prev in list] [next in list] [prev in thread] [next in thread]
List: wsf-java-dev
Subject: [Wsf-dev] [Jython] svn commit r46510 - in trunk/wsf/jython/server:
From: heshan () wso2 ! com
Date: 2009-10-05 5:58:23
Message-ID: E1MugaV-0003qe-6e () wso2 ! org
[Download RAW message or body]
Author: heshan
Date: Sun Oct 4 22:58:22 2009
New Revision: 46510
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=46510
Log:
added server side code for wsf/jython.
Added:
trunk/wsf/jython/server/
trunk/wsf/jython/server/LICENSE.txt
trunk/wsf/jython/server/README.txt
trunk/wsf/jython/server/core/
trunk/wsf/jython/server/core/pom.xml
trunk/wsf/jython/server/core/src/
trunk/wsf/jython/server/core/src/main/
trunk/wsf/jython/server/core/src/main/java/
trunk/wsf/jython/server/core/src/main/java/org/
trunk/wsf/jython/server/core/src/main/java/org/wso2/
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/JPythonServer.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/PythonDeployer.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/ComplexType.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/MyTypes.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SimpleType.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TestSchemaGenClass.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/Type.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PyToOMConverter.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngine.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngineConstants.java
trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptReceiver.java
trunk/wsf/jython/server/core/src/main/resources/
trunk/wsf/jython/server/core/src/main/resources/Processor.py
trunk/wsf/jython/server/distribution/
trunk/wsf/jython/server/distribution/pom.xml
trunk/wsf/jython/server/distribution/src/
trunk/wsf/jython/server/distribution/src/main/
trunk/wsf/jython/server/distribution/src/main/assembly/
trunk/wsf/jython/server/distribution/src/main/assembly/bin-assembly.xml
trunk/wsf/jython/server/distribution/src/main/assembly/src-assembly.xml
trunk/wsf/jython/server/pom.xml
trunk/wsf/jython/server/release-note.html
trunk/wsf/jython/server/samples/
trunk/wsf/jython/server/samples/simpleService.py
Added: trunk/wsf/jython/server/LICENSE.txt
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/LICENSE.txt?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/LICENSE.txt Sun Oct 4 22:58:22 2009
@@ -0,0 +1,203 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
Added: trunk/wsf/jython/server/README.txt
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/README.txt?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/README.txt Sun Oct 4 22:58:22 2009
@@ -0,0 +1,36 @@
+18th September 2008
+
+WSO2 Web Services Framework for Jython 1.0-alpha
+-------------------------------------------
+
+Writing services in Jython
+-------------------------------------
+
+Please follow the instructions in this article \
http://wso2.org/library/articles/deploying-python-service-axis2 +
+Building the source distribution
+--------------------------------
+
+NOTE: JDK 1.5 and Maven 2 is required to build the source.
+
+1.type "mvn clean install" in the base directory (where the source was downloaded \
to) +2.If, the build fails due to a missing artifact build again by typing "mvn clean \
install -up" +
+Support
+-------
+
+Issues can be reported using the public JIRA available at \
http://wso2.org/jira/browse/WSFJython +
+Contact us
+----------
+
+WSO2 WSF/Jython developers can be contacted via the mailing list \
wsf-java-dev@wso2.org +To subscribe please send a message to \
wsf-java-dev-request@wso2.org +
+WSO2 WSF/Jython user mailing list is wsf-jython-user@wso2.org
+To subscribe please send a message to wsf-jython-dev-request@wso2.org
+
+Alternatively, questions can also be raised in the forums: http://wso2.org/forum/797
+Thank you for your interest in WSO2 WSF/Jython
+- The WSO2 WSF/Jython Development Team
+
Added: trunk/wsf/jython/server/core/pom.xml
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/pom.xml?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/pom.xml Sun Oct 4 22:58:22 2009
@@ -0,0 +1,48 @@
+<!--
+ ~ Copyright 2007-2008 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ 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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 \
http://maven.apache.org/maven-v4_0_0.xsd"> + <!-- The Basics -->
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.wso2.wsf.jython</groupId>
+ <artifactId>wsf-jython-deployer</artifactId>
+ <version>1.0-alpha</version>
+ <packaging>jar</packaging>
+ <name>WSO2 WSF Jython - Deployer</name>
+ <url>http://wso2.org</url>
+ <parent>
+ <groupId>org.wso2.wsf.jython</groupId>
+ <artifactId>org.wso2.wsf.jython.deployer</artifactId>
+ <version>1.0-alpha</version>
+ </parent>
+ <!-- Build Settings -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
+
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/JPythonServer.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/JPythonServer.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/JPythonServer.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: heshan Suriyaarachchi
+ * Date: Mar 25, 2008
+ * Time: 2:07:50 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class JPythonServer {
+ public static void main(String[] args) throws Exception{
+ ConfigurationContext configCtx = \
ConfigurationContextFactory.createConfigurationContextFromFileSystem("/home/heshan/rep \
o","/home/heshan/IdeaProjects/PythDeployer/src/org/wso2/wsf/jython/deployer/axis.xml");
+ SimpleHTTPServer server = new SimpleHTTPServer(configCtx ,8080);
+ server.start();
+ System.out.println(" simpleHTTP server started !");
+
+ }
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/PythonDeployer.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/PythonDeployer.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/PythonDeployer.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,384 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer;
+
+import org.apache.axis2.deployment.*;
+import org.apache.axis2.deployment.repository.util.DeploymentFileData;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.description.*;
+import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.python.core.PySystemState;
+import org.python.core.PyObject;
+import org.python.util.PythonInterpreter;
+
+import javax.xml.namespace.QName;
+import java.util.*;
+import java.io.*;
+
+import org.wso2.wsf.jython.messagereceiver.PythonScriptReceiver;
+import org.wso2.wsf.jython.deployer.schemagenarator.*;
+
+public class PythonDeployer implements Deployer {
+ private static final Log log = LogFactory.getLog(PythonDeployer.class);
+
+ private AxisConfiguration axisConfig;
+
+ protected Map schemaMap = new Hashtable();
+
+ private ConfigurationContext configCtx;
+
+
+ public void init(ConfigurationContext configCtx) {
+ this.configCtx = configCtx;
+ this.axisConfig = this.configCtx.getAxisConfiguration();
+ }
+
+
+ public void deploy(DeploymentFileData deploymentFileData) {
+ StringWriter errorWriter = new StringWriter();
+ String serviceStatus = "";
+ try {
+ String repoPath = \
deploymentFileData.getFile().getParentFile().getAbsolutePath(); + \
deploymentFileData.setClassLoader(axisConfig.getServiceClassLoader()); + \
AxisServiceGroup serviceGroup = new AxisServiceGroup(axisConfig); + \
serviceGroup.setServiceGroupClassLoader(deploymentFileData.getClassLoader()); + \
ArrayList serviceList = processService(deploymentFileData, serviceGroup, + \
configCtx, repoPath); + if (serviceList != null) {
+ DeploymentEngine.addServiceGroup(serviceGroup, serviceList, \
deploymentFileData + .getFile().toURL(), deploymentFileData, \
axisConfig); + \
log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_WS, deploymentFileData + \
.getName())); + }
+ } catch (DeploymentException de) {
+ de.printStackTrace();
+ log.error(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE, \
deploymentFileData + .getName(), de.getMessage()), de);
+ PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
+ de.printStackTrace(error_ptintWriter);
+ serviceStatus = "Error:\n" + errorWriter.toString();
+ } catch (AxisFault axisFault) {
+ log.error(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE, \
deploymentFileData + .getName(), axisFault.getMessage()), \
axisFault); + PrintWriter error_ptintWriter = new \
PrintWriter(errorWriter); + axisFault.printStackTrace(error_ptintWriter);
+ serviceStatus = "Error:\n" + errorWriter.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (log.isInfoEnabled()) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ e.printStackTrace(pw);
+ log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
+ deploymentFileData.getName(), sw.getBuffer().toString()));
+ }
+ PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
+ e.printStackTrace(error_ptintWriter);
+ serviceStatus = "Error:\n" + errorWriter.toString();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ if (log.isInfoEnabled()) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ log.info(Messages.getMessage(DeploymentErrorMsgs.INVALID_SERVICE,
+ deploymentFileData.getName(), sw.getBuffer().toString()));
+ }
+ PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
+ t.printStackTrace(error_ptintWriter);
+ serviceStatus = "Error:\n" + errorWriter.toString();
+ } finally {
+ if (serviceStatus.startsWith("Error:")) {
+ axisConfig.getFaultyServices().put(deploymentFileData.getFile().getAbsolutePath(),
+ serviceStatus);
+ }
+ }
+ }
+
+ public ArrayList processService(DeploymentFileData currentFile,
+ AxisServiceGroup axisServiceGroup, \
ConfigurationContext configCtx, String repoPath) + throws AxisFault {
+ try {
+ String shortFileName = \
DescriptionBuilder.getShortFileName(currentFile.getName()); + String \
serviceName = shortFileName; + \
axisServiceGroup.setServiceGroupName(currentFile.getName()); + AxisService \
axisService = null; + if (log.isDebugEnabled()) {
+ System.out.println(" Script Repo Path : " + repoPath);
+ log.debug(shortFileName + " python script is being processed !");
+ log.debug("shortFileName :" + shortFileName);
+ log.debug("currentFileName AbsolutePath :" + \
currentFile.getAbsolutePath()); + log.debug("currnetFileName \
:" + currentFile.getName()); + }
+ axisService = new AxisService();
+ Parameter servicePythonParameter = new Parameter("PythonScript", \
currentFile.getFile()); + \
axisService.addParameter(servicePythonParameter); + String targetNamespace \
= "http://services.mashup.wso2.org/" + serviceName; + \
axisService.setParent(axisServiceGroup); + \
axisService.setClassLoader(currentFile.getClassLoader()); + \
axisService.setName(serviceName); + \
axisService.setTargetNamespace(targetNamespace); +
+ // adding namespaces
+ NamespaceMap map2 = new NamespaceMap();
+ map2.put(Java2WSDLConstants.AXIS2_NAMESPACE_PREFIX, \
Java2WSDLConstants.AXIS2_XSD); + \
map2.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX, + \
Java2WSDLConstants.URI_2001_SCHEMA_XSD); + \
axisService.setNameSpacesMap(map2); +
+ String schemaTargetNamespace = "http://services.mashup.wso2.org/" + \
serviceName + "?xsd"; +
+ // setting up the schema
+ MyTypes types = new MyTypes();
+ SchemaGenerator schemaGenerator = new SchemaGenerator("http://foo.com", \
types); + XmlSchema schema = schemaGenerator.getSchema();
+ axisService.addSchema(schema);
+
+ QName paramElementQname = new QName(schemaTargetNamespace, \
"PythonParameter"); +
+ // setting the python.path variable progarmmatically
+ Properties props = new Properties();
+ String path = ":" + repoPath;
+ props.setProperty("python.path", path);
+ PythonInterpreter.initialize(System.getProperties(), props,
+ new String[]{""});
+ PySystemState.initialize();
+ PythonInterpreter interp = new PythonInterpreter();
+ interp.exec("import sys");
+ interp.exec("print sys.path");
+
+ InputStream inpStream = \
Thread.currentThread().getContextClassLoader().getResourceAsStream("Processor.py"); + \
interp.execfile(inpStream); +
+ String scriptName = "import " + shortFileName;
+ interp.exec(scriptName);
+ //interp.exec("import Processor");
+ String stt = "getDictionary(" + shortFileName + ")";
+ PyObject ob1 = interp.eval(stt);
+
+ String st2 = "dictToJavaMap(" + ob1 + ")";
+ PyObject ob2 = interp.eval(st2);
+ HashMap map = (HashMap) ob2.__tojava__(HashMap.class);
+
+ annotationsToSchema(map, axisService, schemaGenerator);
+ ArrayList serviceList = new ArrayList();
+ serviceList.add(axisService);
+ return serviceList;
+ } catch (Exception e) {
+ throw new DeploymentException(e);
+ }
+ }
+
+ /**
+ * Reads the annotations in the python script and maps the annotations to \
schema. Generates the xml schema for the + * python service
+ *
+ * @param map - The HashMap which contains the annotations of the \
python service + * @param axisService - The axis service
+ * @param schemaGenerator - The schema generator
+ */
+ private void annotationsToSchema(HashMap map, AxisService axisService, \
SchemaGenerator schemaGenerator) { + //HashMap map = (HashMap) \
obj2.__tojava__(HashMap.class); + Iterator k = map.keySet().iterator();
+ while (k.hasNext()) {
+ //['returns:double', 'operationName:double', 'double', ' \
MyClass.multiply', ' var1:integer', ' var2:integer'] + //{'operationName': \
'add','returns': 'int','var1': 'integer','var2': 'integer'} + String key = \
(String) k.next(); + if (log.isDebugEnabled()) {
+ log.debug("\nKey " + key + " === Value " + map.get(key));
+ }
+
+ String str = String.valueOf(map.get(key));
+ str = str.substring(1, str.length() - 1);
+ //create the schema for the deployed script
+ HashMap hmap = new HashMap();
+ String st[], stTemp[];
+ st = str.split(",");
+ if (log.isDebugEnabled()) {
+ log.debug("\n The methods in the python script is :");
+ }
+
+ for (int i = 0; i < st.length - 1; i++) {
+ if (log.isDebugEnabled()) {
+ log.debug("value " + i + " is " + st[i]);
+ }
+ stTemp = st[i].split("-");
+ stTemp[0] = stTemp[0].replaceAll("\"", "");
+ stTemp[1] = stTemp[1].replaceAll("\"", "");
+ hmap.put(stTemp[0].substring(2, stTemp[0].length()), \
stTemp[1].substring(0, stTemp[1].length() - 1)); + }
+ ComplexType inComplexType = new ComplexType();
+ ComplexType outComplexType = new ComplexType();
+ ComplexType innerInComplexType = new ComplexType();
+
+ String opName = "";
+ Iterator k3 = hmap.keySet().iterator();
+ while (k3.hasNext()) {
+ String key2 = (String) k3.next();
+ if (key2.equals("operationName")) {
+ opName = (String) hmap.get(key2);
+ inComplexType.setName((String) hmap.get(key2));
+ if (log.isDebugEnabled()) {
+ log.debug("\noperation name found = = = " + opName);
+ }
+ }
+ }
+
+ Iterator k2 = hmap.keySet().iterator();
+ while (k2.hasNext()) {
+ String key2 = (String) k2.next();
+ String value2 = (String) hmap.get(key2);
+ if (log.isDebugEnabled()) {
+ log.debug("\nKey2 " + key2 + " === Value " + value2);
+ }
+
+ String strTemp2[];
+ boolean isInnerComplex = false;
+
+ //Setting complex types within complex types
+ if (value2.contains("~")) {
+ if (log.isDebugEnabled()) {
+ log.debug("\n\n---------Start: an inner complex type \
--------------"); + log.debug(" Inner complex type name is \
--- " + key2); + }
+ isInnerComplex = true;
+ innerInComplexType.setName(key2);
+ /*innerInComplexType*/
+ //Key2 var3 === Value (a=string~b=integer)~
+ // Here key2 should be the name of the complex schema type \
element name + value2 = value2.replace("(", "");
+ value2 = value2.replace(")", "");
+ strTemp2 = value2.split("~");
+ for (int i = 0; i < strTemp2.length; i++) {
+ String complexItems[] = strTemp2[i].split("=");
+ // o contains the key
+ // 1 contains the value
+ SimpleType simpleType3 = new SimpleType();
+ simpleType3.setName(complexItems[0]);
+ simpleType3.setType(complexItems[1]);
+ if (log.isDebugEnabled()) {
+ log.debug(complexItems[0] + " --- " + \
complexItems[1]); + }
+ innerInComplexType.addMember(simpleType3);
+ }
+
+ inComplexType.addMember(innerInComplexType);
+ if (log.isDebugEnabled()) {
+ log.debug("---------End : an inner complex type \
--------------\n\n"); + }
+ continue;
+ }
+
+ if (key2.equals("operationName")) {
+ // there is a problem when we do like this should do another \
iterator to do so -- problem solved + } else if \
(key2.equals("eturns")) { + outComplexType.setName(opName + " \
response "); + SimpleType simpleType = new SimpleType(); // \
return name == method response + simpleType.setName("returns");
+ simpleType.setType(value2);
+
+ outComplexType.addMember(simpleType);
+ //outComplexType.setName((String)hmap.get(key2));
+ } else {
+ SimpleType simpleType2 = new SimpleType();
+ simpleType2.setName(key2);
+ simpleType2.setType(value2);
+
+ inComplexType.addMember(simpleType2);
+ }
+ }
+
+ XmlSchemaElement inSchemaElement = null;
+ XmlSchemaElement outSchemaElement = null;
+ try {
+ inSchemaElement = schemaGenerator.createInputElement(inComplexType, \
opName); + outSchemaElement = \
schemaGenerator.createOutputElement(outComplexType, opName); + } catch \
(Exception e) { + e.printStackTrace(); //To change body of catch \
statement use File | Settings | File Templates. + }
+ QName inParamElementQname = inSchemaElement.getQName(); // set this to \
the QName of the in message + QName outParamElementQname = \
outSchemaElement.getQName(); +
+ try {
+ processOperation(axisService, inParamElementQname, \
outParamElementQname, opName); + } catch (AxisFault axisFault) {
+ //throw new AxisFault(axisFault.getMessage());
+ axisFault.printStackTrace(); //To change body of catch statement \
use File | Settings | File Templates. + }
+ }
+ }
+
+
+ private void processOperation(AxisService axisService, QName \
inParamElementQname, QName outParamElementQname, String method) throws AxisFault { + \
AxisOperation axisOp = new InOutAxisOperation(new QName(method)); + \
axisOp.setMessageReceiver(new PythonScriptReceiver()); + \
axisOp.setStyle(WSDLConstants.STYLE_DOC); + Parameter parameter = new \
Parameter(); + parameter.setName("OPERATION_NAME");
+ parameter.setValue(method);
+ axisOp.addParameter(parameter);
+ axisService.addOperation(axisOp);
+
+ AxisMessage inMessage = axisOp
+ .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ if (inMessage != null) {
+ // create the complex type & create a QName out of it and set it to the \
setElementQName of in message + inMessage.setName(method + \
Java2WSDLConstants.MESSAGE_SUFFIX); + \
inMessage.setElementQName(inParamElementQname); + }
+ AxisMessage outMessage = axisOp
+ .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+
+ if (outMessage != null) {
+ outMessage.setName(method + Java2WSDLConstants.MESSAGE_SUFFIX);
+ outMessage.setElementQName(outParamElementQname);
+ }
+ if (axisOp.getInputAction() == null) {
+ axisOp.setSoapAction("urn:" + method);
+ }
+ axisConfig.getPhasesInfo().setOperationPhases(axisOp);
+ }
+
+ public void unDeploy(String fileName) {
+ try {
+ axisConfig.removeServiceGroup(fileName);
+ log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED, \
fileName)); + } catch (AxisFault axisFault) {
+ // May be a faulty service
+ axisConfig.removeFaultyService(fileName);
+ }
+ }
+
+ public void setDirectory(String s) {
+
+ }
+
+ public void setExtension(String s) {
+
+ }
+
+
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/ComplexType.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/ComplexType.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/ComplexType.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,32 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer.schemagenarator;
+
+import java.util.ArrayList;
+
+public class ComplexType extends Type{
+
+ private ArrayList members = new ArrayList();
+
+ public ArrayList getMembers() {
+ return members;
+ }
+
+ public void addMember(Type type) {
+ members.add(type);
+ }
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/MyTypes.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/MyTypes.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/MyTypes.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,86 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer.schemagenarator;
+
+import org.apache.ws.commons.schema.constants.Constants;
+
+public class MyTypes extends TypeTable{
+ protected void populateSimpleTypes() {
+ simpleTypetoxsd.put("xs:string", Constants.XSD_STRING);
+ simpleTypetoxsd.put("xs:normalizedString", Constants.XSD_NORMALIZEDSTRING);
+ simpleTypetoxsd.put("xs:token", Constants.XSD_TOKEN);
+ simpleTypetoxsd.put("xs:language", Constants.XSD_LANGUAGE);
+ simpleTypetoxsd.put("xs:Name", Constants.XSD_NAME);
+ simpleTypetoxsd.put("xs:NCName", Constants.XSD_NCNAME);
+ simpleTypetoxsd.put("xs:NOTATION", Constants.XSD_NOTATION);
+ simpleTypetoxsd.put("xs:anyURI", Constants.XSD_ANYURI);
+ simpleTypetoxsd.put("xs:float", Constants.XSD_FLOAT);
+ simpleTypetoxsd.put("xs:double", Constants.XSD_DOUBLE);
+ simpleTypetoxsd.put("xs:duration", Constants.XSD_DURATION);
+ simpleTypetoxsd.put("xs:integer", Constants.XSD_INTEGER);
+ simpleTypetoxsd.put("xs:nonPositiveInteger", \
Constants.XSD_NONPOSITIVEINTEGER); + simpleTypetoxsd.put("xs:negativeInteger", \
Constants.XSD_NEGATIVEINTEGER); + simpleTypetoxsd.put("xs:long", \
Constants.XSD_LONG); + simpleTypetoxsd.put("xs:int", Constants.XSD_INT);
+ simpleTypetoxsd.put("xs:short", Constants.XSD_SHORT);
+ simpleTypetoxsd.put("xs:byte", Constants.XSD_BYTE);
+ simpleTypetoxsd.put("xs:nonNegativeInteger", \
Constants.XSD_NONNEGATIVEINTEGER); + simpleTypetoxsd.put("xs:unsignedLong", \
Constants.XSD_UNSIGNEDLONG); + simpleTypetoxsd.put("xs:unsignedInt", \
Constants.XSD_UNSIGNEDINT); + simpleTypetoxsd.put("xs:unsignedShort", \
Constants.XSD_UNSIGNEDSHORT); + simpleTypetoxsd.put("xs:unsignedByte", \
Constants.XSD_UNSIGNEDBYTE); + simpleTypetoxsd.put("xs:positiveInteger", \
Constants.XSD_POSITIVEINTEGER); + simpleTypetoxsd.put("xs:decimal", \
Constants.XSD_DECIMAL); + simpleTypetoxsd.put("xs:boolean", \
Constants.XSD_BOOLEAN); + simpleTypetoxsd.put("xs:dateTime", \
Constants.XSD_DATETIME); + simpleTypetoxsd.put("xs:date", Constants.XSD_DATE);
+ simpleTypetoxsd.put("xs:time", Constants.XSD_TIME);
+ simpleTypetoxsd.put("xs:gYearMonth", Constants.XSD_YEARMONTH);
+ simpleTypetoxsd.put("xs:gMonthDay", Constants.XSD_MONTHDAY);
+ simpleTypetoxsd.put("xs:gYear", Constants.XSD_YEAR);
+ simpleTypetoxsd.put("xs:gDay", Constants.XSD_DAY);
+ simpleTypetoxsd.put("xs:gMonth", Constants.XSD_MONTH);
+ simpleTypetoxsd.put("xs:QName", Constants.XSD_QNAME);
+ simpleTypetoxsd.put("xs:hexBinary", Constants.XSD_HEXBIN);
+ simpleTypetoxsd.put("xs:base64Binary", Constants.XSD_BASE64);
+ simpleTypetoxsd.put("xs:anyType", Constants.XSD_ANYTYPE);
+
+ // Support for python data types
+ simpleTypetoxsd.put("int", Constants.XSD_INT);
+ simpleTypetoxsd.put("integer", Constants.XSD_INT);
+ simpleTypetoxsd.put("Integer", Constants.XSD_INT);
+ simpleTypetoxsd.put("long", Constants.XSD_LONG);
+ simpleTypetoxsd.put("Long", Constants.XSD_LONG);
+ simpleTypetoxsd.put("double", Constants.XSD_DOUBLE);
+ simpleTypetoxsd.put("Double", Constants.XSD_DOUBLE);
+ simpleTypetoxsd.put("complex", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("Complex", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("string", Constants.XSD_STRING);
+ simpleTypetoxsd.put("String", Constants.XSD_STRING);
+ simpleTypetoxsd.put("dictionary", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("dict", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("Dictionary", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("Dict", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("tuple", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("Tuple", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("list", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("List", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("array", Constants.XSD_ANYTYPE);
+ simpleTypetoxsd.put("Array", Constants.XSD_ANYTYPE);
+
+ }
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SchemaGenerator.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,196 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer.schemagenarator;
+
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+import org.apache.ws.commons.schema.XmlSchemaForm;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+public class SchemaGenerator {
+
+ private String schemaTargetNamespace;
+
+ private String prefix = "ws";
+
+ private XmlSchema xmlSchema;
+
+ private String TYPE = "Type";
+
+ private TypeTable typeTable;
+
+ private String DEFAULT_SCHEMA_NAMESPACE_PREFIX = "xs";
+ private String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+ private String RESPONSE = "Response";
+
+ public NamespaceMap getNamespaceMap() {
+ return nameSpacesMap;
+ }
+
+ private NamespaceMap nameSpacesMap = new NamespaceMap();
+
+ public SchemaGenerator(String schemaTargetNamespace, TypeTable typeTable) {
+ this.schemaTargetNamespace = schemaTargetNamespace;
+ this.typeTable = typeTable;
+ XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
+ xmlSchema = new XmlSchema(this.schemaTargetNamespace, xmlSchemaCollection);
+ xmlSchema.setAttributeFormDefault(new \
XmlSchemaForm(XmlSchemaForm.UNQUALIFIED)); + \
xmlSchema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED)); +
+ nameSpacesMap.put(DEFAULT_SCHEMA_NAMESPACE_PREFIX,
+ URI_2001_SCHEMA_XSD);
+ nameSpacesMap.put(prefix, this.schemaTargetNamespace);
+ xmlSchema.setNamespaceContext(nameSpacesMap);
+ }
+
+ public XmlSchema getSchema() {
+ return xmlSchema;
+ }
+
+ public XmlSchemaElement createInputElement(Type input, String functionName) \
throws Exception { + return createElement(input, functionName);
+ }
+
+ public XmlSchemaElement createOutputElement(Type output, String functionName) \
throws Exception { + return createElement(output, functionName + RESPONSE);
+ }
+
+ private XmlSchemaElement handleComplexType(ComplexType complexType, String \
functionName) + throws Exception {
+ XmlSchemaElement xmlSchemaElement;
+ XmlSchemaComplexType xmlSchemaComplexType =
+ createComplexType(complexType, functionName + TYPE);
+ if (complexType == null) {
+ return null;
+ }
+ xmlSchemaElement = createXMLSchemaElement(functionName, functionName + \
TYPE); + xmlSchemaElement.setSchemaType(xmlSchemaComplexType);
+ xmlSchemaElement.setQName(new QName(schemaTargetNamespace, functionName));
+ return xmlSchemaElement;
+ }
+
+ private XmlSchemaElement createElement(Type param, String functionName) throws \
Exception { + XmlSchemaElement xmlSchemaElement = null;
+ if (param instanceof ComplexType) {
+ ComplexType complexType = (ComplexType) param;
+ xmlSchemaElement =
+ handleComplexType(complexType, functionName);
+ } else if (param instanceof SimpleType) {
+ ComplexType complexType = new ComplexType();
+ complexType.addMember(param);
+ complexType.setName(functionName);
+ xmlSchemaElement =
+ handleComplexType(complexType, functionName);
+ }
+ if (xmlSchemaElement == null) {
+ return null;
+ }
+ QName element =
+ new QName(this.schemaTargetNamespace, functionName, this.prefix);
+ xmlSchema.getItems().add(xmlSchemaElement);
+ xmlSchema.getElements().add(element, xmlSchemaElement);
+ return xmlSchemaElement;
+ }
+
+ private XmlSchemaComplexType createComplexType(ComplexType complexType, String \
elementName) + throws Exception {
+ QName element =
+ new QName(this.schemaTargetNamespace, elementName, this.prefix);
+ XmlSchemaComplexType xmlSchemaComplexType = new \
XmlSchemaComplexType(xmlSchema); + xmlSchemaComplexType.setName(elementName);
+ xmlSchema.getItems().add(xmlSchemaComplexType);
+
+ XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
+ Iterator iterator = complexType.getMembers().iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ XmlSchemaElement xmlSchemaElement;
+ if (object instanceof SimpleType) {
+ SimpleType simpleType = (SimpleType) object;
+ if ((xmlSchemaElement = createXMLSchemaElement(simpleType.getName(), \
simpleType.getType())) != null) { + \
xmlSchemaSequence.getItems().add(xmlSchemaElement); + }
+ } else if (object instanceof ComplexType) {
+ ComplexType complexTypeParam = (ComplexType) object;
+ if ((xmlSchemaElement = handleComplexType(complexTypeParam, \
elementName + + complexTypeParam.getName() + TYPE)) != null) {
+ xmlSchemaElement.setName(complexTypeParam.getName());
+ xmlSchemaSequence.getItems().add(xmlSchemaElement);
+ }
+ }
+ }
+ xmlSchemaComplexType.setParticle(xmlSchemaSequence);
+ typeTable.addComplexSchema(elementName, element);
+ return xmlSchemaComplexType;
+ }
+
+ private XmlSchemaElement createXMLSchemaElement(String name, String paramType) \
throws + Exception {
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ xmlSchemaElement.setName(name);
+ QName qName = typeTable.getQNamefortheType(paramType);
+ if (qName == null) {
+ throw new Exception(
+ "No matching schematype could be found for the type : " + \
paramType); + }
+ xmlSchemaElement.setSchemaTypeName(qName);
+ return xmlSchemaElement;
+ }
+
+ public String getSchemaTargetNamespace() {
+ return schemaTargetNamespace;
+ }
+
+ /**
+ * If the inputType annotations match the pattern of enumeration create the \
appropriate schema element to handle + * that.
+ *
+ * @param name - The name of the parameter
+ * @param enums - Array of enumeration values
+ * @return XmlSchemaSimpleType - An XmlSchemaSimpleType which has a restriction \
and the enumaration. + */
+ private XmlSchemaSimpleType handleEnumeration(String name, String[] enums) {
+ XmlSchemaSimpleTypeRestriction simpleTypeRestriction = new \
XmlSchemaSimpleTypeRestriction(); + // Set the base type to string. 95% of the \
time enumerations are strings so use it. + \
simpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING); + \
XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema); + \
simpleType.setName(name); + simpleType.setContent(simpleTypeRestriction);
+
+ // Create enumeration facets for each value
+ for (int i = 0; i < enums.length; i++) {
+
+ String enumeration = enums[i].trim();
+ XmlSchemaEnumerationFacet enumerationFacet = new \
XmlSchemaEnumerationFacet(); + enumerationFacet.setValue(enumeration);
+ simpleTypeRestriction.getFacets().add(enumerationFacet);
+ }
+
+ return simpleType;
+ }
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SimpleType.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SimpleType.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/SimpleType.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,30 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer.schemagenarator;
+
+public class SimpleType extends Type{
+
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TestSchemaGenClass.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TestSchemaGenClass.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TestSchemaGenClass.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer.schemagenarator;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+
+public class TestSchemaGenClass {
+
+ public static void main(String[] args) throws Exception {
+ MyTypes types = new MyTypes();
+ SchemaGenerator schemaGenerator = new SchemaGenerator("http://foo.com", \
types); + ComplexType complexType= new ComplexType();
+ complexType.setName("Test"); // method name
+ SimpleType simpleType = new SimpleType();
+ simpleType.setName("simple1");
+ simpleType.setType("string");
+ SimpleType simpleType2 = new SimpleType();
+ simpleType2.setName("simple2");
+ simpleType2.setType("string");
+ SimpleType simpleType3 = new SimpleType();
+ simpleType3.setName("simple3");
+ simpleType3.setType("string");
+
+ complexType.addMember(simpleType);
+ complexType.addMember(simpleType2);
+ complexType.addMember(simpleType3);
+
+// ComplexType complexType2= new ComplexType();
+// complexType2.setName("InnerType");
+// SimpleType simpleType4 = new SimpleType();
+// simpleType4.setName("simple4");
+// simpleType4.setType("string");
+//
+// complexType2.addMember(simpleType4);
+// complexType.addMember(complexType2);
+//
+// SimpleType simpleType5 = new SimpleType();
+// simpleType5.setName("simple5");
+// simpleType5.setType("string");
+
+// complexType.addMember(simpleType5);
+ XmlSchemaElement schemaElement = \
schemaGenerator.createInputElement(complexType, "Test"); + \
schemaElement.getQName(); // set this to the QName of the in message + \
XmlSchema schema = schemaGenerator.getSchema(); + System.out.println("");
+ }
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/Type.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/Type.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/Type.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,30 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer.schemagenarator;
+
+public class Type {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/deployer/schemagenarator/TypeTable.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,79 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.deployer.schemagenarator;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+
+public abstract class
+ TypeTable {
+
+ protected HashMap simpleTypetoxsd;
+ protected HashMap complexTypeMap;
+
+ public TypeTable() {
+ simpleTypetoxsd = new HashMap();
+ complexTypeMap = new HashMap();
+ populateSimpleTypes();
+ }
+
+ protected abstract void populateSimpleTypes();
+
+ /**
+ * Retuns the QNAme of the simple type given its name
+ *
+ * @param typeName - The type given in the annotation
+ * @return -QName Representing the annotation type as a xs Type
+ */
+ public QName getSimpleSchemaTypeName(String typeName) {
+ return (QName) simpleTypetoxsd.get(typeName);
+ }
+
+ /**
+ * Adds a complex type to the complexTypeMap
+ *
+ * @param name - The name of the complex type
+ * @param schemaType - The schema Type of the complexType
+ */
+ public void addComplexSchema(String name, QName schemaType) {
+ complexTypeMap.put(name, schemaType);
+ }
+
+ /**
+ * Retuns the QNAme of the complex type given its name
+ *
+ * @param name - The name of the complexType
+ * @return - The QName of the cmplexType
+ */
+ public QName getComplexSchemaType(String name) {
+ return (QName) complexTypeMap.get(name);
+ }
+
+ /**
+ * Given an annotation type returns the corresponding xs type
+ *
+ * @param typeName - The type given in the annotation
+ * @return -QName Representing the annotation type as a xs Type
+ */
+ public QName getQNamefortheType(String typeName) {
+ QName type = getSimpleSchemaTypeName(typeName);
+ if (type == null) {
+ type = getComplexSchemaType(typeName);
+ }
+ return type;
+ }
+}
\ No newline at end of file
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PyToOMConverter.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PyToOMConverter.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PyToOMConverter.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,114 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.messagereceiver;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+import org.apache.axis2.databinding.types.NonPositiveInteger;
+import org.apache.axis2.databinding.types.NonNegativeInteger;
+import org.apache.axis2.databinding.types.PositiveInteger;
+import org.apache.axis2.databinding.types.NegativeInteger;
+import org.python.core.PyInteger;
+
+public class PyToOMConverter {
+
+ public static String convertToString(Object pyObject) {
+ return pyObject.toString();
+ }
+
+ public static String convertToFloat(Object pyObject) throws AxisFault {
+ try {
+ Float floatObject = (Float) pyObject;
+ return ConverterUtil.convertToString(floatObject);
+ } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to float");
+ }
+ }
+
+ public static String convertToInteger(Object pyObject) throws AxisFault {
+ try {
+ Integer integer = (Integer) pyObject;
+ return ConverterUtil.convertToString(integer);
+ } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to integer");
+ }
+ }
+
+ public static String convertToInt(Object pyObject) throws AxisFault {
+ try {
+ Integer integer;
+ if (pyObject instanceof PyInteger) {
+ integer = (Integer) ((PyInteger)pyObject).__tojava__(Integer.class);
+ } else {
+ integer = (Integer) pyObject;
+ }
+ return ConverterUtil.convertToString(integer);
+ } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to int");
+ }
+ }
+
+ public static String convertToNonPositiveInteger(Object pyObject) throws \
AxisFault { + try {
+ NonPositiveInteger integer =
+ ConverterUtil.convertToNonPositiveInteger(pyObject.toString());
+ return integer.toString();
+ } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to non positive \
integer"); + }
+ }
+
+ public static String convertToNonNegativeInteger(Object pyObject) throws \
AxisFault { + try {
+ NonNegativeInteger integer =
+ ConverterUtil.convertToNonNegativeInteger(pyObject.toString());
+ return integer.toString();
+ } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to non negative \
integer"); + }
+ }
+
+ public static String convertToPositiveInteger(Object pyObject) throws AxisFault \
{ + try {
+ PositiveInteger integer = \
ConverterUtil.convertToPositiveInteger(pyObject.toString()); + return \
integer.toString(); + } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to positive \
integer"); + }
+ }
+
+ public static String convertToNegativeInteger(Object pyObject) throws AxisFault \
{ + try {
+ NegativeInteger integer = \
ConverterUtil.convertToNegativeInteger(pyObject.toString()); + return \
integer.toString(); + } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to negative \
integer"); + }
+ }
+
+ public static String convertToLong(Object pyObject) throws AxisFault {
+ try {
+ Long longvalue = (Long) pyObject;
+ return ConverterUtil.convertToString(longvalue);
+ } catch (Exception e) {
+ throw new AxisFault("Unable to convert the return value to long");
+ }
+ }
+
+ //public static String convertToDictionary
+
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngine.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngine.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngine.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,84 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.messagereceiver;
+
+import org.python.core.PySystemState;
+import org.python.core.PyObject;
+import org.python.util.PythonInterpreter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class PythonScriptEngine {
+ private static final Log log = LogFactory.getLog(PythonScriptEngine.class);
+
+ /**
+ * Takes the path of the python script, method name and method arguments and \
executes the given method and + * returns the result
+ *
+ * @param method
+ * @param reader
+ * @param args
+ * @return String
+ */
+ public static Object invoke(String method, String reader, Object args[]) {
+ PySystemState.initialize();
+ PythonInterpreter interp = new PythonInterpreter();
+ String fileName = reader;
+ //String fileName = "/home/heshan/workspace/Axis2Service \
ver2/src/messagereceiver/filepy.py"; + interp.execfile(fileName);
+
+ String str = "";
+ int len = args.length;
+ for (int i = 0; i < len; i++) {
+ if (i == len - 1) {
+ str = str + args[i];
+ } else {
+ str = str + args[i] + ",";
+ }
+ }
+ //PyFloat, PyInteger, PyLong , PyString, PyList, PyDictionary, PyTuple, \
PyArray, PyComplex, + String s4 = "" + method + "(" + str + ")";
+ if (log.isDebugEnabled()) {
+ log.debug("String to be evaluated -->" + s4);
+ }
+ PyObject retObj = interp.eval(s4);
+ return retObj;
+ }
+
+
+ public static boolean isNull(Object object) {
+ System.out.println(object == null);
+ return object == null;
+ }
+
+
+ /* public void execute() {
+ PySystemState.initialize();
+ PythonInterpreter interp = new PythonInterpreter();
+ //interp.exec("import sys");
+ //interp.exec("print sys");
+ String str2 = "filepy.py";
+ interp.execfile(str2);
+ PyObject x = interp.get("d");
+ System.out.println("d: original value " + x);
+ int s1 = 45, s2 = 45;
+ String s3 = "addNumbers(" + s1 + "," + s2 + ")";
+ PyObject y = interp.eval(s3);
+ }
+*/
+
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngineConstants.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngineConstants.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptEngineConstants.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,25 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.messagereceiver;
+
+public interface PythonScriptEngineConstants {
+
+ public static final String ANNOTATED = "Annotated";
+
+ public static final String PYTHON_SCRIPT = "PythonScript";
+
+}
Added: trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptReceiver.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptReceiver.java?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/java/org/wso2/wsf/jython/messagereceiver/PythonScriptReceiver.java Sun \
Oct 4 22:58:22 2009 @@ -0,0 +1,846 @@
+/*
+ * Copyright 2008 WSO2, Inc. http://www.wso2.org
+ *
+ * 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.
+ */
+
+package org.wso2.wsf.jython.messagereceiver;
+
+import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+import org.apache.axis2.databinding.types.*;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.AxisMessage;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axiom.soap.*;
+import org.apache.axiom.om.*;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.ws.commons.schema.*;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.namespace.QName;
+import java.io.*;
+import java.util.*;
+
+import org.python.core.*;
+
+public class PythonScriptReceiver extends AbstractInOutMessageReceiver implements \
MessageReceiver { + private static final Log log = \
LogFactory.getLog(PythonScriptReceiver.class); +
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext \
outMessage) throws AxisFault { + SOAPEnvelope soapEnvelope = \
inMessage.getEnvelope(); + try {
+ String pMethod = null;
+ String pArgs = null;
+ try {
+ pMethod = getPythonMethod(inMessage);
+ pArgs = getArgs(inMessage);
+ } catch (XMLStreamException e) {
+ throw new AxisFault(e.getMessage());
+ }
+ String pReader = readPythonScript(inMessage);
+
+ if (pReader == null) {
+ throw new AxisFault("Unable to load Python file");
+ }
+ if (pMethod == null) {
+ throw new AxisFault("Unable to read the method");
+ }
+
+ OMElement payload = soapEnvelope.getBody().getFirstElement();
+ Object args = payload;
+ if (payload != null) {
+ // We neet to get the Axis Message from the incomming message so \
that we can get its schema. + // We need the schema in order to unwrap \
the parameters. + AxisMessage axisMessage = \
inMessage.getAxisOperation().getMessage( + \
WSDLConstants.MESSAGE_LABEL_IN_VALUE); + XmlSchemaElement \
xmlSchemaElement = axisMessage.getSchemaElement(); + if \
(xmlSchemaElement != null) { + // Once the schema is obtained we \
iterate through the schema looking for the elemants in the payload. + \
// for Each element we extract its value and create a parameter which can be passed \
into the + // pythonscript function.
+ XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
+ if (schemaType instanceof XmlSchemaComplexType) {
+ XmlSchemaComplexType complexType = ((XmlSchemaComplexType) \
schemaType); + List<Object> params = \
handleComplexTypeInRequest(complexType, payload, new ArrayList<String>()); + \
args = params.toArray(); + } else if \
(xmlSchemaElement.getSchemaTypeName() == Constants.XSD_ANYTYPE) { + \
args = payload; + }
+ }
+ } else {
+ // This validates whether the user has sent a bad SOAP message
+ // with a non-XML payload.
+ if (soapEnvelope.getBody().getFirstOMChild() != null) {
+ OMText textPayLoad = (OMText) \
soapEnvelope.getBody().getFirstOMChild(); + //we allow only a \
sequence of spaces + if (textPayLoad.getText().trim().length() > \
0) { + throw new AxisFault(
+ "Non-XML payload is not allowed. PayLoad inside the \
SOAP body needs to be an XML element."); + }
+ }
+ }
+
+ //Setting up the out message
+ AxisMessage outAxisMessage = inMessage.getAxisOperation().getMessage(
+ WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ boolean annotated = false;
+ Parameter parameter = \
outAxisMessage.getParameter(PythonScriptEngineConstants.ANNOTATED); + if \
(parameter != null) { + annotated = (Boolean) parameter.getValue();
+ }
+ // ------------ annotated = true is done for a test . delete it after \
the proj is finished! + annotated = true;
+
+ Object response = PythonScriptEngine.invoke(pMethod, pReader, \
(java.lang.Object[]) (args)); + if (log.isDebugEnabled()) {
+ log.debug("object returned from jython : " + response);
+ }
+
+ // Create the outgoing message
+ SOAPFactory fac;
+ if (inMessage.isSOAP11()) {
+ fac = OMAbstractFactory.getSOAP11Factory();
+ } else {
+ fac = OMAbstractFactory.getSOAP12Factory();
+ }
+ SOAPEnvelope envelope = fac.getDefaultEnvelope();
+ SOAPBody body = envelope.getBody();
+ XmlSchemaElement xmlSchemaElement = outAxisMessage.getSchemaElement();
+ OMElement outElement;
+ String prefix = "ws";
+ if (xmlSchemaElement != null) {
+ QName elementQName = xmlSchemaElement.getSchemaTypeName();
+ OMNamespace namespace = \
fac.createOMNamespace(elementQName.getNamespaceURI(), + \
prefix); + outElement = \
fac.createOMElement(xmlSchemaElement.getName(), namespace); + \
XmlSchemaType schemaType = xmlSchemaElement.getSchemaType(); + if \
(schemaType instanceof XmlSchemaComplexType) { + \
XmlSchemaComplexType complexType = ((XmlSchemaComplexType) schemaType); + \
handleComplexTypeInResponse(complexType, outElement, response, fac, + \
false); + body.addChild(outElement);
+ } else if (xmlSchemaElement.getSchemaTypeName() == \
Constants.XSD_ANYTYPE) { + if \
(!PythonScriptEngine.isNull(response)) { + // If its anyType \
that means we have to add xsi:type + OMElement element = \
buildResponse(false, response, + xmlSchemaElement);
+ if (element != null) {
+ body.addChild(element);
+ }
+ }
+ }
+ } else if (!PythonScriptEngine.isNull(response)) {
+ OMElement element =
+ buildResponse(annotated, response, xmlSchemaElement);
+ if (log.isDebugEnabled()) {
+ log.debug("The built element is " + element.toString());
+ }
+ if (element != null) {
+ body.addChild(element);
+ }
+ }
+ outMessage.setEnvelope(envelope);
+ } catch (Throwable throwable) {
+ AxisFault fault = AxisFault.makeFault(throwable);
+ // This is a workaround to avoid Axis2 sending the SOAPFault with a
+ // http-400 code when sending using SOAP1. We explicitly set the
+ // FualtCode to 'Receiver'.
+ fault.setFaultCode(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapEnvelope.getNamespace().getNamespaceURI())
+ ? SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":" + \
SOAP12Constants + .FAULT_CODE_RECEIVER
+ : SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":" + \
SOAP11Constants + .FAULT_CODE_RECEIVER);
+ throw fault;
+ }
+
+ }
+
+ /**
+ * @param str The string to embed in the OMElement
+ * @return an OMElement
+ * @throws javax.xml.stream.XMLStreamException
+ *
+ */
+ private OMElement getpayLoad(String str) throws XMLStreamException {
+ XMLStreamReader xmlReader =
+ XMLInputFactory.newInstance().createXMLStreamReader(
+ new ByteArrayInputStream(str.getBytes()));
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ StAXOMBuilder staxOMBuilder =
+ new StAXOMBuilder(fac, xmlReader);
+ return staxOMBuilder.getDocumentElement();
+ }
+
+ /**
+ * @param inMessage
+ * @return the pythonscript message to invoke
+ * @throws AxisFault
+ * @throws XMLStreamException
+ */
+ public String getPythonMethod(MessageContext inMessage) throws AxisFault, \
XMLStreamException { + //Look at the method name. if available this should be \
a pythonscript method + AxisOperation op = \
inMessage.getOperationContext().getAxisOperation(); + if (op == null) {
+ throw new AxisFault(Messages.getMessage("notFound", "Operation"));
+ }
+ return op.getName().getLocalPart();
+ }
+
+ /**
+ * @param inMessage
+ * @return the pythonscript source file
+ * @throws AxisFault
+ */
+ public String readPythonScript(MessageContext inMessage) throws AxisFault {
+ AxisService service = inMessage.getAxisService();
+ Parameter implInfoParam = \
service.getParameter(PythonScriptEngineConstants.PYTHON_SCRIPT); +
+// HERE I am changing the code to suit my sample--------------------------------
+// Parameter implInfoParam = service.getParameter("ServiceScript");
+ if (implInfoParam == null) {
+ throw new AxisFault(Messages.getMessage("Parameter is not specified", \
PythonScriptEngineConstants.PYTHON_SCRIPT)); + }
+ //InputStream jsFileStream = \
service.getClassLoader().getResourceAsStream(implInfoParam.getValue().toString()); + \
String fileName = implInfoParam.getValue().toString(); +
+ if (fileName == null) {
+ throw new AxisFault(Messages.getMessage("PythonScriptUnableToLoad", \
implInfoParam.getValue().toString())); + }
+ return fileName;
+ }
+
+ /**
+ * Locates the service pythonscript file associated with ServiceJS parameter and \
returns + * a Reader for it.
+ *
+ * @param inMessage MessageContext object with information about the incoming \
message + * @return an input stream to the pythonscript source file
+ * @throws AxisFault if the parameter ServiceJS is not specified or if the \
service + * implementation is not available
+ */
+ private Reader readJS(MessageContext inMessage) throws AxisFault {
+ InputStream jsFileStream;
+ AxisService service = inMessage.getServiceContext().getAxisService();
+ Parameter implInfoParam = service.getParameter("PythonScript");
+ if (implInfoParam == null) {
+ throw new AxisFault("Parameter 'PythonScript' not specified");
+ }
+ if (implInfoParam.getValue() instanceof File) {
+ try {
+ jsFileStream = new FileInputStream((File) \
(implInfoParam.getValue())); + } catch (FileNotFoundException e) {
+ throw new AxisFault("Unable to load the pythonscript, File not \
Found", e); + }
+ } else {
+ jsFileStream = service.getClassLoader().getResourceAsStream(
+ implInfoParam.getValue().toString());
+ }
+ if (jsFileStream == null) {
+ throw new AxisFault("Unable to load the pythonscript");
+ }
+ return new BufferedReader(new InputStreamReader(jsFileStream));
+ }
+
+ /**
+ * @param inMessage
+ * @return arguments to be sent to the pythonscript function
+ * @throws XMLStreamException
+ */
+ public String getArgs(MessageContext inMessage) throws XMLStreamException {
+
+ String args = inMessage.getEnvelope().getBody().getFirstElement().getText();
+ //String value = firstChild.toStringWithConsume();
+ if (args != null) {
+ return args;
+ }
+ return null;
+
+ }
+
+ private List<Object> handleComplexTypeInRequest(XmlSchemaComplexType \
complexType, OMElement payload, + \
List<String> paramNames) + throws AxisFault {
+ XmlSchemaParticle particle = complexType.getParticle();
+ List<Object> params = new ArrayList<Object>();
+ if (particle instanceof XmlSchemaSequence) {
+ XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) particle;
+ Iterator iterator = xmlSchemaSequence.getItems().getIterator();
+ // now we need to know some information from the
+ // binding operation.
+ while (iterator.hasNext()) {
+ XmlSchemaElement innerElement = (XmlSchemaElement) iterator.next();
+ XmlSchemaType schemaType = innerElement.getSchemaType();
+ if (schemaType instanceof XmlSchemaComplexType) {
+ String innerElementName = innerElement.getName();
+ QName payloadQname = payload.getQName();
+ OMElement complexTypePayload = null;
+ QName qName;
+ // When retrieving elements we have to look for the namespace \
too. There may be + // Ocations even when the children are \
namespace qualified. In such situations + // we should retrieve \
them using that namespace. + // If that fails we try using the \
localname only. + if (payloadQname != null) {
+ qName = new QName(payloadQname.getNamespaceURI(),
+ innerElementName);
+ complexTypePayload = payload.getFirstChildWithName(qName);
+ }
+ if (complexTypePayload == null) {
+ qName = new QName(innerElementName);
+ complexTypePayload = payload.getFirstChildWithName(qName);
+ }
+ if (complexTypePayload == null) {
+ throw new AxisFault(
+ "Required element " + complexType.getName()
+ + " defined in the schema can not be found \
in the request"); + }
+ List<String> innerParamNames = new ArrayList<String>();
+ List<Object> innerParams = \
handleComplexTypeInRequest((XmlSchemaComplexType) schemaType, + \
complexTypePayload, + innerParamNames);
+ } else if (schemaType instanceof XmlSchemaSimpleType) {
+ // Handle enumerations in here.
+ XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) \
schemaType; + XmlSchemaSimpleTypeContent content = \
xmlSchemaSimpleType.getContent(); + if (content instanceof \
XmlSchemaSimpleTypeRestriction) { + // TODO: This feature will \
also be implemented in the future +
+ } else {
+ throw new AxisFault("Unsupported restriction in Schema");
+ }
+ } else {
+ params.add(handleSimpleTypeInRequest(payload, innerElement));
+ paramNames.add(innerElement.getName());
+ }
+ }
+ } else {
+ throw new AxisFault("Unsupported schema type in request");
+ }
+ return params;
+ }
+
+ private Object handleSimpleTypeInRequest(OMElement payload, XmlSchemaElement \
innerElement) throws AxisFault { + long maxOccurs = \
innerElement.getMaxOccurs(); + // Check whether the schema advertises this \
element as an array + if (maxOccurs > 1) {
+ // If its an array get all elements with that name and create a sinple \
parameter out of it + String innerElemenrName = innerElement.getName();
+ Iterator iterator1 = payload.getChildrenWithName(new QName(
+ innerElemenrName));
+ return handleArray(iterator1, innerElement.getSchemaTypeName());
+ } else {
+ return handleSimpleElement(payload, innerElement.getName(),
+ innerElement.getMinOccurs(),
+ innerElement.getSchemaTypeName());
+ }
+ }
+
+
+ /**
+ * Creates an array object that can be passed into a JS function
+ *
+ * @param iterator - Iterator to the omelements that belong to the array
+ * @param type - The schematype of the omelement
+ * //@param engine Reference to the pythonscript engine
+ * @return - An array Object that can be passed into a JS function
+ * @throws AxisFault - In case an exception occurs
+ */
+ private Object handleArray(Iterator iterator, QName type)
+ throws AxisFault {
+ ArrayList objectList = new ArrayList();
+ while (iterator.hasNext()) {
+ OMElement omElement = (OMElement) iterator.next();
+ objectList.add(createParam(omElement, type));
+ }
+ return objectList;
+ }
+
+
+ /**
+ * Creates an object that can be passed into a pythonscript function from an \
OMElement. + *
+ * @param omElement - The OMElement that the parameter should be created for
+ * @param type - The schemaType of the incoming message element
+ * //@param engine - Reference to the pythonscript engine
+ * @return - An Object that can be passed into a Py function
+ * @throws AxisFault - In case an exception occurs
+ */
+ private Object createParam(OMElement omElement, QName type)
+ throws AxisFault {
+ if (log.isDebugEnabled()) {
+ log.debug("QName type of the parameter : " + type.toString());
+ }
+
+ if (Constants.XSD_ANYTYPE.equals(type)) {
+
+ }
+ String value = omElement.getText();
+ if (value == null) {
+ throw new AxisFault(
+ "The value of Element " + omElement.getLocalName() + " cannot be \
null"); + }
+ if (Constants.XSD_BOOLEAN.equals(type)) {
+ try {
+ return ConverterUtil.convertToBoolean(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "boolean"));
+ }
+ }
+ if (Constants.XSD_DOUBLE.equals(type)) {
+ try {
+ return ConverterUtil.convertToDouble(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "double"));
+ }
+ }
+ if (Constants.XSD_FLOAT.equals(type)) {
+ try {
+ return ConverterUtil.convertToFloat(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "float"));
+ }
+ }
+ if (Constants.XSD_INT.equals(type)) {
+ try {
+ return ConverterUtil.convertToInt(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "int"));
+ }
+ }
+ if (Constants.XSD_INTEGER.equals(type)) {
+ try {
+ if ((value == null) || value.equals("")) {
+ return Integer.MIN_VALUE;
+ }
+ if (value.startsWith("+")) {
+ value = value.substring(1);
+ }
+ return new Integer(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "integer"));
+ }
+ }
+ if (Constants.XSD_POSITIVEINTEGER.equals(type)) {
+ try {
+ return ConverterUtil.convertToPositiveInteger(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "positive integer"));
+ }
+ }
+ if (Constants.XSD_NEGATIVEINTEGER.equals(type)) {
+ try {
+ return ConverterUtil.convertToNegativeInteger(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "negative integer"));
+ }
+ }
+ if (Constants.XSD_NONPOSITIVEINTEGER.equals(type)) {
+ try {
+ return ConverterUtil.convertToNonPositiveInteger(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "non-positive integer"));
+ }
+ }
+ if (Constants.XSD_NONNEGATIVEINTEGER.equals(type)) {
+ try {
+ return ConverterUtil.convertToNonNegativeInteger(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "non-negative integer"));
+ }
+ }
+ if (Constants.XSD_LONG.equals(type)) {
+ try {
+ return ConverterUtil.convertToLong(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "long"));
+ }
+ }
+ if (Constants.XSD_SHORT.equals(type)) {
+ try {
+ return ConverterUtil.convertToShort(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "short"));
+ }
+ }
+ if (Constants.XSD_BYTE.equals(type)) {
+ try {
+ return ConverterUtil.convertToByte(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "byte"));
+ }
+ }
+ if (Constants.XSD_UNSIGNEDINT.equals(type)) {
+ try {
+ return ConverterUtil.convertToUnsignedInt(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "unsigned int"));
+ }
+ }
+ if (Constants.XSD_UNSIGNEDLONG.equals(type)) {
+ try {
+ return ConverterUtil.convertToUnsignedLong(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "unsigned long"));
+ }
+ }
+ if (Constants.XSD_UNSIGNEDSHORT.equals(type)) {
+ try {
+ return ConverterUtil.convertToUnsignedShort(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "unsigned short"));
+ }
+ }
+ if (Constants.XSD_UNSIGNEDBYTE.equals(type)) {
+ try {
+ return ConverterUtil.convertToUnsignedByte(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "unsigned byte"));
+ }
+ }
+ if (Constants.XSD_DECIMAL.equals(type)) {
+ try {
+ return ConverterUtil.convertToDecimal(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "decimal"));
+ }
+ }
+ if (Constants.XSD_DURATION.equals(type)) {
+ try {
+ Duration duration = ConverterUtil.convertToDuration(value);
+ return duration.toString();
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "duration"));
+ }
+ }
+ if (Constants.XSD_QNAME.equals(type)) {
+
+ }
+ if (Constants.XSD_HEXBIN.equals(type)) {
+ try {
+ return ConverterUtil.convertToString(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "hexBinary"));
+ }
+ }
+ if (Constants.XSD_BASE64.equals(type)) {
+ try {
+ return ConverterUtil.convertToString(value);
+ } catch (Exception e) {
+ throw new AxisFault(getFaultString(value, "base64Binary"));
+ }
+ }
+ return omElement.getText();
+ }
+
+
+ private String getFaultString(String value, String type) {
+ return "Unable to convert value \"" + value + "\" to " + type;
+ }
+
+
+ private boolean checkRequired(XmlSchemaElement innerElement, Object object) \
throws AxisFault { + if (PythonScriptEngine.isNull(object)) {
+ if (innerElement.getSchemaTypeName() == Constants.XSD_ANYTYPE ||
+ innerElement.getMinOccurs() == 0) {
+ return true;
+ }
+ throw new AxisFault("Required element " + innerElement.getName() + " of \
type " + + innerElement.getSchemaTypeName() +
+ " was not found in the response");
+ }
+ return false;
+ }
+
+
+ private void handleComplexTypeInResponse(XmlSchemaComplexType complexType, \
OMElement outElement, + Object response,
+ OMFactory fac,
+ boolean isInnerParam) throws AxisFault \
{ + XmlSchemaParticle particle = complexType.getParticle();
+ if (particle instanceof XmlSchemaSequence) {
+ XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) particle;
+ XmlSchemaObjectCollection schemaObjectCollection = \
xmlSchemaSequence.getItems(); + int count = \
schemaObjectCollection.getCount(); + Iterator iterator = \
schemaObjectCollection.getIterator(); + // now we need to know some \
information from the binding operation. + while (iterator.hasNext()) {
+ XmlSchemaElement innerElement = (XmlSchemaElement) iterator.next();
+ String name = innerElement.getName();
+ XmlSchemaType schemaType = innerElement.getSchemaType();
+ if (schemaType instanceof XmlSchemaComplexType) {
+ Object object = response;
+
+ if (checkRequired(innerElement, object)) {
+ continue;
+ }
+ XmlSchemaComplexType innerComplexType = (XmlSchemaComplexType) \
schemaType; + OMElement complexTypeElement =
+ fac.createOMElement(name, outElement.getNamespace());
+ outElement.addChild(complexTypeElement);
+
+ handleComplexTypeInResponse(innerComplexType, \
complexTypeElement, object, fac, + true);
+ } else {
+ Object object = response;
+ if (isInnerParam || count > 1) {
+
+ } else {
+ object = response;
+ }
+ if (checkRequired(innerElement, object)) {
+ if (innerElement.getSchemaTypeName() != \
Constants.XSD_ANYTYPE) { + continue;
+ }
+ }
+ handleSimpleTypeinResponse(innerElement, object, fac,
+ outElement);
+ }
+ }
+ } else {
+ throw new AxisFault("Unsupported schema type in response.");
+ }
+ }
+
+
+ private void handleSimpleTypeinResponse(XmlSchemaElement innerElement, Object \
pyObject, + OMFactory factory,
+ OMElement outElement) throws AxisFault {
+ long maxOccurs = innerElement.getMaxOccurs();
+ if (maxOccurs > 1 && \
!innerElement.getSchemaTypeName().equals(Constants.XSD_ANYTYPE)) { + if \
(pyObject instanceof Object[]) { + Object[] objects = (Object[]) \
pyObject; + for (Object object : objects) {
+ outElement.addChild(handleSchemaTypeinResponse(innerElement, \
object, + factory));
+ }
+ } else {
+ outElement.addChild(handleSchemaTypeinResponse(innerElement, \
pyObject, factory)); + }
+ return;
+ }
+ outElement.addChild(
+ handleSchemaTypeinResponse(innerElement, pyObject, factory));
+ }
+
+ private OMElement buildResponse(boolean annotated, Object result,
+ XmlSchemaElement innerElement) throws AxisFault \
{ + // Check whether the innerElement is null.
+ if (innerElement != null) {
+ return createResponseElement(result, innerElement.getName(), \
!annotated); + } else {
+
+ // wrap the response in a wrapper element called return. If the wrapper \
contains an OMElemet return the + // OMElement (There is no use in the \
wrapper). + // There are occations when the function returns a py type \
which is not XML. + // Therefore we need the wrapper element tp wrap it. \
What if the service returned null? just return null. + OMElement element = \
createResponseElement(result, "return", !annotated); + OMElement omElement \
= element.getFirstElement(); + if (omElement == null) {
+ String elementText = element.getText();
+ if (elementText == null || "".equals(elementText)) {
+ return null;
+ }
+ return element;
+ } else if (omElement.getNextOMSibling() != null) {
+ return element;
+ } else {
+ return omElement;
+ }
+ }
+ }
+
+
+ /**
+ * Given pyObject is converted to corresponding OMElement
+ *
+ * @param pyObject - The object that needs to be converted
+ * @param elementName - The element name of the wrapper
+ * @param addTypeInfo - Whether type information should be added into the \
element as an attribute + * @return - OMelement which represents the pyObject
+ * @throws AxisFault - Thrown in case an exception occurs during the conversion
+ */
+ private OMElement createResponseElement(Object pyObject, String elementName,
+ boolean addTypeInfo) throws AxisFault {
+ //String className = pyObject.getClass().getName();
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ //OMNamespace namespace = fac.createOMNamespace("http://www.wso2.org/ns/py \
type", "py"); + OMNamespace xsiNamespace = \
fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi"); + \
OMNamespace xsNamespace = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema", \
"xs"); + OMElement element = fac.createOMElement(elementName, null);
+
+ // Get the OMNode inside the pyObjecting object
+ if (pyObject instanceof PyString) {
+ element.setText((String) pyObject);
+ if (addTypeInfo) {
+ element.declareNamespace(xsNamespace);
+ element.addAttribute("type", "xs:string", xsiNamespace);
+ }
+ } else if (pyObject instanceof PyInteger) {
+ element.setText(pyObject.toString());
+ if (addTypeInfo) {
+ element.declareNamespace(xsNamespace);
+ element.addAttribute("type", "xs:integer", xsiNamespace);
+ }
+ } else if (pyObject instanceof PyFloat) {
+ element.setText(pyObject.toString());
+ if (addTypeInfo) {
+ element.declareNamespace(xsNamespace);
+ element.addAttribute("type", "xs:float", xsiNamespace);
+ }
+ } else if (pyObject instanceof PyLong) {
+ element.setText(pyObject.toString());
+ if (addTypeInfo) {
+ element.declareNamespace(xsNamespace);
+ element.addAttribute("type", "xs:long", xsiNamespace);
+ }
+ } else if (pyObject instanceof PyList) {
+ String strXml = "<List>";
+ String st[];
+ st = pyObject.toString().substring(1, pyObject.toString().length() - \
1).split(","); + for (int i = 0; i < st.length; i++) {
+ strXml = strXml + "<" + i + ">" + st[i] + "</" + i + ">";
+ }
+ strXml = strXml + "</List>";
+ strXml = strXml.replaceAll("'", "");
+ strXml = strXml.replaceAll(" ", "");
+ element.setText(strXml);
+ if (addTypeInfo) {
+ element.declareNamespace(xsNamespace);
+ element.addAttribute("type", "xs:anyType", xsiNamespace);
+ }
+ } else if (pyObject instanceof PyTuple) {
+ String strXml = "<Tuple>";
+ String st[];
+ st = pyObject.toString().substring(1, pyObject.toString().length() - \
1).split(","); + for (int i = 0; i < st.length; i++) {
+ strXml = strXml + "<" + i + ">" + st[i] + "</" + i + ">";
+ }
+ strXml = strXml + "</Tuple>";
+ element.setText(strXml);
+ if (addTypeInfo) {
+ element.declareNamespace(xsNamespace);
+ element.addAttribute("type", "xs:anyType", xsiNamespace);
+ }
+ } else if (pyObject instanceof PyDictionary) {
+ String strXml = "<Dictionary>";
+ String st[], stTemp[];
+ st = pyObject.toString().substring(1, pyObject.toString().length() - \
1).split(","); + for (String aSt : st) {
+ stTemp = aSt.split(":");
+ strXml = strXml + "<" + stTemp[0] + ">" + stTemp[1] + "</" + \
stTemp[0] + ">"; + }
+ strXml = strXml + "</Dictionary>";
+ strXml = strXml.replaceAll(" ", "");
+ strXml = strXml.replaceAll("'", "");
+ element.setText(strXml);
+ if (addTypeInfo) {
+ element.declareNamespace(xsNamespace);
+ element.addAttribute("type", "xs:anyType", xsiNamespace);
+ }
+ }
+ return element;
+ }
+
+
+ private OMElement handleSchemaTypeinResponse(XmlSchemaElement innerElement, \
Object pyObject, + OMFactory factory)
+ throws AxisFault {
+ QName qName = innerElement.getSchemaTypeName();
+ OMElement element = factory.createOMElement(innerElement.getName(), null);
+ if (qName.equals(Constants.XSD_ANYTYPE)) {
+ if (PythonScriptEngine.isNull(pyObject)) {
+ return element;
+ }
+ // need to set annotated as false cause we need to set xsi:type
+ return buildResponse(false, pyObject, innerElement);
+ }
+ if (qName.equals(Constants.XSD_INTEGER)) {
+ String str = PyToOMConverter.convertToInteger(pyObject);
+ element.setText(str);
+ return element;
+ }
+ if (qName.equals(Constants.XSD_INT)) {
+ String str = PyToOMConverter.convertToInt(pyObject);
+ element.setText(str);
+ return element;
+ }
+ if (qName.equals(Constants.XSD_FLOAT)) {
+ String str = PyToOMConverter.convertToFloat(pyObject);
+ element.setText(str);
+ return element;
+ }
+ if (qName.equals(Constants.XSD_LONG)) {
+ String str = PyToOMConverter.convertToLong(pyObject);
+ element.setText(str);
+ return element;
+ }
+ if (qName.equals(Constants.XSD_STRING)) {
+ String str = PyToOMConverter.convertToString(pyObject);
+ element.setText(str);
+ return element;
+ }
+ element.setText(pyObject.toString());
+ return element;
+ }
+
+
+ private Object handleSimpleElement(OMElement payload,
+ String innerElementName, long minOccurs, \
QName schemaType) + throws AxisFault {
+ QName payloadQname = payload.getQName();
+ OMElement omElement = null;
+ QName qName;
+ // When retrieving elements we have to look for the namespace too. There may \
be + // Occations even when the children are namespace qualified. In such \
situations + // we should retrieve them using that namespace.
+ // If that fails we try using the localname only.
+ if (payloadQname != null) {
+ qName = new QName(payloadQname.getNamespaceURI(),
+ innerElementName);
+ omElement = payload.getFirstChildWithName(qName);
+ }
+ if (omElement == null) {
+ qName = new QName(innerElementName);
+ omElement = payload.getFirstChildWithName(qName);
+ }
+ if (omElement == null) {
+ // There was no such element in the payload. Therefore we check for \
minoccurs + // and if its 0 add null as a parameter (If not we might mess \
up the parameters + // we pass into the function).
+ if (minOccurs == 0) {
+ //return Undefined.instance;
+ return null;
+ } else {
+ // If minoccurs is not zero throw an exception.
+ // Do we need to di strict schema validation?
+ throw new AxisFault(
+ "Required element " + innerElementName
+ + " defined in the schema can not be found in the \
request"); + }
+ }
+ return createParam(omElement, schemaType);
+ }
+
+
+}
Added: trunk/wsf/jython/server/core/src/main/resources/Processor.py
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/core/src/main/resources/Processor.py?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/core/src/main/resources/Processor.py Sun Oct 4 22:58:22 \
2009 @@ -0,0 +1,186 @@
+#
+# Copyright 2008 WSO2, Inc. http://www.wso2.org
+#
+# 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.
+#
+
+from types import *
+from java.util import HashMap
+#import inspect
+
+#count = 1
+result = ''
+
+def dictToJavaMap(dict):
+ javaMap = HashMap()
+ for i in dict.items():
+ javaMap[i[0]]=i[1]
+ #for i in javaMap:
+ # print javaMap[i[0]], ' == ' , javaMap[i[0]]
+ return javaMap
+
+
+def echo():
+ print 'echo() invoked'
+
+
+def getDictionary(str1):
+ #print 'str1 == ' , str1
+ string5 = str(str1)
+ li2 = string5.split(" ")
+ #print li2[3]
+ string5 = li2[3].replace('>','')
+ string5 = string5.replace('\'','')
+ #print 'string5 ' , string5
+ ##strFile = '/home/heshan/workspace/IdeaProjects/PYtest/src/pythonScripts/annotationScript.py'
+ ##print 'strFile ', strFile
+ ##strFile = '/home/heshan/repo/scripts/annotationScript.py'
+ ##fh = open(strFile,"r")
+ fh = open(string5,"r")
+
+ igot = fh.readlines()
+ Dictionary = {}
+ for line in igot:
+ if line.find("@annotate") > -1:
+ string1 = line[line.find("("):]
+ string2 = string1[2:len(string1)-2]
+ data = string2
+ q = data.split(",")
+ m = []
+ t = ""
+ con = False
+ for k in range(len(q)):
+ s = q[k].strip()
+ #print 's ==' , s
+ if '(' in s:
+ con = True
+ if con == True and ')' not in s:
+ t += s + ','
+ if ')' in s:
+ t += s + ','
+ m.append(t)
+ t = ""
+ con = False
+ elif con == False:
+ m.append(s)
+ string3 = ""
+ for w in m:
+ #print 'value of w is == ', w
+ S = w
+ where = S.find('=') # Search and find the first position
+ #print where
+ S = S[:where] + '-' + S[(where+1):]
+ #print 'value of s is'
+ #print S
+ #string3 = string3 + w + "$"
+ string3 = string3 + S + "$"
+ string3 = string3.replace(",","~")
+ #print 'string3 ==' , string3
+ li = string3.split("$")
+ key = li[1]
+ #print li
+ Dictionary[key] = li
+ #print
+ #print 'Dictionary'
+ #print Dictionary
+ return Dictionary
+
+
+def analyze_func(obj, method=False):
+ str1 = ''
+ global result
+
+ print '%s' % obj.__name__
+ print 'object passed to func() is ' , obj
+
+ if method:
+ # testing --- object for the class
+ sentence = '%s' % obj
+ words = sentence.split()
+ #print 'words ',words
+ classObj = words.pop(2)
+ classObj = classObj.replace(">","")
+ print 'Method: ' , classObj
+ #print 'Method: %s' % classObj_
+ strme = classObj
+ str1=strme
+ else:
+ print 'Function: %s' % obj.__name__
+ strme = '%s' % obj.__name__
+ #print 'strme value is' ,strme
+ str1=strme
+
+ # A tuple of four things is returned: (args, varargs, varkw, defaults)
+ arginfo = inspect.getargspec(obj)
+ # serach the inspect documentation for a method to get the method name
+ args = arginfo[0]
+ argsvar = arginfo[1]
+
+ print 'result is ' , str1
+ result = result + str1
+ result = result + '@'
+
+ if args:
+ if args[0] == 'self':
+ print '\t%s is an instance method' % obj.__name__
+ args.pop(0)
+ print '\tMethod Arguments: %s' % ' '.join(args)
+ if arginfo[3]:
+ dl = len(arginfo[3])
+ al = len(args)
+ defargs = args[al-dl:al]
+ print 'Default arguments:',zip(defargs, arginfo[3])
+
+ if arginfo[1]:
+ print '\t Positional Args Param: %s' % arginfo[1]
+ if arginfo[2]:
+ print '\t Keyword Args Param: %s' % arginfo[2]
+
+
+def analyze_klass(obj):
+ #print 'Class: %s' % obj.__name__
+ for name in obj.__dict__:
+ item = getattr(obj, name)
+ if type(item) is MethodType:
+ analyze_func(item, True)
+
+
+def classify(module):
+ #print 'Module: %s' % module.__name__
+ for name in dir(module):
+ obj = getattr(module, name)
+ if type(obj) in (ClassType, TypeType):
+ analyze_klass(obj)
+ elif type(obj) is FunctionType:
+ analyze_func(obj)
+ #print ' The final result is === ' , result
+ return result
+
+
+# defines how to annotate a python script
+def annotate(returns, operationName, **params):
+ def decorate(func):
+ params['returns'] = returns
+ params['operationName'] = operationName
+ func.__annotations__ = params
+ return func
+ return decorate
+
+
+if __name__ == "__main__":
+ import test
+ #val=classify(test)
+ Dict = {}
+ Dict = getDictionary("test")
+ print Dict
+
Added: trunk/wsf/jython/server/distribution/pom.xml
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/distribution/pom.xml?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/distribution/pom.xml Sun Oct 4 22:58:22 2009
@@ -0,0 +1,59 @@
+<!--
+ ~ Copyright 2007-2008 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ 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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 \
http://maven.apache.org/maven-v4_0_0.xsd"> + <!-- The Basics -->
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.wso2.wsf.jython</groupId>
+ <artifactId>jython-deployer-distribution</artifactId>
+ <version>1.0-alpha</version>
+ <packaging>pom</packaging>
+ <name>WSO2 WSF Jython Deployer - Distribution</name>
+ <url>http://wso2.org</url>
+ <parent>
+ <groupId>org.wso2.wsf.jython</groupId>
+ <artifactId>org.wso2.wsf.jython.deployer</artifactId>
+ <version>1.0-alpha</version>
+ </parent>
+ <!-- Build Settings -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-1</version>
+ <executions>
+ <execution>
+ <id>distribution-package</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ \
<finalName>wso2-wsf-jython-server-${wsf-jython.version}</finalName> + \
<descriptors> + \
<descriptor>src/main/assembly/bin-assembly.xml</descriptor> + \
<descriptor>src/main/assembly/src-assembly.xml</descriptor> + \
</descriptors> + </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
Added: trunk/wsf/jython/server/distribution/src/main/assembly/bin-assembly.xml
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/distribution/src/main/assembly/bin-assembly.xml?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/distribution/src/main/assembly/bin-assembly.xml Sun Oct \
4 22:58:22 2009 @@ -0,0 +1,55 @@
+<!--
+ ~ Copyright 2007-2008 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ 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.
+-->
+<assembly>
+ <id>bin</id>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>wsf-jython-server-${wsf-jython.version}</baseDirectory>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>../</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.txt</include>
+ <include>release-note.html</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>../core/target</directory>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>wsf-jython-deployer-${wsf-jython.version}.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>../samples</directory>
+ <outputDirectory>samples</outputDirectory>
+ <includes>
+ <include>*.py</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>org.python:jython:jar</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+</assembly>
Added: trunk/wsf/jython/server/distribution/src/main/assembly/src-assembly.xml
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/distribution/src/main/assembly/src-assembly.xml?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/distribution/src/main/assembly/src-assembly.xml Sun Oct \
4 22:58:22 2009 @@ -0,0 +1,46 @@
+<!--
+ ~ Copyright 2007-2008 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ 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.
+-->
+<assembly>
+ <id>src</id>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>wsf-jython-server-${wsf-jython.version}-src</baseDirectory>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>../</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.txt</include>
+ <include>release-note.html</include>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>../</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>**/core/**</include>
+ <include>**/samples/**</include>
+ <include>**/distribution/**</include>
+ </includes>
+ <excludes>
+ <exclude>**/target/**</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</assembly>
Added: trunk/wsf/jython/server/pom.xml
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/pom.xml?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/pom.xml Sun Oct 4 22:58:22 2009
@@ -0,0 +1,166 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 \
http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion>
+ <groupId>org.wso2.wsf.jython</groupId>
+ <artifactId>org.wso2.wsf.jython.deployer</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-alpha</version>
+ <name>WSO2 WSF Jython Deployer - Parent</name>
+ <url>http://wso2.org</url>
+ <inceptionYear>2008</inceptionYear>
+ <!-- ========== -->
+ <!-- Developers -->
+ <!-- ========== -->
+ <developers>
+ <developer>
+ <name>Keith Chapman</name>
+ <id>keith</id>
+ <email>keith AT wso2.com</email>
+ <organization>WSO2 Inc.</organization>
+ <organizationUrl>http://www.wso2.org</organizationUrl>
+ </developer>
+ <developer>
+ <name>Heshan suriyaarachchi</name>
+ <id>heshan</id>
+ <email>heshan AT wso2.com</email>
+ <organization>WSO2 Inc.</organization>
+ <organizationUrl>http://www.wso2.org</organizationUrl>
+ </developer>
+ </developers>
+
+ <!-- Environmental Settings -->
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://wso2.org/jira/browse/WSFJYTHON</url>
+ </issueManagement>
+
+ <repositories>
+ <repository>
+ <id>wso2-maven2-repository</id>
+ <url>http://dist.wso2.org/maven2</url>
+ </repository>
+ <repository>
+ <id>ws-zones-repository</id>
+ <url>http://ws.zones.apache.org/repository2</url>
+ </repository>
+ <repository>
+ <id>apache-snapshots</id>
+ <name>Apache Development Repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ </repository>
+ <!--repository>
+ <id>ibiblio repo</id>
+ <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
+ </repository-->
+ </repositories>
+
+ <distributionManagement>
+ <repository>
+ <id>wso2-maven2-repository</id>
+ <name>WSO2 Maven2 Repository</name>
+ <url>sftp://maven2@dist.wso2.org/home/httpd/dist.wso2.org/maven2</url>
+ </repository>
+ <snapshotRepository>
+ <id>wso2-maven2-snapshot-repository</id>
+ <name>WSO2 Maven2 Repository</name>
+ <url>sftp://maven2@dist.wso2.org/home/httpd/dist.wso2.org/maven2</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <modules>
+ <module>core</module>
+ <module>distribution</module>
+ </modules>
+
+ <dependencies>
+
+ <!-- Jython dependencies -->
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython</artifactId>
+ <version>${jython.version}</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.axiom</groupId>
+ <artifactId>axiom-dom</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>${XmlSchema.version}</version>
+ </dependency>
+ <!-- STAX implementation used in WSAS -->
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2</artifactId>
+ <version>${axis2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons.logging.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- Build Settings -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <wsf-jython.version>1.0-alpha</wsf-jython.version>
+ <axis2.version>1.4.1</axis2.version>
+ <axiom.version>1.2.7</axiom.version>
+ <XmlSchema.version>1.4.2</XmlSchema.version>
+ <commons.logging.version>1.1.1</commons.logging.version>
+ <log4j.version>1.2.13</log4j.version>
+ <woodstox.version>3.2.1</woodstox.version>
+ <jython.version>2.2.1</jython.version>
+ </properties>
+</project>
Added: trunk/wsf/jython/server/release-note.html
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/release-note.html?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/release-note.html Sun Oct 4 22:58:22 2009
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head>
+<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"><title>WSF/Jython \
Release Notes</title></head> +<body style="direction: ltr;" lang="en-US">
+<p>18th September 2008</p>
+<h2><b>WSO2 WSF/Jython 1.0-alpha</b></h2>
+WSO2 WSF/Jython provides an amazingly simple approach to
+create (Code First) and consume Web Services in Jython. This
+framework integrates the <a href="http://ws.apache.org/axis2/">Apache Axis2</a> web \
services engine into +Jython. Thus, providing all the power and versatility \
of the +Axis2 engine to the Jython user. Now, with just a few lines of
+code, Jython users can enjoy the benefits of Service Oriented
+Architecture using Web Services in their applications. <br>
+<br>
+Web Service clients written using WSF/Jython framework could
+invoke enterprise web services which require WS-Security. Sending
+binary attachments as MTOM is also supported.<br>
+<br>
+WSO2 WSF/Jython is released under the <a \
href="http://www.apache.org/licenses/LICENSE-2.0">Apache License \
v2.0</a>.<br><br>There are two pachages that comes with this release, the server side \
and the client side. +<h2><b>Client Side Features</b></h2>
+<ul>
+<li><p>Support for invoking Web Services in a simple clean \
manner</p></li><li><p>Ability to use WS-Addressing when invoking \
services</p></li><li><p>Ability to invoke services which require \
WS-Security</p></li><li><p>Ability to send binary attachments using \
MTOM</p></li></ul><h2>Server side Features<br></h2><ul><li><p>Support for exposing \
services written in Jython</p> +</li>
+<li>
+<p>DataBinding support using a simple annotation mechanism</p>
+</li>
+<li>
+<p>Automated WSDL generation </p></li><li>Ability to expose all enterprise \
features of <a href="http://ws.apache.org/axis2/">Axis2</a> to services written in \
Jython</li> +</ul><h2><b>Reporting Problems</b></h2>
+<p>Issues can be reported using the public JIRA at <a \
href="https://wso2.org/jira/browse/WSFJython">http://wso2.org/jira/browse/WSFJython</a><br>
+</p><h2>Contact us</h2>
+<p>
+WSO2 WSF/Jython developers can be contacted via the mailing \
list <strong></strong><strong><a \
href="mailto:wsf-java-dev@wso2.org">wsf-java-dev@wso2.org</a></strong> +<br>
+<strong></strong>To subscribe please send a message to <a \
href="wsf-java-dev-request@wso2.org?subject=subscribe">wsf-java-dev-request@wso2.org</a></p><p>WSO2 \
WSF/Jython user mailing list is <a \
href="wsf-jython-user@wso2.org">wsf-jython-user@wso2.org</a><br>To subscribe please \
send a message to <a \
href="wsf-jython-user-request@wso2.org">wsf-jython-user-request@wso2.org</a></p><p> \
+Alternatively, questions can also be raised in the forums: +<a \
href="http://wso2.org/forum/194s">http://wso2.org/forum/797</a><br> +</p>
+<p>Thank you for your interest in WSO2 WSF/Jython</p>
+<p><strong>The WSO2 WSF/Jython Development Team</strong></p>
+<br>
+-----------------------------------------------------------
+<br>
+2008 WSO2 Inc.
+</body></html>
\ No newline at end of file
Added: trunk/wsf/jython/server/samples/simpleService.py
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/jython/server/samples/simpleService.py?pathrev=46510
==============================================================================
--- (empty file)
+++ trunk/wsf/jython/server/samples/simpleService.py Sun Oct 4 22:58:22 2009
@@ -0,0 +1,24 @@
+#@annotate("returns=double", "operationName=f", a="double")
+def f(a):
+ return a
+
+#@annotate("returns=int", "operationName=add", var1="integer", var2="integer")
+def add(var1,var2):
+ return var1+var2
+
+#@annotate("returns=double", "operationName=deduct", var1="double", var2="double")
+def deduct(var1,var2):
+ return var1-var2
+
+#@annotate("returns=int", "operationName=addTwo", var1="integer", var2="integer", \
var3=(a="string", b="integer")) +def addTwo(var1,var2,var3):
+ return var1+var2
+
+#@annotate("returns=int", "operationName=doComplexStuff", var1="integer", \
var2="(a="integer", b="integer")", var3="(a="string", b="integer")") +def \
doComplexStuff(var1,var2,var3): + return var1
+
+class MyClass:
+ #@annotate("returns=integer", "operationName=MyClass.multiply", var1="integer", \
var2="integer") + def multiply(var1,var2):
+ return var1*var2
_______________________________________________
Wsf-dev mailing list
Wsf-dev@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/wsf-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic