osgi - CDI @Inject return null in AuthorizingRealm -
i'm try use apache shiro in osgi env. in order use cdi beans on myauthorizingrealm class i've pax-shiro-cdi extension. simple authorizingrealm here:
@shiroini public class myauthorizingrealm extends authorizingrealm { @inject // return null private simpleuserstorage userstorage; @override protected authenticationinfo dogetauthenticationinfo(authenticationtoken authenticationtoken) throws authenticationexception { system.out.println(" bean " + userstorage); usernamepasswordtoken usernamepasswordtoken = (usernamepasswordtoken) authenticationtoken; return new simpleaccount(usernamepasswordtoken.getprincipal(), "123456".tochararray(), super.getname()); }
and simpleuserstorage here :
public class simpleuserstorage { private list<string> users = new arraylist<string>(); public list<string> getusers(){ users.add("user"); users.add("user1"); return users; } }
but strangely can inject simpleuserstorage in restservice class , work well..
simpleuserstorage in restservice , work well. example : @path("/user") public class userrestservice { @inject private simpleuserstorage userstorage; @get @produces("text/html") public string getdatatodisplay() { return "<strong>hehe)</strong>" + userstorage.getusers().size() ; } }
why in myauthorizingrealm got null instead ref of simpleuserstorage ?
i'm user glassfish 4 , try write pure java ee application.
Comments
Post a Comment