You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Musachy Barroso <mu...@gmail.com> on 2008/04/30 17:41:55 UTC

FilterDispatcher and static resources

I think FilterDispatcher should be changed to allow other
implementations to lookup static resources and be more flexible in
general. As it stands right now, static resources cannot be served
from plugins unless you put them in org.apache.struts2.static in a jar
 loaded by the filter's class loader (this is a problem for bundles
loaded with the OSGi plugin)

thoughts?

musachy

-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: FilterDispatcher and static resources

Posted by Musachy Barroso <mu...@gmail.com>.
Yes, like this:

 <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
 <init-param>
       <param-name>pathPrefixes</param-name>
       <param-value>/super_folder</param-value>
  </init-param>

musachy

On Thu, May 1, 2008 at 12:32 PM, Matt Raible <ma...@raibledesigns.com> wrote:
> Is it possible to configure the lookup folders?
>
>  Matt
>
>
>
>  On Thu, May 1, 2008 at 10:30 AM, Musachy Barroso <mu...@gmail.com> wrote:
>  >  As long as no mapping is found for that *.html, and it is inside one
>  >  of the lookup folders (like "static") it should work.
>  >
>  >  musachy
>  >
>  >
>  >
>  >  On Thu, May 1, 2008 at 12:24 PM, Matt Raible <mr...@gmail.com> wrote:
>  >  > We've had a fair amount of issues in the AppFuse project using *.html
>  >  >  as an extension. This is because some plugins and such use *.html
>  >  >  files and Struts attempts to serve them up as Actions rather than
>  >  >  plugins. Will this fix that problem? We've added a StaticFilter[1]
>  >  >  that attempts to fix it, but it doesn't seem to work very well. For
>  >  >  example, debug=console doesn't work with it[2].
>  >  >
>  >  >  Matt
>  >  >
>  >  >  [1] http://static.appfuse.org/appfuse-web/appfuse-web-common/xref/org/appfuse/webapp/filter/StaticFilter.html
>  >  >  [2] http://issues.appfuse.org/browse/APF-1042
>  >  >
>  >  >
>  >  >
>  >  >  On Thu, May 1, 2008 at 9:45 AM, Musachy Barroso <mu...@gmail.com> wrote:
>  >  >  > I'm ready to commit this, but I guess I will wait until Don cuts the
>  >  >  >  new build. This is how it works:
>  >  >  >
>  >  >  >  1. Static content lookup was refactored to DefaultStaticContentLoader
>  >  >  >  which implements StaticContentLoader.
>  >  >  >  2. DefaultStaticContentLoader  does everything FilterDipatcher did
>  >  >  >  before, but it also searches for resources inside a folder called
>  >  >  >  "static". So users don't have to call the folder "struts". New folders
>  >  >  >  can be added passing parameters to FilterDispatcher, like before, but
>  >  >  >  the urls have to starts with "/static" so we have some way to identify
>  >  >  >  them.
>  >  >  >  3. New extension point added "struts.staticContentLoader" to provide a
>  >  >  >  custom loader
>  >  >  >
>  >  >  >  So the 2 uses cases are:
>  >  >  >
>  >  >  >  1. User wants to add a new resource called "test.js" to her plugin.
>  >  >  >  She adds this file under "/static/test.js" and builds the url like:
>  >  >  >     <s:url value="/static/test.js" ..>
>  >  >  >
>  >  >  >  2. User wants to add a new resource called "test.js" to her plugin
>  >  >  >  under folder "/super_folder/test.js". She adds a parameter to the
>  >  >  >  filter:
>  >  >  >   <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>  >  >  >   <init-param>
>  >  >  >        <param-name>pathPrefixes</param-name>
>  >  >  >        <param-value>/super_folder</param-value>
>  >  >  >   </init-param>
>  >  >  >
>  >  >  >   and builds the url like:
>  >  >  >   <s:url value="/static/test.js" ..>
>  >  >  >
>  >  >  >
>  >  >  >  musachy
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >  On Wed, Apr 30, 2008 at 10:35 PM, Jeromy Evans
>  >  >  >  <je...@blueskyminds.com.au> wrote:
>  >  >  >  > Musachy Barroso wrote:
>  >  >  >  >
>  >  >  >  > > I am refactoring that out of FilterDispatcher so it becomes another
>  >  >  >  > > extension point.
>  >  >  >  > >
>  >  >  >  > > musachy
>  >  >  >  > >
>  >  >  >  > >
>  >  >  >  > >
>  >  >  >  >  +1
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >  ---------------------------------------------------------------------
>  >  >  >  >  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  >  >  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >  >  >  >
>  >  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  > --
>  >  >  >  "Hey you! Would you help me to carry the stone?" Pink Floyd
>  >  >  >
>  >  >  >  ---------------------------------------------------------------------
>  >  >  >
>  >  >  >
>  >  >  > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  >  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >  >  >
>  >  >  >
>  >  >
>  >  >
>  >  >
>  >  >  --
>  >  >  http://raibledesigns.com
>  >  >
>  >  >
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >  >
>  >  >
>  >
>  >
>  >
>  >  --
>  >  "Hey you! Would you help me to carry the stone?" Pink Floyd
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >
>  >
>
>
>
>  --
>  http://raibledesigns.com
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: FilterDispatcher and static resources

