1 23 24 package com.sun.enterprise.jbi.serviceengine.work; 25 26 import java.util.logging.Logger ; 27 import java.util.logging.Level ; 28 import com.sun.corba.ee.spi.orbutil.threadpool.ThreadPool; 29 import com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager; 30 import com.sun.corba.ee.spi.orbutil.threadpool.NoSuchThreadPoolException; 31 import com.sun.enterprise.jbi.serviceengine.comm.MessageAcceptor; 32 import com.sun.enterprise.jbi.serviceengine.config.ComponentConfiguration; 33 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException; 34 import com.sun.enterprise.util.S1ASThreadPoolManager; 35 import com.sun.logging.LogDomains; 36 37 42 public class WorkManagerImpl implements WorkManager, Runnable { 43 44 45 private ComponentConfiguration config = null; 46 private String threadPoolName = null; 47 private ThreadPoolManager tpm = null; 48 private ThreadPool tp = null; 49 private MessageAcceptor acceptor= null; 50 51 private static Logger logger = 52 LogDomains.getLogger(LogDomains.SERVER_LOGGER); 53 54 58 public WorkManagerImpl(ComponentConfiguration config) { 59 this.config = config; 60 this.threadPoolName = this.config.getCommonThreadPoolName(); 61 } 62 63 66 public void setPoolName(String poolName) { 67 this.threadPoolName = poolName; 68 } 69 70 74 public String getPoolName() { 75 return this.threadPoolName; 76 } 77 78 81 public MessageAcceptor getMessageAcceptor() { 82 return this.acceptor; 83 } 84 85 92 public void submitWork(OneWork work) { 93 tp.getAnyWorkQueue().addWork(work); 94 } 95 96 99 public void startAcceptor() throws ServiceEngineException { 100 tpm = S1ASThreadPoolManager.getThreadPoolManager(); 101 102 if (getPoolName() == null) { 103 tp = tpm.getDefaultThreadPool(); 105 } else { 106 try { 107 tp = tpm.getThreadPool(getPoolName()); 108 if (logger.isLoggable(Level.FINE)) { 109 logger.log(Level.FINE, 110 "Got the thread pool for :" + getPoolName()); 111 } 112 } catch (NoSuchThreadPoolException e) { 113 logger.log(Level.SEVERE, 114 "workmanager.threadpool_not_found", getPoolName()); 115 throw new ServiceEngineException(e.getMessage()); 116 } 117 } 118 this.acceptor = new MessageAcceptor(); 119 this.acceptor.startAccepting(); 120 } 121 122 125 public void stop() { 126 this.acceptor.release(); 127 } 128 129 public void run() { 130 try { 131 startAcceptor(); 132 } catch(ServiceEngineException se) { 133 se.printStackTrace(); 134 } finally { 135 stop(); 136 } 137 } 138 } 139 | Popular Tags |