The BeanFilterService filters the properties of a java bean or repository item and converts beans into a map of properties. The BeanFilterService reads XML definition files that define which properties of a Java class or repository item should be included in the filtered view of the object. The XML definitions include ways to remap property names and transform properties.

By default, the BeanFilterService is applied to the ModelMap by the REST MVC framework before generating a JSON or XML response. However, you can filter objects at any time. For example, you can use the BeanFilterService as a ComponentActor to filter a repository item before adding it to the ModelMap. This converts the repository item into a map of primitive objects:

<component name="/atg/dynamo/service/filter/bean/BeanFilterSerivce"
    method="applyFilter" method-return-var="rtn">
  <input name="pTargetObject" value="${myRepositoryItem}" />
  <output name="myRepositoryItem" value="{rtn}" />
</component>

There are two types of bean filters, those for repository items and those for Java bean classes. By using the ComponentActor, you can add a component to the ModelMap, which can then be filtered by the class that the component implements. For example:

<actor-template>
  <actor-chain>
    <component id="profile" name="/atg/userprofiling/Profile"
        component-var="profile">
      <output name="profile" value="${profile}" />
    </component>
  </actor-chain>
</actor-template>

This allows the Profile class to filter the components:

<bean-filtering>
  <bean type="atg.userprofiling.Profile">
    <filter id="default">
      <property name="email" />
      <property name="lastName" />
      <property name="firstName" />
      <property name="dataSource" />
      <property name="homeAddress.postalCode" target="homeAddress.postalCode" />
      <property name="gender" />
      <property name="dateOfBirth" />
    </filter>
  </bean>
</bean-filtering>

Bean filters combine filter definitions from all classes or interfaces for an object using the filter-id property. You can also include other bean filters within a bean filter by using the include-filter attribute.

It is best to define afilter for every object, so that you can control its output. Note that if an object has no filters defined, it will output all properties.

The following XML values are defined by the atg/dtds/beanfilter/beanFiltering_1.0.dtd file:


Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices