use of com.ramussoft.common.journal.event.JournalListener in project ramus by Vitaliy-Yakovchuk.
the class DirectoryJournalFactory method getJournal.
@Override
public Journal getJournal(JournaledEngine engine, long branchId) {
if (directory == null) {
Journal journal = new Journal(null, -1l);
journal.setEnable(false);
return journal;
}
Journal journal = journals.get(branchId);
if (journal == null) {
try {
journal = new Journal(new BinaryAccessFile(new File(directory, "ramus-" + branchId + ".journal"), "rw"), branchId);
journal.registerEngine(engine);
journal.setEnable(true);
journals.put(branchId, journal);
for (JournalListener listener : getJournalListeners()) journal.addJournalListener(listener);
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
return journal;
}
use of com.ramussoft.common.journal.event.JournalListener in project ramus by Vitaliy-Yakovchuk.
the class LightClient method getEngine.
@Override
protected Engine getEngine(PluginFactory factory, PersistentFactory persistentFactory) {
try {
Journal journal = new Journal(null, -1l);
journal.setEnable(false);
final JournaledEngine journaledEngine = new JournaledEngine(factory, impl, persistentFactory.getRows(), new DirectoryJournalFactory(null), accessor);
Engine engine = (Engine) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { Engine.class, Journaled.class }, new InvocationHandler() {
private Journaled journaled = new Journaled() {
boolean started = false;
@Override
public void undoUserTransaction() {
}
@Override
public void startUserTransaction() {
started = true;
}
@Override
public void setNoUndoPoint() {
}
@Override
public void setEnable(boolean b) {
}
@Override
public void rollbackUserTransaction() {
started = false;
}
@Override
public void removeJournalListener(JournalListener listener) {
}
@Override
public void redoUserTransaction() {
}
@Override
public boolean isUserTransactionStarted() {
return started;
}
@Override
public boolean isEnable() {
return false;
}
@Override
public JournalListener[] getJournalListeners() {
return new JournalListener[] {};
}
@Override
public void commitUserTransaction() {
started = false;
}
@Override
public void close() {
}
@Override
public boolean canUndo() {
return false;
}
@Override
public boolean canRedo() {
return false;
}
@Override
public void addJournalListener(JournalListener listener) {
}
@Override
public long getBranch() {
return -1l;
}
};
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getDeclaringClass().equals(Journaled.class))
return method.invoke(journaled, args);
return method.invoke(journaledEngine, args);
}
});
return engine;
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
Aggregations