I provide a library (lets call it event-source-lib) which abstracts the implementation of a datasource (in this case an eventstore) from my business services. Within the library I want to inject an eventstore datasource via a local application scoped JNDI namespace resource lookup:
@Resource(lookup="java:app/jdbc/eventstore")
Datasource eventstore;
This is because I have many separate microservices in a JEE container which are using using separate datasources. I want the container to determine which datasource to assign to java:app/eventstore for each microservice.
The naming subsystem in the JBoss wildfly standalone.xml does not seem to support local portable JNDI namespaces, it only supports :jboss, :global and :/.
How can I achieve this? Is there a way to declare global resources and map to local scoped portable JNDI namespaces? I notice that AppName is in the correct namespace, but I have no idea how to add stuff there.
I suspect that jboss-app.xml or jboss-web.xml may be the answer but I cannot find a good example. I am deploying my services as separate war files, they are NOT wrapped up in an ear.