Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » filter order(Is there a way to move to next filter if snap not found)
filter order [message #696857] Thu, 14 July 2011 20:55 Go to next message
David  is currently offline David
Messages: 6
Registered: July 2011
Junior Member
I was wondering if there was a way for the code to move to the next filter that matches the URLPattern if the snap name is not found. If not is there a way to say check this filter and if the URL Pattern doesn't match then move to this filter.

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 
    version="2.5">

  
    <filter>
    	<filter-name>host-filter</filter-name>
    	<filter-class>org.eclipse.virgo.snaps.core.SnapHostFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>host-filter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<context-param>
		<param-name>contextClass</param-name>
		<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
	</context-param>
	
	<!-- Handles all requests into the slice -->
	<servlet>
		<servlet-name>standard</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<load-on-startup>2</load-on-startup>
		<init-param>
			<param-name>contextClass</param-name>
			<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
		</init-param>
	</servlet>

	<servlet-mapping>
		<servlet-name>standard</servlet-name>
		<url-pattern>*.htm</url-pattern>
	</servlet-mapping>

	<filter>
		<filter-name>httpMethodFilter</filter-name>
		<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>httpMethodFilter</filter-name>
		<servlet-name>standard</servlet-name>
	</filter-mapping>
</web-app>


I want it to check the MethodFilter first. I don't mind if I put all methods in a /services subdir and then if the URL doesn't match /services then it checks the ssnaps.
Re: filter order [message #697025 is a reply to message #696857] Fri, 15 July 2011 06:40 Go to previous messageGo to next message
Chris Frost is currently offline Chris Frost
Messages: 227
Registered: January 2010
Location: Southampton, England
Senior Member

Hi,

Snaps is designed to work without affecting the normal flow of an application. So, the normal rules about filter ordering apply, they are given by the Servlet spec and are nothing to do with us. If the Snaps filter can't find a matching Snap then it simply does nothing and calls doFilter() on the filter chain to pass the request on. This means you have two choices and I'm not quite sure on your requirement so I'm not sure which is best.

1. Move the Snaps filter to come after the MethodFilter in your web.xml. This means the Method filter would get to look at requests firsts and the order of the Filter chain depends on the order in which they are defined in the web.xml

2. Put the Snaps filter under a sub-path so that only those requests will result in the Snaps filter going in the filter chain.

Hope that helps, please ask back if not


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: filter order [message #697038 is a reply to message #697025] Fri, 15 July 2011 07:28 Go to previous message
David  is currently offline David
Messages: 6
Registered: July 2011
Junior Member
Thank you,
My issue must be somewhere else then.
Previous Topic:New blog on Virgo and p2
Next Topic:Put yourself on the OSGi map
Goto Forum:
  


Current Time: Sun Apr 20 09:24:52 EDT 2014

Powered by FUDForum. Page generated in 0.03897 seconds