|
I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between.
I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: Main controller.xml <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. Any thoughts? Thanks Scott HotWax Media http://www.hotwaxmedia.com |
|
how about putting a tag on the pre-processor
then include the tag in the URi spec when the URI is accessed it uses the pre-processor in the tag. doubt either way would make much difference at controller reload IO. ========================= BJ Freeman Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=52> Specialtymarket.com <http://www.specialtymarket.com/> Systems Integrator-- Glad to Assist Chat Y! messenger: bjfr33man Scott Gray sent the following on 2/15/2011 2:40 PM: > I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. > > I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: > Main controller.xml > <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> > now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. > > Any thoughts? > > Thanks > Scott > > HotWax Media > http://www.hotwaxmedia.com > |
|
Hi BJ,
That could get pretty complicated (chained requests for example would make this difficult) and you'd still need to tag every request that requires a certain event to be run which would be a pain. Also preprocessor events are intended to be run on every request so I'm not sure how you'd maintain that behavior properly while enabling what you're suggesting. Thanks Scott On 16/02/2011, at 12:54 PM, BJ Freeman wrote: > how about putting a tag on the pre-processor > then include the tag in the URi spec > when the URI is accessed it uses the pre-processor in the tag. > doubt either way would make much difference at controller reload IO. > > > ========================= > BJ Freeman > Strategic Power Office with Supplier Automation <http://www.businessesnetwork.com/automation/viewforum.php?f=52> > Specialtymarket.com <http://www.specialtymarket.com/> > Systems Integrator-- Glad to Assist > > Chat Y! messenger: bjfr33man > > > Scott Gray sent the following on 2/15/2011 2:40 PM: >> I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. >> >> I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: >> Main controller.xml >> <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> >> now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. >> >> Any thoughts? >> >> Thanks >> Scott >> >> HotWax Media >> http://www.hotwaxmedia.com >> > |
|
the one thing i did not consider was behavior of chained requests,
however if what you says is true then that is mute. the current pre-process would be tagged default and the URI tag would be default which is the same thing you describe is the current behavior only the code that deals with this has to be modified. once the code is changed to handle this then adding a new preprocessor with its own tag would not effect the chained requests, unless I am still missing something. this could also allow for more than one preprocess per URI. Scott Gray sent the following on 2/15/2011 8:04 PM: > Hi BJ, > > That could get pretty complicated (chained requests for example would make this difficult) and you'd still need to tag every request that requires a certain event to be run which would be a pain. Also preprocessor events are intended to be run on every request so I'm not sure how you'd maintain that behavior properly while enabling what you're suggesting. > > Thanks > Scott > > On 16/02/2011, at 12:54 PM, BJ Freeman wrote: > >> how about putting a tag on the pre-processor >> then include the tag in the URi spec >> when the URI is accessed it uses the pre-processor in the tag. >> doubt either way would make much difference at controller reload IO. >> >> >> ========================= >> BJ Freeman >> Strategic Power Office with Supplier Automation<http://www.businessesnetwork.com/automation/viewforum.php?f=52> >> Specialtymarket.com<http://www.specialtymarket.com/> >> Systems Integrator-- Glad to Assist >> >> Chat Y! messenger: bjfr33man >> >> >> Scott Gray sent the following on 2/15/2011 2:40 PM: >>> I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. >>> >>> I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: >>> Main controller.xml >>> <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> >>> now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. >>> >>> Any thoughts? >>> >>> Thanks >>> Scott >>> >>> HotWax Media >>> http://www.hotwaxmedia.com >>> >> > |
|
In reply to this post by Scott Gray-2
Why not add the path attribute to the existing <include> element?
-Adrian On 2/15/2011 2:40 PM, Scott Gray wrote: > I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. > > I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: > Main controller.xml > <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> > now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. > > Any thoughts? > > Thanks > Scott > > HotWax Media > http://www.hotwaxmedia.com > |
|
That could be done I suppose, as long as we don't think there's much room for confusion since the two behaviors would be pretty different (include vs substitute).
Regards Scott On 16/02/2011, at 6:05 PM, Adrian Crum <[hidden email]> wrote: > Why not add the path attribute to the existing <include> element? > > -Adrian > > On 2/15/2011 2:40 PM, Scott Gray wrote: >> I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. >> >> I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: >> Main controller.xml >> <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> >> now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. >> >> Any thoughts? >> >> Thanks >> Scott >> >> HotWax Media >> http://www.hotwaxmedia.com >> |
|
From my perspective, having a new element that does basically the same
thing as an existing element is confusing. The only tricky part will be assigning the preprocessor to the correct set of requests in Java. In other words, scoping each preprocessor to a set of requests. From what I recall, the preprocessor element overwrites any included preprocessor elements. -Adrian On 2/15/2011 9:57 PM, Scott Gray wrote: > That could be done I suppose, as long as we don't think there's much room for confusion since the two behaviors would be pretty different (include vs substitute). > > Regards > Scott > > On 16/02/2011, at 6:05 PM, Adrian Crum<[hidden email]> wrote: > >> Why not add the path attribute to the existing<include> element? >> >> -Adrian >> >> On 2/15/2011 2:40 PM, Scott Gray wrote: >>> I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. >>> >>> I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: >>> Main controller.xml >>> <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> >>> now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. >>> >>> Any thoughts? >>> >>> Thanks >>> Scott >>> >>> HotWax Media >>> http://www.hotwaxmedia.com >>> |
|
In my PoC implementation the sub-controller completely replaces the default ControllerConfig object during the doRequest execution so scoping isn't an issue. Basically at the very start of the doRequest method I break up the path info and then try to map the first portion to sub-controller (and then deeper if possible), once done the sub-controller gets assigned to the existing controllerConfig local variable and the request handler deals with it the same way it does now (check https, login, pre-events, request-map, post-events).
It's essentially a completely separate controller for that portion of the webapp. Regards Scott On 16/02/2011, at 7:07 PM, Adrian Crum wrote: > From my perspective, having a new element that does basically the same thing as an existing element is confusing. > > The only tricky part will be assigning the preprocessor to the correct set of requests in Java. In other words, scoping each preprocessor to a set of requests. From what I recall, the preprocessor element overwrites any included preprocessor elements. > > -Adrian > > On 2/15/2011 9:57 PM, Scott Gray wrote: >> That could be done I suppose, as long as we don't think there's much room for confusion since the two behaviors would be pretty different (include vs substitute). >> >> Regards >> Scott >> >> On 16/02/2011, at 6:05 PM, Adrian Crum<[hidden email]> wrote: >> >>> Why not add the path attribute to the existing<include> element? >>> >>> -Adrian >>> >>> On 2/15/2011 2:40 PM, Scott Gray wrote: >>>> I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. >>>> >>>> I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: >>>> Main controller.xml >>>> <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> >>>> now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. >>>> >>>> Any thoughts? >>>> >>>> Thanks >>>> Scott >>>> >>>> HotWax Media >>>> http://www.hotwaxmedia.com >>>> |
|
In reply to this post by Scott Gray-2
This is interesting, thanks Scott.
Maybe another option could be that of adding a "condition" attribute to the pre-processor element (like path="sub"). Jacopo On Feb 15, 2011, at 11:40 PM, Scott Gray wrote: > I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. > > I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: > Main controller.xml > <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> > now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. > > Any thoughts? > > Thanks > Scott > > HotWax Media > http://www.hotwaxmedia.com > |
|
Hi Jacopo,
In theory we could do that but I think it might be problematic because a developer could very easily (and unknowingly) exclude the path from any links/form targets and bypass the preprocessor. If the request uri itself is contained within a separate and distinct controller file then they could not make this mistake, they'd either get a 404 type error or they'd hit the wrong request mapping in the main controller. A possible use case for this feature could be the facility application, the screens for dealing with a single facility could be broken out into a separate sub-controller, you'd add a preprocessor that checks for a facilityId and if not present then redirects to the facility find screen. By doing this you'd never have to worry about a missing facilityId within the screens themselves. We could possibly even take it further and have sub-sessions/scopes for these types of screen groups (something like a MapStack overlaying the real session) and set the facilityId in there without it ever being carried outside of that group. Regards Scott On 16/02/2011, at 10:30 PM, Jacopo Cappellato wrote: > This is interesting, thanks Scott. > > Maybe another option could be that of adding a "condition" attribute to the pre-processor element (like path="sub"). > > Jacopo > > On Feb 15, 2011, at 11:40 PM, Scott Gray wrote: > >> I regularly run into a situation where I need a pre-processor event to run only for a sub-set of a webapp's requests, usually within a particular group of screens (an example might be that you want to check that a specific session attribute or request parameter is set before allowing access to that set of requests). Currently you can only run an event for either a single request (request-map.event) or for every request (preprocessor.event) within a webapp, there isn't really any in-between. >> >> I threw together a quick PoC this morning for a sub-controller implementation that would allow a webapp to have multiple controllers. Basically you have your regular controller at /control/ but within the controller.xml you can define sub-controllers and the path that it should use: >> Main controller.xml >> <sub-controller location="component://example/webapp/example/WEB-INF/sub-controller.xml" path="sub"/> >> now every request to /control/sub/* will use the sub-controller.xml instead of the main controller and is handled in exactly the same way as the main controller would be. >> >> Any thoughts? >> >> Thanks >> Scott >> >> HotWax Media >> http://www.hotwaxmedia.com >> > |
| Free forum by Nabble | Edit this page |
