Author: davsclaus Date: Mon Mar 2 12:52:41 2009 New Revision: 749296 URL: http://svn.apache.org/viewvc?rev=749296&view=rev Log: CAMEL-588: Reduced package tangling.
Added: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/tokenize Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=749296&r1=749295&r2=749296&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Mon Mar 2 12:52:41 2009 @@ -295,6 +295,13 @@ void addInterceptStrategy(InterceptStrategy interceptStrategy); /** + * Gets the interceptor strategies + * + * @return the list of current interceptor strategies + */ + List<InterceptStrategy> getInterceptStrategies(); + + /** * Gets the default error handler builder which is inherited by the routes * * @return the builder Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java?rev=749296&r1=749295&r2=749296&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java Mon Mar 2 12:52:41 2009 @@ -34,9 +34,7 @@ import org.apache.camel.Message; import org.apache.camel.RuntimeCamelException; import org.apache.camel.impl.ExpressionAdapter; -import org.apache.camel.language.bean.BeanLanguage; -import org.apache.camel.language.simple.SimpleLanguage; -import org.apache.camel.processor.DeadLetterChannel; +import org.apache.camel.spi.Language; /** * A helper class for working with <a href="http://camel.apache.org/expression.html">expressions</a>. @@ -679,13 +677,13 @@ String key = command.substring(command.lastIndexOf(".") + 1); date = exchange.getIn().getHeader(key, Date.class); if (date == null) { - throw new IllegalArgumentException("Could not find java.util.Date object at " + command); + throw new IllegalArgumentException("Cannot find java.util.Date object at " + command); } } else if (command.startsWith("out.header.")) { String key = command.substring(command.lastIndexOf(".") + 1); date = exchange.getOut().getHeader(key, Date.class); if (date == null) { - throw new IllegalArgumentException("Could not find java.util.Date object at " + command); + throw new IllegalArgumentException("Cannot find java.util.Date object at " + command); } } else { throw new IllegalArgumentException("Command not supported for dateExpression: " + command); @@ -702,17 +700,19 @@ }; } - public static Expression simpleExpression(final String simple) { + public static Expression simpleExpression(final String expression) { return new ExpressionAdapter() { public Object evaluate(Exchange exchange) { + // resolve language using context to have a clear separation of packages // must call evalute to return the nested langauge evaluate when evaluating // stacked expressions - return SimpleLanguage.simple(simple).evaluate(exchange); + Language language = exchange.getContext().resolveLanguage("simple"); + return language.createExpression(expression).evaluate(exchange); } @Override public String toString() { - return "simple(" + simple + ")"; + return "simple(" + expression + ")"; } }; } @@ -720,9 +720,11 @@ public static Expression beanExpression(final String expression) { return new ExpressionAdapter() { public Object evaluate(Exchange exchange) { + // resolve language using context to have a clear separation of packages // must call evalute to return the nested langauge evaluate when evaluating // stacked expressions - return BeanLanguage.bean(expression).evaluate(exchange); + Language language = exchange.getContext().resolveLanguage("bean"); + return language.createExpression(expression).evaluate(exchange); } @Override @@ -744,8 +746,7 @@ if (value instanceof Readable) { scanner = new Scanner((Readable)value); } else if (value instanceof InputStream) { - scanner = charset == null ? new Scanner((InputStream)value) - : new Scanner((InputStream)value, charset); + scanner = charset == null ? new Scanner((InputStream)value) : new Scanner((InputStream)value, charset); } else if (value instanceof File) { try { scanner = charset == null ? new Scanner((File)value) : new Scanner((File)value, charset); @@ -755,8 +756,7 @@ } else if (value instanceof String) { scanner = new Scanner((String)value); } else if (value instanceof ReadableByteChannel) { - scanner = charset == null ? new Scanner((ReadableByteChannel)value) - : new Scanner((ReadableByteChannel)value, charset); + scanner = charset == null ? new Scanner((ReadableByteChannel)value) : new Scanner((ReadableByteChannel)value, charset); } if (scanner == null) { @@ -770,6 +770,7 @@ if (scanner == null) { scanner = new Scanner(""); } + return scanner; } Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=749296&r1=749295&r2=749296&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java Mon Mar 2 12:52:41 2009 @@ -47,7 +47,6 @@ import org.apache.camel.builder.ExpressionClause; import org.apache.camel.builder.NoErrorHandlerBuilder; import org.apache.camel.builder.ProcessorBuilder; -import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.model.dataformat.DataFormatType; import org.apache.camel.model.language.ConstantExpression; import org.apache.camel.model.language.ExpressionType; @@ -1940,10 +1939,7 @@ List<InterceptStrategy> strategies = new ArrayList<InterceptStrategy>(); CamelContext camelContext = routeContext.getCamelContext(); - if (camelContext instanceof DefaultCamelContext) { - DefaultCamelContext defaultCamelContext = (DefaultCamelContext) camelContext; - strategies.addAll(defaultCamelContext.getInterceptStrategies()); - } + strategies.addAll(camelContext.getInterceptStrategies()); strategies.addAll(routeContext.getInterceptStrategies()); for (InterceptStrategy strategy : strategies) { if (strategy != null) { Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java?rev=749296&r1=749295&r2=749296&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java Mon Mar 2 12:52:41 2009 @@ -24,7 +24,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Processor; -import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.model.ProcessorType; import org.apache.camel.spi.InterceptStrategy; import org.apache.commons.logging.Log; @@ -52,13 +51,10 @@ * @return the debugger or null if none can be found */ public static Debugger getDebugger(CamelContext context) { - if (context instanceof DefaultCamelContext) { - DefaultCamelContext defaultCamelContext = (DefaultCamelContext) context; - List<InterceptStrategy> list = defaultCamelContext.getInterceptStrategies(); - for (InterceptStrategy interceptStrategy : list) { - if (interceptStrategy instanceof Debugger) { - return (Debugger)interceptStrategy; - } + List<InterceptStrategy> list = context.getInterceptStrategies(); + for (InterceptStrategy interceptStrategy : list) { + if (interceptStrategy instanceof Debugger) { + return (Debugger)interceptStrategy; } } return null; Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java?rev=749296&r1=749295&r2=749296&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Delayer.java Mon Mar 2 12:52:41 2009 @@ -20,7 +20,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.Processor; -import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.model.ProcessorType; import org.apache.camel.spi.InterceptStrategy; @@ -46,20 +45,16 @@ * @return the delayer or null if none can be found */ public static DelayInterceptor getDelayer(CamelContext context) { - if (context instanceof DefaultCamelContext) { - DefaultCamelContext defaultCamelContext = (DefaultCamelContext) context; - List<InterceptStrategy> list = defaultCamelContext.getInterceptStrategies(); - for (InterceptStrategy interceptStrategy : list) { - if (interceptStrategy instanceof DelayInterceptor) { - return (DelayInterceptor)interceptStrategy; - } + List<InterceptStrategy> list = context.getInterceptStrategies(); + for (InterceptStrategy interceptStrategy : list) { + if (interceptStrategy instanceof DelayInterceptor) { + return (DelayInterceptor)interceptStrategy; } } return null; } - public Processor wrapProcessorInInterceptors(ProcessorType processorType, Processor target) - throws Exception { + public Processor wrapProcessorInInterceptors(ProcessorType processorType, Processor target) throws Exception { DelayInterceptor delayer = new DelayInterceptor(processorType, target, this); return delayer; } Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java?rev=749296&r1=749295&r2=749296&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java Mon Mar 2 12:52:41 2009 @@ -23,7 +23,6 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.Predicate; import org.apache.camel.Processor; -import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.model.ProcessorType; import org.apache.camel.spi.InterceptStrategy; @@ -53,13 +52,10 @@ * @return the tracer or null if none can be found */ public static Tracer getTracer(CamelContext context) { - if (context instanceof DefaultCamelContext) { - DefaultCamelContext defaultCamelContext = (DefaultCamelContext) context; - List<InterceptStrategy> list = defaultCamelContext.getInterceptStrategies(); - for (InterceptStrategy interceptStrategy : list) { - if (interceptStrategy instanceof Tracer) { - return (Tracer)interceptStrategy; - } + List<InterceptStrategy> list = context.getInterceptStrategies(); + for (InterceptStrategy interceptStrategy : list) { + if (interceptStrategy instanceof Tracer) { + return (Tracer)interceptStrategy; } } return null; @@ -202,4 +198,4 @@ public void setUseJpa(boolean useJpa) { this.useJpa = useJpa; } -} \ No newline at end of file +} Added: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/tokenize URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/tokenize?rev=749296&view=auto ============================================================================== --- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/tokenize (added) +++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/tokenize Mon Mar 2 12:52:41 2009 @@ -0,0 +1,18 @@ +# +# 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. +# + +class=org.apache.camel.language.tokenizer.TokenizeLanguage