-
1. Re: Several issues with injection in AS 7 modules
bmsantos Jan 26, 2012 12:11 PM (in response to bmsantos)1 of 1 people found this helpfulOk, even though it is not a solution for a fully modular login module, I was able to get to a bean by JNDI with the help of AS7 CLI /subsystem=naming:jndi-view command.
This solution will work for my application but it won't be fully modular (reusable) because the interface will be in the module but actually implementation of the bean will have to be in the ear or the bean will never be loaded/detected by the EJB container.
If we use the login module example provided by Anil (see here) and we add a new interface to the module package such as:
public interface ITest {
public String foo();
}
To the ear application we add the implementation such as:
@Stateless
@Local(ITest.class)
public class TestBean implements ITest {
@Override
public String foo() {
return "Hello foo!";
}
}
then we can access it through login module by using the following JNDI lookup:
private ITest iTest;
...
InitialContext ic;
try {
ic = new InitialContext();
iTest = (ITest) ic.lookup("java:global/ear_name_only/my.jar/TestBean");
} catch (NamingException e) {
// do whatever...
}
...
This works but I was hopping that one could inject any bean in the LoginModule AS7 module.
This is only a partial solution since it does not offer full modularity as it would be expected and because of this I do not think this is the answer to the original issue.
If someone has any better ideas on how to enable beans within a AS7 module and inject then within pojo's of that same module, please share.
Is there any heavy weight JBossian that could shed some light on the issue?
Thanks