Posted by Matt Raible <ma...@raibledesigns.com>.
Is it possible to configure the lookup folders?

Matt

On Thu, May 1, 2008 at 10:30 AM, Musachy Barroso <mu...@gmail.com> wrote:
>  As long as no mapping is found for that *.html, and it is inside one
>  of the lookup folders (like "static") it should work.
>
>  musachy
>
>
>
>  On Thu, May 1, 2008 at 12:24 PM, Matt Raible <mr...@gmail.com> wrote:
>  > We've had a fair amount of issues in the AppFuse project using *.html
>  >  as an extension. This is because some plugins and such use *.html
>  >  files and Struts attempts to serve them up as Actions rather than
>  >  plugins. Will this fix that problem? We've added a StaticFilter[1]
>  >  that attempts to fix it, but it doesn't seem to work very well. For
>  >  example, debug=console doesn't work with it[2].
>  >
>  >  Matt
>  >
>  >  [1] http://static.appfuse.org/appfuse-web/appfuse-web-common/xref/org/appfuse/webapp/filter/StaticFilter.html
>  >  [2] http://issues.appfuse.org/browse/APF-1042
>  >
>  >
>  >
>  >  On Thu, May 1, 2008 at 9:45 AM, Musachy Barroso <mu...@gmail.com> wrote:
>  >  > I'm ready to commit this, but I guess I will wait until Don cuts the
>  >  >  new build. This is how it works:
>  >  >
>  >  >  1. Static content lookup was refactored to DefaultStaticContentLoader
>  >  >  which implements StaticContentLoader.
>  >  >  2. DefaultStaticContentLoader  does everything FilterDipatcher did
>  >  >  before, but it also searches for resources inside a folder called
>  >  >  "static". So users don't have to call the folder "struts". New folders
>  >  >  can be added passing parameters to FilterDispatcher, like before, but
>  >  >  the urls have to starts with "/static" so we have some way to identify
>  >  >  them.
>  >  >  3. New extension point added "struts.staticContentLoader" to provide a
>  >  >  custom loader
>  >  >
>  >  >  So the 2 uses cases are:
>  >  >
>  >  >  1. User wants to add a new resource called "test.js" to her plugin.
>  >  >  She adds this file under "/static/test.js" and builds the url like:
>  >  >     <s:url value="/static/test.js" ..>
>  >  >
>  >  >  2. User wants to add a new resource called "test.js" to her plugin
>  >  >  under folder "/super_folder/test.js". She adds a parameter to the
>  >  >  filter:
>  >  >   <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>  >  >   <init-param>
>  >  >        <param-name>pathPrefixes</param-name>
>  >  >        <param-value>/super_folder</param-value>
>  >  >   </init-param>
>  >  >
>  >  >   and builds the url like:
>  >  >   <s:url value="/static/test.js" ..>
>  >  >
>  >  >
>  >  >  musachy
>  >  >
>  >  >
>  >  >
>  >  >
>  >  >  On Wed, Apr 30, 2008 at 10:35 PM, Jeromy Evans
>  >  >  <je...@blueskyminds.com.au> wrote:
>  >  >  > Musachy Barroso wrote:
>  >  >  >
>  >  >  > > I am refactoring that out of FilterDispatcher so it becomes another
>  >  >  > > extension point.
>  >  >  > >
>  >  >  > > musachy
>  >  >  > >
>  >  >  > >
>  >  >  > >
>  >  >  >  +1
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >
>  >  >  >  ---------------------------------------------------------------------
>  >  >  >  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  >  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >  >  >
>  >  >  >
>  >  >
>  >  >
>  >  >
>  >  >
>  >  > --
>  >  >  "Hey you! Would you help me to carry the stone?" Pink Floyd
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >
>  >  >
>  >  > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >  >
>  >  >
>  >
>  >
>  >
>  >  --
>  >  http://raibledesigns.com
>  >
>  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >
>  >
>
>
>
>  --
>  "Hey you! Would you help me to carry the stone?" Pink Floyd
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
http://raibledesigns.com

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


