WICKET-6194 Add Tomcat 8.5+ implementation of PushBuilder

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/6e184f3f
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/6e184f3f
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/6e184f3f

Branch: refs/heads/master
Commit: 6e184f3f298e1f21c62d188d423b8a00b29e9850
Parents: cc6357d
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Sat Jul 2 14:15:00 2016 +0200
Committer: Tobias Soloschenko <[email protected]>
Committed: Sat Jul 9 06:30:39 2016 +0200

----------------------------------------------------------------------
 wicket-experimental/wicket-http2/pom.xml        |  1 +
 .../wicket-http2/wicket-http2-tomcat/pom.xml    | 48 ++++++++++++++++++++
 .../org/apache/wicket/http2/Initializer.java    | 39 ++++++++++++++++
 .../http2/markup/head/Tomcat85PushBuilder.java  | 42 +++++++++++++++++
 .../services/org.apache.wicket.IInitializer     |  1 +
 5 files changed, 131 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/6e184f3f/wicket-experimental/wicket-http2/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-http2/pom.xml 
b/wicket-experimental/wicket-http2/pom.xml
index d7b554e..9f7f7fb 100644
--- a/wicket-experimental/wicket-http2/pom.xml
+++ b/wicket-experimental/wicket-http2/pom.xml
@@ -34,5 +34,6 @@
        <modules>
                <module>wicket-http2-core</module>
                <module>wicket-http2-jetty</module>
+               <module>wicket-http2-tomcat</module>
        </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/wicket/blob/6e184f3f/wicket-experimental/wicket-http2/wicket-http2-tomcat/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-http2/wicket-http2-tomcat/pom.xml 
b/wicket-experimental/wicket-http2/wicket-http2-tomcat/pom.xml
new file mode 100644
index 0000000..658c73f
--- /dev/null
+++ b/wicket-experimental/wicket-http2/wicket-http2-tomcat/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.apache.wicket.experimental.wicket8</groupId>
+               <artifactId>wicket-http2</artifactId>
+               <version>0.1-SNAPSHOT</version>
+               <relativePath>../pom.xml</relativePath>
+       </parent>
+       <artifactId>wicket-http2-tomcat</artifactId>
+       <packaging>jar</packaging>
+       <name>Wicket Http/2 Tomcat 8.5+</name>
+       <description>
+               Wicket’s implementation to use the PushBuilder API
+               to serve resource via http/2 with less requests. This
+               is the Apache Tomcat 8.5+ implementation to resolve the 
PushBuilder API and
+               provide the IInitializer.
+       </description>
+       <dependencies>
+               <dependency>
+                       
<groupId>org.apache.wicket.experimental.wicket8</groupId>
+                       <artifactId>wicket-http2-core</artifactId>
+                       <version>0.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.tomcat</groupId>
+                       <artifactId>tomcat-catalina</artifactId>
+                       <version>8.5.3</version>
+            <scope>provided</scope>
+               </dependency>
+       </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/wicket/blob/6e184f3f/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/Initializer.java
----------------------------------------------------------------------
diff --git 
a/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/Initializer.java
 
b/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/Initializer.java
new file mode 100644
index 0000000..b1ad6d7
--- /dev/null
+++ 
b/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/Initializer.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.http2;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.IInitializer;
+import org.apache.wicket.http2.markup.head.Tomcat85PushBuilder;
+
+/**
+ *
+ */
+public class Initializer implements IInitializer
+{
+       @Override
+       public void init(Application application)
+       {
+               Http2Settings http2Settings = 
Http2Settings.Holder.get(application);
+               http2Settings.setPushBuilder(new Tomcat85PushBuilder());
+       }
+
+       @Override
+       public void destroy(Application application)
+       {
+       }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/6e184f3f/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/markup/head/Tomcat85PushBuilder.java
----------------------------------------------------------------------
diff --git 
a/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/markup/head/Tomcat85PushBuilder.java
 
b/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/markup/head/Tomcat85PushBuilder.java
new file mode 100644
index 0000000..1f1da5d
--- /dev/null
+++ 
b/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/main/java/org/apache/wicket/http2/markup/head/Tomcat85PushBuilder.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.http2.markup.head;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.request.Request;
+import org.apache.wicket.request.cycle.RequestCycle;
+
+/**
+ *
+ */
+public class Tomcat85PushBuilder implements PushBuilder
+{
+       @Override
+       public void push(HttpServletRequest httpServletRequest, String... paths)
+       {
+               Request request = RequestCycle.get().getRequest();
+               HttpServletRequest httpRequest = (HttpServletRequest) 
request.getContainerRequest();
+               org.apache.catalina.connector.Request tomcatRequest = 
(org.apache.catalina.connector.Request) httpRequest;
+               org.apache.catalina.servlet4preview.http.PushBuilder 
pushBuilder = tomcatRequest.getPushBuilder();
+               for (String path : paths)
+               {
+                       pushBuilder.path(path);
+               }
+               pushBuilder.push();
+       }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/6e184f3f/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/resources/META-INF/services/org.apache.wicket.IInitializer
----------------------------------------------------------------------
diff --git 
a/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/resources/META-INF/services/org.apache.wicket.IInitializer
 
b/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/resources/META-INF/services/org.apache.wicket.IInitializer
new file mode 100644
index 0000000..f721b3e
--- /dev/null
+++ 
b/wicket-experimental/wicket-http2/wicket-http2-tomcat/src/resources/META-INF/services/org.apache.wicket.IInitializer
@@ -0,0 +1 @@
+org.apache.wicket.http2.Initializer

Reply via email to