FileDocCategorySizeDatePackage
WorkManagerImpl.javaAPI DocGlassfish v2 API5404Fri May 04 22:30:30 BST 2007com.sun.enterprise.jbi.serviceengine.work

WorkManagerImpl

public class WorkManagerImpl extends Object implements WorkManager, Runnable
Work Manager implementation for JBI Service Engine.
author
Binod PG

Fields Summary
private com.sun.enterprise.jbi.serviceengine.config.ComponentConfiguration
config
private String
threadPoolName
private com.sun.corba.ee.spi.orbutil.threadpool.ThreadPoolManager
tpm
private com.sun.corba.ee.spi.orbutil.threadpool.ThreadPool
tp
private com.sun.enterprise.jbi.serviceengine.comm.MessageAcceptor
acceptor
private static Logger
logger
Constructors Summary
public WorkManagerImpl(com.sun.enterprise.jbi.serviceengine.config.ComponentConfiguration config)
Saves the static service engine instance for use by work manager. Also obtains configured thread pool name.


                           
       
        this.config = config;
        this.threadPoolName = this.config.getCommonThreadPoolName();
    
Methods Summary
public com.sun.enterprise.jbi.serviceengine.comm.MessageAcceptorgetMessageAcceptor()
Retrieves the MessageAcceptor of the work manager.

        return this.acceptor;
    
public java.lang.StringgetPoolName()
Retrieves the name of the thread pool used by this work manager.

        return this.threadPoolName;
    
public voidrun()

        try {
            startAcceptor();
        } catch(ServiceEngineException se) {
            se.printStackTrace();
        } finally {
            stop();
        }
    
public voidsetPoolName(java.lang.String poolName)
Set the name of thread pool.

        this.threadPoolName = poolName;
    
public voidstartAcceptor()
Start the message acceptor thread.

        tpm = S1ASThreadPoolManager.getThreadPoolManager();

        if (getPoolName() == null) { 
            // This will be default orb thread pool
            tp = tpm.getDefaultThreadPool();
        } else {
            try {
                tp = tpm.getThreadPool(getPoolName());
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE,
                    "Got the thread pool for :" + getPoolName());
                }
            } catch (NoSuchThreadPoolException e) {
                logger.log(Level.SEVERE,
                "workmanager.threadpool_not_found", getPoolName());
                throw new ServiceEngineException(e.getMessage());
            }
        }
        this.acceptor = new MessageAcceptor();
        this.acceptor.startAccepting();
    
public voidstop()
Convenience method to release acceptor thread.

        this.acceptor.release();
    
public voidsubmitWork(OneWork work)
Submit a work to the queue of the thread pool. We just submit to a random queue of the thread pool.

param
work Work object as specified by the Appserver thread pool interface.

        tp.getAnyWorkQueue().addWork(work);