public void destroy() throws Exception { LifecycleUtils.destroy(this.objects.values()); } }
/** * Calls {@link #destroy(Object) destroy} for each object in the collection. * If the collection is {@code null} or empty, this method returns quietly. * * @param c the collection of objects to destroy. * @since 0.9 */ public static void destroy(Collection c) { if (c == null || c.isEmpty()) { return; } for (Object o : c) { destroy(o); } } }
/** * Cleanup method that first {@link LifecycleUtils#destroy destroys} all of it's managed caches and then * {@link java.util.Map#clear clears} out the internally referenced cache map. * * @throws Exception if any of the managed caches can't destroy properly. */ public void destroy() throws Exception { while (!caches.isEmpty()) { for (Cache cache : caches.values()) { LifecycleUtils.destroy(cache); } caches.clear(); } }
protected void destroy(SecurityManager sm) { LifecycleUtils.destroy(sm); }
/** * Destroys the {@link WebEnvironment} for the given servlet context. * * @param servletContext the ServletContext attributed to the WebSecurityManager */ public void destroyEnvironment(ServletContext servletContext) { servletContext.log("Cleaning up Shiro Environment"); try { Object environment = servletContext.getAttribute(ENVIRONMENT_ATTRIBUTE_KEY); if (environment instanceof WebEnvironment) { finalizeEnvironment((WebEnvironment) environment); } LifecycleUtils.destroy(environment); } finally { servletContext.removeAttribute(ENVIRONMENT_ATTRIBUTE_KEY); } }
public void destroy() { final Map<String, Object> immutableObjects = Collections.unmodifiableMap(objects); //destroy objects in the opposite order they were initialized: List<Map.Entry<String,?>> entries = new ArrayList<Map.Entry<String,?>>(objects.entrySet()); Collections.reverse(entries); for(Map.Entry<String, ?> entry: entries) { String id = entry.getKey(); Object bean = entry.getValue(); //don't destroy the eventbus until the end - we need it to still be 'alive' while publishing destroy events: if (bean != this.eventBus) { //memory equality check (not .equals) on purpose LifecycleUtils.destroy(bean); BeanEvent event = new DestroyedBeanEvent(id, bean, immutableObjects); eventBus.publish(event); this.eventBus.unregister(bean); //bean is now destroyed - it should not receive any other events } } //only now destroy the event bus: LifecycleUtils.destroy(this.eventBus); }
public void destroy() { LifecycleUtils.destroy(getRealms()); this.realms = null; super.destroy(); }
public void destroy() { LifecycleUtils.destroy(getSessionManager()); this.sessionManager = null; super.destroy(); } }
public void destroy() { LifecycleUtils.destroy(getAuthorizer()); this.authorizer = null; super.destroy(); }
public void destroy() { LifecycleUtils.destroy(getAuthenticator()); this.authenticator = null; super.destroy(); } }
/** * @param sessionMode * @deprecated since 1.2 */ @Deprecated public void setSessionMode(String sessionMode) { log.warn("The 'sessionMode' property has been deprecated. Please configure an appropriate WebSessionManager " + "instance instead of using this property. This property/method will be removed in a later version."); String mode = sessionMode; if (mode == null) { throw new IllegalArgumentException("sessionMode argument cannot be null."); } mode = sessionMode.toLowerCase(); if (!HTTP_SESSION_MODE.equals(mode) && !NATIVE_SESSION_MODE.equals(mode)) { String msg = "Invalid sessionMode [" + sessionMode + "]. Allowed values are " + "public static final String constants in the " + getClass().getName() + " class: '" + HTTP_SESSION_MODE + "' or '" + NATIVE_SESSION_MODE + "', with '" + HTTP_SESSION_MODE + "' being the default."; throw new IllegalArgumentException(msg); } boolean recreate = this.sessionMode == null || !this.sessionMode.equals(mode); this.sessionMode = mode; if (recreate) { LifecycleUtils.destroy(getSessionManager()); SessionManager sessionManager = createSessionManager(mode); this.setInternalSessionManager(sessionManager); } }
protected synchronized void disableSessionValidation() { beforeSessionValidationDisabled(); SessionValidationScheduler scheduler = getSessionValidationScheduler(); if (scheduler != null) { try { scheduler.disableSessionValidation(); if (log.isInfoEnabled()) { log.info("Disabled session validation scheduler."); } } catch (Exception e) { if (log.isDebugEnabled()) { String msg = "Unable to disable SessionValidationScheduler. Ignoring (shutting down)..."; log.debug(msg, e); } } LifecycleUtils.destroy(scheduler); setSessionValidationScheduler(null); } }
@AfterClass public static void tearDownShiro() { doClearSubject(); try { SecurityManager securityManager = getSecurityManager(); LifecycleUtils.destroy(securityManager); } catch (UnavailableSecurityManagerException e) { //we don't care about this when cleaning up the test environment //(for example, maybe the subclass is a unit test and it didn't // need a SecurityManager instance because it was using only mock Subject instances) } setSecurityManager(null); } }
@AfterClass public static void tearDownShiro() { doClearSubject(); try { org.apache.shiro.mgt.SecurityManager securityManager = SecurityUtils.getSecurityManager(); LifecycleUtils.destroy( securityManager ); } catch ( UnavailableSecurityManagerException e ) { // we don't care about this when cleaning up the test environment // (for example, maybe the subclass is a unit test and it didn't // need a SecurityManager instance because it was using only // mock Subject instances) } SecurityUtils.setSecurityManager( null ); }
public void destroy() { LifecycleUtils.destroy(getAuthorizer()); this.authorizer = null; super.destroy(); }
public void destroy() { LifecycleUtils.destroy(getRealms()); this.realms = null; super.destroy(); }
LifecycleUtils.destroy(sm);