[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-dev] Servlet-3.0 WebApp configuration
|
All,
the next big refactor that we need to do to the jetty-7/8 code base is
for the webapp configuration mechanism.
The current mechanism consists of a stack of classes for configuring
different aspects of the webapp:
WEB-INF/lib classloader configuration
jetty-web.xml
web.xml
jetty-env.xml
tag lib discovery
Some of these are extended by the jetty plus classes to handle
annotations and resource injection.
Without considering servlet-3.0, there are a few problems with
this, mostly that inheritance is not the best way to extend
configurations, you can only have a single inheritance path
and mix and match is thus difficult.
With servlet-3.0 the configuration of a webapplication becomes
even more complex. We've already hacked in some support for
this, but I'm now thinking we need to take a step back and
redo the entire configuration mechanism.
The non-functional requirements of the configuration mechanism
are:
+ It must be optional and pluggable, so uses such as geronimo
and jboss can have their own configuration mechanisms.
+ The default needs to be servlet-3.0 compliant
+ It should be easy to take out some features that
might not be best for production/embedded deployments
(eg. auto discovery mechanisms etc.).
to fully configure a 3.0 webapp, the process will need to be
something like below. The key change is that instead of
multiple passes through the configurations - only a single
pass is made, but with each configuration having the
ability to leave data structures for others to work on
eg. sorted list of jars with fragments
and effective web.xml parse tree
UnpackConfiguration
-------------------
unpack war file depending on configured
attributes of the webAppContext
Potentially expand WEB-INF/lib/* separately
to avoid jar locking issues.
WebInfConfiguration:
--------------------
discover WEB-INF/classes and add to class-path
discover WEB-INF/lib/*.jar and for each:
a) add to class-path
b) scan jar index for
i) META-INF/web-fragment.xml
parse (not process) for name and partial orderings
ii) META-INF/*.tld add to list of tlds
iii) META-INF/resources add to resource base.
set Thread context classloader
TempDirConfiguration
--------------------
configure the tempdir location, potentially using a WEB-INF/work directory
WebXmlConfiguration
-------------------
discover defaultweb.xml, WEB-INF/web.xml and override web.xml
a) parse (but not process) to determine
i) if meta-data complete
ii) if there is a web-fragment ordering
Apply orderings to list of WEB-INF/lib/*.jar
Store list of jars as attribute for later configurations.
Use meta-data-complete and orderings to merge
* defaultweb.xml
* web.xml
* web-fragment.xml s
* override web.xml
to obtain an effective web.xml that respects
main merging rules. Store resulting parse
tree as attribute for use by subsequent configuration
process effective web.xml standard configuration
EnvConfiguration
----------------
Process the effective web.xml looking for resources
and other JNDI type stuff.
Process jetty-env.xml
AnnotationConfiguration
-----------------------
For each jar in ordered list scan classes for
a) handled types for ServletContainerInitializers
b) Servlets|Filters|Listeners instances with annotations
i) Setup resource injection for newServlet and newFilter
ContainerInitializerConfiguration
---------------------------------
user JVM service discovery to find ServletContainerInitializer classes
on container classpath.
a) for each initialize use @HandlesTypes to discover interested classes
For each ServletContainerInitializer
i) scan ordered jar list for matching classes (or maybe all jars)
i) call with list of discovered classes and allow to do programmatic
configuration
TagLibConfiguration
-------------------
Combine list of META-INF/*.tld with
* TLDs defined in effective web.xml
* TLDs discovered in WEB-INF/*.tld (including META-INF/resources/WEB-INF/*.tld)
Parse TLDs for listeners - add to listener lists.
ListenerConfiguration
---------------------
Call all listeners (which can do programmatic configuration)
LoadOnStartupConfiguration
--------------------------
Sort and instantiate all load-on-startup servlets