This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void showSimpleEventHandling() { | |
GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase(); | |
database.registerTransactionEventHandler(new TransactionEventHandler<Void>() { | |
@Override | |
public Void beforeCommit(TransactionData data) throws Exception { | |
System.out.println("Committing transaction"); | |
return null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test(expected = TransactionFailureException.class) | |
public void attemptLoggingDeletedNodes() { | |
GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase(); | |
database.registerTransactionEventHandler(new TransactionEventHandler.Adapter<Void>() { | |
@Override | |
public Void beforeCommit(TransactionData data) throws Exception { | |
for (Node deletedNode : data.deletedNodes()) { | |
StringBuilder message = new StringBuilder("About to delete node ID ") | |
.append(deletedNode.getId()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ImprovedTransactionData { | |
boolean hasBeenCreated(Node node); | |
Collection<Node> getAllCreatedNodes(); | |
boolean hasBeenDeleted(Node node); | |
Node getDeleted(Node node); | |
Collection<Node> getAllDeletedNodes(); | |
boolean hasBeenChanged(Node node); |