public boolean vote(Object decree) throws VoteException { if (!(decree instanceof TwoPhaseWrapper)) throw new VoteException("Not my type of decree. Ignore me."); TwoPhaseWrapper wrapper = (TwoPhaseWrapper) decree; // invoke the corresponding operation if (wrapper.isPrepare()) return listener.prepare(wrapper.getDecree()); else if (wrapper.isCommit()) return listener.commit(wrapper.getDecree()); else { listener.abort(wrapper.getDecree()); return false; } }