2.9 Dependency Injection supported on Cosminexus Application Server

The Dependency Injection (DI) is a functionality for the EJB container to automatically set the reference to EJB and resource by specifying annotations (@EJB, @Resource and @Inject) in a field or the set method of the target class.

Among the classes running on the EJB container, following are the classes that become target classes:

Among the classes running on the Web container, following are the classes that become target classes:

When executing DI for referencing the Enterprise Bean home interface or business interface, specify @EJB.

When specifying @Resource, you can execute DI for the types of resources described in the following table.

Table 2-31 Resource types for which DI can be executed with @Resource

Resource typePermission of DI#1
java.lang.String#2N
java.lang.Character#2N
java.lang.Integer#2N
java.lang.Boolean#2N
java.lang.Double#2N
java.lang.Byte#2N
java.lang.Short#2N
java.lang.Long#2N
java.lang.Float#2N
javax.xml.rpc.ServiceN
javax.xml.ws.ServiceN
javax.jws.WebServiceN
javax.sql.DataSource#3Y
javax.jms.ConnectionFactoryY
javax.jms.QueueConnectionFactory#4Y
javax.jms.TopicConnectionFactoryY
javax.mail.SessionY
java.net.URLN
javax.resource.cci.ConnectionFactory#5Y
org.omg.CORBA_2_3.ORBY#6
javax.jms.Queue#3, #7Y
javax.jms.Topic#7Y
javax.resource.cci.InteractionSpecN
javax.transaction.UserTransactionY#8
javax.ejb.EJBContextY#9
javax.ejb.SessionContextY#9
javax.ejb.TimerServiceY#9, #10
JavaBeans resourceY
Interface unique to the object to be managedY
Legend:
Y: Can be used
N: Cannot be used
#1
The correlation to the object to be managed is established with the mappedName element irrespective of the Java Type. Use !# to demarcate the display name of the resource adapter and the name of the object to be managed.
#2
You cannot specify in <env-entry--value>, therefore, you cannot specify a value acquired in DI, lookup.
#3
Applicable to DB Connector.
#4
Applicable to TP1/Message Queue-Access, Cosminexus RM.
#5
Applicable to uCosminexus TP1 Connector.
#6
Runs considering true is specified for ORB shareable element. Note that the ORB object to be injected is a shared instance that is used even with other components.
#7
When using a resource adapter conforming to Connector 1.5, the object to be managed (javax.jms.Destination interface or sub interface) that is defined in JMS is specified in the <connector>-<resourceadapter>-<adminobject>-<adminobject--interface> tag of the standard DD (ra.xml) of resource adapter.
#8
You cannot use in Enterprise Beans or interceptors that run on CMT.
#9
You cannot use in a class that runs on the Web container.
#10
You cannot use in a Stateful Session Bean and an interceptor applied to Stateful Session Bean.