camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1360722 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/converter/stream/ camel-core/src/main/java/org/apache/camel/impl/ camel-core...
Date Thu, 12 Jul 2012 15:22:20 GMT
Author: ningjiang
Date: Thu Jul 12 15:22:19 2012
New Revision: 1360722

URL: http://svn.apache.org/viewvc?rev=1360722&view=rev
Log:
CAMEL-5438 supports dynamic resolve property

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/converter/stream/CachedOutputStream.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
    camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
    camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.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=1360722&r1=1360721&r2=1360722&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 Thu Jul 12 15:22:19
2012
@@ -838,6 +838,14 @@ public interface CamelContext extends Su
     Map<String, String> getProperties();
 
     /**
+     * Gets the property value that can be referenced in the camel context
+     *
+     * @return the string value of property
+     * 
+     */
+    String getProperty(String name);
+    
+    /**
      * Gets the default FactoryFinder which will be used for the loading the factory class
from META-INF
      *
      * @return the default factory finder

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=1360722&r1=1360721&r2=1360722&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 Thu
Jul 12 15:22:19 2012
@@ -593,7 +593,7 @@ public final class ExpressionBuilder {
     public static Expression camelContextPropertyExpression(final String propertyName) {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                return exchange.getContext().getProperties().get(propertyName);
+                return exchange.getContext().getProperty(propertyName);
             }
 
             @Override

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java
Thu Jul 12 15:22:19 2012
@@ -61,8 +61,8 @@ public class CachedOutputStream extends 
     }
 
     public CachedOutputStream(Exchange exchange, boolean closedOnCompletion) {
-        String hold = exchange.getContext().getProperties().get(THRESHOLD);
-        String dir = exchange.getContext().getProperties().get(TEMP_DIR);
+        String hold = exchange.getContext().getProperty(THRESHOLD);
+        String dir = exchange.getContext().getProperty(TEMP_DIR);
         if (hold != null) {
             this.threshold = exchange.getContext().getTypeConverter().convertTo(Long.class,
hold);
         }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Thu
Jul 12 15:22:19 2012
@@ -2481,4 +2481,18 @@ public class DefaultCamelContext extends
             return new ActiveMQUuidGenerator();
         }
     }
+
+    @Override
+    public String getProperty(String name) {
+        String value = getProperties().get(name);
+        if (ObjectHelper.isNotEmpty(value)) {
+            try {
+                value = resolvePropertyPlaceholders(value);
+            } catch (Exception ex) {
+                // throw CamelRutimeException
+                throw new RuntimeCamelException(ex);
+            }
+        }
+        return value;
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java Thu
Jul 12 15:22:19 2012
@@ -174,7 +174,7 @@ public final class CamelContextHelper {
      */
     public static int getMaximumCachePoolSize(CamelContext camelContext) throws IllegalArgumentException
{
         if (camelContext != null) {
-            String s = camelContext.getProperties().get(Exchange.MAXIMUM_CACHE_POOL_SIZE);
+            String s = camelContext.getProperty(Exchange.MAXIMUM_CACHE_POOL_SIZE);
             if (s != null) {
                 try {
                     // we cannot use Camel type converters as they may not be ready this
early
@@ -205,7 +205,7 @@ public final class CamelContextHelper {
      */
     public static int getMaximumEndpointCacheSize(CamelContext camelContext) throws IllegalArgumentException
{
         if (camelContext != null) {
-            String s = camelContext.getProperties().get(Exchange.MAXIMUM_ENDPOINT_CACHE_SIZE);
+            String s = camelContext.getProperty(Exchange.MAXIMUM_ENDPOINT_CACHE_SIZE);
             if (s != null) {
                 // we cannot use Camel type converters as they may not be ready this early
                 try {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java Thu Jul
12 15:22:19 2012
@@ -157,7 +157,7 @@ public final class MessageHelper {
     public static String extractBodyForLogging(Message message, String prepend) {
         boolean streams = false;
         if (message.getExchange() != null) {
-            String property = message.getExchange().getContext().getProperties().get(Exchange.LOG_DEBUG_BODY_STREAMS);
+            String property = message.getExchange().getContext().getProperty(Exchange.LOG_DEBUG_BODY_STREAMS);
             if (property != null) {
                 streams = message.getExchange().getContext().getTypeConverter().convertTo(Boolean.class,
property);
             }
@@ -167,7 +167,7 @@ public final class MessageHelper {
         int maxChars = 1000;
 
         if (message.getExchange() != null) {
-            String property = message.getExchange().getContext().getProperties().get(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
+            String property = message.getExchange().getContext().getProperty(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
             if (property != null) {
                 maxChars = message.getExchange().getContext().getTypeConverter().convertTo(Integer.class,
property);
             }

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
Thu Jul 12 15:22:19 2012
@@ -105,9 +105,9 @@ public class HttpEndpoint extends Defaul
         HttpClient answer = new HttpClient(getClientParams());
 
         // configure http proxy from camelContext
-        if (ObjectHelper.isNotEmpty(getCamelContext().getProperties().get("http.proxyHost"))
&& ObjectHelper.isNotEmpty(getCamelContext().getProperties().get("http.proxyPort")))
{
-            String host = getCamelContext().getProperties().get("http.proxyHost");
-            int port = Integer.parseInt(getCamelContext().getProperties().get("http.proxyPort"));
+        if (ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyHost")) &&
ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyPort"))) {
+            String host = getCamelContext().getProperty("http.proxyHost");
+            int port = Integer.parseInt(getCamelContext().getProperty("http.proxyPort"));
             LOG.debug("CamelContext properties http.proxyHost and http.proxyPort detected.
Using http proxy host: {} port: {}", host, port);
             answer.getHostConfiguration().setProxy(host, port);
         }

Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
(original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
Thu Jul 12 15:22:19 2012
@@ -122,10 +122,10 @@ public class HttpEndpoint extends Defaul
         HttpClient answer = new DefaultHttpClient(clientConnectionManager, getClientParams());
 
         // configure http proxy from camelContext
-        if (ObjectHelper.isNotEmpty(getCamelContext().getProperties().get("http.proxyHost"))
&& ObjectHelper.isNotEmpty(getCamelContext().getProperties().get("http.proxyPort")))
{
-            String host = getCamelContext().getProperties().get("http.proxyHost");
-            int port = Integer.parseInt(getCamelContext().getProperties().get("http.proxyPort"));
-            String scheme = getCamelContext().getProperties().get("http.proxyScheme");
+        if (ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyHost")) &&
ObjectHelper.isNotEmpty(getCamelContext().getProperty("http.proxyPort"))) {
+            String host = getCamelContext().getProperty("http.proxyHost");
+            int port = Integer.parseInt(getCamelContext().getProperty("http.proxyPort"));
+            String scheme = getCamelContext().getProperty("http.proxyScheme");
             // fallback and use either http4 or https4 depending on secure
             if (scheme == null) {
                 scheme = HttpHelper.isSecureConnection(getEndpointUri()) ? "https4" : "http4";

Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
(original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
Thu Jul 12 15:22:19 2012
@@ -383,8 +383,8 @@ public class JettyHttpComponent extends 
         CamelContext camelContext = this.getCamelContext();
         FilterHolder filterHolder = new FilterHolder();
         filterHolder.setInitParameter("deleteFiles", "true");
-        if (ObjectHelper.isNotEmpty(camelContext.getProperties().get(TMP_DIR))) {
-            File file = new File(camelContext.getProperties().get(TMP_DIR));
+        if (ObjectHelper.isNotEmpty(camelContext.getProperty(TMP_DIR))) {
+            File file = new File(camelContext.getProperty(TMP_DIR));
             if (!file.isDirectory()) {
                 throw new RuntimeCamelException(
                         "The temp file directory of camel-jetty is not exists, please recheck
it with directory name :"

Modified: camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
(original)
+++ camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
Thu Jul 12 15:22:19 2012
@@ -268,29 +268,29 @@ public class XMLSecurityDataFormat imple
         Map<String, String> contextProps = context.getProperties();
                
         if (this.recipientKeyAlias == null) {
-            recipientKeyAlias = contextProps.get(XML_ENC_RECIPIENT_ALIAS);
+            recipientKeyAlias = context.getProperty(XML_ENC_RECIPIENT_ALIAS);
         }
 
         if (this.trustStore == null && contextProps.containsKey(XML_ENC_TRUST_STORE_URL))
{
             trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
-            URL trustStoreUrl = new URL(contextProps.get(XML_ENC_TRUST_STORE_URL));
+            URL trustStoreUrl = new URL(context.getProperty(XML_ENC_TRUST_STORE_URL));
             if (trustStorePassword == null) {
-                trustStorePassword = contextProps.get(XML_ENC_TRUST_STORE_PASSWORD);
+                trustStorePassword = context.getProperty(XML_ENC_TRUST_STORE_PASSWORD);
             }
             trustStore.load(trustStoreUrl.openStream(), trustStorePassword.toCharArray());
         }
         
         if (this.keyStore == null && contextProps.containsKey(XML_ENC_KEY_STORE_URL))
{
             keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
-            URL keyStoreUrl = new URL(contextProps.get(XML_ENC_KEY_STORE_URL));
+            URL keyStoreUrl = new URL(context.getProperty(XML_ENC_KEY_STORE_URL));
             if (keyStorePassword == null) {
-                keyStorePassword = contextProps.get(XML_ENC_KEY_STORE_PASSWORD);
+                keyStorePassword = context.getProperty(XML_ENC_KEY_STORE_PASSWORD);
             }
             keyStore.load(keyStoreUrl.openStream(), keyStorePassword.toCharArray());    
         }
         
         if (context.getProperties().containsKey(XML_ENC_KEY_STORE_ALIAS) && this.recipientKeyAlias
== null) {
-            recipientKeyAlias = contextProps.get(XML_ENC_KEY_STORE_ALIAS);
+            recipientKeyAlias = context.getProperty(XML_ENC_KEY_STORE_ALIAS);
         }
     }
     

Modified: camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java?rev=1360722&r1=1360721&r2=1360722&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
(original)
+++ camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
Thu Jul 12 15:22:19 2012
@@ -124,7 +124,7 @@ public class ContextInfo extends OsgiCom
         System.out.println("");
         System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mProperties\u001B[0m"));
         for (String property : camelContext.getProperties().keySet()) {
-            System.out.println(StringEscapeUtils.unescapeJava("\t" + property + " = " + camelContext.getProperties().get(property)));
+            System.out.println(StringEscapeUtils.unescapeJava("\t" + property + " = " + camelContext.getProperty(property)));
         }
         System.out.println("");
         System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mComponents\u001B[0m"));



Mime
View raw message