16.3. JAXB アノテーションの概要設定の作成
設定の XSD は、でオンラインで http://anonsvn.jboss.org/repos/jbossws/projects/jaxbintros/tags/1.0.0.GA/src/main/resources/jaxb-intros.xsd 利用できます。(IDE で、この XSD を namespace に対して登録し http://www.jboss.org/xsd/jaxb/intros ます。)
- @XmlType
- @XmlElement
- https://jaxb.dev.java.net/nonav/2.1.3/docs/api/javax/xml/bind/annotation/XmlElement.html: これは、Field 要素およびMethod 要素になります。
- @XmlAttribute
- https://jaxb.dev.java.net/nonav/2.1.3/docs/api/javax/xml/bind/annotation/XmlAttribute.html: これは、Field 要素およびMethod 要素になります。
設定ファイルの基本構造は、Java クラス(つまり、Fields および Methods を含むクラス)に従います。 <Class>、<Field>、および <Method> 要素はすべて name 属性を必要とします。この属性は、クラス、フィールド、またはメソッドの名前を指定します。この name 属性の値は正規表現をサポートできます。これにより、単一のアノテーション導入設定を複数のクラス、フィールド、またはメンバーでターゲットに設定できます。たとえば、クラス内のフィールドに name-space を設定したり、パッケージのすべてのクラスに対して名前スペースを設定したりできます。
アノテーションのIntroduction 設定はアノテーション定義自体と完全に一致します。各アノテーションの element-value pair はアノテーション導入設定の属性によって表されます。XSD と IDE を使用して設定を編集します。
以下に例を示します。
<?xml version = "1.0" encoding = "UTF-8"?>
<jaxb-intros xmlns="http://www.jboss.org/xsd/jaxb/intros">
<!--
The type namespaces on the customerOrder are
different from the rest of the message...
-->
<Class name="com.activebpel.ordermanagement.CustomerOrder">
<XmlType propOrder="orderDate,name,address,items" />
<Field name="orderDate">
<XmlAttribute name="date" required="true" />
</Field>
<Method name="getXYZ">
<XmlElement
namespace="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager"
nillable="true" />
</Method>
</Class>
<!-- More general namespace config for the rest of the message... -->
<Class name="com.activebpel.ordermanagement.*">
<Method name="get.*">
<XmlElement namespace="http://ordermanagement.activebpel.com/jaws" />
</Method>
</Class>
</jaxb-intros>