@@ -0,0 +1,2433 @@
+/*%0A * JBoss, Home of Professional Open Source.%0A * Copyright 2014 Red Hat, Inc., and individual contributors%0A * as indicated by the @author tags.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0A%0Apackage io.undertow.server.handlers;%0A%0Aimport io.undertow.server.HttpHandler;%0Aimport io.undertow.server.HttpServerExchange;%0Aimport io.undertow.util.HeaderMap;%0Aimport io.undertow.util.HttpString;%0Aimport io.undertow.util.Methods;%0Aimport io.undertow.util.PathMatcher;%0A%0A/**%0A * Handler that pushes resources based on a provided URL%0A *%0A * @author Stuart Douglas%0A */%0Apublic class PushHandler implements HttpHandler %7B%0A%0A    private final PathMatcher%3CString%5B%5D%3E pathMatcher = new PathMatcher%3C%3E();%0A    private final HttpHandler next;%0A    private final HeaderMap requestHeaders = new HeaderMap();%0A%0A    public PushHandler(HttpHandler next) %7B%0A        this.next = next;%0A    %7D%0A%0A    @Override%0A    public void handleRequest(HttpServerExchange exchange) throws Exception %7B%0A        if(exchange.getConnection().isPushSupported()) %7B%0A            PathMatcher.PathMatch%3CString%5B%5D%3E result = pathMatcher.match(exchange.getRelativePath());%0A            if(result != null) %7B%0A                String%5B%5D value = result.getValue();%0A                for(int i = 0; i %3C value.length; ++i) %7B%0A                    exchange.getConnection().pushResource(value%5Bi%5D, Methods.GET, requestHeaders, exchange);%0A                %7D%0A            %7D%0A        %7D%0A        next.handleRequest(exchange);%0A    %7D%0A%0A    public PushHandler addRequestHeader(HttpString name, String value) %7B%0A        requestHeaders.put(name, value);%0A    %7D%0A%0A    public PushHandler addRoute(String url, String ... resourcesToPush) %7B%0A        if(url.endsWith(%22/*%22)) %7B%0A            String partial = url.substring(0, url.length() - 1);%0A            pathMatcher.addPrefixPath(partial, resourcesToPush);%0A        %7D else %7B%0A            pathMatcher.addExactPath(url, resourcesToPush);%0A        %7D%0A        return this;%0A    %7D%0A%0A%7D%0A

Add push handler that can push resources for specific URL's