I just looked at some documentation and indeed there is injection based servlet 
registration.
I'm all for using existing standards but there seem to be some issues with this 
implementation.

Until we stop supporting servlets 2.x (tomcat < 7.0) we would need an adapter 
to support this functionality.

Servlets3 supports dynamically loading servlets 
(ServletContext#add[Servlet|Filter]) but doesn't seem
to have a standard way to remove them which would break servlets in extensions.

Servlets are loaded at start time by scanning over all class files in the 
application, I'm not sure how this will be for performance.

Unless we used special code in the ECM, servlets would not be able to use 
dependency injection without explicitly getting the CM itself.


Given these limitations I think that for now it makes the most sense to break 
from the standard and roll our own servlet which redirects to a servlet which 
is registered as a @Component.


Thanks,
Caleb



On 11/07/2012 08:46 AM, Thomas Mortagne wrote:
> Isn't the possibility to inject servlet without having to modiify web.xml
> part of Servlet 3 ?
> 
> 
> On Wed, Nov 7, 2012 at 2:41 PM, Caleb James DeLisle <
> [email protected]> wrote:
> 
>> Hi,
>>
>> I'd like to register servlets in the component manager and have them
>> called by their hint.
>> The oldcore struts servlet would be @Named("bin") and the rest servlet
>> would be @Named("rest")
>>
>> Reasons to want to do this:
>> * There are things which are currently impossible without a servlet,
>> things like REST, GWT and WebDav.
>> * If somebody has servlet code and they want to make it run in XWiki, this
>> is a real answer for them whereas "rewrite your app using XWiki actions"
>> isn't.
>> * Even if we had an Actions system which made it *possible* to implement
>> REST, GWT, and WebDav entry points, we would have to rewrite the universe
>> since all external libraries use Servlet.
>> * Web.xml is an eyesore, it's full of content which is the concern only of
>> a particular module, this could (mostly) be fixed by using injected
>> servlets.
>>
>> The big reason not to like it is because it could undermine the proposal
>> for Actions.
>> The JIRA issue for actions http://jira.xwiki.org/browse/XWIKI-4713 was
>> opened on January 1 of 2010.
>> It is stalled because nobody really knows how to make an abstraction which
>> represents Servlets or Portlets without any lost features.
>> If we make it easier for servlets to be used, we might begin down a
>> slippery slope toward everything being done using servlets and then we lose
>> portlet compatibility.
>> But the alternative as I see it is to block progress in this direction and
>> hope that somebody steps up to implement Actions which are fully compatible
>> with portlets and servlets.
>>
>>
>> WDYT?
>> Are there reasons not to do this which I missed?
>>
>> Caleb
>>
>> _______________________________________________
>> devs mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
> 
> 
> 


_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to