You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2007/10/17 17:45:50 UTC
[jira] Created: (SLING-64) Refactor Servlets and Script resolution
Refactor Servlets and Script resolution
---------------------------------------
Key: SLING-64
URL: https://issues.apache.org/jira/browse/SLING-64
Project: Sling
Issue Type: Improvement
Components: microsling
Reporter: Felix Meschberger
Fix For: 2.0.0
microsling currently defines a SlingServlet interface which has a canProcess method used to decide whether a servlet is capable of handling a request or not. I think, this mechanism will not scale well if we add more script engines or more servlets.
As a first step towards a simpler approach, I propose the following:
* Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
* Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
* Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
* Refactor MicroSlingServlet such, that
(1) check for a servlet by resource type
(2) try to evaluate a script
(3) fall back to the DefaultSlingServlet
* Also in the MicroSlingServlet register servlets by type (currently there are none of course)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (SLING-64) Refactor Servlets and Script resolution
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-64?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger closed SLING-64.
----------------------------------
Resolution: Fixed
Assignee: Felix Meschberger
Changes have been applied. Closing this issue for now.
> Refactor Servlets and Script resolution
> ---------------------------------------
>
> Key: SLING-64
> URL: https://issues.apache.org/jira/browse/SLING-64
> Project: Sling
> Issue Type: Improvement
> Components: microsling
> Reporter: Felix Meschberger
> Assignee: Felix Meschberger
> Fix For: 2.0.0
>
> Attachments: SLING-64.patch
>
>
> microsling currently defines a SlingServlet interface which has a canProcess method used to decide whether a servlet is capable of handling a request or not. I think, this mechanism will not scale well if we add more script engines or more servlets.
> As a first step towards a simpler approach, I propose the following:
> * Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
> * Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
> * Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
> * Refactor MicroSlingServlet such, that
> (1) check for a servlet by resource type
> (2) try to evaluate a script
> (3) fall back to the DefaultSlingServlet
> * Also in the MicroSlingServlet register servlets by type (currently there are none of course)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (SLING-64) Refactor Servlets and Script resolution
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-64?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Felix Meschberger updated SLING-64:
-----------------------------------
Attachment: SLING-64.patch
Proposed changes
> Refactor Servlets and Script resolution
> ---------------------------------------
>
> Key: SLING-64
> URL: https://issues.apache.org/jira/browse/SLING-64
> Project: Sling
> Issue Type: Improvement
> Components: microsling
> Reporter: Felix Meschberger
> Fix For: 2.0.0
>
> Attachments: SLING-64.patch
>
>
> microsling currently defines a SlingServlet interface which has a canProcess method used to decide whether a servlet is capable of handling a request or not. I think, this mechanism will not scale well if we add more script engines or more servlets.
> As a first step towards a simpler approach, I propose the following:
> * Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
> * Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
> * Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
> * Refactor MicroSlingServlet such, that
> (1) check for a servlet by resource type
> (2) try to evaluate a script
> (3) fall back to the DefaultSlingServlet
> * Also in the MicroSlingServlet register servlets by type (currently there are none of course)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Commented: (SLING-64) Refactor Servlets and Script resolution
Posted by Bertrand Delacretaz <bd...@apache.org>.
On 10/18/07, Carsten Ziegeler <cz...@apache.org> wrote:
> ..Sorry for trying hard to be a pita :) but again, can we please let all
> these discussions take place in the mailing list?...
You're right, sorry about that. We should discuss things here, and
move to Jira once we reach consensus.
-Bertrand
Re: [jira] Commented: (SLING-64) Refactor Servlets and Script resolution
Posted by Torgeir Veimo <to...@pobox.com>.
On 18 Oct 2007, at 07:59, Carsten Ziegeler wrote:
> Sorry for trying hard to be a pita :) but again, can we please let all
> these discussions take place in the mailing list?
> I think it's easy to first discuss a topic in the mailing list and
> then
> create a jira which either sums up the discussion or references the
> mailing list archives.
Ok, here is my proposal from the Jira issue comment:
How about abstracting this a bit, instead of relying on servlets to
say themselves if they can handle a request, to use factories, or
rather, mappers.
A manager would resolve a request to a sling servlet by iterating
through its configured mappers and stopping once a suitable sling
servlet is found. If no mapper resolves a servlet, the default sling
servlet is called.
public interface ServletMapper {
public SlingServlet findServlet(SlingServletRequest request,
Resource resource) throws Exception;
}
A configuration file would specify the order of the mappers, along
with any configuration parameters each mapper needs. (A simple
digester implementation would allow configuration parameters to be
set using reflection.)
A default mapper which maps to servlets based on url and/or jcr node
type or resource type can be provided which would be sufficient in
most cases. For specific needs a sling api user would implement his
own mapper.
Sitemesh uses a similar setup with great success for decorating web
pages based on any combination of url patterns, request parameters
and others. I'm using such a mapper approach successfully in our own
prototype crm framework.
--
Torgeir Veimo
torgeir@pobox.com
Re: [jira] Commented: (SLING-64) Refactor Servlets and Script resolution
Posted by Carsten Ziegeler <cz...@apache.org>.
Sorry for trying hard to be a pita :) but again, can we please let all
these discussions take place in the mailing list?
I think it's easy to first discuss a topic in the mailing list and then
create a jira which either sums up the discussion or references the
mailing list archives.
Carsten
Felix Meschberger (JIRA) wrote:
> [ https://issues.apache.org/jira/browse/SLING-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12535850 ]
>
> Felix Meschberger commented on SLING-64:
> ----------------------------------------
>
>> ... to use factories, or rather, mappers.
>
> Which is at the core of my proposal. Speaking in OSGi terms, Servlets are registered as OSGi services and specify in their service properties the resource type(s) they are willing and able to handle requests for. The Servlet Mapper looks at those registered servlets and selects one on behalf of Sling.
>
> And yes, I ultimately suggest dropping the SlingServlet interface including the canProcess method. Not because I do not like it per-se, but I think it will not scale - rotating to a possibly big number of servlets asking each in turn whether it may handle the request may prevent the system from working.
>
> But this proposal is just about modifying the general working : not looping through servlets but (1) look for servlets by resource type, (2) check for a script and (3) fall back to a defaul servlet. There will be another issue handling the first step in more detail.
>
>> Refactor Servlets and Script resolution
>> ---------------------------------------
>>
>> Key: SLING-64
>> URL: https://issues.apache.org/jira/browse/SLING-64
>> Project: Sling
>> Issue Type: Improvement
>> Components: microsling
>> Reporter: Felix Meschberger
>> Fix For: 2.0.0
>>
>> Attachments: SLING-64.patch
>>
>>
>> microsling currently defines a SlingServlet interface which has a canProcess method used to decide whether a servlet is capable of handling a request or not. I think, this mechanism will not scale well if we add more script engines or more servlets.
>> As a first step towards a simpler approach, I propose the following:
>> * Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
>> * Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
>> * Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
>> * Refactor MicroSlingServlet such, that
>> (1) check for a servlet by resource type
>> (2) try to evaluate a script
>> (3) fall back to the DefaultSlingServlet
>> * Also in the MicroSlingServlet register servlets by type (currently there are none of course)
>
--
Carsten Ziegeler
cziegeler@apache.org
[jira] Commented: (SLING-64) Refactor Servlets and Script
resolution
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12535850 ]
Felix Meschberger commented on SLING-64:
----------------------------------------
> ... to use factories, or rather, mappers.
Which is at the core of my proposal. Speaking in OSGi terms, Servlets are registered as OSGi services and specify in their service properties the resource type(s) they are willing and able to handle requests for. The Servlet Mapper looks at those registered servlets and selects one on behalf of Sling.
And yes, I ultimately suggest dropping the SlingServlet interface including the canProcess method. Not because I do not like it per-se, but I think it will not scale - rotating to a possibly big number of servlets asking each in turn whether it may handle the request may prevent the system from working.
But this proposal is just about modifying the general working : not looping through servlets but (1) look for servlets by resource type, (2) check for a script and (3) fall back to a defaul servlet. There will be another issue handling the first step in more detail.
> Refactor Servlets and Script resolution
> ---------------------------------------
>
> Key: SLING-64
> URL: https://issues.apache.org/jira/browse/SLING-64
> Project: Sling
> Issue Type: Improvement
> Components: microsling
> Reporter: Felix Meschberger
> Fix For: 2.0.0
>
> Attachments: SLING-64.patch
>
>
> microsling currently defines a SlingServlet interface which has a canProcess method used to decide whether a servlet is capable of handling a request or not. I think, this mechanism will not scale well if we add more script engines or more servlets.
> As a first step towards a simpler approach, I propose the following:
> * Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
> * Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
> * Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
> * Refactor MicroSlingServlet such, that
> (1) check for a servlet by resource type
> (2) try to evaluate a script
> (3) fall back to the DefaultSlingServlet
> * Also in the MicroSlingServlet register servlets by type (currently there are none of course)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (SLING-64) Refactor Servlets and Script
resolution
Posted by "Torgeir Veimo (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12535735 ]
Torgeir Veimo commented on SLING-64:
------------------------------------
How about abstracting this a bit, instead of relying on servlets to say themselves if they can handle a request, to use factories, or rather, mappers.
A manager would resolve a request to a sling servlet by iterating through its configured mappers and stopping once a suitable sling servlet is found. If no mapper resolves a servlet, the default sling servlet is called.
public interface ServletMapper {
public SlingServlet findServlet(SlingServletRequest request, Resource resource) throws Exception;
}
A configuration file would specify the order of the mappers, along with any configuration parameters each mapper needs. (A simple digester implementation would allow configuration parameters to be set using reflection.)
A default mapper which maps to servlets based on url and/or jcr node type or resource type can be provided which would be sufficient in most cases. For specific needs a sling api user would implement his own mapper.
Sitemesh uses a similar setup with great success for decorating web pages based on any combination of url patterns, request parameters and others. I'm using such a mapper approach successfully in our own prototype crm framework.
> Refactor Servlets and Script resolution
> ---------------------------------------
>
> Key: SLING-64
> URL: https://issues.apache.org/jira/browse/SLING-64
> Project: Sling
> Issue Type: Improvement
> Components: microsling
> Reporter: Felix Meschberger
> Fix For: 2.0.0
>
> Attachments: SLING-64.patch
>
>
> microsling currently defines a SlingServlet interface which has a canProcess method used to decide whether a servlet is capable of handling a request or not. I think, this mechanism will not scale well if we add more script engines or more servlets.
> As a first step towards a simpler approach, I propose the following:
> * Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
> * Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
> * Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
> * Refactor MicroSlingServlet such, that
> (1) check for a servlet by resource type
> (2) try to evaluate a script
> (3) fall back to the DefaultSlingServlet
> * Also in the MicroSlingServlet register servlets by type (currently there are none of course)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (SLING-64) Refactor Servlets and Script
resolution
Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SLING-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12535851 ]
Bertrand Delacretaz commented on SLING-64:
------------------------------------------
> * Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
> * Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
> * Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
> * Refactor MicroSlingServlet such, that
> (1) check for a servlet by resource type
> (2) try to evaluate a script
> (3) fall back to the DefaultSlingServlet
> * Also in the MicroSlingServlet register servlets by type (currently there are none of course)
I'm ok with all that, except maybe swapping 2) and 1), i.e. checking for a script first, and if there's none look for a servlet?
The rationale would be that servlets implement "standard" mechanisms which can be overridden by scripts.
But I'm not sure if that's the best way, we can probably go as you suggest and maybe change if there's a real need to.
> Refactor Servlets and Script resolution
> ---------------------------------------
>
> Key: SLING-64
> URL: https://issues.apache.org/jira/browse/SLING-64
> Project: Sling
> Issue Type: Improvement
> Components: microsling
> Reporter: Felix Meschberger
> Fix For: 2.0.0
>
> Attachments: SLING-64.patch
>
>
> microsling currently defines a SlingServlet interface which has a canProcess method used to decide whether a servlet is capable of handling a request or not. I think, this mechanism will not scale well if we add more script engines or more servlets.
> As a first step towards a simpler approach, I propose the following:
> * Merge the DefaultSlingServlet and the SlingPostServlet to a single DefaultSlingServlet
> * Replace Rhino and Velocity servlets by respective ScriptEngines (and define the interface for that)
> * Refactor the SlingScriptResolver such that after resolving the script, it is also evaluated through a ScriptEngine
> * Refactor MicroSlingServlet such, that
> (1) check for a servlet by resource type
> (2) try to evaluate a script
> (3) fall back to the DefaultSlingServlet
> * Also in the MicroSlingServlet register servlets by type (currently there are none of course)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.