mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Allow a Web Script to override transactional response buffer size
- <transaction buffersize="xxx"> where xxx is bytes - 0 or less disables cache - default = 4096 - use with care git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14701 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,6 +66,7 @@ import org.alfresco.web.scripts.WebScriptResponse;
|
|||||||
import org.alfresco.web.scripts.WrappingWebScriptResponse;
|
import org.alfresco.web.scripts.WrappingWebScriptResponse;
|
||||||
import org.alfresco.web.scripts.Description.RequiredAuthentication;
|
import org.alfresco.web.scripts.Description.RequiredAuthentication;
|
||||||
import org.alfresco.web.scripts.Description.RequiredTransaction;
|
import org.alfresco.web.scripts.Description.RequiredTransaction;
|
||||||
|
import org.alfresco.web.scripts.Description.RequiredTransactionParameters;
|
||||||
import org.alfresco.web.scripts.Description.TransactionCapability;
|
import org.alfresco.web.scripts.Description.TransactionCapability;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -329,19 +330,29 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Begin retry transaction block: " + description.getRequiredTransaction() + "," + description.getTransactionCapability());
|
logger.debug("Begin retry transaction block: " + description.getRequiredTransaction() + ","
|
||||||
|
+ description.getRequiredTransactionParameters().getCapability());
|
||||||
|
|
||||||
WebScriptResponse redirectedRes = scriptRes;
|
WebScriptResponse redirectedRes = scriptRes;
|
||||||
if (description.getTransactionCapability() == TransactionCapability.readwrite)
|
RequiredTransactionParameters trxParams = description.getRequiredTransactionParameters();
|
||||||
|
if (trxParams.getCapability() == TransactionCapability.readwrite)
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (trxParams.getBufferSize() > 0)
|
||||||
logger.debug("Creating Transactional Response for ReadWrite transaction");
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Creating Transactional Response for ReadWrite transaction; buffersize=" + trxParams.getBufferSize());
|
||||||
|
|
||||||
// create buffered response that's sensitive transaction boundary
|
// create buffered response that's sensitive transaction boundary
|
||||||
BufferedResponse bufferedRes = new BufferedResponse(scriptRes);
|
BufferedResponse bufferedRes = new BufferedResponse(scriptRes, trxParams.getBufferSize());
|
||||||
AlfrescoTransactionSupport.bindResource(BUFFERED_RESPONSE_KEY, bufferedRes);
|
AlfrescoTransactionSupport.bindResource(BUFFERED_RESPONSE_KEY, bufferedRes);
|
||||||
AlfrescoTransactionSupport.bindListener(bufferedRes);
|
AlfrescoTransactionSupport.bindListener(bufferedRes);
|
||||||
redirectedRes = bufferedRes;
|
redirectedRes = bufferedRes;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Transactional Response bypassed for ReadWrite - buffersize=0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
script.execute(scriptReq, redirectedRes);
|
script.execute(scriptReq, redirectedRes);
|
||||||
@@ -384,14 +395,15 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("End retry transaction block: " + description.getRequiredTransaction() + "," + description.getTransactionCapability());
|
logger.debug("End retry transaction block: " + description.getRequiredTransaction() + ","
|
||||||
|
+ description.getRequiredTransactionParameters().getCapability());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
boolean readonly = description.getTransactionCapability() == TransactionCapability.readonly;
|
boolean readonly = description.getRequiredTransactionParameters().getCapability() == TransactionCapability.readonly;
|
||||||
boolean requiresNew = description.getRequiredTransaction() == RequiredTransaction.requiresnew;
|
boolean requiresNew = description.getRequiredTransaction() == RequiredTransaction.requiresnew;
|
||||||
retryingTransactionHelper.doInTransaction(work, readonly, requiresNew);
|
retryingTransactionHelper.doInTransaction(work, readonly, requiresNew);
|
||||||
}
|
}
|
||||||
@@ -499,15 +511,17 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
|||||||
private ByteArrayOutputStream outputStream;
|
private ByteArrayOutputStream outputStream;
|
||||||
private OutputStreamWriter outputWriter;
|
private OutputStreamWriter outputWriter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
*
|
*
|
||||||
* @param res
|
* @param res
|
||||||
|
* @param bufferSize
|
||||||
*/
|
*/
|
||||||
public BufferedResponse(WebScriptResponse res)
|
public BufferedResponse(WebScriptResponse res, int bufferSize)
|
||||||
{
|
{
|
||||||
this.res = res;
|
this.res = res;
|
||||||
this.outputStream = new ByteArrayOutputStream(4096);
|
this.outputStream = new ByteArrayOutputStream(bufferSize);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.outputWriter = new OutputStreamWriter(outputStream, "UTF-8");
|
this.outputWriter = new OutputStreamWriter(outputStream, "UTF-8");
|
||||||
|
Reference in New Issue
Block a user