Package org.apache.camel.spi
Interface BeanIntrospection
-
- All Superinterfaces:
AfterPropertiesConfigured
,AutoCloseable
,Service
,StaticService
public interface BeanIntrospection extends StaticService, AfterPropertiesConfigured
Used for introspecting beans properties via Java reflection; such as extracting current property values, or updating one or more properties etc. End users should favour usingorg.apache.camel.support.PropertyBindingSupport
instead.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
BeanIntrospection.ClassInfo
Structure of an introspected class.static class
BeanIntrospection.MethodInfo
Structure of an introspected method.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BeanIntrospection.ClassInfo
cacheClass(Class<?> clazz)
Introspects the given class.void
clearCache()
Clears the introspection cache.Set<Method>
findSetterMethods(Class<?> clazz, String name, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase)
Find all the setter methods on the classlong
getCachedClassesCounter()
Number of classes in the introspection cache.long
getInvokedCounter()
Number of times bean introspection has been invokedLoggingLevel
getLoggingLevel()
Logging level used for logging introspection usage.Object
getOrElseProperty(Object target, String propertyName, Object defaultValue, boolean ignoreCase)
Gets the property or else returning the default value.boolean
getProperties(Object target, Map<String,Object> properties, String optionPrefix)
Will inspect the target for properties.boolean
getProperties(Object target, Map<String,Object> properties, String optionPrefix, boolean includeNull)
Will inspect the target for properties.Method
getPropertyGetter(Class<?> type, String propertyName, boolean ignoreCase)
Gets the getter method for the property.boolean
isExtendedStatistics()
Whether to gather extended statistics for introspection usage.void
resetCounters()
Reset the statistics counters.void
setExtendedStatistics(boolean extendedStatistics)
Whether to gather extended statistics for introspection usage.void
setLoggingLevel(LoggingLevel loggingLevel)
Logging level used for logging introspection usage.boolean
setProperty(CamelContext context, Object target, String name, Object value)
This method supports three modes to set a property: 1.boolean
setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value, String refName, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase)
This method supports three modes to set a property: 1.-
Methods inherited from interface org.apache.camel.AfterPropertiesConfigured
afterPropertiesConfigured
-
-
-
-
Method Detail
-
getInvokedCounter
long getInvokedCounter()
Number of times bean introspection has been invoked
-
resetCounters
void resetCounters()
Reset the statistics counters.
-
isExtendedStatistics
boolean isExtendedStatistics()
Whether to gather extended statistics for introspection usage.
-
setExtendedStatistics
void setExtendedStatistics(boolean extendedStatistics)
Whether to gather extended statistics for introspection usage.
-
getLoggingLevel
LoggingLevel getLoggingLevel()
Logging level used for logging introspection usage. Is using TRACE level as default.
-
setLoggingLevel
void setLoggingLevel(LoggingLevel loggingLevel)
Logging level used for logging introspection usage. Is using TRACE level as default.
-
getProperties
boolean getProperties(Object target, Map<String,Object> properties, String optionPrefix)
Will inspect the target for properties. Notice a property must have both a getter/setter method to be included. Notice all null values will be included.- Parameters:
target
- the target beanproperties
- the map to fill in found propertiesoptionPrefix
- an optional prefix to append the property key- Returns:
- true if any properties was found, false otherwise.
-
getProperties
boolean getProperties(Object target, Map<String,Object> properties, String optionPrefix, boolean includeNull)
Will inspect the target for properties. Notice a property must have both a getter/setter method to be included.- Parameters:
target
- the target beanproperties
- the map to fill in found propertiesoptionPrefix
- an optional prefix to append the property keyincludeNull
- whether to include null values- Returns:
- true if any properties was found, false otherwise.
-
cacheClass
BeanIntrospection.ClassInfo cacheClass(Class<?> clazz)
Introspects the given class.- Parameters:
clazz
- the class- Returns:
- the introspection result as a
BeanIntrospection.ClassInfo
structure.
-
clearCache
void clearCache()
Clears the introspection cache.
-
getCachedClassesCounter
long getCachedClassesCounter()
Number of classes in the introspection cache.
-
getOrElseProperty
Object getOrElseProperty(Object target, String propertyName, Object defaultValue, boolean ignoreCase)
Gets the property or else returning the default value.- Parameters:
target
- the target beanpropertyName
- the property namedefaultValue
- the default valueignoreCase
- whether to ignore case for matching the property name- Returns:
- the property value, or the default value if the target does not have a property with the given name
-
getPropertyGetter
Method getPropertyGetter(Class<?> type, String propertyName, boolean ignoreCase) throws NoSuchMethodException
Gets the getter method for the property.- Parameters:
type
- the target classpropertyName
- the property nameignoreCase
- whether to ignore case for matching the property name- Returns:
- the getter method
- Throws:
NoSuchMethodException
- is thrown if there are no getter method for the property
-
setProperty
boolean setProperty(CamelContext context, Object target, String name, Object value) throws Exception
This method supports three modes to set a property: 1. Setting a Map property where the property name refers to a map via name[aKey] where aKey is the map key to use. 2. Setting a property that has already been resolved, this is the case whencontext
andrefName
are NULL andvalue
is non-NULL. 3. Setting a property that has not yet been resolved, the property will be resolved based on the suitable methods found matching the property name on thetarget
bean. For this mode to be triggered the parameterscontext
andrefName
must NOT be NULL, andvalue
MUST be NULL.- Throws:
Exception
-
setProperty
boolean setProperty(CamelContext context, TypeConverter typeConverter, Object target, String name, Object value, String refName, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) throws Exception
This method supports three modes to set a property: 1. Setting a Map property where the property name refers to a map via name[aKey] where aKey is the map key to use. 2. Setting a property that has already been resolved, this is the case whencontext
andrefName
are NULL andvalue
is non-NULL. 3. Setting a property that has not yet been resolved, the property will be resolved based on the suitable methods found matching the property name on thetarget
bean. For this mode to be triggered the parameterscontext
andrefName
must NOT be NULL, andvalue
MUST be NULL.- Throws:
Exception
-
-