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 using org.apache.camel.support.PropertyBindingSupport instead.
  • 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

      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 bean
      properties - the map to fill in found properties
      optionPrefix - 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 bean
      properties - the map to fill in found properties
      optionPrefix - an optional prefix to append the property key
      includeNull - 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 bean
      propertyName - the property name
      defaultValue - the default value
      ignoreCase - 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 class
      propertyName - the property name
      ignoreCase - 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

      Method getPropertySetter(Class<?> type, String propertyName) throws NoSuchMethodException
      Gets the setter method for the property.
      Parameters:
      type - the target class
      propertyName - 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 when context and refName are NULL and value 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 the target bean. For this mode to be triggered the parameters context and refName must NOT be NULL, and value 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 when context and refName are NULL and value 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 the target bean. For this mode to be triggered the parameters context and refName must NOT be NULL, and value 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