-
1. Re: Access simple bean (non-EJB) using JNDI
jaysensharma Nov 29, 2014 12:04 AM (in response to srinivas427)"context.xml" file based approach will not work in AS7/Wildfly. So if you want to add a custom object in the JNDI tree of your JBoss for remote access then you may need to use the standard options like creating a class (example: MyCustomObjectFactory) by implementing "javax.naming.spi.ObjectFactory" Then it can be easily accessed from the JNDI tree, locally or remotely.
<subsystem xmlns="urn:jboss:domain:naming:1.1"> <bindings> <object-factory name="java:jboss/exported/test2" module="test.jndi.demo" class="test.jndi.demo.MyCustomObjectFactory"/> </bindings> </subsystem>
The JNDI framework allows for object implementations to be loaded in dynamically via object factories. For example, when looking up a printer bound in the name space, if the print service binds printer names to References, the printer Reference could be used to create a printer object, so that the caller of lookup can directly operate on the printer object after the lookup. An ObjectFactory is responsible for creating objects of a specific type. refer to https://docs.oracle.com/javase/6/docs/api/javax/naming/spi/ObjectFactory.html
Refer to [1] for a simple demo on the same:
[1] Binding & Remote Lookup of Custom Objects in JNDI tree of JBoss AS7.1.1