Showing posts with label jython. Show all posts
Showing posts with label jython. Show all posts

Wednesday, July 14, 2010

Extend the Axis2 Framework to Support JVM Based Scripting Languages

This article explains how to extend the Axis2 framework to support Java Virtual Machine (JVM) based scripting languages such as Jython, JRuby, etc. It provides a high level overview of the subject, covering some key concepts of Apache Axis2 and how it can be used to come up with an extension to a JVM based scripting language. After going through this article, a developer will be able to extend the Axis2 framework to support the JVM based scripting language of his or her choice.

If you are interested, read the full article on InfoQ.com.

I take this opportunity to thank Nandika for doing the technical review and Charles Humble for doing the editorial review.

Sunday, August 16, 2009

GSoC: Experience

This was my second consecutive year as a Google Summer of Code student. During past 3 months I learned a lot of things. I discussed these in an earlier posts. In a nutshell;

1) I worked with a mentor (Matt Boersma) from a different time zone. This was the first time that I worked with a mentor from a different timezone. Our time difference was nearly 12 hours. We preferred email over chat since it was more conveinent for us.

2) It was a privilege to work as a summer of code student for Python Software Foundation (PSF). All the people who were mentoring me helped me a lot, ranging from shaping up the application (project proposal) to development.

3)It was a greatopportunity for me to work with experienced developers.

I would like to take this opportunity to thank my mentor Matt Boersma and Jython community for helping me to make my project a success. I would also take this opportunity to thank my co-mentors Jim Baker and Frank Wierzbicki.

I would like to state that it was a privilege and a honor to be selected as a GSoC student for a second time and thank Google for organizing a program like this. I am looking forward to participating in next year's GSoC as a mentor. :)

Saturday, August 15, 2009

GSoC: Update

During the development phase, I came across some problems. This is a follow up to my earlier posts. You can have a look at them here.

1) One problem is the way the API is designed to define the XML payload. I designed the WSF/Jython API in such a way that it is comparable with the WSF/Ruby implementation. Therefore WSF/Jython API should adhere to the API specified by WSF/Ruby.

When generating code using Axis2's code generation framework, you should generate it in a such a way that it should support XML object model(preferably in the case of axis2 - apache axiom). Therefore it would be better if the API supported axiom, inorder to use the code generation part. Consider the following example.

from org.wso2.wsf.jython.jythonwsclient import *

req_payload_string = "<deduct><var1>1.8</var1><var2>4.87594</var2></deduct>"
LOG_FILE_NAME = "/home/heshan/IdeaProjects/MRclient/src/python_client.log"
END_POINT = "http://localhost:8070/axis2/services/annotationScript/deduct"

try:
client = WSClient({}, LOG_FILE_NAME)
req_message = WSMessage(req_payload_string, {"to" :END_POINT})
print " Sending OM : " , req_payload_string
res_message = client.request(req_message)
print " Response Message: " , res_message

except WSFault, e:
e.printStackTrace();

In above code snippet, the payload is set as a string. i.e.

req_payload_string = "<deduct><var1>1.8</var1><var2>4.87594</var2></deduct>"

What should be done is to keep the above feature intact with the API and do a feature addition that will support Apache Axiom.

2) Therefore, the existing WSF/Jython codebase should be modified to support axiom for Jython (should look into this further).

3) Modify the existing codebase to include the code generation part. Having said that there should be more work done to seamlessly integrate this(code-generation part) to WSF/Jython code. More coding have to be done on code generation module for Jython.

4) In a earlier post I said of modifying the Python deployer to support Contract First approach. This happens in the server-side code generation. It's a problem that I am still having.

5) In the same post I said that
0nly generate the client code and use the existing WSF/Jython's client API. Then before running the client code you can add the WSF/Jython client-side jar to the class path.
Now it seems like the best option out of the two options mentioned in the above post.

[The above arguments are my opinions and may subject to change.]

Friday, July 10, 2009

GSoC: How to integrate with existing code base

This post will contain my arguments on "How to integrate this project to the existing WSF/Jython code base". This is a followup to my last post.

1. Modify the Python deployer to support Contract First approach.

2. To support Contract First approach you need to be able to generate a skeleton and a message receiver for your service. The generic message receiver that I have already written may not work because it works only on a limited schema structure.

