java - OrientDB register Hooks -
i'm trying out hooks on orientdb, i'm not sure how register orecordhooks on graph.
orientgraph graph = new orientgraph("remote:localhost/test"); myhook hook = new myhook();
the myhook class looks this:
public class myhook extends orecordhookabstract implements odatabaselifecyclelistener { public myhook() { orient.instance().adddblifecyclelistener(this); } @override public distributed_execution_mode getdistributedexecutionmode() { system.out.println("0"); return null; } @override public priority getpriority() { system.out.println("1"); return priority.first; } @override public void onrecordaftercreate(orecord irecord) { system.out.println("2"); } @override public result onrecordbeforecreate(orecord irecord) { system.out.println("3"); return orecordhook.result.record_changed; } @override public result onrecordbeforeread(orecord irecord) { system.out.println("4"); return orecordhook.result.record_changed; } @override public void onrecordafterread(orecord irecord) { system.out.println("5"); } @override public result onrecordbeforeupdate(orecord irecord) { system.out.println("6"); return orecordhook.result.record_changed; } @override public void onrecordafterupdate(orecord irecord) { system.out.println("7"); } @override public result onrecordbeforedelete(orecord irecord) { system.out.println("8"); return orecordhook.result.record_changed; } @override public void onrecordafterdelete(orecord irecord) { system.out.println("9"); } @override public void oncreate(odatabaseinternal idatabase) {e system.out.println("10"); idatabase.registerhook(this); } @override public void onopen(odatabaseinternal idatabase) { system.out.println("11"); idatabase.registerhook(this); } @override public void onclose(odatabaseinternal idatabase) { system.out.println("12"); idatabase.unregisterhook(this); } @override public void oncreateclass(odatabaseinternal idatabase, oclass iclass) { system.out.println("13"); } @override public void ondropclass(odatabaseinternal idatabase, oclass iclass) { system.out.println("14"); } }
after creating , deleting bunch of vertices , edges hooks 1, 13 , 12 fire, getpriority(), oncreateclass() , onclose(). why don't of orecordhooks fire?
to register hook on orientgraph instance can following:
graph.getrawgraph().registerhook(hook);