Package org.milyn.event.types

Examples of org.milyn.event.types.ElementVisitEvent


        if(filterEvents != null && !filterEvents.contains(event.getClass())) {
            return true;
        }

        if(event instanceof ElementVisitEvent) {
            ElementVisitEvent visitEvent = (ElementVisitEvent) event;
            ContentHandler handler = visitEvent.getConfigMapping().getContentHandler();
            if(visitEvent.getSequence() == VisitSequence.BEFORE) {
                VisitBeforeReport reportAnnotation = handler.getClass().getAnnotation(VisitBeforeReport.class);
                if(reportAnnotation != null) {
                    return !evalReportCondition(visitEvent, reportAnnotation.condition());
                }
            } else {
View Full Code Here


                if (logger.isDebugEnabled()) {
                    logger.debug("(Assembly) Calling visitBefore on element [" + DomUtils.getXPath(element) + "]. Config [" + config + "]");
                }
                assemblyUnit.visitBefore(element, executionContext);
                if (eventListener != null) {
                    eventListener.onEvent(new ElementVisitEvent(element, configMap, VisitSequence.BEFORE));
                }
            } catch (Throwable e) {
                String errorMsg = "(Assembly) visitBefore failed [" + assemblyUnit.getClass().getName() + "] on [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "].";
                processVisitorException(element, e, configMap, VisitSequence.BEFORE, errorMsg);
            }
View Full Code Here

            if (logger.isDebugEnabled()) {
                logger.debug("(Assembly) Calling visitAfter on element [" + DomUtils.getXPath(element) + "]. Config [" + config + "]");
            }
            visitAfter.visitAfter(element, executionContext);
            if (eventListener != null) {
                eventListener.onEvent(new ElementVisitEvent(element, configMap, VisitSequence.AFTER));
            }
        } catch (Throwable e) {
            String errorMsg = "(Assembly) visitAfter failed [" + visitAfter.getClass().getName() + "] on [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "].";
            processVisitorException(element, e, configMap, VisitSequence.AFTER, errorMsg);
        }
