Refresh VOs in application scope shared AM programmatically

To make sure application scope shared module is caching the latest data from database, we could set the VO’s “AutoRefresh” property to “true”:

<ViewObject
  xmlns="http://xmlns.oracle.com/bc4j"
  Name="XXXVO"
  Version="12.1.3.2.36"
  InheritPersonalization="merge"
  BindingStyle="OracleName"
  CustomQuery="true"
  ComponentClass="com.xxx.model.base.BaseVOImpl"
  PageIterMode="Full"
  FetchSize="100"
  RangeSize="100"
  AutoRefresh="true">
  ...

It uses Oracle DB’s continuous query notification feature. In situation that you can’t use that feature, you could use following code to refresh all VO in the application scope shared AM:

The key line is to use findOrCreateSharedApplicationModule to look up the application scope shared AM, the last parameter value “ApplicationModuleImpl.SHARED_SCOPE_APPLICATION” indicates the scope:

ApplicationModule sharedAm = ((ApplicationModuleImpl)am).findOrCreateSharedApplicationModule(
      "AppScopeAM", "AppScopeAMShared", ApplicationModuleImpl.SHARED_SCOPE_APPLICATION);

After the lookup, all VO in the AM are refreshed.