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}" />

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:

    <component id="profile" name="/atg/userprofiling/Profile"
      <output name="profile" value="${profile}" />

This allows the Profile class to filter the components:

  <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" />

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 a filter 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, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices