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
org.apache.camel.support.PropertyBindingSupport instead.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classStructure of an introspected class.static final classStructure of an introspected method. -
Method Summary
Modifier and TypeMethodDescriptioncacheClass(Class<?> clazz) Introspects the given class.voidClears the introspection cache.findSetterMethods(Class<?> clazz, String name, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) Find all the setter methods on the classlongNumber of classes in the introspection cache.longNumber 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.booleanWill inspect the target for properties.booleangetProperties(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.booleanWhether to gather extended statistics for introspection usage.voidReset the statistics counters.voidsetExtendedStatistics(boolean extendedStatistics) Whether to gather extended statistics for introspection usage.voidsetLoggingLevel(LoggingLevel loggingLevel) Logging level used for logging introspection usage.booleansetProperty(CamelContext context, Object target, String name, Object value) This method supports three modes to set a property: 1.booleansetProperty(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.ClassInfostructure.
-
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 whencontextandrefNameare NULL andvalueis 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 thetargetbean. For this mode to be triggered the parameterscontextandrefNamemust NOT be NULL, andvalueMUST 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 whencontextandrefNameare NULL andvalueis 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 thetargetbean. For this mode to be triggered the parameterscontextandrefNamemust NOT be NULL, andvalueMUST 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
-