Class ComponentsQueryFactoryBean

java.lang.Object
com.zfabrik.springframework.ComponentsQueryFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<Map<String,​Object>>

public class ComponentsQueryFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<Map<String,​Object>>
Factory bean abstracting a z2 components query with a property set as filter condition and returning a key value map with a predefined key property.

The purpose of the key property is to provide an identifying information to the application. If none set, the component name will be used as key.

The map is backed by an IComponentsRepository.findComponents(com.zfabrik.util.expression.X) query result that is cached internally. It is absolutely immutable by the consumer and may change during software updates.

Use like this:

 <bean id="someBeans" class="com.zfabrik.springframework.ComponentsQueryFactoryBean">
         <property name="className" value="sample.ITheBeanInterface"/>
   <property name="filter">
     <props>
       <prop key="sample.iAmABean">true</prop>
     </props>
   </property>
 </bean>
 
In this case, all components that have a name value pair sample.iAmABean=true in their component properties would be queried and looked up as extensions of the class sample.ITheBeanInterface.
  • Field Details

    • clz

      protected Class<?> clz
    • filter

      protected X filter
    • idPropName

      protected String idPropName
    • map

      protected Map<String,​Object> map
  • Constructor Details

    • ComponentsQueryFactoryBean

      public ComponentsQueryFactoryBean()
  • Method Details

    • setClassName

      public void setClassName(String className) throws Exception
      Set the type of the single query result item. The map provided by this factory bean will use this type as value type.
      Parameters:
      className -
      Throws:
      Exception
    • setFilter

      public void setFilter(Map<String,​Object> filter)
      Filter properties. All filter name value pairs will be combined into a boolean filter expression consisting of an AND conjunction.
      Parameters:
      props -
    • setIdPropertyName

      public void setIdPropertyName(String idPropName)
      Id property. The result map key that is used by the application to identify the bean internally. If omitted some internal key will be used
    • getObject

      public Map<String,​Object> getObject() throws Exception
      provides the actual collection instance
      Specified by:
      getObject in interface org.springframework.beans.factory.FactoryBean<Map<String,​Object>>
      Throws:
      Exception
    • getObjectType

      public Class<?> getObjectType()
      Returns Collection.class
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<Map<String,​Object>>
    • isSingleton

      public boolean isSingleton()
      The result bean is indeed a singleton
      Specified by:
      isSingleton in interface org.springframework.beans.factory.FactoryBean<Map<String,​Object>>