I have attached the patch I use. With this patch, I can use the GzipHandler
with this configuration :
<!-- GZIP -->
<Get id="OldHandler" name="handler"/>
<Set name="handler">
<New id="GzipHandler" class=
"org.eclipse.jetty.server.handler.gzip.GzipHandler">
<Set name="handler">
<Ref id="OldHandler"/>
</Set>
</New>
</Set>
Le mercredi 16 janvier 2019 15:39:49 UTC+1, Jérémie Brébec a écrit :
>
> I don't know if it's an issue in paxweb or just a configuration difficult
> to write.
>
> I want to activate a GzipHandler in order to gzip contents served by my
> servlets. The old Jetty GzipFilter is deprecated and do nothing.
>
> This Handler is a HandlerWrapper, it hooks the handler chain in order to
> provider a wrapped response (which do the gzip encoding). I am not able to
> configure such handlers in the jetty.xml (PaxWeb-Jetty assumes at several
> location that the first handler is the JettyServerHandlerCollection and I
> can't replace it with the GzipHandler or any other HandlerWrapper without
> issues/exceptions).
>
> I have a working solution, but it necessites some change in the codebase.
> However, I suppose I am not the only one who want to use gzip and paxweb,
> so I don't know if I am missing something :-)
>
> Le mercredi 16 janvier 2019 14:52:56 UTC+1, Grzegorz Grzybek a écrit :
>>
>> Hello
>>
>> There are 40 unresolved issues in
>> https://ops4j1.jira.com/projects/PAXWEB/summary/statistics - I didn't
>> see any about gzip.
>> Could you refresh my memory? :)
>>
>> regards
>> Grzegorz Grzybek
>>
>> śr., 16 sty 2019 o 14:31 Jean-Baptiste Onofré <[email protected]>
>> napisał(a):
>>
>>> Not with recent 7.2.x version.
>>>
>>> I think it deserves a unit test ;)
>>>
>>> Regards
>>> JB
>>> On 16/01/2019 14:20, Jérémie Brébec wrote:
>>>
>>> Hello,
>>>
>>> I reopen this old thread, but has anyone a working example of a
>>> GzipHandler with PaxWeb (7.2.5) ?
>>>
>>> Thanks !
>>>
>>> Le mercredi 30 août 2017 06:20:23 UTC+2, Achim Nierbeck a écrit :
>>>>
>>>> Hi,
>>>>
>>>> if this is an issue for you please file a bug in our Jira.
>>>>
>>>> Thanks, Achim
>>>>
>>>> 2017-08-10 7:44 GMT+02:00 Eric Lessard <[email protected]>:
>>>>
>>>>> Any update on this or work around available? We're running into a
>>>>> similar problem and are looking at options to compress our static content.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> --
>>>>> --
>>>>> ------------------
>>>>> OPS4J - http://www.ops4j.org - [email protected]
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "OPS4J" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Apache Member
>>>> Apache Karaf <http://karaf.apache.org/> Committer & PMC
>>>> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
>>>> Committer & Project Lead
>>>> blog <http://notizblog.nierbeck.de/>
>>>> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>>>>
>>>> Software Architect / Project Manager / Scrum Master
>>>>
>>>> --
>>> --
>>> ------------------
>>> OPS4J - http://www.ops4j.org - [email protected]
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "OPS4J" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> --
>>> ------------------
>>> OPS4J - http://www.ops4j.org - [email protected]
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "OPS4J" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerImpl.java b/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerImpl.java
index 9ee91b7..40cba66 100644
--- a/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerImpl.java
+++ b/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerImpl.java
@@ -274,7 +274,7 @@
@Override
public void addHandler(Handler handler) {
- HandlerCollection handlerCollection = (HandlerCollection) server.getHandler();
+ HandlerCollection handlerCollection = server.getRootHandlerCollection();
handlerCollection.addHandler(handler);
if (priorityComparator != null) {
Handler[] handlers = handlerCollection.getHandlers();
@@ -286,12 +286,12 @@
@Override
public Handler[] getHandlers() {
- return ((HandlerCollection) server.getHandler()).getHandlers();
+ return server.getRootHandlerCollection().getHandlers();
}
@Override
public void removeHandler(Handler handler) {
- ((HandlerCollection) server.getHandler()).removeHandler(handler);
+ server.getRootHandlerCollection().removeHandler(handler);
}
@Override
@@ -918,7 +918,7 @@
requestLog.setLogServer(configureRequestParameters.logServer);
requestLogHandler.setRequestLog(requestLog);
- ((HandlerCollection) server.getHandler()).addHandler(requestLogHandler);
+ server.getRootHandlerCollection().addHandler(requestLogHandler);
}
@Override
diff --git a/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerWrapper.java b/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerWrapper.java
index c096784..ef6cce5 100644
--- a/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerWrapper.java
+++ b/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/JettyServerWrapper.java
@@ -133,10 +133,14 @@
private Bundle jettyBundle;
private ServiceTracker<PackageAdmin, PackageAdmin> packageAdminTracker;
+ private HandlerCollection rootCollections;
+
JettyServerWrapper(ServerModel serverModel, ThreadPool threadPool) {
super(threadPool);
this.serverModel = serverModel;
- setHandler(new JettyServerHandlerCollection(serverModel));
+
+ rootCollections = new JettyServerHandlerCollection(serverModel);
+ setHandler(rootCollections);
jettyBundle = FrameworkUtil.getBundle(getClass());
@@ -154,6 +158,10 @@
}
}
+
+ public HandlerCollection getRootHandlerCollection() {
+ return rootCollections;
+ }
public void configureContext(final Map<String, Object> attributes, final Integer timeout, final String cookie,
final String domain, final String path, final String url, final Boolean cookieHttpOnly,
@@ -264,7 +272,7 @@
sch.getSecurityHandler().setServer(null);
sch.getSessionHandler().setServer(null);
sch.getErrorHandler().setServer(null);
- ((HandlerCollection) getHandler()).removeHandler(sch);
+ rootCollections.removeHandler(sch);
sch.destroy();
}
}
@@ -284,7 +292,7 @@
scanner.scanBundles(containerInitializers);
}
- HttpServiceContext context = new HttpServiceContext((HandlerContainer) getHandler(), model.getContextParams(),
+ HttpServiceContext context = new HttpServiceContext(rootCollections, model.getContextParams(),
getContextAttributes(bundleContext), model.getContextName(), model.getHttpContext(),
model.getAccessControllerContext(), model.getContainerInitializers(), model.getJettyWebXmlURL(),
model.getVirtualHosts());