Mercurial > hg > Members > nobuyasu > jungle-network
view src/main/java/alice/jungle/persistent/PersistentJungleTree.java @ 135:2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 12 Jan 2014 06:18:37 +0900 (2014-01-11) |
parents | f9e29a52efd3 |
children | 6f104ab4eb81 |
line wrap: on
line source
package alice.jungle.persistent; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.AtomicReservableReference; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultJungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.TreeContext; public class PersistentJungleTree <T extends TreeNode<T>> implements JungleTree { private final AtomicReservableReference<TreeContext<T>> repository; private final String uuid; private final String treeName; private final ChangeListWriter writer; private final TreeEditor editor; public PersistentJungleTree(String _treeName, TreeContext<T> _tc,String _uuid, ChangeListWriter _writer,TreeEditor _editor) { treeName = _treeName; repository = new AtomicReservableReference<TreeContext<T>>(_tc); uuid = _uuid; writer = _writer; editor = _editor; } @Override public JungleTreeEditor getTreeEditor() { TreeContext<T> tc = repository.get(); PersistentTransactionManager<T> txManager = new PersistentTransactionManager<T>(treeName, writer,tc,repository,uuid); T root = tc.getTreeNode(); return new DefaultJungleTreeEditor<T>(root,txManager,editor); } @Override public Node getRootNode() { TreeContext<T> tc = repository.get(); ChangeSet cs = tc.getChangeSet(); return cs.getRoot(); } @Override public JungleTreeEditor getLocalTreeEditor() { return getTreeEditor(); } }