No because this breaks the whole idea of "do one thing well".
The microcontainer is a dependency state machine.
Besides, despite your assertion only a small percentage of POJOs end up in JNDI
and then not always trivially, e.g. they need to wrapped in object factories.
There already is a mechansim to add adhoc metadata to beans that can
be processed by pluggable interceptors so you can do
<bean ...> <annotation>org.jboss.jndi.JNDIBinding("blah")</annotation> or <bean ..> <annotation org.jboss.jndi.JNDIBinding(value="blah" objectFactory=com.acme.SomeObjectFactory)</annotation>
Which makes this much more extenisbe in terms of matching the
metadata (the annotation) to the implementation (the aspect).
Additionally, you can meta-annotate the metadata to say it requires another service,
@Depends("jboss:service=Naming") public @interface JNDIBinding ...
So you know beans annotated with JNDIBinding must wait for the Naming Service
This is a much more generic mechanism than the "hacky" approach you describe.
1) It requires not extra handling in the microcontainer
2) You can use AOP to map the metadata to any aspect implementation you like
3) The metadata is extensible as new requirements are understood.
I appreciate your response, though I think "hacky" was a bit strong... :) I merely thought that a jndi-name attribute could serve as a shorthand for the JNDIBinding annotation that you mentioned. It is very similar to the <attribute name="JNDIName"...> element that one can nest under MBean tags. Is that considered "hacky" as well?
Having a shorthand or "easier" way of doing configuration is not unprecedented in JBoss. For example, people used to have to write mbean *-service.xml files to set up datasources in AS. Now they just have to write a *-ds.xml file, which is a simpler syntax, although under the hood it just gets trasnformed. (Or at least that's how it used to be implemented...)
Last, your repsponse addressed putting the POJO in JNDI. I didn't see what the recommended approach is to expose the POJO as a JMX MBean. Is there an <annotation ..> for that is well?