Return-Path: Delivered-To: apmail-struts-dev-archive@www.apache.org Received: (qmail 74509 invoked from network); 1 Mar 2009 09:44:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Mar 2009 09:44:43 -0000 Received: (qmail 29229 invoked by uid 500); 1 Mar 2009 09:44:37 -0000 Delivered-To: apmail-struts-dev-archive@struts.apache.org Received: (qmail 29196 invoked by uid 500); 1 Mar 2009 09:44:37 -0000 Mailing-List: contact dev-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list dev@struts.apache.org Received: (qmail 29185 invoked by uid 99); 1 Mar 2009 09:44:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Mar 2009 01:44:36 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [195.159.87.244] (HELO ns1.officenet.no) (195.159.87.244) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Mar 2009 09:44:28 +0000 Received: from [95.34.27.238] (helo=andreak-laptop.localnet) by ns1.officenet.no with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1LdiDG-0004PM-2Y for dev@struts.apache.org; Sun, 01 Mar 2009 10:44:06 +0100 From: Andreas Joseph Krogh Organization: OfficeNet AS To: "Struts Developers List" Subject: Re: Accessing properties set in struts.xml and/or struts.properties Date: Sun, 1 Mar 2009 10:43:47 +0100 User-Agent: KMail/1.11.0 (Linux/2.6.27-11-generic; KDE/4.2.0; i686; ; ) References: <200902252227.25591.andreak@officenet.no> <200902270910.15283.andreak@officenet.no> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200903011043.48340.andreak@officenet.no> X-Spam-Score: -4.3 X-Spam-Report: SpamAssasin (score=-4.3, required 5.0 ALL_TRUSTED=-1.8,AWL=-2.495,BAYES_50=0.001) X-Virus-Checked: Checked by ClamAV on apache.org On Sunday 01 March 2009 02:48:31 Jeromy Evans wrote: > Hi Andreas, >=20 > The perfect place to filter the URLs is before they reach the =20 > Container at all. > The next-best place is within a custom ActionMapper as Jelmer =20 > suggested as that's what it's designed for. I don't think you'll gain =20 > much performance filtering before the ActionMapper and it will confuse =20 > the architecture a little. >=20 > Modifying the default ActionMapper to accept a property that specifies =20 > an exclusion pattern may be a good idea. >=20 > The properties in struts.xml are available by dependency injection in =20 > objects created by Struts2, but the filter is too soon to use that =20 > feature. Instead you'll have to get a reference to the xwork =20 > Container and ask it for the property: >=20 > String pattern =3D =20 > configuration.getContainer().getInstance(String.class, =20 > "struts.action.url_exclude_pattern"); >=20 > The Configuration instance is available from the =20 > ConfigurationManager. The ConfigurationManager is created during the =20 > InitOperations once when the filter initializes. This is when the =20 > configuration is first read/provided (but it may be re-read/provided =20 > later). The ConfigurationManager is available from the Dispatcher, =20 > which is available in the PrepareOperations used by the =20 > StrutsPrepareFilter. >=20 > To access the configuration in your own version of the =20 > StrutsPrepareFilter, you'll have to replace the filter and =20 > PrepareOperations with a version that checks the URL and configuration =20 > before creating the ActionContext. >=20 > Configuration configuration =3D =20 > dispatcher.getConfigurationManager().getConfiguration(); >=20 > StrutsPrepareFilter will still need to chain to the next filter, so =20 > you'll also have to modify the StrutsExecuteFilter so it doesn't run =20 > but does chain to its next filter. Doesn't seem very elegant. >=20 > Hope that gets you started. This is what I've implemented here: https://issues.apache.org/struts/browse/WW-3017 If you look at the attachment "filters2.diff" (https://issues.apache.org/st= ruts/secure/attachment/13965/filters2.diff) you'll see what I've done. I did think about modifying the action-mapper or sub-classing it, but that = doesn't really cut it. The point is that I want to be able to configure thi= s *one* place regardless of which action-mapper I use. For example, if I wa= nt to use the Restful2ActionMapper I want the same exclusion-logic to apply= for it. I've implemented the check for exclusion *after* the action-context is crea= ted on purpose. The point is that I don't want Struts to try to auto-map an= action based on the excluded URI, and possibly fail, but I *do* want to be= able to use all the other goodies struts2 provides, like the s-tags etc. M= y patch implements just this and is very useful for me. Please take a look at the code and comment. =2D-=20 Andreas Joseph Krogh Senior Software Developer / CEO =2D-----------------------+---------------------------------------------+ OfficeNet AS | The most difficult thing in the world is to | Rosenholmveien 25 | know how to do a thing and to watch | 1414 Troll=E5sen | somebody else doing it wrong, without | NORWAY | comment. | | | Tlf: +47 24 15 38 90 | | =46ax: +47 24 15 38 91 | | Mobile: +47 909 56 963 | | =2D-----------------------+---------------------------------------------+ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For additional commands, e-mail: dev-help@struts.apache.org