/** * {@inheritDoc} * * @see org.xwiki.component.manager.ComponentManager#release(java.lang.Object) */ public <T> void release(T component) throws ComponentLifecycleException { try { this.plexusContainer.release(component); } catch (org.codehaus.plexus.component.repository.exception.ComponentLifecycleException e) { throw new ComponentLifecycleException("Failed to release component [" + component + "]", e); } }
@Override protected void afterHandle(Request request, Response response) { Map<String, Object> attributes = getContext().getAttributes(); /* Remove all the components that have been through the component manager and that have a PER_LOOKUP policy. */ ComponentManager componentManager = (ComponentManager) attributes.get(Constants.XWIKI_COMPONENT_MANAGER); List<XWikiRestComponent> releasableComponents = (List<XWikiRestComponent>) attributes.get(Constants.RELEASABLE_COMPONENT_REFERENCES); if (releasableComponents != null) { /* Release all the releasable components. */ for (XWikiRestComponent component : releasableComponents) { try { componentManager.release(component); } catch (ComponentLifecycleException e) { getLogger().log( Level.WARNING, String.format("Unable to release component %s. (%s)", component.getClass().getName(), e .getMessage())); } } } /* Avoid that empty entities make the engine forward the response creation to the XWiki servlet. */ if (response.getEntity() != null) { if (!response.getEntity().isAvailable()) { response.setEntity(null); } } }