Java EE 8一直在发展,并且已经提出了几个新的组件JSR。 JSR 365将定义CDI 2.0的规范。 红帽公司已经开始研究Weld 3的实现原型,并且Alpha3最近发布了 。
Red Hat的Java EE 8兼容应用服务器将是WildFly,将在其中实现所有不同的技术。 同时,您如何尝试这些早期实验版本?
技术提示29显示了如何修补先前版本的WildFly8.x。 本技巧将利用该机制在WildFly 8.2中安装Weld 3 Alpha3。 您也可以下载Weld 3 Alpha3 Standalone或Weld 3 Alpha3作为WildFly 9.0 Alpha1的补丁 。
说明非常简单:
- 下载并解压缩WildFly 8.2 :
http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zip unzip wildfly-8.2.0.Final.zip
- 下载WildWly 8.2的Weld 3 Alpha3补丁 :
curl -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
- 将补丁应用为(也可以在补丁中捆绑的自述文件中找到):
./wildfly-8.2.0.Final/bin/jboss-cli.sh --command="patch apply ./weld3-alpha3-patch-wildfly8.2.zip" {"outcome" : "success","result" : {} }
- 启动WildFly:
./wildfly-8.2.0.Final/bin/standalone.sh
- 从javaee7-samples运行一个简单的CDI测试:
mvn -f cdi/nobeans-xml/pom.xml test -Dwildfly-remote-arquillian
并在WildFly控制台中看到的输出为:
20: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/content 20: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.war 20:53:30,953 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-5) HV000001: Hibernate Validator 5.1.3.Final 20:53:31,131 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016005: Starting Services for CDI deployment: test.war 20: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.war 20:53:32,141 INFO [org.wildfly.extension.undertow] (MSC service thread 1-15) JBAS017534: Registered web context: /test 20: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: /test 20:53:33,464 INFO [org.jboss.weld.deployer] (MSC service thread 1-16) JBAS016009: Stopping weld service for deployment test.war 20:53:33,490 INFO [org.jboss.as.server.deployment] (MSC service thread 1-12) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 40ms 20: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/content 20:53:33,498 INFO [org.jboss.as.server] (management-handler-thread - 1) JBAS018558: Undeployed "test.war" (runtime-name: "test.war")
注意,“ 3.0.0(Alpha 3)”的焊接版本在日志中正确显示。
就功能而言,这是到目前为止可用的功能:
- 使用
@Priority
的观察者方法的声明式排序 - 扩展否决权和修改观察者方法的能力
- 支持Java 8可重复注释作为限定符和拦截器绑定
- 增强的
AnnotatedType
API - 异步事件
- 简化焊接专用属性的配置
- 番石榴不再在内部使用
更多的细节,包括代码示例,在Weld 3.0.0 Alpha1 Released和Weld 3的更新中进行了说明 。 所有原型API都在org.jboss.weld.experimental
软件包中,以指示早期性质。
以下是一些资源供您查看:
- Java文档
- Maven坐标
org.jboss.weldweld-api3.0.Alpha3
- 在Weld论坛或cdi-dev邮件列表中的反馈。
创建了Java EE 8 Samples存储库 ,并将开始在那里添加一些CDI 2.0示例,敬请期待。
请享用!
翻译自: https://www.javacodegeeks.com/2014/12/patching-weld-3-in-wildfly-8-2-first-experimental-ri-of-java-ee-8.html