vgritsenko 01/08/15 18:27:24 Modified: src/org/apache/cocoon/components/language/generator Tag: cocoon_20_branch GeneratorSelector.java Log: patching memory leaks. taked excalibur's approach to store component-handler mapping. Revision Changes Path No revision No revision 1.1.1.1.2.7 +20 -3 xml-cocoon2/src/org/apache/cocoon/components/language/generator/GeneratorSelector.java Index: GeneratorSelector.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/generator/GeneratorSelector.java,v retrieving revision 1.1.1.1.2.6 retrieving revision 1.1.1.1.2.7 diff -u -r1.1.1.1.2.6 -r1.1.1.1.2.7 --- GeneratorSelector.java 2001/07/13 19:00:24 1.1.1.1.2.6 +++ GeneratorSelector.java 2001/08/16 01:27:23 1.1.1.1.2.7 @@ -32,7 +32,7 @@ * includes Sitemaps and XSP Pages * * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a> - * @version CVS $Revision: 1.1.1.1.2.6 $ $Date: 2001/07/13 19:00:24 $ + * @version CVS $Revision: 1.1.1.1.2.7 $ $Date: 2001/08/16 01:27:23 $ */ public class GeneratorSelector extends ExcaliburComponentSelector implements Disposable { @@ -49,6 +49,9 @@ protected Map componentHandlers = new HashMap(); + /** Dynamic component handlers mapping. */ + private Map componentMapping = new HashMap(); + public void contextualize(Context context) { super.contextualize(context); this.context = context; @@ -83,12 +86,26 @@ // if it isn't loaded, it may already be compiled... try { ComponentHandler handler = (ComponentHandler) this.componentHandlers.get(hint); - - return (Component) handler.get(); + Component component = (Component) handler.get(); + componentMapping.put(component, handler); + return component; } catch (Exception ce) { getLogger().debug("Could not access component for hint: " + hint); throw new ComponentException("Could not access component for hint: " + hint, null); } + } + } + + public void release(Component component) { + ComponentHandler handler = (ComponentHandler)componentMapping.get(component); + if (handler != null) { + try { + handler.put(component); + } catch (Exception e) { + getLogger().error("Error trying to release component", e); + } + } else { + super.release(component); } } ---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]