1 16 package org.springframework.webflow.execution.repository.continuation; 17 18 import java.io.ByteArrayInputStream ; 19 import java.io.IOException ; 20 import java.io.ObjectInputStream ; 21 22 import org.springframework.webflow.execution.FlowExecution; 23 24 33 public class SerializedFlowExecutionContinuationFactory implements FlowExecutionContinuationFactory { 34 35 38 private boolean compress = true; 39 40 43 public boolean getCompress() { 44 return compress; 45 } 46 47 50 public void setCompress(boolean compress) { 51 this.compress = compress; 52 } 53 54 public FlowExecutionContinuation createContinuation(FlowExecution flowExecution) throws ContinuationCreationException { 55 return new SerializedFlowExecutionContinuation(flowExecution, compress); 56 } 57 58 public FlowExecutionContinuation createContinuation(byte[] bytes) throws ContinuationUnmarshalException { 59 try { 60 ObjectInputStream ois = new ObjectInputStream (new ByteArrayInputStream (bytes)); 61 try { 62 return (FlowExecutionContinuation)ois.readObject(); 63 } 64 finally { 65 ois.close(); 66 } 67 } 68 catch (IOException e) { 69 throw new ContinuationUnmarshalException("IO problem while creating a flow execution continuation", e); 70 } 71 catch (ClassNotFoundException e) { 72 throw new ContinuationUnmarshalException("Class not found while creating a flow execution continuation", e); 73 } 74 } 75 } | Popular Tags |