FileDocCategorySizeDatePackage
EventHandlerBase.javaAPI DocJava SE 6 API3130Tue Jun 10 00:21:44 BST 2008com.sun.corba.se.impl.transport

EventHandlerBase

public abstract class EventHandlerBase extends Object implements EventHandler

Fields Summary
protected ORB
orb
protected Work
work
protected boolean
useWorkerThreadForEvent
protected boolean
useSelectThreadToWait
protected SelectionKey
selectionKey
Constructors Summary
Methods Summary
private voiddprint(java.lang.String msg)

	ORBUtility.dprint("EventHandlerBase", msg);
    
public java.nio.channels.SelectionKeygetSelectionKey()

	return selectionKey;
    
public com.sun.corba.se.spi.orbutil.threadpool.WorkgetWork()

	return work;
    
public voidhandleEvent()

	if (orb.transportDebugFlag) {
	    dprint(".handleEvent->: " + this);
	}
	getSelectionKey().interestOps(getSelectionKey().interestOps() &
				      (~ getInterestOps()));
	if (shouldUseWorkerThreadForEvent()) {
	    Throwable throwable = null;
	    try {
		if (orb.transportDebugFlag) {
		    dprint(".handleEvent: addWork to pool: " + 0);
		}
		orb.getThreadPoolManager().getThreadPool(0)
		    .getWorkQueue(0).addWork(getWork());
	    } catch (NoSuchThreadPoolException e) {
		throwable = e;
	    } catch (NoSuchWorkQueueException e) {
		throwable = e;
	    }
	    // REVISIT: need to close connection.
	    if (throwable != null) {
		if (orb.transportDebugFlag) {
		    dprint(".handleEvent: " + throwable);
		}
		INTERNAL i = new INTERNAL("NoSuchThreadPoolException");
		i.initCause(throwable);
		throw i;
	    }
	} else {
	    if (orb.transportDebugFlag) {
		dprint(".handleEvent: doWork");
	    }
	    getWork().doWork();
	}
	if (orb.transportDebugFlag) {
	    dprint(".handleEvent<-: " + this);
	}
    
public voidsetSelectionKey(java.nio.channels.SelectionKey selectionKey)

	this.selectionKey = selectionKey;
    
public voidsetUseSelectThreadToWait(boolean x)

	useSelectThreadToWait = x;
    
public voidsetUseWorkerThreadForEvent(boolean x)

	useWorkerThreadForEvent = x;
    
public voidsetWork(com.sun.corba.se.spi.orbutil.threadpool.Work work)

	this.work = work;
    
public booleanshouldUseSelectThreadToWait()

	return useSelectThreadToWait;
    
public booleanshouldUseWorkerThreadForEvent()

	return useWorkerThreadForEvent;