Push Notification Bridge persistence plugin
The Push Notification Bridge stores subscription information in memory. To persist this information past the end of the bridge process, implement a persistence plugin.
The persistence API
The Push Notification Bridge persistence API provides the following interfaces for
you to use to develop your persistence plugin:
- SaverFactory
- Your implementation of this interface is referenced by the bridge configuration and is called by the bridge to build the Saver object.
- Saver
- Your implementation of this interface is called by the bridge when push notification subscriptions and unsubscriptions are made. It uses this information to update the persisted model of the subscriptions.
- Loader
- Your implementation of this interface is called by the bridge when it starts and is used to update the model of subscriptions held in memory by the bridge.
- Context
- This provides a context for events passed to the Saver interface. It is used for logging and audit trail purposes.
Full API documentation is available at the following location: Java API documentation.
An example implementation of the persistence API is available on GitHub: https://github.com/pushtechnology/push-notification-persistence-example. This example is basic and uses Java™ serialization to persist the subscription model.
Note: The example persistence plugin is not suitable for production
use.
Developing the persistence plugin
A JAR file that contains the persistence API is available on the Push Technology Maven™ repository.
To use Maven to declare the dependency, first add the
Push Technology public repository to your
pom.xml file:
<repositories> <repository> <id>push-repository</id> <url>https://download.pushtechnology.com/maven/</url> </repository> </repositories>Next declare the following dependency in your pom.xml file:
<dependency> <groupId>com.pushtechnology</groupId> <artifactId>push-notification-persistence-api</artifactId> <version>1.0</version> </dependency>
Using the persistence plugin
- Compile your persistence code.
- Ensure that the compiled code is on the classpath of the Java Virtual Machine (JVM) that runs the bridge.
- Configure the bridge to use your persistence plugin. Use the saverFactory attribute of the persistence element to specify the name of the SaverFactory class in your plugin. For example:
<persistence saverFactory="com.example.pnb.SaverFactory"/>
The content of the persistence element can be text content. This content is passed into the saver factory as arguments.
For more information, see Configuring your Push Notification Bridge.