- Current Difficulties with Java Web Services
- A New Framework for Java Web Services
A New Framework for Java Web Services
Having read this far, you may have the impression that I’m not a huge fan of JAX-*. Actually, that’s not true. Those standards are powerful and necessary parts of Java. They provide a toolset for creating web services.
However, what we need is a framework, not just a toolset. At Proxisoft, we discovered how to create an easy-to-use web services framework on top of the JAX-* toolset. And how to decouple it from source code, and make it framework-aware. We’ve developed the “ON/OFF” switch for web services and released it as our Netrifex product.
Zero Coding (Almost)
Most of the complex programming described earlier can be automated using algorithms that traverse class dependencies and insert annotations where needed. The algorithms developed by Proxisoft provide a default binding that applies annotations in a standard manner. In addition to eliminating complex and time-consuming programming, this approach has the advantage of standardization.
The Proxisoft algorithms also deal with the complexities of missing no-arg constructors. This is a non-trivial problem, and our solution cannot be adequately described in this short article. However, the basic idea for missing no-arg constructors involves adding them and tracing code (both at compile and runtime) to ensure proper initialization of instances that get constructed for web services processing.
We also handle the other problems I described: parameters and return types that are interfaces or abstract classes, and cyclic class dependencies. Interfaces and abstract classes are dealt with by employing substitutable types. In essence, we identify the concrete classes that implement an interface and inject the annotations necessary so that our web services can substitute the appropriate class for an interface. Cyclic class dependencies are also identified and handled with a default implementation of CycleRecoverable in the appropriate places.
These algorithms produce the default web services. The defaults can be tweaked or augmented if desired, but are also usable right “out of the box.”
Bytecode, Not Source Code
The Proxisoft algorithms, as implemented in Netrifex, can be applied at runtime because they work with Java bytecode. Netrifex employs new technology, which we call bytecode mirroring, that generates web services against a mirror image of an application’s bytecode. As a result, you can add web services to an existing application, at runtime, in production, without modifying the original code in any way.
At runtime, Netrifex maintains a mirror of the application bytecode that is needed to support web services. Netrifex modifies this mirrored code to web-serviceenable it using the algorithms described earlier. The modified bytecode’s web services are deployed in a service layer, separated from the running application. When a web service gets invoked, Netrifex uses the modified bytecode in the mirror to deserialize the request into Java instances. Then, Netrifex delegates the invocation of the corresponding Java method to the unmodified application.
As a result, web services created and deployed using Netrifex are extremely agile. The mirrored bytecode can be modified, on-the-fly, at runtime, without requiring any changes in the underlying application.
Framework Awareness
In addition to algorithms that automate the JAX-* annotation process, we have also developed algorithms that can intelligently generate web services that leverage existing frameworks like Struts and Spring.
Recall the Struts e-commerce application discussed earlier. Suppose that it has an Action class for processing purchase orders called ProcessOrderAction. For a variety of reasons, you cannot simply annotate a Struts Action class and deploy it as a meaningful web service. Netrifex solves these problems by generating a wrapper class for ProcessOrderAction. This wrapper class can be annotated to provide a useful web service, and delegate the processing of invocations to the original ProcessOrderAction class.
Proxisoft has identified wrapper patterns that can be applied to classes developed in Struts and Spring. These patterns are used by Netrifex to generate and deploy web services that are integrated with the underlying application framework. New patterns and frameworks are continually being added to Netrifex. In the next release, there will be features making it easy for users to add their own patterns to support their own frameworks.
Conclusion
Proxisoft has made considerable progress toward simplifying Java Web Services. We are aiming to replace a complex and cumbersome programming process with a simple “ON/OFF” switch.
From the beginning, our approach has been to leverage the power of JAX-* while shielding developers from its programming complexity. In the process, we’ve invented a new framework based on sophisticated algorithms and new approaches for web-serviceenablement.
Our framework has been implemented in the Netrifex product. I encourage you to give Netrifex a try. You can download a free trial here. If you have any comments or suggestions, please send me an email.