1 package com.opensymphony.webwork.interceptor; 2 3 import com.opensymphony.xwork.ActionInvocation; 4 5 import java.io.Serializable ; 6 7 13 public class BackgroundProcess implements Serializable { 14 protected Object action; 15 protected ActionInvocation invocation; 16 protected String result; 17 protected Exception exception; 18 protected boolean done; 19 20 public BackgroundProcess(String threadName, final ActionInvocation invocation, int threadPriority) { 21 this.invocation = invocation; 22 this.action = invocation.getAction(); 23 try { 24 final Thread t = new Thread (new Runnable () { 25 public void run() { 26 try { 27 beforeInvocation(); 28 result = invocation.invokeActionOnly(); 29 afterInvocation(); 30 } catch (Exception e) { 31 exception = e; 32 } 33 34 done = true; 35 } 36 }); 37 t.setName(threadName); 38 t.setPriority(threadPriority); 39 t.start(); 40 } catch (Exception e) { 41 exception = e; 42 } 43 } 44 45 51 protected void beforeInvocation() throws Exception { 52 } 53 54 61 protected void afterInvocation() throws Exception { 62 } 63 64 public Object getAction() { 65 return action; 66 } 67 68 public ActionInvocation getInvocation() { 69 return invocation; 70 } 71 72 public String getResult() { 73 return result; 74 } 75 76 public Exception getException() { 77 return exception; 78 } 79 80 public boolean isDone() { 81 return done; 82 } 83 } 84 | Popular Tags |