Github user mikewalch commented on a diff in the pull request: https://github.com/apache/incubator-fluo/pull/817#discussion_r107466485 --- Diff: docs/applications.md --- @@ -114,25 +114,45 @@ To create an observer, follow these steps: // invert row and value tx.set(value, new Column("inv", "data"), row); } + } + ``` +2. Create a class that implements [ObserverProvider] like the example below. The purpose of this + class is associate a set Observers with columns that trigger the observers. The class can + create multiple observers. + ```java + class AppObserverProvider implements ObserverProvider { @Override - public ObservedColumn getObservedColumn() { - return new ObservedColumn(new Column("obs", "data"), NotificationType.STRONG); + public void provide(Registry or, Context ctx) { + //setup InvertObserver to be triggered when the column obs:data is modified + or.register(new Column("obs", "data"), + NotificationType.STRONG, + new InvertObserver()); + + //Observer is a Functional interface. So Obsevers can be written as lambdas. + or.register(new Column("new","data"), + NotificationType.WEAK, + (tx,row,col) -> { + Bytes combined = combineNewAndOld(tx,row); + tx.set(row, new Column("current","data"), combined); + }); } } ``` -2. Build a jar containing this class and include this jar in the `lib/` directory of your Fluo + +3. Build a jar containing thses classes and include this jar in the `lib/` directory of your Fluo application. -3. Configure your Fluo instance to use this observer by modifying the Observer section of +4. Configure your Fluo instance to use this observer factory by modifying the Observer section of --- End diff -- should be `observer provider`
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---