Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-10-28 02:33:38 -0400
committerGreg Wilkins2015-10-28 02:33:38 -0400
commit5093aa3d405dc3b048d6f65b4d42315670e4195c (patch)
treebdfdd082ee1e07b365a06bf39fb17ca8b3d081d7 /jetty-servlets
parent36de309e9f7e33e53f7781393f5e7cc49938a6b9 (diff)
downloadorg.eclipse.jetty.project-5093aa3d405dc3b048d6f65b4d42315670e4195c.tar.gz
org.eclipse.jetty.project-5093aa3d405dc3b048d6f65b4d42315670e4195c.tar.xz
org.eclipse.jetty.project-5093aa3d405dc3b048d6f65b4d42315670e4195c.zip
Updated PushBuilder to draft for servlet 4.0
Diffstat (limited to 'jetty-servlets')
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
index d6710d74db..aa6e66be2f 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/PushCacheFilter.java
@@ -46,6 +46,7 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.Dispatcher;
+import org.eclipse.jetty.server.PushBuilder;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil;
@@ -186,14 +187,13 @@ public class PushCacheFilter implements Filter
long primaryTimestamp = primaryResource._timestamp.get();
if (primaryTimestamp != 0)
{
- RequestDispatcher dispatcher = request.getServletContext().getRequestDispatcher(path);
if (now - primaryTimestamp < TimeUnit.MILLISECONDS.toNanos(_associatePeriod))
{
- ConcurrentMap<String, RequestDispatcher> associated = primaryResource._associated;
+ ConcurrentMap<String, String> associated = primaryResource._associated;
// Not strictly concurrent-safe, just best effort to limit associations.
if (associated.size() <= _maxAssociations)
{
- if (associated.putIfAbsent(path, dispatcher) == null)
+ if (associated.putIfAbsent(path, path) == null)
{
if (LOG.isDebugEnabled())
LOG.debug("Associated {} to {}", path, referrerPathNoContext);
@@ -253,11 +253,14 @@ public class PushCacheFilter implements Filter
// Push associated for non conditional
if (!conditional && !primaryResource._associated.isEmpty())
{
- for (RequestDispatcher dispatcher : primaryResource._associated.values())
+ PushBuilder builder = Request.getBaseRequest(request).getPushBuilder();
+
+ for (String associated : primaryResource._associated.values())
{
if (LOG.isDebugEnabled())
- LOG.debug("Pushing {} for {}", dispatcher, path);
- ((Dispatcher)dispatcher).push(request);
+ LOG.debug("Pushing {} for {}", associated, path);
+
+ builder.path(associated).push();
}
}
@@ -297,7 +300,7 @@ public class PushCacheFilter implements Filter
private static class PrimaryResource
{
- private final ConcurrentMap<String, RequestDispatcher> _associated = new ConcurrentHashMap<>();
+ private final ConcurrentMap<String, String> _associated = new ConcurrentHashMap<>();
private final AtomicLong _timestamp = new AtomicLong();
}
}

Back to the top