Search in sources :

Example 1 with BranchListener

use of com.ramussoft.common.event.BranchListener in project ramus by Vitaliy-Yakovchuk.

the class JournaledEngine method setActiveBranch.

@Override
public void setActiveBranch(long branchId) {
    deligate.setActiveBranch(branchId);
    branchId = deligate.getActiveBranch();
    synchronized (swithJournalLock) {
        journal = journalFactory.getJournal(this, branchId);
    }
    BranchEvent event = new BranchEvent(this, false, branchId, -1l);
    for (BranchListener listener : getBranchListeners()) listener.branchActivated(event);
}
Also used : BranchListener(com.ramussoft.common.event.BranchListener) BranchEvent(com.ramussoft.common.event.BranchEvent)

Example 2 with BranchListener

use of com.ramussoft.common.event.BranchListener in project ramus by Vitaliy-Yakovchuk.

the class JournaledEngine method deleteBranch.

@Override
public void deleteBranch(long branchId) {
    BranchEvent event = new BranchEvent(this, false, branchId, -1l);
    long active = getActiveBranch();
    deligate.deleteBranch(branchId);
    for (BranchListener listener : getBranchListeners()) listener.branchDeleted(event);
    if (active == branchId) {
        event = new BranchEvent(this, false, getActiveBranch(), -1l);
        for (BranchListener listener : getBranchListeners()) listener.branchActivated(event);
    }
}
Also used : BranchListener(com.ramussoft.common.event.BranchListener) BranchEvent(com.ramussoft.common.event.BranchEvent)

Example 3 with BranchListener

use of com.ramussoft.common.event.BranchListener in project ramus by Vitaliy-Yakovchuk.

the class JournaledEngine method createBranch.

@Override
public void createBranch(long parent, long branchId, String reason, int type, String module) {
    if (parent == -1l)
        parent = getActiveBranch();
    deligate.createBranch(parent, branchId, reason, type, module);
    synchronized (swithJournalLock) {
        Journal parentBranchJournal = journalFactory.getJournal(this, parent);
        parentBranchJournal.store(new NewBranchCommand(this, parent, branchId, reason, type, module));
        // parentBranchJournal.setLock(true);
        journal = journalFactory.getJournal(this, branchId);
    }
    BranchEvent event = new BranchEvent(this, false, branchId, parent);
    for (BranchListener listener : getBranchListeners()) listener.branchCreated(event);
    for (BranchListener listener : getBranchListeners()) listener.branchActivated(event);
}
Also used : BranchListener(com.ramussoft.common.event.BranchListener) BranchEvent(com.ramussoft.common.event.BranchEvent) NewBranchCommand(com.ramussoft.common.journal.command.NewBranchCommand)

Aggregations

BranchEvent (com.ramussoft.common.event.BranchEvent)3 BranchListener (com.ramussoft.common.event.BranchListener)3 NewBranchCommand (com.ramussoft.common.journal.command.NewBranchCommand)1