Mitch Pronschinske is the Lead Research Analyst at DZone. Researching and compiling content for DZone's research guides is his primary job. He likes to make his own ringtones, watches cartoons/anime, enjoys card and board games, and plays the accordion. Mitch is a DZone Zone Leader and has posted 2578 posts at DZone. You can read more from them at their website. View Full User Profile

Weld 1.0.1 Runs on GAE

02.10.2010
| 13987 views |
  • submit to reddit
In the last 24 hours, the Weld team at JBoss has pushed out a full distribution of the second candidate release for Weld 1.0.1.  Weld is the open source JBoss reference implementation of the Contexts and Dependency Injection (CDI) specification, which was approved only a few months ago along with the Java EE 6 spec.  The first 1.0.1 candidate release was only published as artifacts to the Maven Central Repository, but CR2 is the first Weld 1.0.1 release in the form of a full distribution.  Even though it's a tiny version number change, Weld 1.0.1 includes some significant new features like support for running on Google App Engine, stronger Java SE support, and the improved CDI TCK (Technology Compatibility Kit).

GAE Support
In addition to many bug fixes and major memory usage improvements, Weld 1.0.1 now has basic support for running on Google App Engine's scalable infrastructure.  This support was made possible with the help of the Weld community, which identified the patch assumptions that prevented Weld from running on GAE.  Moving forward, the Weld developers will look for more outstanding conflicts and resolve them in order to make Weld go beyond just basic support.  If you're anxious to get started, there's a demonstration already posted on the JBoss blog that shows developers how to avoid certain pitfalls and get their CDE + JSF 2 applications up and running on GAE.  The post is the first part of a GAE tutorial series that will take developers through App Engine signup, installing the GAE SDK plugin for Eclipse, managing required CDI and JSF libraries and configurations, and then deployment.  You can go see the an example of the Weld numberguess application on appspot for proof of this support.

Weld SE
JBoss says that the Java SE support is what really sets Weld apart from other CDI RIs like Resin CanDI and Apache OpenWebBeans.  In Weld 1.0.1 CR2, several improvements have been made to the Java SE support.  Now there is documented support for interceptors and decorators along with a refactoring to use the standard BeforeShutdown event.  The Weld team says the most noticeable improvement in the Java SE support is the simplification of the bootstrap API (new Weld()).  Example below:
Weld weld = new Weld().initialize();
weld.instance().select(Foo.class).get();
weld.event().select(Bar.class).fire(new Bar());
weld.shutdown();

Weld CDI TCK
Version 1.0.1 will now include the CDI TCK, which has gotten a lot of improvements recently thanks to the Apache OpenWebBeans team.  By resolving deficiencies such as broken tests and invalid spec interpretations, the CDI TCK has become much more robust.  

Weld is included in JBoss AS 6 and Glassfish v3 (and in WebProfile development).  For JBoss AS users on the bleeding edge (version 6 M2), AS 6 snapshots will allow you to get the Weld 1.0.1 CR2 out of box experience.  Another option is to update the JBoss AS 6 installation using the following command from the root of the Weld distribution:

JBOSS_HOME=/path/to/jboss-as-6 mvn -f jboss-as/pom.xml

Here is a list of benefits that CDI offers:
  • Improved lifecycle for stateful objects, bound to well-defined contexts
  • A typesafe approach for dependency injection
  • Object interaction through an event notification facility
  • A better method for binding interceptors to objects
  • A new interceptor that is more appropriate for use in solving business problems, called a decorator
  • An SPI for building portable extensions to the container.

CR2 is now available for the final inspection stage.  The Weld team would like as much feedback from the open source community as possible before the final release of Weld 1.0.1 on February 19th.  Moving forward, the Weld team plans on building the next version of Weld (1.0.2) over the next three months, focusing on performance, scalability, and bug fixes.  They will also be shifting some of the team's focus to Seam 3 development.

Comments

Reza Rahman replied on Wed, 2010/02/10 - 4:56pm

Mitchell,

Just a minor point - Resin CanDI can actually run in Java SE as an embedded runtime with full support for all enterprise services including @TransactionAttribute, @Schedule, @Asynchronous, @Lock and @Startup. We can certainly run CanDI on GAE if there is sufficient interest in the community.

Cheers,

Reza

========================

Resin EJB 3.1 Lite Container Developer

Exper Group Member, Java EE 6 and EJB 3.1

Author, EJB 3 in Action

Edvin Syse replied on Thu, 2010/03/25 - 4:07pm

I see this bootstrap example all over the web, but i believe that it is incorrect.

Weld weld = new Weld().initialize();

initialize() returns a WeldContainer object, so the line should be:

WeldContainer container = new Weld.initialize()

The problem is that without the reference to the Weld object, you cannot shutdown the container. I believe that the complete example should be something like:

Weld weld = new Weld();
WeldContainer container = weld.initialize();
container.instance().select(Foo.class).get();
container.event().select(Bar.class).fire(new Bar());
weld.shutdown();

Please correct me if I'm wrong :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.