vgritsenko 01/08/15 18:26:35
Modified: src/org/apache/cocoon/components/language/generator
GeneratorSelector.java
Log:
patching memory leaks. taked excalibur's approach to store component-handler mapping.
Revision Changes Path
1.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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GeneratorSelector.java 2001/07/13 19:07:30 1.6
+++ GeneratorSelector.java 2001/08/16 01:26:35 1.7
@@ -32,7 +32,7 @@
* includes Sitemaps and XSP Pages
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/07/13 19:07:30 $
+ * @version CVS $Revision: 1.7 $ $Date: 2001/08/16 01:26:35 $
*/
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]