uCosminexus Application Server, Common Container Functionality Guide

[Contents][Glossary][Index][Back][Next]

2.6.5 Setting the optional names for the Enterprise Beans

This section describes how to set up an optional name for Enterprise Beans.

You can set up an optional name for the Enterprise Beans using the following methods:

This subsection describes the respective methods.

Note that when you use this functionality, you must first specify whether you want to use the optional name, in usrconf.properties of the server management commands. For details on the settings, see 2.6.7 Execution environment settings.

Organization of this subsection
(1) Method of specifying the settings in cosminexus.xml
(2) Method of specifying the settings in annotations
(3) When an optional name is specified in both server management commands and annotations

(1) Method of specifying the settings in cosminexus.xml

To set up the optional name for an Enterprise Bean, you specify the settings in the <ejb-jar> tag of cosminexus.xml. The following table describes the optional name settings for the Enterprise Beans in cosminexus.xml.

Table 2-25 Setting the optional names for the Enterprise Beans in cosminexus.xml

Items Specified tags Settings
Remote interface <session> - <optional-name> tag Specifies the optional name for the remote interface of the Session Bean.
<entity> - <optional-name> tag Specifies the optional name for the remote interface of the Entity Bean.
Local interface <session> - <local-optional-name> tag Specifies the optional name for the local interface of the Session Bean.
<entity> - <local-optional-name> tag Specifies the optional name for the local interface of the Entity Bean.

For details on the specified tags, see 2.2 Details of attributes specified in the Cosminexus application property file (cosminexus.xml) in the uCosminexus Application Server Application and Resource Definition Reference Guide.

Reference note
You can also specify the optional name for the Enterprise Beans using annotations. If the optional name is specified using the annotations and if a different optional name is set up using the server management commands, the value set up with the server management commands becomes valid.
For details, see (3) When an optional name is specified in both server management commands and annotations.

(2) Method of specifying the settings in annotations

You specify the optional name in the mappedName attribute of @Stateless, @Stateful, or @Singleton.

The following is an example of coding when the optional name is specified using annotations. In this example, the optional name "MyFoo" of the Stateless Session Bean is specified in the mappedName attribute of @Stateless.

 
@Stateless(mappedName="MyFoo")
public class FooEB implements FooIF {
 ...
}
 
public interface FooIF {
...
}
 

The optional name specified in the mappedName attribute of @Stateless, @Stateful, or @Singleton is set up in the <hitachi-session-bean-property><mapped-name> tag of the Session Bean property file.

(3) When an optional name is specified in both server management commands and annotations

If the optional name is specified by specifying the mappedName attribute of @Stateless, @Stateful, or @Singleton, and if the optional name is specified in the <optional-name> tag or <local-optional-name> tag in cosminexus.xml, the specification in the <optional-name> tag and <local-optional-name> tag becomes valid.

The following table lists the tags that become valid when the optional name is specified in both server management commands and annotations.

Table 2-26 Tags that become valid when the optional name is specified in both server management commands and annotations

Target for setting up the optional name Only the mappedName attribute of @Stateless, @Stateful, or @Singleton is specified Only the <optional-name> tag or <local-optional-name> tag is specified When both mappedName attribute of @Stateless, @Stateful, or @Singleton, and the <optional-name> tag or <local-optional-name> tag are specified
Remote interface <mapped-name> tag # <optional-name> tag <optional-name> tag
Local interface <mapped-name> tag # <local-optional-name> tag <local-optional-name> tag

#: The tag in which the value specified in the mappedName attribute of @Stateless, @Stateful, or @Singleton is set up.