Changeset 3975 for trunk/pfixcore/src
- Timestamp:
- 01/12/09 16:22:06 (3 years ago)
- Location:
- trunk/pfixcore/src
- Files:
-
- 1 added
- 8 modified
-
de/schlund/pfixcore/util/StateUtil.java (modified) (3 diffs)
-
de/schlund/pfixcore/workflow/app/DefaultIWrapperState.java (modified) (8 diffs)
-
de/schlund/pfixcore/workflow/app/IHandlerContainerImpl.java (modified) (4 diffs)
-
de/schlund/pfixcore/workflow/app/IWrapperContainerImpl.java (modified) (3 diffs)
-
de/schlund/pfixcore/workflow/context/RequestContextImpl.java (modified) (5 diffs)
-
de/schlund/pfixxml/PfixServletRequestImpl.java (modified) (3 diffs)
-
de/schlund/pfixxml/perflogging/CorePerfLoggingAspect.java (added)
-
org/pustefixframework/http/AbstractPustefixRequestHandler.java (modified) (2 diffs)
-
org/pustefixframework/http/AbstractPustefixXMLRequestHandler.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pfixcore/src/de/schlund/pfixcore/util/StateUtil.java
r3822 r3975 41 41 import de.schlund.pfixxml.ResultDocument; 42 42 import de.schlund.pfixxml.SPDocument; 43 import de.schlund.pfixxml.perflogging.PerfEvent;44 import de.schlund.pfixxml.perflogging.PerfEventType;45 43 46 44 … … 65 63 66 64 67 @SuppressWarnings("deprecation")68 65 public static void renderContextResources(Context context, ResultDocument resdoc, StateConfig config) throws Exception { 69 66 Map<String, ?> contextResources = config.getContextResources(); … … 71 68 for (String nodename : contextResources.keySet()) { 72 69 Object cr = contextResources.get(nodename); 73 String classname = cr.getClass().getName(); 74 Class<?> clazz = cr.getClass(); 75 if(Enhancer.isEnhanced(clazz)) { 76 clazz = clazz.getSuperclass(); 77 classname = clazz.getName(); 78 } 79 if (LOG.isDebugEnabled()) { 80 LOG.debug("*** Auto appending status for " + classname + " at node " + nodename); 81 } 82 PerfEvent pe = new PerfEvent(PerfEventType.CONTEXTRESOURCE_INSERTSTATUS, classname); 83 pe.start(); 84 if (cr instanceof de.schlund.pfixcore.workflow.ContextResource) { 85 LOG.debug("***** Resource implements ContextResource => calling insertStatus(...) of " + clazz.getName()); 86 ((de.schlund.pfixcore.workflow.ContextResource) cr).insertStatus(resdoc, resdoc.createNode(nodename)); 87 } else { 88 boolean found_annotation = false; 89 for (Method m : clazz.getMethods()) { 90 if (m.isAnnotationPresent(InsertStatus.class)) { 91 Class<?>[] params = m.getParameterTypes(); 92 Class<?> rettype = m.getReturnType(); 93 if (params.length == 0 && rettype != null) { 94 LOG.debug("***** Found @InsertStatus for Object:" + m.getName() + "() of " + clazz.getName()); 95 ResultDocument.addObject(resdoc.createNode(nodename), m.invoke(cr, new Object[] {})); 96 } else if (params.length == 1 && params[0].isAssignableFrom(Element.class)) { 97 LOG.debug("***** Found @InsertStatus for " + m.getName() + "(Element) of " + clazz.getName()); 98 m.invoke(cr, resdoc.createNode(nodename)); 99 } else if (params.length == 2 && params[0].isAssignableFrom(ResultDocument.class) && params[1].isAssignableFrom(Element.class)) { 100 LOG.debug("***** Found @InsertStatus for " + m.getName() + "(ResultDocument, Element) of " + clazz.getName()); 101 m.invoke(cr, resdoc, resdoc.createNode(nodename)); 102 } else { 103 throw new PustefixApplicationException("Exception when trying to call annotated method '@InsertStatus' " + 104 "of " + clazz.getName() + ": Need either a signature of either " + 105 "method(Element) or method(ResultDocument, Element)"); 106 } 107 found_annotation = true; 108 break; 70 renderContextResource(cr, resdoc, nodename); 71 } 72 } 73 74 @SuppressWarnings("deprecation") 75 private static void renderContextResource(Object cr, ResultDocument resdoc, String nodename) throws Exception { 76 String classname = cr.getClass().getName(); 77 Class<?> clazz = cr.getClass(); 78 if(Enhancer.isEnhanced(clazz)) { 79 clazz = clazz.getSuperclass(); 80 classname = clazz.getName(); 81 } 82 if (LOG.isDebugEnabled()) { 83 LOG.debug("*** Auto appending status for " + classname + " at node " + nodename); 84 } 85 if (cr instanceof de.schlund.pfixcore.workflow.ContextResource) { 86 LOG.debug("***** Resource implements ContextResource => calling insertStatus(...) of " + clazz.getName()); 87 ((de.schlund.pfixcore.workflow.ContextResource) cr).insertStatus(resdoc, resdoc.createNode(nodename)); 88 } else { 89 boolean found_annotation = false; 90 for (Method m : clazz.getMethods()) { 91 if (m.isAnnotationPresent(InsertStatus.class)) { 92 Class<?>[] params = m.getParameterTypes(); 93 Class<?> rettype = m.getReturnType(); 94 if (params.length == 0 && rettype != null) { 95 LOG.debug("***** Found @InsertStatus for Object:" + m.getName() + "() of " + clazz.getName()); 96 ResultDocument.addObject(resdoc.createNode(nodename), m.invoke(cr, new Object[] {})); 97 } else if (params.length == 1 && params[0].isAssignableFrom(Element.class)) { 98 LOG.debug("***** Found @InsertStatus for " + m.getName() + "(Element) of " + clazz.getName()); 99 m.invoke(cr, resdoc.createNode(nodename)); 100 } else if (params.length == 2 && params[0].isAssignableFrom(ResultDocument.class) && params[1].isAssignableFrom(Element.class)) { 101 LOG.debug("***** Found @InsertStatus for " + m.getName() + "(ResultDocument, Element) of " + clazz.getName()); 102 m.invoke(cr, resdoc, resdoc.createNode(nodename)); 103 } else { 104 throw new PustefixApplicationException("Exception when trying to call annotated method '@InsertStatus' " + 105 "of " + clazz.getName() + ": Need either a signature of either " + 106 "method(Element) or method(ResultDocument, Element)"); 109 107 } 110 } 111 if (!found_annotation) { 112 LOG.debug("***** Serializing the complete resource " + clazz.getName()); 113 ResultDocument.addObject(resdoc.createNode(nodename), cr); 108 found_annotation = true; 109 break; 114 110 } 115 111 } 116 pe.save(); 112 if (!found_annotation) { 113 LOG.debug("***** Serializing the complete resource " + clazz.getName()); 114 ResultDocument.addObject(resdoc.createNode(nodename), cr); 115 } 117 116 } 118 117 } -
trunk/pfixcore/src/de/schlund/pfixcore/workflow/app/DefaultIWrapperState.java
r3832 r3975 22 22 import java.util.Map; 23 23 24 import org.pustefixframework.generated.CoreStatusCodes;25 24 import org.pustefixframework.config.contextxmlservice.IWrapperConfig; 26 25 import org.pustefixframework.config.contextxmlservice.StateConfig; 26 import org.pustefixframework.generated.CoreStatusCodes; 27 27 28 28 import de.schlund.pfixcore.util.TokenManager; … … 36 36 import de.schlund.pfixxml.ResultDocument; 37 37 import de.schlund.pfixxml.XMLException; 38 import de.schlund.pfixxml.perflogging.PerfEvent;39 import de.schlund.pfixxml.perflogging.PerfEventType;40 38 41 39 /** … … 89 87 ResdocFinalizer rfinal = getResdocFinalizer(context); 90 88 ResultDocument resdoc = new ResultDocument(); 91 PerfEvent pe = new PerfEvent(PerfEventType.PAGE_INITIWRAPPERS, context.getCurrentPageRequest().toString()); 92 93 pe.start(); 89 94 90 IWrapperContainer wrp_container = getIHandlerContainer(context).createIWrapperContainerInstance(context, preq, resdoc); 95 pe.save();96 91 97 92 if (isSubmitTrigger(context, preq)) { … … 113 108 context.addPageMessage(CoreStatusCodes.FORM_TOKEN_INVALID, null, null); 114 109 if (errorPage.equals("")) { 115 pe = new PerfEvent(PerfEventType.PAGE_RETRIEVECURRENTSTATUS, context.getCurrentPageRequest().toString());116 pe.start();117 110 wrp_container.retrieveCurrentStatus(false); 118 pe.save();119 111 rfinal.onWorkError(wrp_container); 120 112 context.prohibitContinue(); … … 131 123 if (stateConf != null && stateConf.requiresToken()) { 132 124 context.addPageMessage(CoreStatusCodes.FORM_TOKEN_MISSING, null, null); 133 pe = new PerfEvent(PerfEventType.PAGE_RETRIEVECURRENTSTATUS, context.getCurrentPageRequest().toString());134 pe.start();135 125 wrp_container.retrieveCurrentStatus(false); 136 pe.save();137 126 rfinal.onWorkError(wrp_container); 138 127 context.prohibitContinue(); … … 142 131 143 132 if (valid) { 144 pe = new PerfEvent(PerfEventType.PAGE_HANDLESUBMITTEDDATA, context.getCurrentPageRequest().toString());145 pe.start();146 133 wrp_container.handleSubmittedData(); 147 pe.save();148 134 149 135 if (wrp_container.errorHappened()) { … … 154 140 CAT.debug(" => No error happened during work... end of submit reached successfully."); 155 141 CAT.debug(" => retrieving current status."); 156 pe = new PerfEvent(PerfEventType.PAGE_RETRIEVECURRENTSTATUS, context.getCurrentPageRequest().toString());157 pe.start();158 142 wrp_container.retrieveCurrentStatus(false); 159 pe.save();160 143 161 144 rfinal.onSuccess(wrp_container); … … 165 148 CAT.debug(">>> Retrieving current status..."); 166 149 167 pe = new PerfEvent(PerfEventType.PAGE_RETRIEVECURRENTSTATUS, context.getCurrentPageRequest().toString());168 pe.start();169 150 wrp_container.retrieveCurrentStatus(true); 170 pe.save();171 151 if (CAT.isDebugEnabled()) { 172 152 if (isDirectTrigger(context, preq)) { -
trunk/pfixcore/src/de/schlund/pfixcore/workflow/app/IHandlerContainerImpl.java
r3897 r3975 31 31 import de.schlund.pfixxml.PfixServletRequest; 32 32 import de.schlund.pfixxml.ResultDocument; 33 import de.schlund.pfixxml.perflogging.PerfEvent;34 import de.schlund.pfixxml.perflogging.PerfEventType;35 33 36 34 /** … … 102 100 for (Iterator<IHandler> iter = handlers.iterator(); iter.hasNext(); ) { 103 101 IHandler handler = iter.next(); 104 PerfEvent pe = new PerfEvent(PerfEventType.IHANDLER_PREREQUISITESMET, handler.getClass().getName());105 pe.start();106 102 boolean test = handler.prerequisitesMet(context); 107 pe.save();108 103 109 104 if (!test) { … … 176 171 */ 177 172 private boolean doIsActive(IHandler handler, Context ctx) throws Exception{ 178 PerfEvent pe = new PerfEvent(PerfEventType.IHANDLER_ISACTIVE, handler.getClass().getName());179 pe.start();180 173 boolean test = handler.isActive(ctx); 181 pe.save();182 174 return test; 183 175 } … … 193 185 */ 194 186 private boolean doNeedsData(IHandler handler, Context ctx) throws Exception{ 195 PerfEvent pe = new PerfEvent(PerfEventType.IHANDLER_NEEDSDATA, handler.getClass().getName());196 pe.start();197 187 boolean test = handler.needsData(ctx); 198 pe.save();199 188 return test; 200 189 } -
trunk/pfixcore/src/de/schlund/pfixcore/workflow/app/IWrapperContainerImpl.java
r3822 r3975 47 47 import de.schlund.pfixxml.ResultDocument; 48 48 import de.schlund.pfixxml.XMLException; 49 import de.schlund.pfixxml.perflogging.PerfEvent;50 import de.schlund.pfixxml.perflogging.PerfEventType;51 49 import de.schlund.pfixxml.resources.FileResource; 52 50 import de.schlund.pfixxml.resources.ResourceUtil; … … 66 64 private Set<IWrapper> allsubmit = new TreeSet<IWrapper>(); 67 65 private Set<IWrapper> allretrieve = new TreeSet<IWrapper>(); 68 p rivateContext context = null;66 public Context context = null; 69 67 private ResultDocument resdoc = null; 70 68 private RequestData reqdata = null; … … 235 233 wrapper.tryParamLogging(); 236 234 if (!wrapper.errorHappened()) { 237 PerfEvent pe = new PerfEvent(PerfEventType.IHANDLER_HANDLESUBMITTEDDATA, handler.getClass().getName());238 pe.start();239 235 handler.handleSubmittedData(context, wrapper); 240 pe.save();241 236 } 242 237 } -
trunk/pfixcore/src/de/schlund/pfixcore/workflow/context/RequestContextImpl.java
r3969 r3975 67 67 import de.schlund.pfixxml.SPDocument; 68 68 import de.schlund.pfixxml.Variant; 69 import de.schlund.pfixxml.perflogging.PerfEvent;70 import de.schlund.pfixxml.perflogging.PerfEventType;71 69 import de.schlund.util.statuscodes.StatusCode; 72 70 … … 842 840 State state = getStateForPageRequest(page); 843 841 844 PerfEvent pe = new PerfEvent(PerfEventType.PAGE_NEEDSDATA, page.getName());845 pe.start();846 842 boolean retval; 847 843 try { … … 850 846 throw new PustefixApplicationException("Exception while running needsData() for page " + page.getName(), e); 851 847 } 852 pe.save();853 848 854 849 currentpagerequest = saved; … … 865 860 State state = getStateForPageRequest(page); 866 861 867 PerfEvent pe = new PerfEvent(PerfEventType.PAGE_ISACCESSIBLE, page.getName());868 pe.start();869 862 boolean retval; 870 863 try { … … 873 866 throw new PustefixApplicationException("Got exception from state for page " + page.getName() + " while calling isAccessible()", e); 874 867 } 875 pe.save();876 868 877 869 return retval; -
trunk/pfixcore/src/de/schlund/pfixxml/PfixServletRequestImpl.java
r3750 r3975 39 39 import de.schlund.pfixxml.multipart.MultipartHandler; 40 40 import de.schlund.pfixxml.multipart.PartData; 41 import de.schlund.pfixxml.perflogging.PerfEvent;42 import de.schlund.pfixxml.perflogging.PerfEventType;43 41 import de.schlund.pfixxml.serverutil.SessionHelper; 44 42 import de.schlund.pfixxml.util.CookieUtils; … … 100 98 */ 101 99 public PfixServletRequestImpl(HttpServletRequest req, Properties properties) { 102 PerfEvent pe = new PerfEvent(PerfEventType.PFIXSERVLETREQUEST_INIT); 103 pe.start(); 104 100 105 101 starttime = System.currentTimeMillis(); 106 102 getRequestParams(req, properties); … … 113 109 session = req.getSession(false); 114 110 115 pe.setIdentfier(uri);116 pe.save();117 111 } 118 112 -
trunk/pfixcore/src/org/pustefixframework/http/AbstractPustefixRequestHandler.java
r3916 r3975 54 54 import de.schlund.pfixxml.exceptionprocessor.ExceptionConfig; 55 55 import de.schlund.pfixxml.exceptionprocessor.ExceptionProcessor; 56 import de.schlund.pfixxml.perflogging.PerfEvent;57 import de.schlund.pfixxml.perflogging.PerfEventType;58 56 import de.schlund.pfixxml.serverutil.SessionAdmin; 59 57 import de.schlund.pfixxml.serverutil.SessionHelper; … … 416 414 LOG.debug("*** >>> End of redirection management, handling request now.... <<< ***\n"); 417 415 418 PerfEvent pe = new PerfEvent(PerfEventType.XMLSERVER_CALLPROCESS, req.getRequestURI());419 pe.start();420 416 callProcess(preq, req, res); 421 pe.save();422 417 } 423 418 -
trunk/pfixcore/src/org/pustefixframework/http/AbstractPustefixXMLRequestHandler.java
r3906 r3975 63 63 import de.schlund.pfixxml.perflogging.AdditionalTrailInfo; 64 64 import de.schlund.pfixxml.perflogging.AdditionalTrailInfoFactory; 65 import de.schlund.pfixxml.perflogging.PerfEvent;66 import de.schlund.pfixxml.perflogging.PerfEventType;67 65 import de.schlund.pfixxml.resources.FileResource; 68 66 import de.schlund.pfixxml.resources.ResourceUtil; … … 389 387 if (spdoc == null) { 390 388 391 // Performace tracking392 PerfEvent pe = new PerfEvent(PerfEventType.XMLSERVER_GETDOM);393 pe.start();394 389 currtime = System.currentTimeMillis(); 395 390 … … 407 402 } 408 403 } 409 410 //Performance tracking411 pe.setIdentfier(spdoc.getPagename());412 pe.save();413 404 414 405 … … 541 532 } 542 533 543 //Performance tracking544 PerfEvent pe = new PerfEvent(PerfEventType.XMLSERVER_HANDLEDOCUMENT, spdoc.getPagename());545 pe.start();546 547 534 if (spdoc.docIsUpdateable()) { 548 535 if (stylesheet.indexOf("::") > 0) { … … 570 557 setCookies(spdoc,res); 571 558 } 559 560 boolean modified_or_no_etag = doHandleDocument(spdoc, stylesheet, paramhash, preq, res, session); 561 562 long handletime = System.currentTimeMillis() - currtime; 563 preq.getRequest().setAttribute(TRAFOTIME, handletime); 564 565 Map<String, Object> addinfo = addtrailinfo.getData(preq); 566 567 if (session != null && !spdoc.getTrailLogged()) { 568 StringBuffer logbuff = new StringBuffer(); 569 logbuff.append(session.getAttribute(VISIT_ID) + "|"); 570 logbuff.append(session.getId() + "|"); 571 logbuff.append(preq.getRemoteAddr() + "|"); 572 logbuff.append(preq.getServerName() + "|"); 573 logbuff.append(stylesheet + "|"); 574 logbuff.append(preq.getOriginalRequestURI()); 575 if (preq.getQueryString() != null) { 576 logbuff.append("?" + preq.getQueryString()); 577 } 578 String flow = (String) paramhash.get("pageflow"); 579 if (flow != null) { 580 logbuff.append("|" + flow); 581 } 582 for (Iterator<String> keys = addinfo.keySet().iterator(); keys.hasNext(); ) { 583 logbuff.append("|" + addinfo.get(keys.next())); 584 } 585 LOGGER_TRAIL.warn(logbuff.toString()); 586 spdoc.setTrailLogged(); 587 } 588 589 if (LOGGER.isInfoEnabled()) { 590 LOGGER.info(">>> Complete handleDocument(...) took " + handletime + "ms" + 591 " (needed xslt: " + modified_or_no_etag + ")"); 592 } 593 594 try { 595 if (modified_or_no_etag && 596 (spdoc.getResponseContentType() == null || spdoc.getResponseContentType().startsWith("text/html"))) { 597 OutputStream out = res.getOutputStream(); 598 OutputStreamWriter writer = new OutputStreamWriter(out, res.getCharacterEncoding()); 599 writer.write("\n<!--"); 600 for (Iterator<String> keys = addinfo.keySet().iterator(); keys.hasNext(); ) { 601 String key = keys.next(); 602 writer.write(" " + key + ": " + addinfo.get(key)); 603 } 604 writer.write(" -->"); 605 writer.flush(); 606 } 607 } catch (Exception e) { 608 // ignore 609 } 610 } 611 612 private boolean doHandleDocument(SPDocument spdoc, String stylesheet, TreeMap<String, Object> paramhash, 613 PfixServletRequest preq, HttpServletResponse res, HttpSession session) throws PustefixCoreException { 572 614 573 615 boolean modified_or_no_etag = true; … … 582 624 } 583 625 584 PerfEvent pe_etag = new PerfEvent(PerfEventType.XMLSERVER_CREATEETAG, spdoc.getPagename()); 585 pe_etag.start(); 586 String etag_outgoing = MD5Utils.hex_md5(output.toString()); 587 pe_etag.save(); 626 String etag_outgoing = createETag(output.toString(), spdoc); 588 627 res.setHeader("ETag", etag_outgoing); 589 628 590 629 if (getRendering(preq) == RENDERMODE.RENDER_NORMAL && etag_incoming != null && etag_incoming.equals(etag_outgoing)) { 591 630 //it's important to reset the content type, because old Apache versions in conjunction … … 603 642 } 604 643 } 605 606 long handletime = System.currentTimeMillis() - currtime; 607 preq.getRequest().setAttribute(TRAFOTIME, handletime); 608 609 Map<String, Object> addinfo = addtrailinfo.getData(preq); 610 611 if (session != null && !spdoc.getTrailLogged()) { 612 StringBuffer logbuff = new StringBuffer(); 613 logbuff.append(session.getAttribute(VISIT_ID) + "|"); 614 logbuff.append(session.getId() + "|"); 615 logbuff.append(preq.getRemoteAddr() + "|"); 616 logbuff.append(preq.getServerName() + "|"); 617 logbuff.append(stylesheet + "|"); 618 logbuff.append(preq.getOriginalRequestURI()); 619 if (preq.getQueryString() != null) { 620 logbuff.append("?" + preq.getQueryString()); 621 } 622 String flow = (String) paramhash.get("pageflow"); 623 if (flow != null) { 624 logbuff.append("|" + flow); 625 } 626 for (Iterator<String> keys = addinfo.keySet().iterator(); keys.hasNext(); ) { 627 logbuff.append("|" + addinfo.get(keys.next())); 628 } 629 LOGGER_TRAIL.warn(logbuff.toString()); 630 spdoc.setTrailLogged(); 631 } 632 633 pe.save(); 634 635 if (LOGGER.isInfoEnabled()) { 636 LOGGER.info(">>> Complete handleDocument(...) took " + handletime + "ms" + 637 " (needed xslt: " + modified_or_no_etag + ")"); 638 } 639 640 try { 641 if (modified_or_no_etag && 642 (spdoc.getResponseContentType() == null || spdoc.getResponseContentType().startsWith("text/html"))) { 643 OutputStream out = res.getOutputStream(); 644 OutputStreamWriter writer = new OutputStreamWriter(out, res.getCharacterEncoding()); 645 writer.write("\n<!--"); 646 for (Iterator<String> keys = addinfo.keySet().iterator(); keys.hasNext(); ) { 647 String key = keys.next(); 648 writer.write(" " + key + ": " + addinfo.get(key)); 649 } 650 writer.write(" -->"); 651 writer.flush(); 652 } 653 } catch (Exception e) { 654 // ignore 655 } 656 } 657 644 645 return modified_or_no_etag; 646 } 647 648 private String createETag(String output, SPDocument spdoc) { 649 String etag_outgoing = MD5Utils.hex_md5(output.toString()); 650 return etag_outgoing; 651 } 658 652 659 653 private void render(SPDocument spdoc, RENDERMODE rendering, HttpServletResponse res, TreeMap<String, Object> paramhash, String stylesheet, OutputStream output) throws RenderingException {
