Repository: camel Updated Branches: refs/heads/master 76ddb8538 -> f9254da06
CAMEL-9372: camel java dsl - Parameters with uris should denote that with an annotation Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f9254da0 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f9254da0 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f9254da0 Branch: refs/heads/master Commit: f9254da06cd33f4af62c0553121ef35bcba220b9 Parents: 76ddb853 Author: Claus Ibsen <davscl...@apache.org> Authored: Fri Mar 3 14:11:28 2017 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Mar 3 14:11:28 2017 +0100 ---------------------------------------------------------------------- .../org/apache/camel/model/AOPDefinition.java | 11 ++- .../apache/camel/model/ProcessorDefinition.java | 96 +++++++++++--------- .../org/apache/camel/model/RouteDefinition.java | 11 ++- .../apache/camel/model/RoutesDefinition.java | 9 +- .../org/apache/camel/spi/AsEndpointUri.java | 34 +++++++ 5 files changed, 103 insertions(+), 58 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f9254da0/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java b/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java index 588585a..b99f711 100644 --- a/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java @@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.camel.Processor; import org.apache.camel.processor.AOPProcessor; +import org.apache.camel.spi.AsEndpointUri; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.RouteContext; @@ -136,7 +137,7 @@ public class AOPDefinition extends OutputDefinition<AOPDefinition> { * @param afterUri the uri of the after endpoint * @return the builder */ - public AOPDefinition around(String beforeUri, String afterUri) { + public AOPDefinition around(@AsEndpointUri String beforeUri, @AsEndpointUri String afterUri) { this.beforeUri = beforeUri; this.afterUri = afterUri; this.afterFinallyUri = null; @@ -150,7 +151,7 @@ public class AOPDefinition extends OutputDefinition<AOPDefinition> { * @param afterUri the uri of the after endpoint * @return the builder */ - public AOPDefinition aroundFinally(String beforeUri, String afterUri) { + public AOPDefinition aroundFinally(@AsEndpointUri String beforeUri, @AsEndpointUri String afterUri) { this.beforeUri = beforeUri; this.afterUri = null; this.afterFinallyUri = afterUri; @@ -163,7 +164,7 @@ public class AOPDefinition extends OutputDefinition<AOPDefinition> { * @param beforeUri the uri of the before endpoint * @return the builder */ - public AOPDefinition before(String beforeUri) { + public AOPDefinition before(@AsEndpointUri String beforeUri) { this.beforeUri = beforeUri; this.afterUri = null; this.afterFinallyUri = null; @@ -176,7 +177,7 @@ public class AOPDefinition extends OutputDefinition<AOPDefinition> { * @param afterUri the uri of the after endpoint * @return the builder */ - public AOPDefinition after(String afterUri) { + public AOPDefinition after(@AsEndpointUri String afterUri) { this.beforeUri = null; this.afterUri = afterUri; this.afterFinallyUri = null; @@ -189,7 +190,7 @@ public class AOPDefinition extends OutputDefinition<AOPDefinition> { * @param afterUri the uri of the after endpoint * @return the builder */ - public AOPDefinition afterFinally(String afterUri) { + public AOPDefinition afterFinally(@AsEndpointUri String afterUri) { this.beforeUri = null; this.afterUri = null; this.afterFinallyUri = afterUri; http://git-wip-us.apache.org/repos/asf/camel/blob/f9254da0/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java index c40a0bd..4804297 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java @@ -66,6 +66,7 @@ import org.apache.camel.processor.interceptor.Delayer; import org.apache.camel.processor.interceptor.HandleFault; import org.apache.camel.processor.interceptor.StreamCaching; import org.apache.camel.processor.loadbalancer.LoadBalancer; +import org.apache.camel.spi.AsEndpointUri; import org.apache.camel.spi.AsPredicate; import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.IdAware; @@ -617,7 +618,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type to(String uri) { + public Type to(@AsEndpointUri String uri) { addOutput(new ToDefinition(uri)); return (Type) this; } @@ -629,7 +630,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type toD(String uri) { + public Type toD(@AsEndpointUri String uri) { ToDynamicDefinition answer = new ToDynamicDefinition(); answer.setUri(uri); addOutput(answer); @@ -643,7 +644,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type toD(String uri, boolean ignoreInvalidEndpoint) { + public Type toD(@AsEndpointUri String uri, boolean ignoreInvalidEndpoint) { ToDynamicDefinition answer = new ToDynamicDefinition(); answer.setUri(uri); answer.setIgnoreInvalidEndpoint(ignoreInvalidEndpoint); @@ -659,7 +660,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type toF(String uri, Object... args) { + public Type toF(@AsEndpointUri String uri, Object... args) { addOutput(new ToDefinition(String.format(uri, args))); return (Type) this; } @@ -697,7 +698,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type serviceCall(String name, String uri) { + public Type serviceCall(String name, @AsEndpointUri String uri) { ServiceCallDefinition answer = new ServiceCallDefinition(); answer.setName(name); answer.setUri(uri); @@ -727,7 +728,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type to(ExchangePattern pattern, String uri) { + public Type to(ExchangePattern pattern, @AsEndpointUri String uri) { addOutput(new ToDefinition(uri, pattern)); return (Type) this; } @@ -754,7 +755,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type to(String... uris) { + public Type to(@AsEndpointUri String... uris) { for (String uri : uris) { addOutput(new ToDefinition(uri)); } @@ -799,7 +800,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder */ @SuppressWarnings("unchecked") - public Type to(ExchangePattern pattern, String... uris) { + public Type to(ExchangePattern pattern, @AsEndpointUri String... uris) { for (String uri : uris) { addOutput(new ToDefinition(uri, pattern)); } @@ -875,7 +876,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param uri The endpoint uri which is used for sending the exchange * @return the builder */ - public Type inOnly(String uri) { + public Type inOnly(@AsEndpointUri String uri) { return to(ExchangePattern.InOnly, uri); } @@ -903,7 +904,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param uris list of endpoints to send to * @return the builder */ - public Type inOnly(String... uris) { + public Type inOnly(@AsEndpointUri String... uris) { return to(ExchangePattern.InOnly, uris); } @@ -917,7 +918,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param endpoints list of endpoints to send to * @return the builder */ - public Type inOnly(Endpoint... endpoints) { + public Type inOnly(@AsEndpointUri Endpoint... endpoints) { return to(ExchangePattern.InOnly, endpoints); } @@ -957,7 +958,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param uri The endpoint uri which is used for sending the exchange * @return the builder */ - public Type inOut(String uri) { + public Type inOut(@AsEndpointUri String uri) { return to(ExchangePattern.InOut, uri); } @@ -985,7 +986,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param uris list of endpoints to send to * @return the builder */ - public Type inOut(String... uris) { + public Type inOut(@AsEndpointUri String... uris) { return to(ExchangePattern.InOut, uris); } @@ -1170,7 +1171,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param uris list of endpoints * @return the builder */ - public Type pipeline(String... uris) { + public Type pipeline(@AsEndpointUri String... uris) { PipelineDefinition answer = new PipelineDefinition(); addOutput(answer); answer.to(uris); @@ -1738,7 +1739,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param recipients expression to decide the destinations * @return the builder */ - public RecipientListDefinition<Type> recipientList(Expression recipients) { + public RecipientListDefinition<Type> recipientList(@AsEndpointUri Expression recipients) { RecipientListDefinition<Type> answer = new RecipientListDefinition<Type>(recipients); addOutput(answer); return answer; @@ -1752,7 +1753,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param delimiter a custom delimiter to use * @return the builder */ - public RecipientListDefinition<Type> recipientList(Expression recipients, String delimiter) { + public RecipientListDefinition<Type> recipientList(@AsEndpointUri Expression recipients, String delimiter) { RecipientListDefinition<Type> answer = new RecipientListDefinition<Type>(recipients); answer.setDelimiter(delimiter); addOutput(answer); @@ -1766,6 +1767,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param delimiter a custom delimiter to use * @return the builder */ + @AsEndpointUri public ExpressionClause<RecipientListDefinition<Type>> recipientList(String delimiter) { RecipientListDefinition<Type> answer = new RecipientListDefinition<Type>(); answer.setDelimiter(delimiter); @@ -1779,6 +1781,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * * @return the expression clause to configure the expression to decide the destinations */ + @AsEndpointUri public ExpressionClause<RecipientListDefinition<Type>> recipientList() { RecipientListDefinition<Type> answer = new RecipientListDefinition<Type>(); addOutput(answer); @@ -1887,7 +1890,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * the list of URIs in the routing slip. * @return the builder */ - public RoutingSlipDefinition<Type> routingSlip(Expression expression, String uriDelimiter) { + public RoutingSlipDefinition<Type> routingSlip(@AsEndpointUri Expression expression, String uriDelimiter) { RoutingSlipDefinition<Type> answer = new RoutingSlipDefinition<Type>(expression, uriDelimiter); addOutput(answer); return answer; @@ -1905,7 +1908,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param expression to decide the destinations * @return the builder */ - public RoutingSlipDefinition<Type> routingSlip(Expression expression) { + public RoutingSlipDefinition<Type> routingSlip(@AsEndpointUri Expression expression) { RoutingSlipDefinition<Type> answer = new RoutingSlipDefinition<Type>(expression); addOutput(answer); return answer; @@ -1940,7 +1943,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * until it evaluates <tt>null</tt> to indicate no more destinations. * @return the builder */ - public DynamicRouterDefinition<Type> dynamicRouter(Expression expression) { + public DynamicRouterDefinition<Type> dynamicRouter(@AsEndpointUri Expression expression) { DynamicRouterDefinition<Type> answer = new DynamicRouterDefinition<Type>(expression); addOutput(answer); return answer; @@ -1957,6 +1960,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the expression clause to configure the expression to decide the destinations, * which will be invoked repeatedly until it evaluates <tt>null</tt> to indicate no more destinations. */ + @AsEndpointUri public ExpressionClause<DynamicRouterDefinition<Type>> dynamicRouter() { DynamicRouterDefinition<Type> answer = new DynamicRouterDefinition<Type>(); addOutput(answer); @@ -2421,7 +2425,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @param uri the dynamic endpoint to wiretap to (resolved using simple language by default) * @return the builder */ - public WireTapDefinition<Type> wireTap(String uri) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri) { WireTapDefinition answer = new WireTapDefinition(); answer.setUri(uri); addOutput(answer); @@ -2441,7 +2445,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @deprecated use the fluent builder from {@link WireTapDefinition}, will be removed in Camel 3.0 */ @Deprecated - public WireTapDefinition<Type> wireTap(String uri, ExecutorService executorService) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri, ExecutorService executorService) { WireTapDefinition answer = new WireTapDefinition(); answer.setUri(uri); answer.setExecutorService(executorService); @@ -2462,7 +2466,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @deprecated use the fluent builder from {@link WireTapDefinition}, will be removed in Camel 3.0 */ @Deprecated - public WireTapDefinition<Type> wireTap(String uri, String executorServiceRef) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri, String executorServiceRef) { WireTapDefinition answer = new WireTapDefinition(); answer.setUri(uri); answer.setExecutorServiceRef(executorServiceRef); @@ -2484,7 +2488,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @deprecated use the fluent builder from {@link WireTapDefinition}, will be removed in Camel 3.0 */ @Deprecated - public WireTapDefinition<Type> wireTap(String uri, Expression body) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri, Expression body) { return wireTap(uri, true, body); } @@ -2499,7 +2503,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @deprecated use the fluent builder from {@link WireTapDefinition}, will be removed in Camel 3.0 */ @Deprecated - public WireTapDefinition<Type> wireTap(String uri, boolean copy) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri, boolean copy) { WireTapDefinition answer = new WireTapDefinition(); answer.setUri(uri); answer.setCopy(copy); @@ -2519,7 +2523,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @deprecated use the fluent builder from {@link WireTapDefinition}, will be removed in Camel 3.0 */ @Deprecated - public WireTapDefinition<Type> wireTap(String uri, boolean copy, Expression body) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri, boolean copy, Expression body) { WireTapDefinition answer = new WireTapDefinition(); answer.setUri(uri); answer.setCopy(copy); @@ -2542,7 +2546,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @deprecated use the fluent builder from {@link WireTapDefinition}, will be removed in Camel 3.0 */ @Deprecated - public WireTapDefinition<Type> wireTap(String uri, Processor processor) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri, Processor processor) { return wireTap(uri, true, processor); } @@ -2558,7 +2562,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @deprecated use the fluent builder from {@link WireTapDefinition}, will be removed in Camel 3.0 */ @Deprecated - public WireTapDefinition<Type> wireTap(String uri, boolean copy, Processor processor) { + public WireTapDefinition<Type> wireTap(@AsEndpointUri String uri, boolean copy, Processor processor) { WireTapDefinition answer = new WireTapDefinition(); answer.setUri(uri); answer.setCopy(copy); @@ -3389,7 +3393,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.Enricher */ - public Type enrich(String resourceUri) { + public Type enrich(@AsEndpointUri String resourceUri) { return enrich(resourceUri, null); } @@ -3402,7 +3406,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.Enricher */ - public Type enrich(String resourceUri, AggregationStrategy aggregationStrategy) { + public Type enrich(@AsEndpointUri String resourceUri, AggregationStrategy aggregationStrategy) { return enrich(resourceUri, aggregationStrategy, false); } @@ -3412,7 +3416,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * * @return the builder */ - public EnrichClause<ProcessorDefinition<Type>> enrichWith(String resourceUri) { + public EnrichClause<ProcessorDefinition<Type>> enrichWith(@AsEndpointUri String resourceUri) { EnrichClause<ProcessorDefinition<Type>> clause = new EnrichClause<>(this); enrich(resourceUri, clause); return clause; @@ -3424,7 +3428,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * * @return the builder */ - public EnrichClause<ProcessorDefinition<Type>> enrichWith(String resourceUri, boolean aggregateOnException) { + public EnrichClause<ProcessorDefinition<Type>> enrichWith(@AsEndpointUri String resourceUri, boolean aggregateOnException) { EnrichClause<ProcessorDefinition<Type>> clause = new EnrichClause<>(this); enrich(resourceUri, clause, aggregateOnException, false); return clause; @@ -3436,7 +3440,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * * @return the builder */ - public EnrichClause<ProcessorDefinition<Type>> enrichWith(String resourceUri, boolean aggregateOnException, boolean shareUnitOfWork) { + public EnrichClause<ProcessorDefinition<Type>> enrichWith(@AsEndpointUri String resourceUri, boolean aggregateOnException, boolean shareUnitOfWork) { EnrichClause<ProcessorDefinition<Type>> clause = new EnrichClause<>(this); enrich(resourceUri, clause, aggregateOnException, shareUnitOfWork); return clause; @@ -3453,7 +3457,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.Enricher */ - public Type enrich(String resourceUri, AggregationStrategy aggregationStrategy, boolean aggregateOnException) { + public Type enrich(@AsEndpointUri String resourceUri, AggregationStrategy aggregationStrategy, boolean aggregateOnException) { return enrich(resourceUri, aggregationStrategy, aggregateOnException, false); } @@ -3470,7 +3474,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @see org.apache.camel.processor.Enricher */ @SuppressWarnings("unchecked") - public Type enrich(String resourceUri, AggregationStrategy aggregationStrategy, boolean aggregateOnException, boolean shareUnitOfWork) { + public Type enrich(@AsEndpointUri String resourceUri, AggregationStrategy aggregationStrategy, boolean aggregateOnException, boolean shareUnitOfWork) { EnrichDefinition answer = new EnrichDefinition(); answer.setExpression(new ConstantExpression(resourceUri)); answer.setAggregationStrategy(aggregationStrategy); @@ -3556,6 +3560,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return a expression builder clause to set the expression to use for computing the endpoint to use * @see org.apache.camel.processor.PollEnricher */ + @AsEndpointUri public ExpressionClause<EnrichDefinition> enrich() { EnrichDefinition answer = new EnrichDefinition(); addOutput(answer); @@ -3577,7 +3582,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.PollEnricher */ - public Type pollEnrich(String resourceUri) { + public Type pollEnrich(@AsEndpointUri String resourceUri) { return pollEnrich(resourceUri, null); } @@ -3597,7 +3602,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.PollEnricher */ - public Type pollEnrich(String resourceUri, AggregationStrategy aggregationStrategy) { + public Type pollEnrich(@AsEndpointUri String resourceUri, AggregationStrategy aggregationStrategy) { return pollEnrich(resourceUri, -1, aggregationStrategy); } @@ -3619,7 +3624,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.PollEnricher */ - public Type pollEnrich(String resourceUri, long timeout, AggregationStrategy aggregationStrategy) { + public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, AggregationStrategy aggregationStrategy) { return pollEnrich(resourceUri, timeout, aggregationStrategy, false); } @@ -3641,7 +3646,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.PollEnricher */ - public Type pollEnrich(String resourceUri, long timeout, String aggregationStrategyRef) { + public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, String aggregationStrategyRef) { return pollEnrich(resourceUri, timeout, aggregationStrategyRef, false); } @@ -3652,7 +3657,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * * @return the builder */ - public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(String resourceUri) { + public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(@AsEndpointUri String resourceUri) { EnrichClause<ProcessorDefinition<Type>> clause = new EnrichClause<>(this); pollEnrich(resourceUri, -1, clause, false); return clause; @@ -3664,7 +3669,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * * @return the builder */ - public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(String resourceUri, long timeout) { + public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(@AsEndpointUri String resourceUri, long timeout) { EnrichClause<ProcessorDefinition<Type>> clause = new EnrichClause<>(this); pollEnrich(resourceUri, timeout, clause, false); return clause; @@ -3676,7 +3681,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * * @return the builder */ - public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(String resourceUri, long timeout, boolean aggregateOnException) { + public EnrichClause<ProcessorDefinition<Type>> pollEnrichWith(@AsEndpointUri String resourceUri, long timeout, boolean aggregateOnException) { EnrichClause<ProcessorDefinition<Type>> clause = new EnrichClause<>(this); pollEnrich(resourceUri, timeout, clause, aggregateOnException); return clause; @@ -3703,7 +3708,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @see org.apache.camel.processor.PollEnricher */ @SuppressWarnings("unchecked") - public Type pollEnrich(String resourceUri, long timeout, AggregationStrategy aggregationStrategy, boolean aggregateOnException) { + public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, AggregationStrategy aggregationStrategy, boolean aggregateOnException) { PollEnrichDefinition pollEnrich = new PollEnrichDefinition(); pollEnrich.setExpression(new ConstantExpression(resourceUri)); pollEnrich.setTimeout(timeout); @@ -3734,7 +3739,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @see org.apache.camel.processor.PollEnricher */ @SuppressWarnings("unchecked") - public Type pollEnrich(String resourceUri, long timeout, String aggregationStrategyRef, boolean aggregateOnException) { + public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, String aggregationStrategyRef, boolean aggregateOnException) { PollEnrichDefinition pollEnrich = new PollEnrichDefinition(); pollEnrich.setExpression(new ConstantExpression(resourceUri)); pollEnrich.setTimeout(timeout); @@ -3761,7 +3766,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return the builder * @see org.apache.camel.processor.PollEnricher */ - public Type pollEnrich(String resourceUri, long timeout) { + public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout) { return pollEnrich(resourceUri, timeout, (String) null); } @@ -3849,7 +3854,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @see org.apache.camel.processor.PollEnricher */ @SuppressWarnings("unchecked") - public Type pollEnrich(Expression expression, long timeout, String aggregationStrategyRef, boolean aggregateOnException) { + public Type pollEnrich(@AsEndpointUri Expression expression, long timeout, String aggregationStrategyRef, boolean aggregateOnException) { PollEnrichDefinition pollEnrich = new PollEnrichDefinition(); pollEnrich.setExpression(new ExpressionDefinition(expression)); pollEnrich.setTimeout(timeout); @@ -3874,6 +3879,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> * @return a expression builder clause to set the expression to use for computing the endpoint to poll from * @see org.apache.camel.processor.PollEnricher */ + @AsEndpointUri public ExpressionClause<PollEnrichDefinition> pollEnrich() { PollEnrichDefinition answer = new PollEnrichDefinition(); addOutput(answer); http://git-wip-us.apache.org/repos/asf/camel/blob/f9254da0/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java b/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java index eee2f3b..48f10a5 100644 --- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java @@ -47,12 +47,15 @@ import org.apache.camel.impl.DefaultRouteContext; import org.apache.camel.model.rest.RestBindingDefinition; import org.apache.camel.model.rest.RestDefinition; import org.apache.camel.processor.interceptor.HandleFault; +import org.apache.camel.spi.AsEndpointUri; import org.apache.camel.spi.Contract; import org.apache.camel.spi.LifecycleStrategy; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.RouteContext; import org.apache.camel.spi.RoutePolicy; import org.apache.camel.spi.RoutePolicyFactory; +import org.apache.camel.spi.Transformer; +import org.apache.camel.spi.Validator; import org.apache.camel.util.CamelContextHelper; import org.apache.camel.util.ObjectHelper; @@ -96,7 +99,7 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition> { public RouteDefinition() { } - public RouteDefinition(String uri) { + public RouteDefinition(@AsEndpointUri String uri) { from(uri); } @@ -107,7 +110,7 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition> { /** * This route is created from the REST DSL. */ - public void fromRest(String uri) { + public void fromRest(@AsEndpointUri String uri) { from(uri); rest = true; } @@ -314,7 +317,7 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition> { * @param uri the from uri * @return the builder */ - public RouteDefinition from(String uri) { + public RouteDefinition from(@AsEndpointUri String uri) { getInputs().add(new FromDefinition(uri)); return this; } @@ -336,7 +339,7 @@ public class RouteDefinition extends ProcessorDefinition<RouteDefinition> { * @param uris the from uris * @return the builder */ - public RouteDefinition from(String... uris) { + public RouteDefinition from(@AsEndpointUri String... uris) { for (String uri : uris) { getInputs().add(new FromDefinition(uri)); } http://git-wip-us.apache.org/repos/asf/camel/blob/f9254da0/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java b/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java index c29f8ee..3f51b0e 100644 --- a/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java @@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlTransient; import org.apache.camel.Endpoint; import org.apache.camel.ErrorHandlerFactory; +import org.apache.camel.spi.AsEndpointUri; import org.apache.camel.spi.Metadata; /** @@ -151,7 +152,7 @@ public class RoutesDefinition extends OptionalIdentifiedDefinition<RoutesDefinit * @param uri the from uri * @return the builder */ - public RouteDefinition from(String uri) { + public RouteDefinition from(@AsEndpointUri String uri) { RouteDefinition route = createRoute(); route.from(uri); return route(route); @@ -175,7 +176,7 @@ public class RoutesDefinition extends OptionalIdentifiedDefinition<RoutesDefinit * @param uris the from uri * @return the builder */ - public RouteDefinition from(String... uris) { + public RouteDefinition from(@AsEndpointUri String... uris) { RouteDefinition route = createRoute(); route.from(uris); return route(route); @@ -240,7 +241,7 @@ public class RoutesDefinition extends OptionalIdentifiedDefinition<RoutesDefinit * @param uri uri of the endpoint * @return the interceptor builder to configure */ - public InterceptFromDefinition interceptFrom(final String uri) { + public InterceptFromDefinition interceptFrom(@AsEndpointUri final String uri) { InterceptFromDefinition answer = new InterceptFromDefinition(uri); getInterceptFroms().add(answer); return answer; @@ -253,7 +254,7 @@ public class RoutesDefinition extends OptionalIdentifiedDefinition<RoutesDefinit * @param uri uri of the endpoint * @return the builder */ - public InterceptSendToEndpointDefinition interceptSendToEndpoint(final String uri) { + public InterceptSendToEndpointDefinition interceptSendToEndpoint(@AsEndpointUri final String uri) { InterceptSendToEndpointDefinition answer = new InterceptSendToEndpointDefinition(uri); getInterceptSendTos().add(answer); return answer; http://git-wip-us.apache.org/repos/asf/camel/blob/f9254da0/tooling/spi-annotations/src/main/java/org/apache/camel/spi/AsEndpointUri.java ---------------------------------------------------------------------- diff --git a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/AsEndpointUri.java b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/AsEndpointUri.java new file mode 100644 index 0000000..aa4b402 --- /dev/null +++ b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/AsEndpointUri.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spi; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Indicates that the Camel string/expression should be used as an endpoint uri. + * <p/> + * For example the EIPs which accepts uris as string/expression parameters. + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) +public @interface AsEndpointUri { +}