Use JNDI to Configure your Java EE App

There are a lot of people talking about Java EE configuration these days. But often they forget about JNDI (Java Naming and Directory Interface).

Configuration using JNDI has the advantage that you can use dependency injection. i.e.

@Resource(mappedName = “java:global/mystring”)
private String mystring;

The configuration for example in JBosss EAP or Wildfly is pretty simple made in the standalone.xml (or domain.xml) file:

    <simple name="java:global/mystring" 
            value=”My String” 

As you can see the type can be defined. If you need more complex objects simply use ObjectFactory

Read more about JNDI in WildFly:
and more about ObjectFactory: