1 package org.sapia.ubik.rmi.server; 2 3 import java.io.Externalizable ; 4 import java.io.IOException ; 5 import java.io.ObjectInput ; 6 import java.io.ObjectOutput ; 7 8 import org.sapia.ubik.net.Connection; 9 import org.sapia.ubik.net.ServerAddress; 10 import org.sapia.ubik.rmi.server.command.Command; 11 12 13 24 public abstract class RMICommand extends Command implements Externalizable { 25 protected transient Config _config; 26 protected VmId _vmId = VmId.getInstance(); 27 28 public RMICommand() { 29 } 30 31 42 public void init(Config config) { 43 _config = config; 44 } 45 46 51 public VmId getVmId() { 52 return _vmId; 53 } 54 55 61 public ServerAddress getServerAddress() { 62 return _config.getServerAddress(); 63 } 64 65 70 public final Connection getConnection() { 71 return _config.getConnection(); 72 } 73 74 79 public abstract Object execute() throws Throwable ; 80 81 84 public void readExternal(ObjectInput in) 85 throws IOException , ClassNotFoundException { 86 _vmId = (VmId) in.readObject(); 87 } 88 89 92 public void writeExternal(ObjectOutput out) throws IOException { 93 out.writeObject(_vmId); 94 } 95 } 96 | Popular Tags |