Java EE 8 is moving along and several new component JSRs have been filed. JSR 365 will define the specification for CDI 2.0. Red Hat has already started working on the implementation prototype in Weld 3 and Alpha3 was released recently.
The Java EE 8 compliant application server from Red Hat will be WildFly where all the different technologies will be implemented. In the meanwhile, how do you try out these early experimental releases?
Tech Tip #29 showed how to patch WildFly 8.x from a previous release. This tip will leverage that mechanism to install Weld 3 Alpha3 in WildFly 8.2. You can also download Weld 3 Alpha3 Standalone or Weld 3 Alpha3 as patch to WildFly 9.0 Alpha1.
The instructions are rather simple:
- Download and unzip WildFly 8.2:
1234http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zipunzip wildfly-8.2.0.Final.zip - Download Weld 3 Alpha3 Patch for WildFly 8.2:
123curl -L -o weld3-alpha3-patch-wildfly8.2.zip http://sourceforge.net/projects/jboss/files/Weld/3.0.0.Alpha3/wildfly-8.2.0.Final-weld-3.0.0.Alpha3-patch.zip/download - Apply the patch as (also available in README bundled in the patch):
1234567./wildfly-8.2.0.Final/bin/jboss-cli.sh --command="patch apply ./weld3-alpha3-patch-wildfly8.2.zip"{"outcome" : "success","result" : {}} - Start WildFly:
123./wildfly-8.2.0.Final/bin/standalone.sh - Run a simple CDI test from javaee7-samples:
123mvn -f cdi/nobeans-xml/pom.xml test -Dwildfly-remote-arquillian
1234567891011121314151620:53:30,434 INFO [org.jboss.as.repository] (management-handler-thread - 1) JBAS014900: Content added at location /Users/arungupta/tools/weld3/wildfly-8.2.0.Final/standalone/data/content/4c/c6675b4f1fb33fe40dda3f94ac4979b3e2a4d0/content20:53:30,453 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "test.war" (runtime-name: "test.war")20:53:30,878 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016002: Processing weld deployment test.war20:53:30,953 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-5) HV000001: Hibernate Validator 5.1.3.Final20:53:31,131 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016005: Starting Services for CDI deployment: test.war20:53:31,163 INFO [org.jboss.weld.Version] (MSC service thread 1-5) WELD-000900: 3.0.0 (Alpha3)20:53:31,195 INFO [org.jboss.weld.deployer] (MSC service thread 1-9) JBAS016008: Starting weld service for deployment test.war20:53:32,141 INFO [org.wildfly.extension.undertow] (MSC service thread 1-15) JBAS017534: Registered web context: /test20:53:32,178 INFO [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "test.war" (runtime-name : "test.war")20:53:33,454 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017535: Unregistered web context: /test20:53:33,464 INFO [org.jboss.weld.deployer] (MSC service thread 1-16) JBAS016009: Stopping weld service for deployment test.war20:53:33,490 INFO [org.jboss.as.server.deployment] (MSC service thread 1-12) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 40ms20:53:33,497 INFO [org.jboss.as.repository] (management-handler-thread - 1) JBAS014901: Content removed from location /Users/arungupta/tools/weld3/wildfly-8.2.0.Final/standalone/data/content/4c/c6675b4f1fb33fe40dda3f94ac4979b3e2a4d0/content20:53:33,498 INFO [org.jboss.as.server] (management-handler-thread - 1) JBAS018558: Undeployed "test.war" (runtime-name: "test.war")
In terms of features, here is what is available so far:
- Declarative ordering of observer methods using
@Priority
- Ability for an extension to veto and modify an observer method
- Support for Java 8 repeatable annotations as qualifiers and interceptor bindings
- Enhanced
AnnotatedType
API - Asynchronous events
- Simplified configuration of Weld-specific properties
- Guava is no longer used internally
More details, including code samples, are explained in Weld 3.0.0 Alpha1 Released and An update on Weld 3. All the prototyped API is in org.jboss.weld.experimental
package indicating the early nature.
Here are some resources for you to look at:
- Javadocs
- Maven coordinates
1234567<dependency><groupId>org.jboss.weld</groupId><artifactId>weld-api</artifactId><version>3.0.Alpha3</version></dependency> - Feedback at Weld forums or the cdi-dev mailing list.
Created Java EE 8 Samples repository and will start adding some CDI 2.0 samples there, stay tuned.
Enjoy!