3. Another way to look at the above argument(2) may be; only generate the client code and use the existing WSF/Jython's client API. Then before running the client code you can add the WSF/Jython client-side jar to the class path.

The above arguments are my opinion(for now) on integrating the gsoc code to existing code base. The above arguments may subject to change.

Sunday, July 5, 2009

GSOC: Problems faced during development

Earlier I said that I would be writing a blog post on the problems which I encountered during the development phase of my GSoC project. Here I am compiling them to a list. Some points in the list may not directly be problems but important things which came across during the process.

1. Had a problem with building axis2. This was overcome when I found a workaround for this. (This was a hard issue to regenerate because this will only happen occasionally.)

2. There were lot of dependencies inside axis2's code generation framework. Some dependencies were not set by the build script. Therefore had to manually add the dependencies and run the code. When it gives a compilation error stating a dependency is not there, had to set the dependencies. This took some time :).

3. Had to take some time to understand the existing code base and the architecture of the code generation framework.

4. Learned to work with XSLTs.

5. Another important point to note is that the WSF/Jython distribution, now needs some additional libraries to successfully run. You may have wondered "why is this happening?". As you may already know WSF/Jython is built on top of Apache Axis2. The new releases of Axis2 are having more dependencies towards other liblaries/jars (eg. wsdl4j, etc). Since I no longer work for WSO2, I do not have the access writes to change the build script for WSF/Jython. As soon as I get there, I would remember to revise the build script. Until then you could do a small workaround:)

Download Axis2 standard binary distribution. Then extract it. Add the jars which are residing in the lib folder, to the classpath. Then you could carry on with your work.

6. How to integrate this project to the existing WSF/Jython development. (I will present my arguments on this on a new post)


Saturday, June 27, 2009

Design for Jython Extension for Axis2

In a earlier post I said that I am coming up with a Jython extension for Axis2. This will be a code generation tool for jython. This will use existing infrastructure in Axis2 to support Contract First Web services in Jython. What I am planning to do is to integrate this code generation tool into WSF/Jython. Then WSF/Jython will be able to support both, contract-first and code-first approaches. Thus, making the life easier for the Jython developer :).


The code generation engine calls the extensions one by one and then calls a component what is known as the Emitter. Emitter is the actual component that does the significant bit of work in the code generation process. Emitters are usually language dependent and hence one language has one emitter associated with it. Therefore there should be an emitter to support Jython code generation. This simple yet powerful architecture is shown in the above illustration.

The Emitter processes the WSDL and builds a object model. The object model is simply an XML file which contains the object model of the WSDL with respect to Axis2 information model (ie. axis service, axis operation, axis message, etc). The template is a XSLT file which contains information on how the code should be generated. Then the built object model is parsed against the template to build the jython source code.

Thursday, June 25, 2009

Jython extension for Apache Axis2

In a earlier post I mentioned that my proposal for GSoC 2009 was accepted. There I didn't give much details on what my project is about. Here is a description of my project.

If you have tried out WSO2 WSF/Jython, you will know that it is based on code-first approach. Web services, is a technology to deliver the architectural style defined in SOA. Although there seems to be a general confusion about the relationship between SOA and Web services, it is important to know that Web services are an implementation methodology that adopts standard protocols to execute SOA. There are two widely used techniques in Web service development, ie.
  1. Code First
  2. Contract First
With the contract-first approach, the contract for the Web service is determined first and then the supporting tools are used to generate the implementation code. In contrast, in the code-first approach, first the implementation code is created and then the Web service development framework is used to produce the contract for the Web service.

In simpler terms; in WSF/Jython what I am doing is asking you to write the web service and the client. Then based on the service, a WSDL is generated and exposed as a Web service. Afterwards jython client can be used to invoke the service (ie. code-first).

When it comes to contract-first it is vice versa of the above scenario. First we will have to take the provided WSDL in to consideration. Then based on this WSDL, the code should be generated. Following are the advantages of using contract first approach.
  • Loose coupling between applications
  • Interoperability between multiple services
  • Abstraction hides underlying implementation details
  • Collaboration and agreement between all parties

Tuesday, April 21, 2009

Google Summer of Code Accepted Projects Announced

Yesterday I received an email from Google stating that my project proposal for Google Summer of Code 2009 has been selected. I am thrilled of being selected as a GSoC student for Python Software Foundation. I would like to take this oppertunity to thank Jim Baker and Keith Chapman for helping me to iron out my proposal. My mentor for this project will be Matt Boersma. Frank Wierzbicki and Jim Baker will be actively involved in this project as well. I am looking foreward to having a great summer with GSoC.

