1 4 package org.oddjob.framework; 5 6 import java.io.IOException ; 7 import java.io.ObjectInputStream ; 8 import java.io.ObjectOutputStream ; 9 import java.io.Serializable ; 10 11 import org.oddjob.images.IconHelper; 12 import org.oddjob.state.JobStateHandler; 13 14 abstract public class SerializableJob extends SimpleJob 15 implements Serializable { 16 private static final long serialVersionUID = 20050925; 17 18 19 22 private void writeObject(ObjectOutputStream s) 23 throws IOException { 24 if (destroyed) { 25 throw new IllegalStateException ("[" + this + "] destroyed"); 26 } 27 lock.accquire("Hard reset in progress."); 28 try { 29 s.defaultWriteObject(); 30 s.writeObject(getName()); 31 if (getLogger().startsWith(getClass().getName())) { 32 s.writeObject(null); 33 } 34 else { 35 s.writeObject(getLogger()); 36 } 37 s.writeObject(stateHandler); 38 s.writeObject(iconHelper); 39 } 40 finally { 41 lock.release(); 42 } 43 } 44 45 48 private void readObject(ObjectInputStream s) 49 throws IOException , ClassNotFoundException { 50 s.defaultReadObject(); 51 setName((String ) s.readObject()); 52 setLogger((String ) s.readObject()); 53 stateHandler = (JobStateHandler) s.readObject(); 54 stateHandler.setSource(this); 55 iconHelper = (IconHelper) s.readObject(); 56 iconHelper.setSource(this); 57 } 58 59 } 60 | Popular Tags |