Re: FilterDispatcher and static resources

Posted by Musachy Barroso <mu...@gmail.com>.
 As long as no mapping is found for that *.html, and it is inside one
of the lookup folders (like "static") it should work.

musachy

On Thu, May 1, 2008 at 12:24 PM, Matt Raible <mr...@gmail.com> wrote:
> We've had a fair amount of issues in the AppFuse project using *.html
>  as an extension. This is because some plugins and such use *.html
>  files and Struts attempts to serve them up as Actions rather than
>  plugins. Will this fix that problem? We've added a StaticFilter[1]
>  that attempts to fix it, but it doesn't seem to work very well. For
>  example, debug=console doesn't work with it[2].
>
>  Matt
>
>  [1] http://static.appfuse.org/appfuse-web/appfuse-web-common/xref/org/appfuse/webapp/filter/StaticFilter.html
>  [2] http://issues.appfuse.org/browse/APF-1042
>
>
>
>  On Thu, May 1, 2008 at 9:45 AM, Musachy Barroso <mu...@gmail.com> wrote:
>  > I'm ready to commit this, but I guess I will wait until Don cuts the
>  >  new build. This is how it works:
>  >
>  >  1. Static content lookup was refactored to DefaultStaticContentLoader
>  >  which implements StaticContentLoader.
>  >  2. DefaultStaticContentLoader  does everything FilterDipatcher did
>  >  before, but it also searches for resources inside a folder called
>  >  "static". So users don't have to call the folder "struts". New folders
>  >  can be added passing parameters to FilterDispatcher, like before, but
>  >  the urls have to starts with "/static" so we have some way to identify
>  >  them.
>  >  3. New extension point added "struts.staticContentLoader" to provide a
>  >  custom loader
>  >
>  >  So the 2 uses cases are:
>  >
>  >  1. User wants to add a new resource called "test.js" to her plugin.
>  >  She adds this file under "/static/test.js" and builds the url like:
>  >     <s:url value="/static/test.js" ..>
>  >
>  >  2. User wants to add a new resource called "test.js" to her plugin
>  >  under folder "/super_folder/test.js". She adds a parameter to the
>  >  filter:
>  >   <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>  >   <init-param>
>  >        <param-name>pathPrefixes</param-name>
>  >        <param-value>/super_folder</param-value>
>  >   </init-param>
>  >
>  >   and builds the url like:
>  >   <s:url value="/static/test.js" ..>
>  >
>  >
>  >  musachy
>  >
>  >
>  >
>  >
>  >  On Wed, Apr 30, 2008 at 10:35 PM, Jeromy Evans
>  >  <je...@blueskyminds.com.au> wrote:
>  >  > Musachy Barroso wrote:
>  >  >
>  >  > > I am refactoring that out of FilterDispatcher so it becomes another
>  >  > > extension point.
>  >  > >
>  >  > > musachy
>  >  > >
>  >  > >
>  >  > >
>  >  >  +1
>  >  >
>  >  >
>  >  >
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >  >
>  >  >
>  >
>  >
>  >
>  >
>  > --
>  >  "Hey you! Would you help me to carry the stone?" Pink Floyd
>  >
>  >  ---------------------------------------------------------------------
>  >
>  >
>  > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >
>  >
>
>
>
>  --
>  http://raibledesigns.com
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: FilterDispatcher and static resources

Posted by Matt Raible <mr...@gmail.com>.
We've had a fair amount of issues in the AppFuse project using *.html
as an extension. This is because some plugins and such use *.html
files and Struts attempts to serve them up as Actions rather than
plugins. Will this fix that problem? We've added a StaticFilter[1]
that attempts to fix it, but it doesn't seem to work very well. For
example, debug=console doesn't work with it[2].

Matt

[1] http://static.appfuse.org/appfuse-web/appfuse-web-common/xref/org/appfuse/webapp/filter/StaticFilter.html
[2] http://issues.appfuse.org/browse/APF-1042

