Title/Summary: Asynchronous Servlet integration with SCA callbacks

Student: Florian Moga

Student e-mail: moga.flo AT gmail DOT com

Student Major: Computer Science

Student Degree: Undergraduate

Student Graduation: June 2011

Organization: Apache Software Foundation

Assigned Mentor: Ant Elder

Abstract

Apache Tuscany provides a comprehensive infrastructure for SOA development using a service oriented approach. Apache Tuscany implements Service Component Architecture (SCA) which defines a flexible, service-based model for construction, assembly and deployment of network of services. It reduces the effort needed to develop this type of applications by pushing out of the business logic things like protocol handling or interactions between components, which make the components reusable and help the developer to concentrate on their business logic implementation.

Also, Tuscany has an asynchronous programming API which enables easily creating asynchronous services. Last December, the new Java EE 6 spec has been released containing exciting new features. One of them can be found in the Servlets 3.0 spec which now supports asynchronous programming.

The goal of this project would be investigating how can the new asynchronous Servlet features be integrated with SCA callbacks from Tuscany. After a detailed study, an extension of the way callbacks are done with Servlets will be designed in the spirit of SCA and implemented using the new Servlet API. A demo consisting in an async webapp and documentation will also be developed in order to demonstrate the advantages that the new design will posses.

Detailed Description

Typical SCA applications model the communication between a service client and the service provider using the following concepts:

  • a service - which is a set of one or more operations contained in an interface which is implemented by the service provider
  • a reference - which is used by the client to invoke the operations of the service provider. The reference is typically a proxy object which implements the same interface as the service provider implements.

For asynchronous services, SCA has the concept of the callback. A callback implies that communication is two-way and asynchronous. Responses sent by the service provider involve the service provider calling back the client using a separate interface, which the client must implement.

So, the SCA prototype of an asynchronous service assumes the use of two interfaces:

  • the service interface - implemented by the service provider and injected to the client
  • the callback interface - implemented by the client and injected to the service provider

An important aspect of the SCA approach to asynchronous services is that the client can be called back by the service provider via the callback interface at any time after the initial invocation of the service by the client. The service provider may use any of the operations defined in the callback interface and in response to a single request from the client, the provider may call one, multiple or zero operations in the callback interface.

Moving on to the new features of the Servlets 3.0 spec we can notice that HTTP streaming can be easily achieved using the asynchronous API. The idea behind HTTP streaming consists in the client initializing a connection and keeping it open until a timeout is reached or the servlet commits the response. Meanwhile, the servlet can send messages to the client using the previously allocated communication channel.

This can be done by using an AsyncContext. An AsyncContext can be initialized using one of the two startAsync() methods which can be found in ServletRequest and implicitly in HttpServletRequest API. Until the AsyncContext#complete() method is called causing the response to commit, subsequent flushes on the Writer or OutputStream attached to the ServletResponse can be performed having the effect of sending a message back to the client each time without closing the established communication channel.

Based on the information presented above, an integration of the new Java EE API and Tuscany seems to be a natural step in the evolution of Tuscany. This project will consist in finding a way to integrate the Servlets 3.0 API with the SCA callback concept. This will probably materialize in extending implementation.web and writing a new binding for the new communication system.

Deliverables

  1. An investigation of the possible ways of integrating asynchronous Servlets with SCA callbacks
  2. Design and implementation of the best solution
  3. Consistent unit testing of the implementation to assure proper functionality
  4. A demo and a tutorial to illustrate how the new features can be used

Additional Information

Development Schedule

April 20 - May 23

  • Keep studying the Servlets API and Tuscany code
  • Discuss integration and design with the Tuscany community

May 24 - July 15

  • Exchange ideas with the community and agree upon an initial design
  • Write a document that will contain a detailed description and analysis of the solution found for integration. It will also describe the initial design that was created for it, consisting in some technical details and UML diagrams.
  • Start the development phase in an Agile manner. This approach will help incrementally improving the design and assuring good functionality by performing unit testing as implementation is still in progress. Any changes in the design will be reflected in the above document. Class stubs will be created according to the design and implementation will be in progress.

July 16

  • Mid-term evaluation of the project.

July 17 - August 16

  • Finish the development phase - implementation and unit testing
  • Review the work done. If needed, apply necessary fixes and refactor code.
  • Write the code for a demo:
    • server-side SCA components
    • client browser page that will invoke the service on the server (using JavaScript libraries)
  • Write a tutorial for the new features using the above demo as an example

August 17 - August 19

  • Make the last fine adjustments to all the deliverables for the final submission.

August 20

  • Final evaluation deadline.

Community Interaction

The nature of this project assumes community interaction to be a big part of it especially in the first phase when design decisions need to be taken. I will make the community fully aware of the status of the project, ideas or questions I have and I will reply to it's requests as fast as I can through the following means:

  • the Tuscany mailing list
  • JIRA issue tracking system
  • #tuscany IRC channel on freenode
  • private chat on GTalk

I believe communication is a vital part of any project, especially when talking about open source software and I am open to full interaction with the Tuscany community.

Biography

I am 21 years old and I am currently a second year student in the field of Computer Science at the Babes Bolyai University from Cluj-Napoca, Romania. I posses a strong algorithmic background, earned in multiple national and international informatics contests where I constantly occupied top ranking positions. I also posses experience with Java development and knowledge of the related frameworks and technologies like Struts, Hibernate, Spring and of course Servlets, JSP, Web Services, JPA and others. This project is very appealing to me as it gives me the possibility to deepen my previous knowledge in Java EE and become more familiar with Tuscany, which looks like a very useful tool for developers.

  • No labels