1 2 package SOFA.SOFAnode.Made.TIR.Impl; 3 import java.io.IOException ; 4 import java.rmi.RemoteException ; 5 import java.rmi.server.UnicastRemoteObject ; 6 7 import SOFA.SOFAnode.Made.TIR.BindTypeKind; 8 import SOFA.SOFAnode.Made.TIR.BindTypeNormal; 9 import SOFA.SOFAnode.Made.TIR.Container; 10 import SOFA.SOFAnode.Made.TIR.DefinitionKind; 11 import SOFA.SOFAnode.Made.TIR.Repository; 12 import SOFA.SOFAnode.Made.TIR.StateKind; 13 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit; 14 15 public class BindTypeNormalImpl extends UnicastRemoteObject implements BindTypeNormal, TIRImplObject { 16 DefinitionKindImpl defKindImpl; 17 StateKindImpl stKindImpl; 18 BindTypeKind btk; 19 String nm; 20 21 public BindTypeNormalImpl(String name) throws RemoteException { 22 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_BindType); 23 stKindImpl = new StateKindImpl(StateKind.sk_work); 24 btk = new BindTypeKindImpl(BindTypeKind.btk_normal); 25 nm = name; 26 } 27 28 public BindTypeNormalImpl() throws RemoteException { 29 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_BindType); 30 stKindImpl = new StateKindImpl(StateKind.sk_normal); 31 btk = new BindTypeKindImpl(BindTypeKind.btk_normal); 32 nm = null; 33 } 34 35 36 public DefinitionKind get_def_kind() throws RemoteException { 37 return (DefinitionKind) defKindImpl; 38 } 39 40 41 public StateKind get_state() throws RemoteException { 42 return (StateKind) stKindImpl; 43 } 44 45 public BindTypeKind get_bt_kind() throws RemoteException { 46 return btk; 47 } 48 49 public String name() throws RemoteException { 50 return nm; 51 } 52 53 public void save(Storage st) throws RemoteException , TIRExceptStorage { 54 try { 55 st.curOutFile.writeInt(btk.value()); 56 Storage.writeString(st.curOutFile, nm); 57 } catch (IOException e) { 58 throw new TIRExceptStorage("Can't write in directory "+st.current+"."); 59 } 60 } 61 62 public void load(Storage st) throws RemoteException , TIRExceptStorage { 63 try { 64 nm = Storage.readString(st.curInFile); 65 } catch (IOException e) { 66 throw new TIRExceptStorage("Can't read in directory "+st.current+"."); 67 } 68 } 69 70 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage {} 71 72 public boolean isNew() { 73 return (stKindImpl.value()==StateKind.sk_work); 74 } 75 76 public void canCommit() throws RemoteException , TIRExceptCommit {;} 77 78 public void doCommit(Container in, Repository rep) throws RemoteException { 79 if (stKindImpl.value()==StateKind.sk_normal) 80 return; 81 if (isNew()) { 82 stKindImpl.toNormal(); 83 } 84 } 85 86 public void doAbort(long workId) throws RemoteException {} 87 } 88 | Popular Tags |