Fields Summary |
---|
protected static boolean | embeddedInGlassFishIs Grizzly embedded in GlassFish. |
private static final String | CONFIG_PROPERTY |
private static final String | SERVICE_CONFIG_PROPERTY |
private static final String | DEFAULT_SERVICE_CONFIG |
private static final String | SERVICE_NAMEThe default context for receiving requests. |
private org.safehaus.asyncweb.container.ServiceContainer | containerThe BasicServiceContainer which handle non blocking
request. |
private org.safehaus.asyncweb.transport.nio.HttpIOHandler | httpIOHandlerThe default IoHandler |
Methods Summary |
---|
private void | configureAsyncWebRuntime()Builds an async web container - adding transport and
services
String configDir = null;
if ( embeddedInGlassFish ){
configDir ="file://"
+ System.getProperty("com.sun.aas.instanceRoot")
+ File.separator + "config";
} else if ( rootFolder != null){
try{
configDir ="file://"
+ new File(rootFolder).getCanonicalPath()
+ File.separator + "conf";
} catch (IOException ex){
logger.log(Level.SEVERE,"Config error", ex);
}
} else {
throw new IllegalStateException("rootFolder cannot be null");
}
String[] configs = new String[] { configDir + File.separator
+ "AsyncWeb.xml", configDir
+ File.separator
+ DEFAULT_SERVICE_CONFIG
+ File.separator + "*.xml"};
ApplicationContext ctx = new FileSystemXmlApplicationContext(configs);
container = (ServiceContainer) ctx.getBean("container");
container.addTransport(this);
HttpServiceHandler httpServiceHandler =
(HttpServiceHandler)ctx.getBean("httpServiceHandler");
HttpService rooService = new RootAsyncService();
httpServiceHandler.addHttpService(SERVICE_NAME, rooService);
|
protected void | expireIdleKeys()Cancel keep-alive connections.
if ( keepAliveTimeoutInSeconds <= 0 || !selector.isOpen()) return;
long current = System.currentTimeMillis();
if (current < getNextKeysExpiration()) {
return;
}
setNextKeysExpiration(current + getKaTimeout());
Set<SelectionKey> readyKeys = selector.keys();
if (readyKeys.isEmpty()){
return;
}
Iterator<SelectionKey> iterator = readyKeys.iterator();
SelectionKey key;
while (iterator.hasNext()) {
key = iterator.next();
if ( !key.isValid() ) {
keepAlivePipeline.untrap(key);
continue;
}
// Keep-alive expired
if ( key.attachment() != null ) {
long expire = 0L;
if (key.attachment() instanceof Long){
expire = (Long) key.attachment();
} else {
expire = (Long) ((ReadTask)key.attachment()).getIdleTime();
}
if (current - expire >= getKaTimeout()) {
cancelKey(key);
} else if (expire + getKaTimeout() < getNextKeysExpiration()){
setNextKeysExpiration(expire + getKaTimeout());
}
}
}
|
public void | initEndpoint()Init the AsyncWeb runtime and this
SelectorThread
configureAsyncWebRuntime();
httpIOHandler = new HttpIOHandler();
httpIOHandler.setContainer(container);
super.initEndpoint();
|
public com.sun.enterprise.web.connector.grizzly.ProcessorTask | newProcessorTask(boolean initialize)Creates a new AsyncWebProcessorTask and configure it
to delegate AsyncWeb requests to its associated HttpIoHandler
AsyncWebProcessorTask task = new AsyncWebProcessorTask();
task.setMaxHttpHeaderSize(maxHttpHeaderSize);
task.setBufferSize(requestBufferSize);
task.setSelectorThread(this);
task.setRecycle(recycleTasks);
task.setIoHandler(httpIOHandler);
task.initialize();
if ( keepAlivePipeline.dropConnection() ) {
task.setDropConnection(true);
}
task.setPipeline(processorPipeline);
return task;
|
public void | setServiceContainer(org.safehaus.asyncweb.container.ServiceContainer container)Set the ServiceContainer used by this
SelectorThread
this.container = container;
|
public void | startEndpoint()Start the SelectorThread
super.startEndpoint();
try{
container.start();
} catch (Exception ex){
logger.log(Level.SEVERE,"AsyncWeb startup exception.", ex);
throw new IOException(ex.getMessage());
}
|
public void | stoptEndpoint()Stop the SelectorThread
try{
container.stop();
} catch (Exception ex){
logger.log(Level.SEVERE,"AsyncWeb stop exception.", ex);
throw new IOException(ex.getMessage());
}
super.stopEndpoint();
|