\ Tomcat /
 
-|

Tomcat Webservices JSR109 implementation

| ---
 

Functionalities

This patch is made for the february 2007 svn version of Tomcat.

The functionality developped is the declaration of a webservice (JSR 109) in the catalina code.

Installation

You have to download the webservices JSR 109 patch for Tomcat 6.0 or the last update with only the factories. Then to install you have to apply the webservices JSR 109 patch on a last svn snapshot (6.0) from Tomcat website. Then you just have to compile the Tomcat server like always with ant. You have also to download the jaxrpc jar and wsdl4j jar for the webservices. If you are using axis and a servlet which call a webservice on the same tomcat server, it seems to have an issue with the jaxrpc library. You have to use in this case java 1.6

Technicals comments

The modified files in java/org/apache/catalina

I add the service-ref declaration just the same way like the ejb or the resources in core/NamingContextListener.java, in deploy/NamingResources.java and startup/WebRuleSet.java. I modified the existing bean to configure the webservices deploy/ContextService.java. I create a special bean to configure the webservices' handlers, deploy/ContextHandler.java.

The new files in java/org/apache/naming

factory/ServiceProxy.java A proxy class on the Service interface class. It permits to get the port-component-ref declared in the web deployment descriptor or in the local wsdl.
factory/ServiceRefFactory.java It is the instantiation of the Service object as explained in the JSR109. I have some dubts concerning the initialisation of the role in a handler list.
Handler.java Configuration bean for the webservice's handler.
ServiceRef.java Configuration bean for the service reference.

The modified files in java/org/apache/naming

I add the default factories constants in factory/Constants.java for the service and the handler class.

The declaration of a Handler doesn't work with the axis library as explain in the bug report.

Links

 
-|

Tomcat Servlets 1.5 implementation

| ---
 

Functionalities

This patch is made for the march 2006 svn version of Tomcat.

The functionality developped is all the changelog of the servlets specification 2.5 in the catalina code.

Installation

You have to choose between the servlet 2.5 patch for Tomcat 6.0 and the servlet 2.5 patch for Tomcat 5.5. Then to install you have to apply the servlet 2.5 patch on a last svn snapshot (5.5 or 6.0) from Tomcat website. Then you just have to compile the Tomcat server like always with ant. But now you can't use any other version of java but the 1.5 You have also to download the jaxws jar for the webservices.

An example of the annotations use is available. You have to compile this annotations example with java 1.5, I'm sorry I haven't made a build.xml for this web application. Basically I took the servlets example application available on the svn repository and I tested some new functionalities that I have developped.

web.xml Multiple occurences of HelloWorldExample servlet mappings.
HelloWorldExample.java Annotations added : @Resource and @PostConstruct. The Resource is a database called TestDB, which have one table called test. In this table the first column is a String.
ContextListener.java Annotations added : @DeclareRoles, @RunAs, @Resources, @Resource and @PostConstruct. The Resource declared is a String. Then I just call it and display it in the log.

Technicals comments

The new files in container/catalina/src/share/org/apache/catalina

deploy/ContextService.java It is a bean used to register a WebService.
startup/WebAnnotationSet.java It is a parser used at the startup of an web application. It looks for the annotations in all the servlets, listeners and filters. Then it accomplished the appropriated treatment (Resources and Rolename registration...).
util/ProcessAnnotation.java It is an another parser used before a class instanciation. It looks for the annotations. Then it accomplished the appropriated treatment (Resources injection, Postconstruct method invokation...).

The entire directory servletapi/jsr250 is dedicated to the annotations interfaces from the JSR250 specifications. I also put EJB annotations interfaces, because I didn't know where else I could put it... This has to been corrected

When the user call a Resource annotation, to declare something, the specification doesn't tell what the mappedName property is for. It may have to change.

env-ref element It is used as the Resource value.
service-ref element It is used as the Resource wsdlfile.
resource-ref element It is used as a Resource property.
message-destination-ref element It is used as a Resource usage.
resource-env-ref element It is used as a Resource property.

When the user code an EJB annotation, I just fill the javabean ContextLocalEjb or ContextEjb depending on the mappedName value. Then the Home javabean property is filled with the annotation beanName property. It may have to change

Tomcat doesn't support the webservices declarations. So I put the entry in WebRulesSet.java and I create the javabean. But I think that the Javabean has to be more detailled, in particular concerning the handler part. Then I applicate the same idea with the others annotations. I fill my javabean ContextService.

The ProcessAnnotation is used each time that a class is instancied. It is like a big loop which look for all the annotations. My code could be accelerated here if the ProcessAnnotation would already know where the annotations are. I imagine that WebAnnotationSet fills a structure with the classname, the annotation type and the object which have the annotation and then ProcessAnnotation only looks through this structure. But I still don't have the structure type in my mind.

I choosed to not use apt (it is the new compiler tool in java 1.5) and to do all the treatment on the annotations in the container. I don't know if it is the best solution. I just thought like an end user... Changing my development tool would have made me feel uneasier, because it is different to parameter it.

Links

Documentation

This is an howto which explain how to use Tomcat as a JMS client. Right now it only explain how to configure a resource to get it work with ActiveMQ, Joram, OpenJms and Jboss Messaging.

This is an another howto which explain how to use Tomcat as an EJB client. Right now it only explain how to configure a resource to get it work with OpenEJB.



© Fabien Carrion, 2006 - 2008.

Valid XHTML 1.0 Strict Valid CSS!