Thursday, September 18, 2008

WSO2 WSF/Jython 1.0-alpha


WSO2 WSF/Jython provides an amazingly simple approach to create (Code First) and consume Web Services in Jython. This framework integrates the Apache Axis2 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.

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.

WSO2 WSF/Jython is released under the Apache License v2.0.

There are two packages that comes with this release, the server side and the client side.

Client Side Features

  • Support for invoking Web Services in a simple clean manner

  • Ability to use WS-Addressing when invoking services

  • Ability to invoke services which require WS-Security

  • Ability to send binary attachments using MTOM

Server side Features

  • Support for exposing services written in Jython

  • DataBinding support using a simple annotation mechanism

  • Automated WSDL generation

  • Ability to expose all enterprise features of Axis2 to services written in Jython

Articles

http://wso2.org/library/invoking-enterprise-web-services-using-jython

http://wso2.org/library/articles/deploying-python-service-axis2

Reporting Problems

Issues can be reported using the public JIRA 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-user-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

Wednesday, September 17, 2008

Deploying a Python Service on Axis2

Apache Axis2/Java, is a popular open source Web service engine. It currently supports exposing services written in Java, Javascript and Ruby as Web services. This article discusses the Python data Binding that enable exposing Web services written in Python.

Axis2/Java is now able to expose a service written Python as a Web service. The underlying deployer will read the annotations and perform data-binding, schema generation. Schema generated will be passed on to the Axis2 engine, which will then perform the WSDL generation. Thereafter, a client is able to invoke the service using the WSDL generated.

Invoking Enterprise Web Services using Jython

This article discusses the usage of WSO2 WSF/Jython API to write Web service clients in Jython. WSF/Jython's Jython-Client API can be used to write a Jython service clients. It supports attachments with MTOM, SOAP, REST and WS-* standards such as WS-Addressing, WS-Security.

Tuesday, September 16, 2008

Jython Web Services with Axis2 - WSO2 WSF/Jython 1.0 alpha release

WSO2 Web Services Framework for Jython (WSO2 WSF/Jython), is an open source framework for exposing and consuming enterprise level Web Services in Jython.

You can download the source and binary distributions from the following URL.
http://wso2.org/projects/wsf/jython

You can read the following articles.
http://wso2.org/library/articles/deploying-python-service-axis2
http://wso2.org/library/invoking-enterprise-web-services-using-jython

Pleas feel free to send any feedback to our forum.
http://wso2.org/forum/797

For further details please visit our project's website at:
http://wso2.org/projects/wsf/jython

Thursday, September 4, 2008

My Presentation @ WSO2 - WSF/Jython

Every week we are having an Internal Presentation at WSO2. This week I did a presentation on the project I worked on during my internship with WSO2 - WSF/Jython.This framework helps to expose python scripts as web services through the Python Deployer and write service clients using the WSF/Jython API. I am planning to do a WSO2 WSF/Jython release by next week. I have written some articles to OT on using this API. The articles will be published with the release as well. Therefore I am looking foreward to next week. :)
WSO2 WSF/Jython
View SlideShare presentation or Upload your own.


Thursday, July 10, 2008

"SUN Setting" their eyes on Python



SUN is planning to support Jython and Python languages. This will be done in their future Netbeans IDE releases. It will support Syntax highlighting with version support, Code Completion, Python/Jython support, PyUnit support, Debugger support, Python library manager, Bundled Jython Package and Execution of python scripts. Earlier this year SUN hired Frank Wierzbicki (who is leading the Jython project). I think he might be one of the forces behind this decision. So it is a good news that SUN opted to support Jython and Python.

What is Jython?



JPython was the first implementation of Python programming language in java. Then the project was moved to SourceForge and renamed Jython. Jython is a programming hybrid. It exhibits the strengths of both its parents, namely Java and Python. Since Jython is written in 100% pure java , scripts written using jython will run on top of any compliant Java Virtual Machine (JVM). Jython interpreter will support existing java libraries as if they were your own python modules.
I have been playing around with Jython for about 6 months now. I have an idea to start a mini-tutorial series out of the knowledge I gathered upto now. So stay tuned in to my blog ;)