Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed ../apidocs/ links.

...

On occasion, you may need to know when invalidations occur, to clear your own cache. For example, if you have a binding that creates new classes, the way PropertyConduitSource does, you need to discard any cached classes or instances when a change is detected in component classes.

You do this by registering a listener with the correct InvalidationEventHub service.

For example, your service may be in the business of creating new classes based on component classes, and keep a cache of those classes:

...

Here, the service implementation impl,ements implements the InvalidationEventListener interface, as well as its service interface. The question is: how does it register for notifications?

In your module, you will want to use a service builder method, such as so:

Code Block
java
java
public static MyService buildMyService(@Autobuild MyServiceImpl service, @ComponentClasses InvalidationEventHub hub)
{
  hub.addInvalidationListener(service);

  return service;
}

...

The built in InvalidationEventHub services provide notifications of changes to component classes, to component templates, and to component message catalogs. If you wish to check some other resources (for example, files in a directory of the file system or rows in a database table), you should register as an UpdateListener with the UpdateListenerHub service.

Periodically (the frequency is configurable), UpdateListeners are notified that they should check for updates. Typically, UpdateListeners are also InvalidationEventHubs (or provide InvalidationEventHubs), so that other interested parties can be alerted when underlying data changes.