JBoss configuration and usage
The intent of this file is not to provide a full documentation about JBoss, EJBs or dependency injection but to give some hints that might be useful when working on the project.
Main configuration file
A JBoss application server is configured mostly using XML files. The most important one is the standalone.xml
which is located in docker/wildfly/standalone.xml.
The basic structure seems to be generated (guess made by second project team) but manual modifications hab do be made, too. For example the connection of the PostgreSQL JDBC driver is configured here.
Building and deploying the services
To see how to run the application, go to the readme file.
When building with gradle, the modules result in seperate .war
archives which are copied into the JBoss docker container. JBoss should then reload them automatically.
In case you are unsure whether the deployment succeeded following the console output, you can use the JBoss admin web app to see if the services have been deployed into the running server.
The web app can be entered at http://localhost:9990/. When credentials are requested, enter admin
as username and Admin
as password (case sensitive!) which is the default for this console. Navigate to Deployments
where the modules should be listed if deployment worked fine.
Using depedency injection to request services
To use an EJB it can be requested using dependency injection. The dependency injection provider which is responsible for the work behind the system is JNDI
. Use the following style to request an EJB instance.
@Resource(lookup = "java:global/global/ApplicationBean")
private Application application;
The 'global' part of the lookup uri is unrelated to the global
module but means that a globally available service is required. The field type has to be an interface type and the name at the end of the lookup uri has to be the appropriate implementation.
Providing services for dependency injection
Declaring a class as EJB makes it automatically available for usage per dependency injection. Therefor an interface with the @Remote
annotation is required if the service should be available in other modules as well. Use @Local
otherwise.
The implementing service class can have either @Stateless
, @Stateful
or @Singleton
. It is recommended to use stateless EJBs if possible.
EJBs should always be created and managed by JBoss and never be instantiated manually using the new
keyword. This is mandatory to make things like dependency injection work.