struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: Accessing properties set in struts.xml and/or struts.properties
Date Sun, 01 Mar 2009 01:48:31 GMT
Hi Andreas,

The perfect place to filter the URLs is before they reach the  
Container at all.
The next-best place is within a custom ActionMapper as Jelmer  
suggested as that's what it's designed for.  I don't think you'll gain  
much performance filtering before the ActionMapper and it will confuse  
the architecture a little.

Modifying the default ActionMapper to accept a property that specifies  
an exclusion pattern may be a good idea.

The properties in struts.xml are available by dependency injection in  
objects created by Struts2, but the filter is too soon to use that  
feature.  Instead you'll have to get a reference to the xwork  
Container and ask it for the property:

  String pattern =  
configuration.getContainer().getInstance(String.class,  
"struts.action.url_exclude_pattern");

The Configuration instance is available from the  
ConfigurationManager.  The ConfigurationManager is created during the  
InitOperations once when the filter initializes.  This is when the  
configuration is first read/provided (but it may be re-read/provided  
later).  The ConfigurationManager is available from the Dispatcher,  
which is available in the PrepareOperations used by the  
StrutsPrepareFilter.

To access the configuration in your own version of the  
StrutsPrepareFilter, you'll have to replace the filter and  
PrepareOperations with a version that checks the URL and configuration  
before creating the ActionContext.

Configuration configuration =  
dispatcher.getConfigurationManager().getConfiguration();

StrutsPrepareFilter will still need to chain to the next filter, so  
you'll also have to modify the StrutsExecuteFilter so it doesn't run  
but does chain to its next filter.  Doesn't seem very elegant.

Hope that gets you started.
regards,
  Jeromy Evans


On 27/02/2009, at 7:10 PM, Andreas Joseph Krogh wrote:

> On Friday 27 February 2009 08:50:16 Jelmer Kuperus wrote:
>> I implemented something similarar while back by implementing a custom
>> actionmapper. You can then set that one as the default by changing a
>> property
>>
>> It allowed me to get the behaviour i wanted without changing any
>> struts code. I remember there being some gotchas tho.
>
> Yea, I was hoping to avoid having to maintain my own implementation  
> just for this feature so I'm hoping someone steps up and explains  
> how the struts2-code works with respect to accessing the config- 
> properties:-)
>
>> Personally i think exclusion would be a usefull feature
>
> Good:-)
>
> I see quite a lot of other improvements struts2 could benefit from,  
> especially the taglibs, and will post a list soon of things me and  
> my company would like to implement.
>
> -- 
> Andreas Joseph Krogh <andreak@officenet.no>
> Senior Software Developer / CEO
> ------------------------ 
> +---------------------------------------------+
> OfficeNet AS            | The most difficult thing in the world is  
> to |
> Rosenholmveien 25       | know how to do a thing and to  
> watch         |
> 1414 TrollÄsen          | somebody else doing it wrong,  
> without       |
> NORWAY                  |  
> comment.                                    |
>                        |                                             |
> Tlf:    +47 24 15 38 90  
> |                                             |
> Fax:    +47 24 15 38 91  
> |                                             |
> Mobile: +47 909  56 963  
> |                                             |
> ------------------------ 
> +---------------------------------------------+
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message