gzip compression [message #82893] |
Mon, 05 February 2007 16:50  |
Eclipse User |
|
|
|
Originally posted by: s0347354.sms.ed.ac.uk
Hey all,
I am trying to apply GZIP compression to certain mime types downloaded
from Jetty (running in the osgi http service).
I normally do this by adding a filter to my web.xml file....
e.g.
<filter>
<filter-name>2WayFilter</filter-name>
<filter-class>com.osmoticweb.gzipfilter.GZIP2WayFilter</filter-class >
</filter>
<filter-mapping>
<filter-name>2WayFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
What could I add to the plugin.xml to achieve the same effect? If it is
not as simple as just adding something to the plugin.xml, can someone
give me an example of how to do this programatically?
Thanks very much!
Will
|
|
|
Re: gzip compression [message #83313 is a reply to message #82893] |
Wed, 14 February 2007 14:06   |
Eclipse User |
|
|
|
Hi Will,
The OSGi HttpService does not currently support Filters and subsequently
either does http.registry ... at least directly.
For the moment here's what I'd suggest...
Take a look in equinox-incubator/org.eclipse.equinox.helper as the
FilterServletAdaptor might help.
The FilterServletAdaptor let's you wrap another Servlet with a Filter so
that all requests to that servlet are filtered.
If you're filtering "resources" you'll need to mix it with the
ResourceServlet.
--
Here's a quick example using where I've modified the sample.http.Activator:
Filter filter = new Filter() {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
System.out.println("Filtered");
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
}
};
httpService.registerServlet("/helloworld.html", new
FilterServletAdaptor(filter, null, new ResourceServlet("/helloworld.html")),
null, null);
--
If you want to use the FilterServletAdaptor along with the http.registry
extensions you could wrap all the logic in a single Servlet and then
delegate
e.g. something like ...
public MyServlet() {
this.delegate = new FilterServletAdaptor(filter, null, new
ResourceServlet("/helloworld.html"));
} ... and then delegate the other methods
however I'd instead suggest creating an IExecutableExtensionFactory to
manufacture the Servlet.
--
In terms of mapping, the obvious difference is that the filter is applied
per resource/servlet instead of by context scoped URL. An implementation
"could" introduce native Filtering at the URL level and still achieve good
component isolation however that would require new API. That might be worth
a look post 3.3.
HTH
-Simon
"Will Ryan" <s0347354@sms.ed.ac.uk> wrote in message
news:eq88r8$nru$1@utils.eclipse.org...
> Hey all,
>
> I am trying to apply GZIP compression to certain mime types downloaded
> from Jetty (running in the osgi http service).
>
> I normally do this by adding a filter to my web.xml file....
> e.g.
> <filter>
> <filter-name>2WayFilter</filter-name>
> <filter-class>com.osmoticweb.gzipfilter.GZIP2WayFilter</filter-class >
> </filter>
>
> <filter-mapping>
> <filter-name>2WayFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
>
> What could I add to the plugin.xml to achieve the same effect? If it is
> not as simple as just adding something to the plugin.xml, can someone give
> me an example of how to do this programatically?
>
> Thanks very much!
>
> Will
|
|
|
Re: gzip compression [message #83341 is a reply to message #83313] |
Thu, 15 February 2007 09:33  |
Eclipse User |
|
|
|
Originally posted by: s0347354.sms.ed.ac.uk
Cheers Simon for all your help. I'll give that a go.
Will
Simon Kaegi wrote:
> Hi Will,
>
> The OSGi HttpService does not currently support Filters and subsequently
> either does http.registry ... at least directly.
>
> For the moment here's what I'd suggest...
> Take a look in equinox-incubator/org.eclipse.equinox.helper as the
> FilterServletAdaptor might help.
> The FilterServletAdaptor let's you wrap another Servlet with a Filter so
> that all requests to that servlet are filtered.
> If you're filtering "resources" you'll need to mix it with the
> ResourceServlet.
> --
> Here's a quick example using where I've modified the sample.http.Activator:
> Filter filter = new Filter() {
> public void destroy() {
> }
> public void doFilter(ServletRequest request, ServletResponse response,
> FilterChain chain) throws IOException, ServletException {
> System.out.println("Filtered");
> chain.doFilter(request, response);
> }
> public void init(FilterConfig filterConfig) throws ServletException {
> }
> };
> httpService.registerServlet("/helloworld.html", new
> FilterServletAdaptor(filter, null, new ResourceServlet("/helloworld.html")),
> null, null);
> --
> If you want to use the FilterServletAdaptor along with the http.registry
> extensions you could wrap all the logic in a single Servlet and then
> delegate
> e.g. something like ...
> public MyServlet() {
> this.delegate = new FilterServletAdaptor(filter, null, new
> ResourceServlet("/helloworld.html"));
> } ... and then delegate the other methods
>
> however I'd instead suggest creating an IExecutableExtensionFactory to
> manufacture the Servlet.
> --
>
> In terms of mapping, the obvious difference is that the filter is applied
> per resource/servlet instead of by context scoped URL. An implementation
> "could" introduce native Filtering at the URL level and still achieve good
> component isolation however that would require new API. That might be worth
> a look post 3.3.
>
> HTH
> -Simon
>
> "Will Ryan" <s0347354@sms.ed.ac.uk> wrote in message
> news:eq88r8$nru$1@utils.eclipse.org...
>> Hey all,
>>
>> I am trying to apply GZIP compression to certain mime types downloaded
>> from Jetty (running in the osgi http service).
>>
>> I normally do this by adding a filter to my web.xml file....
>> e.g.
>> <filter>
>> <filter-name>2WayFilter</filter-name>
>> <filter-class>com.osmoticweb.gzipfilter.GZIP2WayFilter</filter-class >
>> </filter>
>>
>> <filter-mapping>
>> <filter-name>2WayFilter</filter-name>
>> <url-pattern>/*</url-pattern>
>> </filter-mapping>
>>
>>
>> What could I add to the plugin.xml to achieve the same effect? If it is
>> not as simple as just adding something to the plugin.xml, can someone give
>> me an example of how to do this programatically?
>>
>> Thanks very much!
>>
>> Will
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.20359 seconds