uCosminexus Application Server, EJB Container Functionality Guide
You set up an interceptor as an EJB-JAR property either by specifying in an annotation or by using a DD or a property file.
The default interceptor is applicable to all the components included in EJB-JAR.
In a DD, you can specify the information of the default interceptor by coding the <interceptor-binding> tag below the <ejb-jar> tag.
The following table describes the components to be specified below the <interceptor-binding> tag:
Table 2-46 Components (default interceptor) to be specified below the <interceptor-binding> tag when using a DD
Tag names | Optional/ Required |
Contents of the file |
---|---|---|
<description> | Optional | Specify any information. |
<ejb-name> | Required | Specify a wild card (*). |
<interceptor-class> | Required | Specify the class name of the interceptor class in the element. |
The value of the components specified in any other tag is not applied.
The following is an example of coding of the DD when the default interceptor is used:
<ejb-jar> ... <assembly-descriptor> <interceptor-binding> <description xml:lang="en">Default Interceptor</description> <ejb-name>*</ejb-name> <interceptor-class>test.ejb30.MyDefaultIC</interceptor-class> <interceptor-class>test.ejb30.MyDefaultIC2</interceptor-class> </interceptor-binding> </assembly-descriptor> ... </ejb-jar> |
In this example of coding, test.ejb30.MyDefaultIC and test.ejb30.MyDefaultIC2 are specified as the default interceptor classes.
The specification method of the class name in the interceptor-class tag conforms to the EJB 3.0 specification. Specify as per the following rules:
For details on annotations, see 2. Dependency Injection and Annotation corresponding to the annotation servers in the uCosminexus Application Server API Reference Guide.
The class level interceptor is applicable to the specified classes. This point describes how to set a class level interceptor by using a DD and by using the EJB-JAR property file in the execution environment.
In a DD, you can specify the information of the class level interceptor by describing the <interceptor-binding> tag below the <ejb-jar> tag.
The following table describes the elements below the <interceptor-binding> tag.
Table 2-47 Elements (class level interceptor) to be specified below the <interceptor-binding> tag when using a DD tag
Tag name | Mandatory/Optional | Contents to be specified |
---|---|---|
<ejb-name> | Mandatory | Specify EJB name. |
<interceptor-class> | Mandatory | Specify the class name of the interceptor class in the element. |
Note that elements are not specified in the <method> tag.
The method level interceptor is applicable to the specified business methods. This point describes how to set a method level interceptor by using a DD and by using the EJB-JAR property file in the execution environment.
In a DD, you can specify the information of the method level interceptor by describing the <interceptor-binding> tag below the <ejb-jar> tag.
The following table describes the elements below the <interceptor-binding> tag.
Table 2-48 Elements (method level interceptor) to be specified below the <interceptor-binding> tag when using a DD tag
Tag name | Mandatory/Optional | Contents to be specified |
---|---|---|
<ejb-name> | Mandatory | Specify the EJB name. |
<interceptor-class> | Mandatory | Specify the class name of the interceptor class in the element. |
<method-name> | Mandatory | Specify the method name in the element. |
<method-params> | Optional | Specify the argument list for the method in the element. |
The following table describes the range of the business methods that define the method level interceptor when you specify a business method in the <method-name> tag and you omit the value specified for the <method-params> tag or you specify the argument list in the <method-params> tag. Note that when * (wild card) is specified in the <method-name> tag, the definition of the method level interceptor is not used.
Table 2-49 Range of business methods that define the method level interface
Value specified in the <method-params> tag | Range of business methods that define the method level interceptor |
---|---|
The value is omitted. | An interceptor is defined for all business methods that have exactly matching method names. |
An argument list is specified. | An interceptor is defined for the business methods that have exactly matching method names and argument list. If you specify an argument list, you can overwrite the information specified in an annotation in the DD. |
The definition of the method level interceptor that is used when executing a business method is determined in the following order:
Note that when the business method to be executed corresponds to both definitions, namely the definition in which the method specified in the <method-name> tag and the argument list specified in the <method-params> tag match completely, and the definition in which the method specified in the <method-name> tag is matching and the argument list is not specified in the <method-params> tag, then the definition that completely matches with the method name and argument list is used.
Also, the method level interceptor specified using annotations is handled as a definition in which the method names and the argument list match completely. If you want to overwrite the method level interceptor specified using annotations in DD, you must describe the interceptor in DD by using a definition in which the method names and the argument list match completely.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.