Ce contenu n'est pas disponible dans la langue sélectionnée.
Appendix A. Reference Material
A.1. EJB Java Naming and Directory Interface Reference Copier lienLien copié sur presse-papiers!
The Java Naming and Directory Interface lookup name for a session bean uses the following syntax:
ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
-
<appName>: If the session bean’s JAR file has been deployed within an enterprise archive (EAR) then theappNameis the name of the respective EAR. By default, the name of an EAR is its file name without the.earsuffix. The application name can be overridden in itsapplication.xmlfile. If the session bean is not deployed in an EAR, then leave theappNameblank. -
<moduleName>: ThemoduleNameis the name of the JAR file in which the session bean is deployed. The default name of the JAR file is its file name without the.jarsuffix. The module name can be overridden in the JAR’sejb-jar.xmlfile. -
<distinctName>: JBoss EAP allows each deployment to specify an optional distinct name. If the deployment does not have a distinct name, then leave thedistinctNameblank. -
<beanName>: ThebeanNameis the simple class name of the session bean to be invoked. -
<viewClassName>: TheviewClassNameis the fully qualified class name of the remote interface. This includes the package name of the interface. -
?stateful: The?statefulsuffix is required when the Java Naming and Directory Interface name refers to a stateful session bean. It is not included for other bean types.
For example, if we deployed hello.jar having a stateful bean org.jboss.example.HelloBean that exposed a remote interface org.jboss.example.Hello, then the Java Naming and Directory Interface lookup name would be:
ejb:/hello/HelloBean!org.jboss.example.Hello?stateful"
ejb:/hello/HelloBean!org.jboss.example.Hello?stateful"
A.2. EJB Reference Resolution Copier lienLien copié sur presse-papiers!
This section covers how JBoss EAP implements @EJB and @Resource. Please note that XML always overrides annotations but the same rules apply.
- Rules for the @EJB annotation
-
The
@EJBannotation also has amappedName()attribute. The specification leaves this as vendor specific metadata, but JBoss EAP recognizesmappedName()as the global Java Naming and Directory Interface name of the EJB you are referencing. If you have specified amappedName(), then all other attributes are ignored and this global Java Naming and Directory Interface name is used for binding. If you specify
@EJBwith no attributes defined:@EJB ProcessPayment myEjbref;
@EJB ProcessPayment myEjbref;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Then the following rules apply:
-
The EJB JAR of the referencing bean is searched for an EJB with the interface used in the
@EJBinjection. If there are more than one EJB that publishes same business interface, then an exception is thrown. If there is only one bean with that interface then that one is used. - Search the EAR for EJB that publish that interface. If there are duplicates, then an exception is thrown. Otherwise the matching bean is returned.
- Search globally in JBoss EAP runtime for an EJB of that interface. Again, if duplicates are found, an exception is thrown.
-
The EJB JAR of the referencing bean is searched for an EJB with the interface used in the
-
@EJB.beanName()corresponds to<ejb-link>. If thebeanName()is defined, then use the same algorithm as@EJBwith no attributes defined except use thebeanName()as a key in the search. An exception to this rule is if you use the ejb-link # syntax: it allows you to put a relative path to a JAR in the EAR where the EJB you are referencing is located. Refer to the EJB 3.2 specification for more details.
-
The
A.3. Project Dependencies for Remote EJB Clients Copier lienLien copié sur presse-papiers!
Maven projects that include the invocation of session beans from remote clients require the following dependencies from the JBoss EAP Maven repository. There are two ways to declare EJB client dependencies, as described in the sub-sections below.
The artifactId versions are subject to change. See the JBoss EAP Maven Repository for the latest versions.
Maven Dependencies for Remote EJB Clients
The jboss-eap-jakartaee8 Bill of Materials (BOM) packages the correct version of many of the artifacts commonly required by a JBoss EAP application. The BOM dependency is specified in the <dependencyManagement> section of the pom.xml with the scope of import.
Example: POM File <dependencyManagement> Section
The remaining dependencies are specified in the <dependencies> section of the pom.xml file.
Example: POM File <dependencies> Section
The ejb-remote quickstart that ships with JBoss EAP provides a complete working example of remote EJB client application. See the client/pom.xml file located in root directory of that quickstart for a complete example of dependency configuration for remote session bean invocation.
Single artifactID for jboss-ejb-client Dependencies
You can use the wildfly-ejb-client-bom artifactID and add the jboss-ejb-client library to include all the required dependencies for EJB clients:
You must use the EJB_CLIENT_BOM_VERSION that is available in the JBoss EAP Maven repository.
A.4. jboss-ejb3.xml Deployment Descriptor Reference Copier lienLien copié sur presse-papiers!
jboss-ejb3.xml is a custom deployment descriptor that can be used in either EJB JAR or WAR archives. In an EJB JAR archive it must be located in the META-INF/ directory. In a WAR archive it must be located in the WEB-INF/ directory.
The format is similar to ejb-jar.xml, using some of the same namespaces and providing some other additional namespaces. The contents of jboss-ejb3.xml are merged with the contents of ejb-jar.xml, with the jboss-ejb3.xml items taking precedence.
This document only covers the additional non-standard namespaces used by jboss-ejb3.xml. See http://java.sun.com/xml/ns/javaee/ for documentation on the standard namespaces.
The root namespace is http://www.jboss.com/xml/ns/javaee.
- Assembly descriptor namespaces
-
The following namespaces can all be used in the
<assembly-descriptor>element. They can be used to apply their configuration to a single bean, or to all beans in the deployment by using a wildcard (*) as theejb-name. - The security namespace (
urn:security) xmlns:s="urn:security"
xmlns:s="urn:security"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This allows you to set the
security-domainand therun-as-principalfor an EJB.<s:security> <ejb-name>*</ejb-name> <s:security-domain>myDomain</s:security-domain> <s:run-as-principal>myPrincipal</s:run-as-principal> </s:security>
<s:security> <ejb-name>*</ejb-name> <s:security-domain>myDomain</s:security-domain> <s:run-as-principal>myPrincipal</s:run-as-principal> </s:security>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The resource adapter namespace:
urn:resource-adapter-binding xmlns:r="urn:resource-adapter-binding"
xmlns:r="urn:resource-adapter-binding"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This allows you to set the resource adapter for a Message-Driven Bean.
<r:resource-adapter-binding> <ejb-name>*</ejb-name> <r:resource-adapter-name>myResourceAdapter</r:resource-adapter-name> </r:resource-adapter-binding>
<r:resource-adapter-binding> <ejb-name>*</ejb-name> <r:resource-adapter-name>myResourceAdapter</r:resource-adapter-name> </r:resource-adapter-binding>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The IIOP namespace:
urn:iiop xmlns:u="urn:iiop"
xmlns:u="urn:iiop"Copy to Clipboard Copied! Toggle word wrap Toggle overflow The IIOP namespace is where IIOP settings are configured.
- The pool namespace:
urn:ejb-pool:1.0 xmlns:p="urn:ejb-pool:1.0"
xmlns:p="urn:ejb-pool:1.0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This allows you to select the pool that is used by the included stateless session beans or Message-Driven Beans. Pools are defined in the server configuration.
<p:pool> <ejb-name>*</ejb-name> <p:bean-instance-pool-ref>my-pool</p:bean-instance-pool-ref> </p:pool>
<p:pool> <ejb-name>*</ejb-name> <p:bean-instance-pool-ref>my-pool</p:bean-instance-pool-ref> </p:pool>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The cache namespace:
urn:ejb-cache:1.0 xmlns:c="urn:ejb-cache:1.0"
xmlns:c="urn:ejb-cache:1.0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This allows you to select the cache that is used by the included stateful session beans. Caches are defined in the server configuration.
<c:cache> <ejb-name>*</ejb-name> <c:cache-ref>my-cache</c:cache-ref> </c:cache>
<c:cache> <ejb-name>*</ejb-name> <c:cache-ref>my-cache</c:cache-ref> </c:cache>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThere are known issues with the
jboss-ejb3-spec-2_0.xsdfile that may result in schema validation errors. You can ignore these errors. For more information, see https://bugzilla.redhat.com/show_bug.cgi?id=1192591.
A.5. Configure an EJB Thread Pool Copier lienLien copié sur presse-papiers!
You can create an EJB thread pool using the management console or the management CLI.
A.5.1. Configuring an EJB Thread Pool Using the Management Console Copier lienLien copié sur presse-papiers!
Procedure
- Log in to the management console.
-
Navigate to Configuration
Subsystems EJB and click View. -
Select Container
Thread Pool. - Click Add and specify the Name and Max Threads values.
- Click Save.
A.5.2. Configure an EJB Thread Pool Using the Management CLI Copier lienLien copié sur presse-papiers!
Procedure
Use the
addoperation with the following syntax:/subsystem=ejb3/thread-pool=THREAD_POOL_NAME:add(max-threads=MAX_SIZE)
/subsystem=ejb3/thread-pool=THREAD_POOL_NAME:add(max-threads=MAX_SIZE)Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
THREAD_POOL_NAMEwith the required name for the thread pool. -
Replace
MAX_SIZEwith the maximum size of the thread pool.
-
Replace
Use the
read-resourceoperation to confirm the creation of the thread pool:/subsystem=ejb3/thread-pool=THREAD_POOL_NAME:read-resource
/subsystem=ejb3/thread-pool=THREAD_POOL_NAME:read-resourceCopy to Clipboard Copied! Toggle word wrap Toggle overflow To reconfigure all the services in the
ejb3subsystem to use a new thread pool, use the following commands:/subsystem=ejb3/thread-pool=bigger:add(max-threads=100, core-threads=10) /subsystem=ejb3/service=async:write-attribute(name=thread-pool-name, value="bigger") /subsystem=ejb3/service=remote:write-attribute(name=thread-pool-name, value="bigger") /subsystem=ejb3/service=timer-service:write-attribute(name=thread-pool-name, value="bigger") reload
/subsystem=ejb3/thread-pool=bigger:add(max-threads=100, core-threads=10) /subsystem=ejb3/service=async:write-attribute(name=thread-pool-name, value="bigger") /subsystem=ejb3/service=remote:write-attribute(name=thread-pool-name, value="bigger") /subsystem=ejb3/service=timer-service:write-attribute(name=thread-pool-name, value="bigger") reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow XML Configuration Sample:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
A.5.3. EJB Thread Pool Attributes Copier lienLien copié sur presse-papiers!
EJB thread pools can be configured using attributes to run more efficiently for specific configuration needs.
-
The
max-threadsattribute determines the total or maximum number of threads that the executor supports.
/subsystem=ejb3/thread-pool=default:write-attribute(name=max-threads, value=9)
{"outcome" => "success"}
/subsystem=ejb3/thread-pool=default:write-attribute(name=max-threads, value=9)
{"outcome" => "success"}
-
The
core-threadsattribute determines the number of threads that are kept in the executor’s pool. This includes idle threads. If thecore-threadsattribute is not specified, it will default to the value ofmax-threads.
/subsystem=ejb3/thread-pool=default:write-attribute(name=core-threads, value=3)
{"outcome" => "success"}
/subsystem=ejb3/thread-pool=default:write-attribute(name=core-threads, value=3)
{"outcome" => "success"}
-
The
keepalive-timeattribute determines the amount of time that a non-core thread will be allowed to remain idle. After this time, the non-core thread is removed.
/subsystem=ejb3/thread-pool=default:write-attribute(name=keepalive-time, value={time=5, unit=MINUTES})
{"outcome"=> "success"}
/subsystem=ejb3/thread-pool=default:write-attribute(name=keepalive-time, value={time=5, unit=MINUTES})
{"outcome"=> "success"}
-
To change the time without changing the units of time for the
keepalive-timeattribute, use the following command:
/subsystem=ejb3/thread-pool=default:write-attribute(name=keepalive-time.time, value=10)
{"outcome"=> "success"}
/subsystem=ejb3/thread-pool=default:write-attribute(name=keepalive-time.time, value=10)
{"outcome"=> "success"}
Revised on 2022-02-01 13:02:13 UTC