Package org.apache.camel.spi
Interface BeanIntrospection
- All Superinterfaces:
AfterPropertiesConfigured
,AutoCloseable
,Service
,StaticService
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 using
instead.
invalid reference
org.apache.camel.support.PropertyBindingSupport
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
Structure of an introspected class.static final class
Structure of an introspected method. -
Method Summary
Modifier and TypeMethodDescriptioncacheClass
(Class<?> clazz) Introspects the given class.void
Clears the introspection cache.findSetterMethods
(Class<?> clazz, String name, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) Find all the setter methods on the classlong
Number of classes in the introspection cache.long
Number of times bean introspection has been invokedLogging level used for logging introspection usage.getOrElseProperty
(Object target, String propertyName, Object defaultValue, boolean ignoreCase) Gets the property or else returning the default value.boolean
Will inspect the target for properties.boolean
getProperties
(Object target, Map<String, Object> properties, String optionPrefix, boolean includeNull) Will inspect the target for properties.getPropertyGetter
(Class<?> type, String propertyName, boolean ignoreCase) Gets the getter method for the property.getPropertySetter
(Class<?> type, String propertyName) Gets the setter method for the property.boolean
Whether to gather extended statistics for introspection usage.void
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 Details
-
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
Logging level used for logging introspection usage. Is using TRACE level as default. -
getProperties
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
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
-
getPropertySetter
Gets the setter method for the property.- Parameters:
type
- the target classpropertyName
- the property name- Returns:
- the setter method
- Throws:
NoSuchMethodException
- is thrown if there are no setter 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
-
findSetterMethods
Set<Method> findSetterMethods(Class<?> clazz, String name, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) Find all the setter methods on the class
-