Package org.apache.camel.spi

Examples of org.apache.camel.spi.Policy


        return this;
    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Policy policy = resolvePolicy(routeContext);
        ObjectHelper.notNull(policy, "policy", this);

        // before wrap
        policy.beforeWrap(routeContext, this);

        // create processor after the before wrap
        Processor childProcessor = this.createChildProcessor(routeContext, true);

        // wrap
        Processor target = policy.wrap(routeContext, childProcessor);

        if (!(target instanceof Service)) {
            // wrap the target so it becomes a service and we can manage its lifecycle
            target = new WrapProcessor(target, childProcessor);
        }
View Full Code Here


    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = createOutputsProcessor(routeContext);

        Policy policy = resolvePolicy(routeContext);
        if (policy == null) {
            throw new IllegalArgumentException("No policy configured: " + this);
        }
        return policy.wrap(childProcessor);
    }
View Full Code Here

        return this;
    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Policy policy = resolvePolicy(routeContext);
        ObjectHelper.notNull(policy, "policy", this);

        // before wrap
        policy.beforeWrap(routeContext, this);

        // create processor after the before wrap
        Processor childProcessor = this.createChildProcessor(routeContext, true);

        // wrap
        Processor target = policy.wrap(routeContext, childProcessor);

        // wrap the target so it becomes a service and we can manage its lifecycle
        WrapProcessor wrap = new WrapProcessor(target, childProcessor);
        return wrap;
    }
View Full Code Here

        return this;
    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Policy policy = resolvePolicy(routeContext);
        ObjectHelper.notNull(policy, "policy", this);

        // before wrap
        policy.beforeWrap(routeContext, this);

        // create processor after the before wrap
        Processor childProcessor = this.createChildProcessor(routeContext, true);

        // wrap
        Processor target = policy.wrap(routeContext, childProcessor);

        // wrap the target so it becomes a service and we can manage its lifecycle
        WrapProcessor wrap = new WrapProcessor(target, childProcessor);
        return wrap;
    }
View Full Code Here

        }

        // no explicit reference given from user so we can use some convention over configuration here

        // try to lookup by scoped type
        Policy answer = null;
        if (type != null) {
            // try find by type, note that this method is not supported by all registry
            Map types = routeContext.lookupByType(type);
            if (types.size() == 1) {
                // only one policy defined so use it
View Full Code Here

                SpringTransactionPolicy requried = new SpringTransactionPolicy(lookup("PROPAGATION_REQUIRED", TransactionTemplate.class));
                SpringTransactionPolicy notsupported = new SpringTransactionPolicy(lookup("PROPAGATION_NOT_SUPPORTED", TransactionTemplate.class));
                SpringTransactionPolicy requirenew = new SpringTransactionPolicy(lookup("PROPAGATION_REQUIRES_NEW", TransactionTemplate.class));

                Policy rollback = new Policy() {
                    public void beforeWrap(RouteContext routeContext, ProcessorDefinition<?> definition) {
                    }

                    public Processor wrap(RouteContext routeContext, Processor processor) {
                        return new DelegateProcessor(processor) {
                            @Override
                            public void process(Exchange exchange) throws Exception {
                                processNext(exchange);
                                throw new RuntimeException("rollback");
                            }

                            @Override
                            public String toString() {
                                return "rollback(" + getProcessor() + ")";
                            }
                        };
                    }
                };

                Policy catchRollback = new Policy() {
                    public void beforeWrap(RouteContext routeContext, ProcessorDefinition<?> definition) {
                    }

                    public Processor wrap(RouteContext routeContext, Processor processor) {
                        return new DelegateProcessor(processor) {
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.Policy

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.