graphaware / neo4j-framework

GraphAware Neo4j Framework
245 stars 68 forks source link

Module that supports registration of lifecycle events by putting them on the ClassPath #87

Closed jasperblues closed 6 years ago

jasperblues commented 6 years ago

Given a . .

public interface LifecycleEvent {

    Class<? extends Entity> appliesTo();

    void configure(Map<String, String> config);

    default String name() { return this.getClass().getSimpleName(); }

}

. . that has a name and is applicable to either Nodes or Relationships.

Such an event is configurable with a Map<String, String> of properties from the neo4j.conf file. Ideally we'd resolve to type-safe fine-grained config, like with Spring's @Value annotation, but that's not included in the PR. Maybe later.

There are two kinds of specialisation:

One for on-commit events . .

public interface CommitEvent<E extends Entity> extends LifecycleEvent {

    boolean applyIfNeeded(E entity);
}

Another for scheduled . . .

public interface ScheduledEvent<E extends Entity> extends LifecycleEvent {

    Long effectiveDate(E entity);

    boolean applyIfNeeded(E entity);

    String indexName();
}

To Use:

Annotations:

We talked configuring events using annotations in the ticket, however I thought implementation of an interface would be better. If annotations are still desirable, that can be added.

Feel free to request any clarifications or changes.