Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 14896 invoked from network); 30 Mar 2008 07:31:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Mar 2008 07:31:19 -0000 Received: (qmail 20246 invoked by uid 500); 30 Mar 2008 07:31:18 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 20185 invoked by uid 500); 30 Mar 2008 07:31:18 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 20169 invoked by uid 99); 30 Mar 2008 07:31:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Mar 2008 00:31:18 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Mar 2008 07:30:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8DF161A9832; Sun, 30 Mar 2008 00:30:55 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r642694 - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ Date: Sun, 30 Mar 2008 07:30:54 -0000 To: cvs@cocoon.apache.org From: joerg@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080330073056.8DF161A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: joerg Date: Sun Mar 30 00:30:41 2008 New Revision: 642694 URL: http://svn.apache.org/viewvc?rev=642694&view=rev Log: Minimize the data that's stored with ContinuationContext to limit the Continuation's memory footprint. Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/Continuation.java cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ContinuationContext.java cocoon/branches/BRANCH_2_1_X/status.xml Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java?rev=642694&r1=642693&r2=642694&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/AbstractContinuable.java Sun Mar 30 00:30:41 2008 @@ -38,9 +38,11 @@ public abstract class AbstractContinuable implements Continuable { private ContinuationContext getContext() { - if (Continuation.currentContinuation()==null) + Continuation currentContinuation = Continuation.currentContinuation(); + if (currentContinuation == null) { throw new IllegalStateException("No continuation is running"); - return (ContinuationContext) Continuation.currentContinuation().getContext(); + } + return (ContinuationContext) currentContinuation.getContext(); } public Logger getLogger() { @@ -55,14 +57,14 @@ ContinuationContext context = getContext(); - if (context.getLogger()!=null) + if (context.getLogger()!=null) context.getLogger().debug("send page and wait '" + uri + "'"); FlowHelper.setContextObject(ContextHelper.getObjectModel(context.getAvalonContext()), bizdata); if (SourceUtil.indexOfSchemeColon(uri) == -1) { uri = "cocoon:/" + uri; - if (getContext().getRedirector().hasRedirected()) { + if (context.getRedirector().hasRedirected()) { throw new IllegalStateException("Pipeline has already been processed for this request"); } try { @@ -74,6 +76,7 @@ throw new IllegalArgumentException("uri is not allowed to contain a scheme (cocoon:/ is always automatically used)"); } + context.onSuspend(); Continuation.suspend(); } @@ -85,14 +88,14 @@ ContinuationContext context = getContext(); - if (context.getLogger()!=null) + if (context.getLogger()!=null) context.getLogger().debug("send page '" + uri + "'"); FlowHelper.setContextObject(ContextHelper.getObjectModel(context.getAvalonContext()), bizdata); if (SourceUtil.indexOfSchemeColon(uri) == -1) { uri = "cocoon:/" + uri; - if (getContext().getRedirector().hasRedirected()) { + if (context.getRedirector().hasRedirected()) { throw new IllegalStateException("Pipeline has already been processed for this request"); } try { Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/Continuation.java URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/Continuation.java?rev=642694&r1=642693&r2=642694&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/Continuation.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/Continuation.java Sun Mar 30 00:30:41 2008 @@ -16,10 +16,12 @@ */ package org.apache.cocoon.components.flow.java; +import java.util.Collections; import java.util.HashMap; +import java.util.Map; /** - * Continations object to store the current execution. The contiunation + * Continuation object to store the current execution. The continuation * object can only used once. * * @author Stephan Michels @@ -27,10 +29,11 @@ * @version CVS $Id$ */ public class Continuation { - private ContinuationStack stack; - private Object context; + + private static final Map continuations = Collections.synchronizedMap(new HashMap()); - private static HashMap continuationsmap = new HashMap(); + private final ContinuationStack stack; + private Object context; public boolean restoring = false; public boolean capturing = false; @@ -73,7 +76,6 @@ * Stop the running continuation. */ public static void suspend() { - Continuation continuation = Continuation.currentContinuation(); if (continuation == null) @@ -96,7 +98,7 @@ } /** - * True, is the continuation freeze the strack trace, and stops the continuation. + * True, if the continuation freezes the stack trace, and stops the continuation. */ public boolean isCapturing() { return capturing; @@ -106,18 +108,14 @@ * Bind the continuation to running thread. */ public void registerThread() { - synchronized (continuationsmap) { - continuationsmap.put(Thread.currentThread(), this); - } + continuations.put(Thread.currentThread(), this); } /** * Unbind the continuation to running thread. */ public void deregisterThread() { - synchronized (continuationsmap) { - continuationsmap.remove(Thread.currentThread()); - } + continuations.remove(Thread.currentThread()); } /** @@ -125,9 +123,7 @@ * current thread. */ public static Continuation currentContinuation() { - synchronized (continuationsmap) { - Thread t = Thread.currentThread(); - return (Continuation) continuationsmap.get(t); - } + Thread t = Thread.currentThread(); + return (Continuation) continuations.get(t); } } Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ContinuationContext.java URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ContinuationContext.java?rev=642694&r1=642693&r2=642694&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ContinuationContext.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ContinuationContext.java Sun Mar 30 00:30:41 2008 @@ -46,6 +46,19 @@ public ContinuationContext() { } + /** + * The Continuation has been suspended, now clean up the context. + * Only {@link #object} and {@link #method} should be carried over. + * See {@link JavaInterpreter#handleContinuation(String, java.util.List, Redirector)} + */ + public void onSuspend() { + this.logger = null; + this.avalonContext = null; + this.manager = null; + this.redirector = null; + this.parameters = null; + } + public void setObject(Object object) { this.object = object; } @@ -94,11 +107,12 @@ return redirector; } - public Parameters getParameters() { - return parameters; - } + public Parameters getParameters() { + return parameters; + } - public void setParameters(Parameters parameters) { - this.parameters = parameters; - } + public void setParameters(Parameters parameters) { + this.parameters = parameters; + } + } Modified: cocoon/branches/BRANCH_2_1_X/status.xml URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=642694&r1=642693&r2=642694&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/status.xml (original) +++ cocoon/branches/BRANCH_2_1_X/status.xml Sun Mar 30 00:30:41 2008 @@ -182,6 +182,9 @@ + + Javaflow: Minimize the data that's stored with ContinuationContext to limit the Continuation's memory footprint. + Forms: Widget Label is not Show/Hide when we change the widget state in ajax mode.