1 23 24 package com.sun.enterprise.jbi.serviceengine.work; 25 26 import java.util.logging.Logger ; 27 import javax.jbi.messaging.MessageExchange; 28 import javax.jbi.messaging.DeliveryChannel; 29 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException; 30 import com.sun.corba.ee.spi.orbutil.threadpool.Work; 31 import com.sun.enterprise.jbi.serviceengine.core.JavaEEServiceEngineContext; 32 import com.sun.logging.LogDomains; 33 34 39 public abstract class OneWork implements Work { 40 41 private long nqTime; 42 protected static final Logger logger = 43 LogDomains.getLogger(LogDomains.SERVER_LOGGER); 44 private MessageExchange me = null; 45 private DeliveryChannel channel = null; 46 private boolean useCurrentThread = true; 47 private JavaEEServiceEngineContext seContext; 48 private WorkManager wm = null; 49 private ServiceEngineException exception = null; 50 51 52 56 public OneWork() { 57 this.channel = JavaEEServiceEngineContext.getInstance().getDeliveryChannel(); 58 this.wm = JavaEEServiceEngineContext.getInstance().getWorkManager(); 59 } 60 61 64 public abstract void doWork(); 65 66 71 public void setEnqueueTime(long tme) { 72 this.nqTime = tme; 73 } 74 75 80 public long getEnqueueTime() { 81 return nqTime; 82 } 83 84 87 public void setMessageExchange(MessageExchange me) { 88 this.me = me; 89 } 90 91 94 public MessageExchange getMessageExchange() { 95 return me; 96 } 97 98 106 public void setUseCurrentThread(boolean flag) { 107 this.useCurrentThread = flag; 108 } 109 110 114 public boolean getUseCurrentThread() { 115 return this.useCurrentThread; 116 } 117 118 121 public WorkManager getWorkManager() { 122 return this.wm; 123 } 124 125 128 public DeliveryChannel getDeliveryChannel() { 129 return this.channel; 130 } 131 132 136 public ServiceEngineException getException() { 137 return this.exception; 138 } 139 140 144 public void setException(Throwable t) { 145 this.exception = new ServiceEngineException(t); 146 } 147 148 153 protected void execute() { 154 if (getUseCurrentThread()) { 155 doWork(); 156 } else { 157 getWorkManager().submitWork(this); 158 } 159 } 160 161 166 public String getName() { 167 return "One JBI Work"; 168 } 169 } 170 | Popular Tags |