public static void init(Initializable initializable) throws ShiroException { initializable.init(); }
public void afterInjection(Initializable injectee) { injectee.init(); } }
/** * Calls the <tt>init()</tt> methods on the bean if it implements {@link org.apache.shiro.util.Initializable} * * @param object the object being initialized. * @param name the name of the bean being initialized. * @return the initialized bean. * @throws BeansException if any exception is thrown during initialization. */ public Object postProcessBeforeInitialization(Object object, String name) throws BeansException { if (object instanceof Initializable) { try { if (log.isDebugEnabled()) { log.debug("Initializing bean [" + name + "]..."); } ((Initializable) object).init(); } catch (Exception e) { throw new FatalBeanException("Error initializing bean [" + name + "]", e); } } return object; }
@Test public void testAfterInjection() throws Exception { Initializable initializable = createMock(Initializable.class); initializable.init(); replay(initializable); InitializableInjectionListener underTest = new InitializableInjectionListener(); underTest.afterInjection(initializable); verify(initializable); } }
public void afterInjection(Initializable injectee) { injectee.init(); } }
public static void init(Initializable initializable) throws ShiroException { initializable.init(); }
public static void init(Initializable initializable) throws ShiroException { initializable.init(); }
/** * Calls the <tt>init()</tt> methods on the bean if it implements {@link org.apache.shiro.util.Initializable} * * @param object the object being initialized. * @param name the name of the bean being initialized. * @return the initialized bean. * @throws BeansException if any exception is thrown during initialization. */ public Object postProcessBeforeInitialization(Object object, String name) throws BeansException { if (object instanceof Initializable) { try { if (log.isDebugEnabled()) { log.debug("Initializing bean [" + name + "]..."); } ((Initializable) object).init(); } catch (Exception e) { throw new FatalBeanException("Error initializing bean [" + name + "]", e); } } return object; }
@Override public void init() throws Throwable { for ( Realm realm : realms ) { if ( realm instanceof Initializable ) { ((Initializable) realm).init(); } if ( realm instanceof CachingRealm ) { ((CachingRealm) realm).setCacheManager( cacheManager ); } if ( realm instanceof RealmLifecycle ) { ((RealmLifecycle) realm).initialize(); } } }
public void start() { // reload the config this.securityConfiguration.clearCache(); // if we are restarting this component the getCacheManager will be null // TODO: need better lifecycle management of cache (done), make sure this works with the NEXUS tests before // removing comment CacheManager cacheManager = this.cacheManagerComponent.getCacheManager(); // if( cacheManager == null) // { // try // { // cacheManager = this.cacheManagerComponent.buildCacheManager( null ); // } // catch ( IOException e ) // { // throw new IllegalStateException( "Failed to restart CacheManagerComponent" ); // } // } // setup the CacheManager ( this could be injected if we where less coupled with ehcache) // The plexus wrapper can interpolate the config EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager( cacheManager ); this.getSecurityManager().setCacheManager( ehCacheManager ); if ( org.apache.shiro.util.Initializable.class.isInstance( this.getSecurityManager() ) ) { ( (org.apache.shiro.util.Initializable) this.getSecurityManager() ).init(); } this.setSecurityManagerRealms(); }