Mitch Pronschinske is a Senior Content Analyst at DZone. That means he writes and searches for the finest developer content in the land so that you don't have to. He often eats peanut butter and bananas, likes to make his own ringtones, enjoys card and board games, and is married to an underwear model. Mitch is a DZone Zone Leader and has posted 2574 posts at DZone. You can read more from them at their website. View Full User Profile

Weld Chugging Along

08.31.2010
| 7662 views |
  • submit to reddit
The first beta for the next version of JBoss' Weld is here.  It has been approximately six months since JBoss released Weld 1.0.1, which added support for running on Google AppEngine.  The new beta for Weld 1.1 features about 60 bugfixes and new EJB 3.1 features.

Weld 1.1, the reference implementation of JSR-299: Contexts and Dependency Injection is based on the CDI 1.0 API.  Weld is being integrated into the JBoss Application Server, and version 1.1 should be available in the next release of JBoss AS 6.0.  Until then you'll need to use a snapshot build of JBoss AS.  Weld is also used in GlassFish v3 and supports several servlet containers such as Tomcat and Jetty.

Here are some of the new features in Weld 1.1:

  • Weld has migrated to Google Guava from google-collections
  • New EJB 3.1 features displayed in the new Pastecode example
  • Improvements in error reporting
  • Better memory usage
  • Unsafe instantiators
  • A new proxy layer that doesn't suffer from the memory leaks in Javasssist
  • About 60 bugfixes

Weld 1.1 also has the ability to exclude classes from being scanned and then deployed as beans.  This is achieved by configuring the beans.xml for the bean archive being deployed.  beans.xml may be parsed outside of Weld.

Here's an example of the configuration:
<beans xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:weld="http://jboss.org/schema/weld/beans"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd
http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">

<weld:scan>
<!-- Don't include GWT support if GWT is not installed -->
<weld:exclude name="com.acme.gwt.**">
<weld:if-class-available name="!com.google.GWT"/>
</weld:exclude>
</weld:scan>

</beans>
Another way to use Weld is with Java SE.  There is also strong support for Weld in the emerging Arquillian testing framework, which allows you to test in Weld SE, Tomcat, Jetty, JBoss AS, GlassFish, or a mocked out Java EE container.

You can find the 1.0.2 version of the CDI TCK here.