Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

11.2.2.3. スキャンプロセスからの Bean の除外

概要

Weld の機能の 1 つである CDI の JBoss EAP 6 実装は、アーカイブ内のクラスをスキャンから除外し、コンテナーライフサイクルイベントを発生させ、Bean としてデプロイする機能です。これは JSR-299 仕様の一部ではありません。

例11.1 Bean からパッケージを除外します

次の例には、いくつかの <weld:exclude> タグがあります。
  1. 最初のものはすべての Swing クラスを除外します。
  2. 2 つ目は、Google Web Toolkit がインストールされていない場合、GoogleWebToolkit クラスを除外します。
  3. 3 番目は、システムプロパティーの場合、文字列 Blether (正規表現を使用) で終わるクラスを除外します verbosity に設定されます。
  4. 4 つ目は、Wicket クラスが存在し、 viewlayerシステムプロパティーが設定されていません。
<?xml version="1.0" encoding="UTF-8"?>
<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://docs.jboss.org/cdi/beans_1_0.xsd
          http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
    
    <weld:scan>
      
        <!-- Don't deploy the classes for the swing app! -->
        <weld:exclude name="com.acme.swing.**" />
      
        <!-- 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>
        
        <!--
            Exclude classes which end in Blether if the system property verbosity is set to low
            i.e.
              java ... -Dverbosity=low            
        -->        
        <weld:exclude pattern="^(.*)Blether$">
            <weld:if-system-property name="verbosity" value="low"/>
        </weld:exclude>
        
       <!--
             Don't include JSF support if Wicket classes are present, and the viewlayer system
             property is not set
        -->
        <weld:exclude name="com.acme.jsf.**">
            <weld:if-class-available name="org.apache.wicket.Wicket"/>
            <weld:if-system-property name="!viewlayer"/>
        </weld:exclude>
    </weld:scan>
</beans>
Weld 固有の設定オプションの公式仕様は を参照してください http://jboss.org/schema/weld/beans_1_1.xsd