mcardle 2005/08/30 18:35:10 CEST
Modified files:
core/src/java/org/jahia/operations/valves
EsiInvalidateValve.java
Log:
* supports invalidation via HTML piggybacking or SOAP (new default)
* some refactoring
Revision Changes Path
1.3 +52 -44
jahia/core/src/java/org/jahia/operations/valves/EsiInvalidateValve.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/operations/valves/EsiInvalidateValve.java.diff?r1=1.2&r2=1.3&f=h
Index: EsiInvalidateValve.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/operations/valves/EsiInvalidateValve.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EsiInvalidateValve.java 25 Aug 2005 18:32:34 -0000 1.2
+++ EsiInvalidateValve.java 30 Aug 2005 16:35:09 -0000 1.3
@@ -35,6 +35,7 @@
import org.jahia.services.esi.EsiInvalidation;
+import org.jahia.services.esi.EsiSOAPInvalidation;
/**
* <p>Title: </p>
@@ -87,11 +88,9 @@
ParamBean paramBean = (ParamBean) context; //using parambean since
we need the getrealresponse() method, not present in porcessingContext
- StringBuffer strFinal = null;
-
-
- if (paramBean.settings().lookupBoolean(SettingsBean.
- ESI_CACHE_ACTIVATED)) {
+ if
(paramBean.settings().lookupBoolean(SettingsBean.ESI_CACHE_ACTIVATED)
+ && ServicesRegistry.getInstance().getEsiService().
+ checkForAnyContentToInvalidate()) {
//Get ESI invalidation message for all objects to invalidate
//invMessage =
EsiInvalidation.getPendingObjectsToInvalidate(paramBean);
@@ -104,44 +103,11 @@
//TODO: might wanna check if the current contenttype is of
"charset=" type
//since we don't want to add ESI commands to pics which will be
ignored by ESI server
if (invMessage != null) {
- strFinal = new StringBuffer();
- strFinal.append("\n <!-- START of ESI invalidation message
--> \n");
- strFinal.append("<pre> \n");
- //TODO: REMOVE output=yes param. Only for debug purposes
- strFinal.append("<esi:invalidate output=\"yes\"> \n");
- //str.append("<esi:invalidate> \n");
-
strFinal.append(EsiInvalidation.addSOAPXMLWrapper(invMessage.toString()));
- strFinal.append("</esi:invalidate> \n");
- strFinal.append("</pre> \n");
- strFinal.append("<!-- END of ESI invalidation message -->");
-
- logger.debug("PiggyBack Invalidation Message : \n" +
strFinal.toString() );
-
- //Add invalidation message as piggy-back to current HTML
response
- try {
- HttpServletResponse realResp =
paramBean.getRealResponse();
- ServletOutputStream outputStream =
realResp.getOutputStream();
- OutputStreamWriter streamWriter = new OutputStreamWriter(
- outputStream);
- streamWriter.write(strFinal.toString()
- , 0, strFinal.length());
- logger.debug("ESI Invalidation Piggy-back Message: \n" +
- strFinal);
- //out.print(strFinal.toString());
- streamWriter.flush();
- } catch (java.io.IOException ioe) {
- logger.error(
- "Error writing cache output, IOException
generated error",
- ioe);
- JahiaException outputException = new
- JahiaException(
- "OperationsManager.handleOperations",
- "Error writing ESI content to writer",
- JahiaException.SECURITY_ERROR,
- JahiaException.ERROR_SEVERITY,
- ioe);
- throw new PipelineException(outputException);
- }
+
+ if (paramBean.settings().getEsiUsePiggyBackInvalidation())
+ piggyBackInvalidation(invMessage, paramBean);
+ else
+ EsiSOAPInvalidation.SOAPInvalidation(invMessage,
paramBean);
//TODO: Really should get confirmation from SOAP that
objects have actually been invalidated
//TODO: before doing any of the operations below:
@@ -157,11 +123,53 @@
ServicesRegistry.getInstance().getEsiService().emptyInvalidatedTemplates(TempsToInvalidate);
ServicesRegistry.getInstance().getEsiService().emptyInvalidatedFragments(FragsToInvalidate);
-
}
}
valveContext.invokeNext(context);
}
+
+ private void piggyBackInvalidation(String invMessage, ParamBean
paramBean) throws PipelineException {
+ StringBuffer strFinal;
+ strFinal = new StringBuffer();
+ strFinal.append("\n <!-- START of ESI invalidation message --> \n");
+ strFinal.append("<pre> \n");
+ //TODO: REMOVE output=yes param. Only for debug purposes
+ strFinal.append("<esi:invalidate output=\"yes\"> \n");
+ //str.append("<esi:invalidate> \n");
+ strFinal.append(EsiInvalidation.addSOAPXMLWrapper(invMessage));
+ strFinal.append("</esi:invalidate> \n");
+ strFinal.append("</pre> \n");
+ strFinal.append("<!-- END of ESI invalidation message -->");
+
+ logger.debug("PiggyBack Invalidation Message : \n" +
strFinal.toString() );
+
+ //Add invalidation message as piggy-back to current HTML response
+ try {
+ HttpServletResponse realResp = paramBean.getRealResponse();
+ ServletOutputStream outputStream = realResp.getOutputStream();
+ OutputStreamWriter streamWriter = new OutputStreamWriter(
+ outputStream);
+ streamWriter.write(strFinal.toString()
+ , 0, strFinal.length());
+ logger.debug("ESI Invalidation Piggy-back Message: \n" +
+ strFinal);
+ //out.print(strFinal.toString());
+ streamWriter.flush();
+ } catch (java.io.IOException ioe) {
+ logger.error(
+ "Error writing cache output, IOException generated
error",
+ ioe);
+ JahiaException outputException = new
+ JahiaException(
+ "OperationsManager.handleOperations",
+ "Error writing ESI content to writer",
+ JahiaException.SECURITY_ERROR,
+ JahiaException.ERROR_SEVERITY,
+ ioe);
+ throw new PipelineException(outputException);
+ }
+ }
+
} //end EsiInvalidateValve