Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [config-dev] Config questions

There is always documentation. If no source code is available, there should be a clear documentation that states what are the requirements to be able to install it on a runtime.


On Thu, 26 Aug 2021 at 18:36, Laird Nelson <ljnelson@xxxxxxxxx> wrote:
On Thu, Aug 26, 2021 at 9:09 AM Scott Stark <starksm64@xxxxxxxxx> wrote:
What is the JNDI way of knowing what configuration properties are in use?

You can apply @jakarta.annotation.Resource at the type level. From the javadocs:

If the annotation is applied to the component class, the annotation declares a resource that the application will look up at runtime.

The intention of allowing this was to facilitate an ecosystem of class-oriented tools that could discover what programmatic Context lookups were taking place within an otherwise opaque component.

So if I'm "in" a class named Gorp, and I'm looking up "frobnicator" from a Context programmatically at runtime "inside" it, I would add @Resource to the class in which I'm performing the lookup:

@Resource(name = "frobnicator", type = Frobnicator.class)
public class Gorp {
  public void doSomething() {
    Frobnicator frobnicator = (Frobnicator)context.lookup("frobnicator");

(Obviously if the application developer puts @Resource(name = "nonexistent", type = Frobnicator.class) instead of @Resource(name = "frobnicator", type = Frobnicator.class) and nevertheless looks up "frobnicator" she has made a mistake.)

Then the idea was an application server would ship with some (probably GUI) tool that would discover those annotations and could therefore enable the application assembler and the deployer to learn that a Frobnicator-typed reference would need to exist such that it is accessible to the component at runtime using the component's namespace.

Note as well in all of this that there is, of course, no requirement that the name by which the application assembler or deployer refers to the reference be the same as the name by which the component developer refers to it, nor is there any requirement on how the Frobnicator would be installed into the JNDI tree.

config-dev mailing list
To unsubscribe from this list, visit

Back to the top