1 21 package net.sf.hajdbc.distributable; 22 23 import java.io.Externalizable ; 24 import java.io.IOException ; 25 import java.io.ObjectInput ; 26 import java.io.ObjectOutput ; 27 28 import net.sf.hajdbc.Database; 29 import net.sf.hajdbc.DatabaseCluster; 30 31 37 public abstract class DatabaseCommand implements Externalizable 38 { 39 protected String databaseId; 40 41 44 protected DatabaseCommand() 45 { 46 } 48 49 53 public DatabaseCommand(Database database) 54 { 55 this.databaseId = database.getId(); 56 } 57 58 61 public void writeExternal(ObjectOutput output) throws IOException 62 { 63 output.writeUTF(this.databaseId); 64 } 65 66 69 public void readExternal(ObjectInput input) throws IOException 70 { 71 this.databaseId = input.readUTF(); 72 } 73 74 79 public abstract void execute(DatabaseCluster databaseCluster); 80 81 84 @Override 85 public String toString() 86 { 87 return this.getClass().getName() + " [" + this.databaseId + "]"; 88 } 89 } 90 | Popular Tags |