You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/04/13 11:27:21 UTC
svn commit: r1467578 -
/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
Author: davsclaus
Date: Sat Apr 13 09:27:20 2013
New Revision: 1467578
URL: http://svn.apache.org/r1467578
Log:
CAMEL-6260: Setting options on endpoint now set accessible with reflection to allow setting on package visibile classes. Thanks to Jury Matveentsev for the patch.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=1467578&r1=1467577&r2=1467578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java Sat Apr 13 09:27:20 2013
@@ -225,11 +225,15 @@ public final class IntrospectionSupport
if (info.isGetter && info.hasGetterAndSetter) {
String name = info.getterOrSetterShorthandName;
try {
+ // we may want to set options on classes that has package view visibility, so override the accessible
+ method.setAccessible(true);
Object value = method.invoke(target);
properties.put(optionPrefix + name, value);
rc = true;
} catch (Exception e) {
- // ignore
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Error invoking getter method " + method + ". This exception is ignored.", e);
+ }
}
}
}
@@ -483,6 +487,8 @@ public final class IntrospectionSupport
try {
// If the type is null or it matches the needed type, just use the value directly
if (value == null || parameterType.isAssignableFrom(ref.getClass())) {
+ // we may want to set options on classes that has package view visibility, so override the accessible
+ setter.setAccessible(true);
setter.invoke(target, ref);
if (LOG.isDebugEnabled()) {
LOG.debug("Configured property: {} on bean: {} with value: {}", new Object[]{name, target, ref});
@@ -491,6 +497,8 @@ public final class IntrospectionSupport
} else {
// We need to convert it
Object convertedValue = convert(typeConverter, parameterType, ref);
+ // we may want to set options on classes that has package view visibility, so override the accessible
+ setter.setAccessible(true);
setter.invoke(target, convertedValue);
if (LOG.isDebugEnabled()) {
LOG.debug("Configured property: {} on bean: {} with value: {}", new Object[]{name, target, ref});
@@ -509,6 +517,8 @@ public final class IntrospectionSupport
}
}
// ignore exceptions as there could be another setter method where we could type convert successfully
+ } catch (SecurityException e) {
+ typeConversionFailed = e;
} catch (NoTypeConversionAvailableException e) {
typeConversionFailed = e;
} catch (IllegalArgumentException e) {