View Full Code Here

        }
    }

    private void processVisitorException(Element element, Throwable error, ContentHandlerConfigMap configMapping, VisitSequence visitSequence, String errorMsg) throws SmooksException {
        if (eventListener != null) {
            eventListener.onEvent(new ElementVisitEvent(element, configMapping, visitSequence, error));
        }

        executionContext.setTerminationError(error);

        if(terminateOnVisitorException) {
View Full Code Here

                    if (logger.isDebugEnabled()) {
                        logger.debug("Applying processing resource [" + config + "] to element [" + DomUtils.getXPath(element) + "] before applying resources to its child elements.");
                    }
                    visitor.visitBefore(element, executionContext);
                    if (eventListener != null) {
                        eventListener.onEvent(new ElementVisitEvent(element, configMap, VisitSequence.BEFORE));
                    }
                } catch (Throwable e) {
                    String errorMsg = "Failed to apply processing unit [" + visitor.getClass().getName() + "] to [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "].";
                    processVisitorException(element, e, configMap, VisitSequence.BEFORE, errorMsg);
                }
            } else if(visitSequence == VisitSequence.AFTER) {
                // Register the targeting event...
                if (eventListener != null) {
                    eventListener.onEvent(new ResourceTargetingEvent(element, config, VisitSequence.AFTER));
                }

                DOMVisitAfter visitor = (DOMVisitAfter) configMap.getContentHandler();
                try {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Applying processing resource [" + config + "] to element [" + DomUtils.getXPath(element) + "] after applying resources to its child elements.");
                    }
                    visitor.visitAfter(element, executionContext);
                    if (eventListener != null) {
                        eventListener.onEvent(new ElementVisitEvent(element, configMap, VisitSequence.AFTER));
                    }
                } catch (Throwable e) {
                    String errorMsg = "Failed to apply processing unit [" + visitor.getClass().getName() + "] to [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "].";
                    processVisitorException(element, e, configMap, VisitSequence.BEFORE, errorMsg);
                }
            } else if(visitSequence == VisitSequence.CLEAN) {
                // Register the targeting event...
                if (eventListener != null) {
                    eventListener.onEvent(new ResourceTargetingEvent(element, config, VisitSequence.CLEAN));
                }

                ContentHandler contentHandler = configMap.getContentHandler();
                if(contentHandler instanceof VisitLifecycleCleanable) {
                    VisitLifecycleCleanable visitor = (VisitLifecycleCleanable) contentHandler;
                    try {
                        if (logger.isDebugEnabled()) {
                            logger.debug("Cleaning up processing resource [" + config + "] that was targeted to element [" + DomUtils.getXPath(element) + "].");
                        }
                        visitor.executeVisitLifecycleCleanup(new Fragment(element), executionContext);
                        if (eventListener != null) {
                            eventListener.onEvent(new ElementVisitEvent(element, configMap, VisitSequence.CLEAN));
                        }
                    } catch (Throwable e) {
                        String errorMsg = "Failed to clean up [" + visitor.getClass().getName() + "]. Targeted at [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "].";
                        processVisitorException(element, e, configMap, VisitSequence.CLEAN, errorMsg);
                    }
View Full Code Here

        if(defaultSerializationOn && applyDefaultSerialization()) {
            try {
                defaultSerializer.visitAfter(currentProcessor.element, execContext);
                if(eventListener != null) {
                    eventListener.onEvent(new ElementVisitEvent(currentProcessor.element, defaultSerializerMapping, VisitSequence.AFTER));
                }
            } catch (IOException e) {
                throw new SmooksException("Unexpected exception applying defaultSerializer.", e);
            }
            flush = true;
View Full Code Here

                        if(mapping.getResourceConfig().isTargetedAtElement(currentProcessor.element, execContext)) {
                            mapping.getContentHandler().visitBefore(currentProcessor.element, execContext);
                            // Register the targeting event.  No need to register this event again on the visitAfter...
                            if(eventListener != null) {
                                eventListener.onEvent(new ResourceTargetingEvent(element, mapping.getResourceConfig(), VisitSequence.BEFORE));
                                eventListener.onEvent(new ElementVisitEvent(element, mapping, VisitSequence.BEFORE));
                            }
                        }
                    } catch(Throwable t) {
                        String errorMsg = "Error in '" + mapping.getContentHandler().getClass().getName() + "' while processing the visitBefore event.";
                        processVisitorException(currentProcessor.element, t, mapping, VisitSequence.BEFORE, errorMsg);
                    }
                }
            }
        }

        if(defaultSerializationOn && applyDefaultSerialization()) {
            try {
                defaultSerializer.visitBefore(currentProcessor.element, execContext);
                if(eventListener != null) {
                    eventListener.onEvent(new ElementVisitEvent(element, defaultSerializerMapping, VisitSequence.BEFORE));
                }
            } catch (IOException e) {
                throw new SmooksException("Unexpected exception applying defaultSerializer.", e);
            }
        }
View Full Code Here

        try {
            if(afterMapping.getResourceConfig().isTargetedAtElement(currentProcessor.element, execContext)) {
                afterMapping.getContentHandler().visitAfter(currentProcessor.element, execContext);
                if(eventListener != null) {
                    eventListener.onEvent(new ElementVisitEvent(currentProcessor.element, afterMapping, VisitSequence.AFTER));
                }
            }
        } catch(Throwable t) {
            String errorMsg = "Error in '" + afterMapping.getContentHandler().getClass().getName() + "' while processing the visitAfter event.";
            processVisitorException(currentProcessor.element, t, afterMapping, VisitSequence.AFTER, errorMsg);
View Full Code Here

        public SAXElementVisitorMap elementVisitorConfig;
    }

    private void processVisitorException(SAXElement element, Throwable error, ContentHandlerConfigMap configMapping, VisitSequence visitSequence, String errorMsg) throws SmooksException {
        if (eventListener != null) {
            eventListener.onEvent(new ElementVisitEvent(element, configMapping, visitSequence, error));
        }

        processVisitorException(error, errorMsg);
    }
View Full Code Here

TOP

Related Classes of org.milyn.event.types.ElementVisitEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.