|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.tcp.StaticResourcesAdapter
com.sun.grizzly.tcp.http11.GrizzlyAdapter
com.sun.grizzly.tcp.http11.GrizzlyAdapterChain
public class GrizzlyAdapterChain
The GrizzlyAdapterChain class allow the invokation of multiple GrizzlyAdapter
every time a new HTTP requests is ready to be handled. Requests are mapped
to their associated GrizzlyAdapter at runtime using the mapping
information configured when invoking the GrizzlyAdapterChain#addGrizzlyAdapter
(com.sun.grizzly.tcp.http11.GrizzlyAdapter, java.lang.String[])
Below is a simple example using two {@link Servlet}
GrizzlyWebServer ws = new GrizzlyWebServer(path);
ServletAdapter sa = new ServletAdapter();
sa.setRootFolder(".");
sa.setServletInstance(new ServletTest("Adapter-1"));
ws.addGrizzlyAdapter(sa, new String[]{"/Adapter-1"});
ServletAdapter sa2 = new ServletAdapter();
sa2.setRootFolder("/tmp");
sa2.setServletInstance(new ServletTest("Adapter-2"));
ws.addGrizzlyAdapter(sa2, new String[]{"/Adapter-2"});
System.out.println("Grizzly WebServer listening on port 8080");
ws.start();
Note: This class is NOT thread-safe, so make sure you synchronize
when dynamically adding and removing {@link GrizzlyAdapter}
| Field Summary | |
|---|---|
protected static int |
MAPPED_ADAPTER
|
protected static int |
MAPPING_DATA
|
| Fields inherited from class com.sun.grizzly.tcp.http11.GrizzlyAdapter |
|---|
ADAPTER_NOTES, ALLOW_BACKSLASH, chunkingDisabled |
| Fields inherited from class com.sun.grizzly.tcp.StaticResourcesAdapter |
|---|
cache, commitErrorResponse, fileFolders, logger, resourcesContextPath |
| Constructor Summary | |
|---|---|
GrizzlyAdapterChain()
|
|
| Method Summary | |
|---|---|
void |
addGrizzlyAdapter(GrizzlyAdapter adapter)
Deprecated. - uses addGrizzlyAdapter(com.sun.grizzly.tcp.http11.GrizzlyAdapter, java.lang.String[]) |
void |
addGrizzlyAdapter(GrizzlyAdapter adapter,
String[] mappings)
Add a GrizzlyAdapter and its assciated array of mapping. |
void |
destroy()
Invoked when the GrizzlyWebServer or SelectorThread
is stopped or removed. |
boolean |
removeAdapter(GrizzlyAdapter adapter)
Remove a GrizzlyAdapter |
void |
service(GrizzlyRequest request,
GrizzlyResponse response)
Map the GrizzlyRequest to the proper GrizzlyAdapter |
void |
start()
Called when the GrizzlyAdapter's container is started by invoking
GrizzlyWebServer#start or when . |
| Methods inherited from class com.sun.grizzly.tcp.http11.GrizzlyAdapter |
|---|
afterService, afterService, isAllowEncodedSlash, isHandleStaticResources, service, setAllowEncodedSlash, setDecodeUrl, setHandleStaticResources |
| Methods inherited from class com.sun.grizzly.tcp.StaticResourcesAdapter |
|---|
addRootFolder, customizedErrorPage, getDefaultContentType, getResourcesContextPath, getRootFolder, getRootFolders, initWebDir, isUseSendFile, service, setDefaultContentType, setLogger, setResourcesContextPath, setRootFolder, setUseSendFile |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int MAPPING_DATA
protected static final int MAPPED_ADAPTER
| Constructor Detail |
|---|
public GrizzlyAdapterChain()
| Method Detail |
|---|
public void start()
GrizzlyAdapterGrizzlyAdapter's container is started by invoking
GrizzlyWebServer#start or when . By default,
it does nothing.
start in class GrizzlyAdapter
public void service(GrizzlyRequest request,
GrizzlyResponse response)
GrizzlyRequest to the proper GrizzlyAdapter
service in class GrizzlyAdapterrequest - The GrizzlyRequestresponse - The GrizzlyResponsepublic void addGrizzlyAdapter(GrizzlyAdapter adapter)
addGrizzlyAdapter(com.sun.grizzly.tcp.http11.GrizzlyAdapter, java.lang.String[])
GrizzlyAdapter to the chain.
{@link - GrizzlyAdapter} to the chain.
public void addGrizzlyAdapter(GrizzlyAdapter adapter,
String[] mappings)
GrizzlyAdapter and its assciated array of mapping. The mapping
data will be used to map incoming request to its associated GrizzlyAdapter.
adapter - GrizzlyAdapter instancemappings - an array of mapping.public void destroy()
GrizzlyAdapterGrizzlyWebServer or SelectorThread
is stopped or removed. By default, this method does nothing. Just override
the method if you need to clean some resource.
destroy in class GrizzlyAdapterpublic boolean removeAdapter(GrizzlyAdapter adapter)
GrizzlyAdapter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||