Java 类org.apache.camel.model.language.ConstantExpression 实例源码

项目:syndesis    文件:SalesforceStreamingConnector.java   
@Override
public final String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    final String query = "SELECT Id FROM " + sObjectName;
    final String topicName = topicNameFor(options);
    options.put("topicName", topicName);
    options.put(SalesforceEndpointConfig.SOBJECT_QUERY, query);
    options.remove(SalesforceEndpointConfig.SOBJECT_NAME);

    final String salesforceComponent = getComponentScheme();

    if (!topicName.endsWith("_delete")) {
        final Enricher enricher = new Enricher(
            new ConstantExpression(salesforceComponent + ":getSObject?rawPayload=true&sObjectName=" + sObjectName));
        enricher.setCamelContext(getCamelContext());

        setBeforeConsumer(enricher);
    }

    return super.createEndpointUri(scheme, options);
}
项目:connectors    文件:AbstractSalesforceStreamingConnector.java   
@Override
public String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException {
    final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME);

    final String query = "SELECT Id FROM " + sObjectName;
    options.put("topicName", topicNameFor(options));
    options.put(SalesforceEndpointConfig.SOBJECT_QUERY, query);
    options.remove(SalesforceEndpointConfig.SOBJECT_NAME);

    final String salesforceComponent = getComponentName() + "-component";

    final Enricher enricher = new Enricher(
        new ConstantExpression(salesforceComponent + ":getSObject?rawPayload=true&sObjectName=" + sObjectName));
    enricher.setCamelContext(getCamelContext());

    setBeforeConsumer(enricher);

    return super.createEndpointUri(scheme, options);
}
项目:Camel    文件:CustomProcessorFactoryTest.java   
public Processor createProcessor(RouteContext routeContext, ProcessorDefinition<?> definition) throws Exception {
    if (definition instanceof SplitDefinition) {
        // add additional output to the splitter
        SplitDefinition split = (SplitDefinition) definition;
        split.addOutput(new ToDefinition("mock:extra"));
    }

    if (definition instanceof SetBodyDefinition) {
        SetBodyDefinition set = (SetBodyDefinition) definition;
        set.setExpression(new ConstantExpression("body was altered"));
    }

    // return null to let the default implementation create the processor, we just wanted to alter the definition
    // before the processor was created
    return null;
}
项目:Camel    文件:ValidatorResourceResolverFactoryTest.java   
@Override
protected RouteBuilder[] createRouteBuilders() throws Exception {
    return new RouteBuilder[] {new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").setHeader("xsd_file", new ConstantExpression("org/apache/camel/component/validator/xsds/person.xsd"))
                .recipientList(new SimpleExpression("validator:${header.xsd_file}?resourceResolverFactory=#resourceResolverFactory")).to("mock:end");
        }

    }, new RouteBuilder() {
        @Override
        public void configure() throws Exception {

            from("direct:startComponent").setHeader("xsd_file", new ConstantExpression("org/apache/camel/component/validator/xsds/person.xsd"))
                .recipientList(new SimpleExpression("validator:${header.xsd_file}")).to("mock:end");

        }
    }};
}
项目:Camel    文件:XsltUriResolverFactoryTest.java   
@Override
protected RouteBuilder[] createRouteBuilders() throws Exception {
    return new RouteBuilder[] {new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start") //
                .setHeader("xslt_file", new ConstantExpression("xslt/staff/staff.xsl")) //
                .recipientList(new SimpleExpression("xslt:${header.xslt_file}?uriResolverFactory=#uriResolverFactory")) //
                .to("mock:result");
        }
    }, new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:startComponent") //
                .setHeader("xslt_file", new ConstantExpression("xslt/staff/staff.xsl")) //
                .recipientList(new SimpleExpression("xslt:${header.xslt_file}")) //
                .to("mock:result");
        }
    }};
}
项目:Camel    文件:ExpressionClauseSupport.java   
/**
 * Specify the constant expression value
 */
public T constant(Object value) {
    if (value instanceof String) {
        return expression(new ConstantExpression((String) value));
    } else {
        return expression(ExpressionBuilder.constantExpression(value));
    }
}
项目:Camel    文件:DefinitionPolicyPerProcessorTest.java   
public void beforeWrap(RouteContext routeContext, ProcessorDefinition<?> definition) {
    SetBodyDefinition bodyDef = (SetBodyDefinition) definition.getOutputs().get(0);
    bodyDef.setExpression(new ConstantExpression("body was altered"));
}
项目:Camel    文件:ProcessorDefinition.java   
/**
 * The <a href="http://camel.apache.org/content-enricher.html">Content Enricher EIP</a>
 * enriches an exchange with additional data obtained from a <code>resourceUri</code>.
 *
 * @param resourceUri           URI of resource endpoint for obtaining additional data.
 * @param aggregationStrategy   aggregation strategy to aggregate input data and additional data.
 * @param aggregateOnException  whether to call {@link org.apache.camel.processor.aggregate.AggregationStrategy#aggregate(org.apache.camel.Exchange, org.apache.camel.Exchange)} if
 *                              an exception was thrown.
 * @param shareUnitOfWork       whether to share unit of work
 * @return the builder
 * @see org.apache.camel.processor.Enricher
 */
@SuppressWarnings("unchecked")
public Type enrich(String resourceUri, AggregationStrategy aggregationStrategy, boolean aggregateOnException, boolean shareUnitOfWork) {
    EnrichDefinition answer = new EnrichDefinition();
    answer.setExpression(new ConstantExpression(resourceUri));
    answer.setAggregationStrategy(aggregationStrategy);
    answer.setAggregateOnException(aggregateOnException);
    answer.setShareUnitOfWork(shareUnitOfWork);
    addOutput(answer);
    return (Type) this;
}