Hi,
After discussing the Model I'd now like to discuss the architecture
for request handling. I propose the following:
General Architecture:
* A Request Manager component to handle incoming requests.
* Action classes called by the Request Manager
Details:
* In web.xml we define a ServletContextListener for initializing the
Component Manager (CM) the first time XWiki is started. This puts the
component manager as an attribute in ServletContext. For Plexus this
means registering PlexusServletContextListener.java
* In web.xml we define the main XWiki Servlet. It depends on the CM.
For Plexus this means extending the PlexusServlet class. The main
thing that Servlet does it use the CM to find the Request Manager
component and to call it. The other thing it does is create a
XWikiRequest component and a Session component so that the CM can
inject them in components requiring them.
* The request manager is configured using the Component Manager
configuration mechanism. For Plexus this is through a component.xml
file located in META-INF/plexus. The configuration defines the
different components to use for the different actions. For example:
<components>
<component>
<role>org.xwiki.request.Action</role>
<implementation>org.xwiki.request.ViewAction</implementation>
<configuration>
<action>view</action>
<order>100</order>
</configuration>
</component>
...
</components>
Note: The order is there so that it's possible for non-core
components to contribute Actions. For example this is useful for the
ZipExplorer component which will contribute a
ZipExplorerDownloadAction which should be executed before the default
DownloadAction.
* Other details: We'll have a XWikiRequest and a XWikiResponse
classes and a URL Handler component and a XWikiURL class.
* Here's an example of how an Action will be coded:
public class MyAction implements Action
{
private XWikiRequest request;
private XWikiSession session;
public XWikiResponse execute()
{
...
}
}
The request and session object in this example are being injected
automatically by the CM.
* There are 2 kinds of configuration: static configuration like the
one shown above for registering action names and order for Actions
and user configuration (the one we currently have in xwiki.cfg). For
user configuration we can have a Configuration component or even
better have the config properties automatically injected in the
component so that the component writer would one write:
private List plugins;
(in that case the mapping between "plugins" and the xwiki.plugins
property would be defined in components.xml)
* For logging, we can have define our own LoggerManager component and
tell the CM to use it by registering it in plexus.xml. This will
allow not to depend on any specific CM for logging (otherwise we
would get a org.plexus.logger.Logger object).
To summarize, with this proposal there are only 2 classes that depend
on the CM:
- the servlet context initializer
- the main servlet which is just using the CM to call the Request
Manager.
WDYT?
For OSGi lovers, how would you implement this in OSGi?
Thanks
-Vincent