Hi Mo, I *think* the simplest thing for JEE would be to use the JndiObjectFactory to pull it from the JEE JNDI context. For example, to look up a JNDI datasource and use it with the JdbcRealm:
[main] ... datasource = org.apache.shiro.jndi.JndiObjectFactory datasource.resourceName = jdbc/mydatasource # if the JNDI name is prefixed with java:comp/env (like a JEE environment), # uncomment this line: #datasource.resourceRef = true jdbcRealm = com.foo.my.JdbcRealm jdbcRealm.datasource = $datasource Please let us know if this does not meet your needs - JEE CDI is where we'd like a lot of help from the community if possible. Thanks, Les On Sat, Mar 2, 2013 at 1:48 AM, Mo Maison <[email protected]> wrote: > > I use shiro in a JEE6 environment, configuring it thanks to > a simple .ini resource in classpath. > With Ini Shiro creates all objects graph by itself (reflectively, > using class names and empty constructors). > > Unless I missed something, using this way of proceeding > it is not possible to inject existing external objects into > Ini variables. For example, injecting a JEE managed object > would be desirable. > Studying code, it might be sufficient to use > new ReflectionBuilder( defaults) > this constructor is called from > IniSecurityManagerFactory.buildInstances() > and defaults is got by calling createDefaults() which could > be overriden in IniSecurityManagerFactory, but I didn't manage > to make it work. > > Did I miss something ? > Is there any easy way to achieve this injection ? It would be nice > to accept an initial objects map in Ini configuration API. > Or should I forget completely about Ini configuration limitations > and use something different like Spring or CDI ? > > Thank you for your advices. > > Regards, > > M. Maison