On Thu, May 1, 2008 at 9:45 AM, Musachy Barroso <mu...@gmail.com> wrote:
> I'm ready to commit this, but I guess I will wait until Don cuts the
>  new build. This is how it works:
>
>  1. Static content lookup was refactored to DefaultStaticContentLoader
>  which implements StaticContentLoader.
>  2. DefaultStaticContentLoader  does everything FilterDipatcher did
>  before, but it also searches for resources inside a folder called
>  "static". So users don't have to call the folder "struts". New folders
>  can be added passing parameters to FilterDispatcher, like before, but
>  the urls have to starts with "/static" so we have some way to identify
>  them.
>  3. New extension point added "struts.staticContentLoader" to provide a
>  custom loader
>
>  So the 2 uses cases are:
>
>  1. User wants to add a new resource called "test.js" to her plugin.
>  She adds this file under "/static/test.js" and builds the url like:
>     <s:url value="/static/test.js" ..>
>
>  2. User wants to add a new resource called "test.js" to her plugin
>  under folder "/super_folder/test.js". She adds a parameter to the
>  filter:
>   <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>   <init-param>
>        <param-name>pathPrefixes</param-name>
>        <param-value>/super_folder</param-value>
>   </init-param>
>
>   and builds the url like:
>   <s:url value="/static/test.js" ..>
>
>
>  musachy
>
>
>
>
>  On Wed, Apr 30, 2008 at 10:35 PM, Jeromy Evans
>  <je...@blueskyminds.com.au> wrote:
>  > Musachy Barroso wrote:
>  >
>  > > I am refactoring that out of FilterDispatcher so it becomes another
>  > > extension point.
>  > >
>  > > musachy
>  > >
>  > >
>  > >
>  >  +1
>  >
>  >
>  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  >  For additional commands, e-mail: dev-help@struts.apache.org
>  >
>  >
>
>
>
>
> --
>  "Hey you! Would you help me to carry the stone?" Pink Floyd
>
>  ---------------------------------------------------------------------
>
>
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
http://raibledesigns.com

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


Re: FilterDispatcher and static resources

Posted by Musachy Barroso <mu...@gmail.com>.
I'm ready to commit this, but I guess I will wait until Don cuts the
new build. This is how it works:

1. Static content lookup was refactored to DefaultStaticContentLoader
which implements StaticContentLoader.
2. DefaultStaticContentLoader  does everything FilterDipatcher did
before, but it also searches for resources inside a folder called
"static". So users don't have to call the folder "struts". New folders
can be added passing parameters to FilterDispatcher, like before, but
the urls have to starts with "/static" so we have some way to identify
them.
3. New extension point added "struts.staticContentLoader" to provide a
custom loader

So the 2 uses cases are:

1. User wants to add a new resource called "test.js" to her plugin.
She adds this file under "/static/test.js" and builds the url like:
    <s:url value="/static/test.js" ..>

2. User wants to add a new resource called "test.js" to her plugin
under folder "/super_folder/test.js". She adds a parameter to the
filter:
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  <init-param>
       <param-name>pathPrefixes</param-name>
       <param-value>/super_folder</param-value>
  </init-param>

  and builds the url like:
  <s:url value="/static/test.js" ..>


musachy


On Wed, Apr 30, 2008 at 10:35 PM, Jeromy Evans
<je...@blueskyminds.com.au> wrote:
> Musachy Barroso wrote:
>
> > I am refactoring that out of FilterDispatcher so it becomes another
> > extension point.
> >
> > musachy
> >
> >
> >
>  +1
>
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: FilterDispatcher and static resources

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Musachy Barroso wrote:
> I am refactoring that out of FilterDispatcher so it becomes another
> extension point.
>
> musachy
>
>   
+1


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


Re: FilterDispatcher and static resources

Posted by Musachy Barroso <mu...@gmail.com>.
I am refactoring that out of FilterDispatcher so it becomes another
extension point.

musachy

On Wed, Apr 30, 2008 at 4:31 PM, Brian Pontarelli <br...@pontarelli.com> wrote:
> Musachy Barroso wrote:
>
> > I think FilterDispatcher should be changed to allow other
> > implementations to lookup static resources and be more flexible in
> > general. As it stands right now, static resources cannot be served
> > from plugins unless you put them in org.apache.struts2.static in a jar
> >  loaded by the filter's class loader (this is a problem for bundles
> > loaded with the OSGi plugin)
> >
> > thoughts?
> >
> >
>
>  Yeah, JCatapult actually has its own static resource handler because of
> this. Should be made pluggable and generic.
>
>  -bp
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: FilterDispatcher and static resources

Posted by Brian Pontarelli <br...@pontarelli.com>.
Musachy Barroso wrote:
> I think FilterDispatcher should be changed to allow other
> implementations to lookup static resources and be more flexible in
> general. As it stands right now, static resources cannot be served
> from plugins unless you put them in org.apache.struts2.static in a jar
>  loaded by the filter's class loader (this is a problem for bundles
> loaded with the OSGi plugin)
>
> thoughts?
>   

Yeah, JCatapult actually has its own static resource handler because of 
this. Should be made pluggable and generic.

-bp


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