Changeset f1dd779


Ignore:
Timestamp:
Nov 21, 2012 8:49:18 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c0d82fe
Parents:
be8697c
Message:

RouterConsole? compile fixes for Jetty 7.
Convert LocaleWebAppHandler? from extending WebAppContext? to
extending HandlerWrapper?, since handle() is now final in WebAppContext?.
Untested.

Location:
apps/routerconsole
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/build.xml

    rbe8697c rf1dd779  
    6161                <pathelement location="../../../router/java/build/router.jar" />
    6262                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
     63                <pathelement location="../../jetty/jettylib/jetty-http.jar" />
     64                <pathelement location="../../jetty/jettylib/jetty-io.jar" />
     65                <pathelement location="../../jetty/jettylib/jetty-security.jar" />
     66                <pathelement location="../../jetty/jettylib/jetty-servlet.jar" />
     67                <pathelement location="../../jetty/jettylib/jetty-servlets.jar" />
    6368                <pathelement location="../../jetty/jettylib/jetty-util.jar" />
    64                 <pathelement location="../../jetty/jettylib/jetty-sslengine.jar" />
    65                 <pathelement location="../../jetty/jettylib/jetty-java5-threadpool.jar" />
     69                <pathelement location="../../jetty/jettylib/jetty-webapp.jar" />
    6670                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
    6771                <pathelement location="../../jetty/jettylib/jsp-api.jar" />
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java

    rbe8697c rf1dd779  
    1818import static net.i2p.update.UpdateType.*;
    1919
    20 import org.mortbay.jetty.handler.ContextHandlerCollection;
     20import org.eclipse.jetty.server.handler.ContextHandlerCollection;
    2121
    2222/**
  • apps/routerconsole/java/src/net/i2p/router/web/ConsolePasswordManager.java

    rbe8697c rf1dd779  
    1313import net.i2p.router.util.RouterPasswordManager;
    1414
    15 //import org.mortbay.jetty.security.UnixCrypt;
     15//import org.eclipse.jetty.util.security.UnixCrypt;
    1616
    1717/**
  • apps/routerconsole/java/src/net/i2p/router/web/LocaleWebAppHandler.java

    rbe8697c rf1dd779  
    11package net.i2p.router.web;
    22
     3import java.io.File;
    34import java.io.IOException;
    45import java.util.Locale;
     
    1112import net.i2p.I2PAppContext;
    1213
    13 import org.mortbay.jetty.webapp.WebAppContext;
     14import org.eclipse.jetty.server.Request;
     15import org.eclipse.jetty.server.handler.HandlerWrapper;
     16import org.eclipse.jetty.server.session.SessionHandler;
     17import org.eclipse.jetty.servlet.ServletHandler;
     18import org.eclipse.jetty.webapp.WebAppContext;
    1419
    1520/**
     
    2227 * @author zzz
    2328 */
    24 public class LocaleWebAppHandler extends WebAppContext
     29public class LocaleWebAppHandler extends HandlerWrapper
    2530{
    2631    private final I2PAppContext _context;
     32    private final WebAppContext _wac;
    2733
    28     public LocaleWebAppHandler(I2PAppContext ctx, String path, String warPath) {
    29         super(warPath, path);
     34    public LocaleWebAppHandler(I2PAppContext ctx, String path, String warPath,
     35                               File tmpdir, ServletHandler servletHandler) {
     36        super();
    3037        _context = ctx;
     38        _wac = new WebAppContext(warPath, path);
    3139        setInitParams(WebAppStarter.INIT_PARAMS);
     40        _wac.setTempDirectory(tmpdir);
     41        _wac.setExtractWAR(false);
     42        _wac.setSessionHandler(new SessionHandler());
     43        _wac.setServletHandler(servletHandler);
     44        setHandler(_wac);
    3245    }
    3346   
     
    3851     *  Unless language == "en".
    3952     */
    40     @Override
    4153    public void handle(String pathInContext,
     54                       Request baseRequest,
    4255                       HttpServletRequest httpRequest,
    43                        HttpServletResponse httpResponse,
    44                        int dispatch)
     56                       HttpServletResponse httpResponse)
    4557         throws IOException, ServletException
    4658    {
    47         // Handle OPTIONS (nothing to override)
    48         if ("OPTIONS".equals(httpRequest.getMethod()))
    49         {
    50             handleOptions(httpRequest, httpResponse);
    51             return;
    52         }
    5359
    5460        // transparent rewriting
     
    7884                    String testPath = pathInContext.substring(0, len - 4) + '_' + lang + ".jsp";
    7985                    // Do we have a servlet for the new path that isn't the catchall *.jsp?
    80                     Map.Entry servlet = getServletHandler().getHolderEntry(testPath);
     86                    Map.Entry servlet = _wac.getServletHandler().getHolderEntry(testPath);
    8187                    if (servlet != null) {
    8288                        String servletPath = (String) servlet.getKey();
     
    9197        }
    9298        //System.err.println("New path: " + newPath);
    93         super.handle(newPath, httpRequest, httpResponse, dispatch);
     99        super.handle(newPath, baseRequest, httpRequest, httpResponse);
    94100        //System.err.println("Was handled? " + httpRequest.isHandled());
    95101    }
     
    113119     *  @since 0.8
    114120     */
     121/****  not in Jetty 7
    115122    public void handleOptions(HttpServletRequest request,
    116123                              HttpServletResponse response)
     
    119126        response.sendError(405);
    120127    }
     128****/
     129
     130    /**
     131     *  Mysteriously removed from Jetty 7
     132     */
     133    private void setInitParams(Map params) {
     134        setInitParams(_wac, params);
     135    }
     136
     137    /**
     138     *  @since Jetty 7
     139     */
     140    public static void setInitParams(WebAppContext context, Map<?,?> params) {
     141        for (Map.Entry e : params.entrySet()) {
     142            context.setInitParameter((String)e.getKey(), (String)e.getValue());
     143        }
     144    }
    121145}
  • apps/routerconsole/java/src/net/i2p/router/web/LogsHelper.java

    rbe8697c rf1dd779  
    88import net.i2p.util.VersionComparator;
    99
    10 import org.mortbay.jetty.Server;
     10import org.eclipse.jetty.server.Server;
    1111import org.tanukisoftware.wrapper.WrapperManager;
    1212
  • apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java

    rbe8697c rf1dd779  
    3535import net.i2p.util.VersionComparator;
    3636
    37 import org.mortbay.jetty.handler.ContextHandlerCollection;
     37import org.eclipse.jetty.server.handler.ContextHandlerCollection;
    3838
    3939
  • apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java

    rbe8697c rf1dd779  
    4343import net.i2p.util.VersionComparator;
    4444
    45 import org.mortbay.jetty.AbstractConnector;
    46 import org.mortbay.jetty.Connector;
    47 import org.mortbay.jetty.NCSARequestLog;
    48 import org.mortbay.jetty.Server;
    49 import org.mortbay.jetty.bio.SocketConnector;
    50 import org.mortbay.jetty.handler.ContextHandlerCollection;
    51 import org.mortbay.jetty.handler.DefaultHandler;
    52 import org.mortbay.jetty.handler.HandlerCollection;
    53 import org.mortbay.jetty.handler.RequestLogHandler;
    54 import org.mortbay.jetty.nio.SelectChannelConnector;
    55 import org.mortbay.jetty.security.Credential.MD5;
    56 import org.mortbay.jetty.security.DigestAuthenticator;
    57 import org.mortbay.jetty.security.HashUserRealm;
    58 import org.mortbay.jetty.security.Constraint;
    59 import org.mortbay.jetty.security.ConstraintMapping;
    60 import org.mortbay.jetty.security.SecurityHandler;
    61 import org.mortbay.jetty.security.SslSocketConnector;
    62 import org.mortbay.jetty.security.SslSelectChannelConnector;
    63 import org.mortbay.jetty.servlet.ServletHandler;
    64 import org.mortbay.jetty.servlet.ServletHolder;
    65 import org.mortbay.jetty.servlet.SessionHandler;
    66 import org.mortbay.jetty.webapp.WebAppContext;
    67 import org.mortbay.thread.QueuedThreadPool;
    68 import org.mortbay.thread.concurrent.ThreadPool;
     45import org.eclipse.jetty.security.HashLoginService;
     46import org.eclipse.jetty.security.ConstraintMapping;
     47import org.eclipse.jetty.security.ConstraintSecurityHandler;
     48import org.eclipse.jetty.security.SecurityHandler;
     49import org.eclipse.jetty.security.authentication.DigestAuthenticator;
     50import org.eclipse.jetty.server.AbstractConnector;
     51import org.eclipse.jetty.server.Connector;
     52import org.eclipse.jetty.server.NCSARequestLog;
     53import org.eclipse.jetty.server.Server;
     54import org.eclipse.jetty.server.bio.SocketConnector;
     55import org.eclipse.jetty.server.handler.ContextHandlerCollection;
     56import org.eclipse.jetty.server.handler.DefaultHandler;
     57import org.eclipse.jetty.server.handler.HandlerCollection;
     58import org.eclipse.jetty.server.handler.HandlerWrapper;
     59import org.eclipse.jetty.server.handler.RequestLogHandler;
     60import org.eclipse.jetty.server.nio.SelectChannelConnector;
     61import org.eclipse.jetty.server.ssl.SslSocketConnector;
     62import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
     63import org.eclipse.jetty.servlet.ServletHandler;
     64import org.eclipse.jetty.servlet.ServletHolder;
     65import org.eclipse.jetty.webapp.WebAppContext;
     66import org.eclipse.jetty.util.security.Constraint;
     67import org.eclipse.jetty.util.security.Credential;
     68import org.eclipse.jetty.util.security.Credential.MD5;
     69import org.eclipse.jetty.util.thread.ExecutorThreadPool;
     70import org.eclipse.jetty.util.thread.QueuedThreadPool;
     71import org.eclipse.jetty.util.thread.ThreadPool;
    6972
    7073/**
     
    307310        try {
    308311            ThreadPool ctp = new CustomThreadPoolExecutor();
    309             ctp.prestartAllCoreThreads();
     312            // Gone in Jetty 7
     313            //ctp.prestartAllCoreThreads();
    310314            _server.setThreadPool(ctp);
    311315        } catch (Throwable t) {
     
    320324        HandlerCollection hColl = new HandlerCollection();
    321325        ContextHandlerCollection chColl = new ContextHandlerCollection();
    322         _server.addHandler(hColl);
     326        // gone in Jetty 7
     327        //_server.addHandler(hColl);
     328        _server.setHandler(hColl);
    323329        hColl.addHandler(chColl);
    324330        hColl.addHandler(new DefaultHandler());
     
    356362            _webAppsDir += '/';
    357363
    358         WebAppContext rootWebApp = null;
     364        HandlerWrapper rootWebApp = null;
    359365        ServletHandler rootServletHandler = null;
    360366        List<Connector> connectors = new ArrayList(4);
     
    512518            }
    513519
    514             rootWebApp = new LocaleWebAppHandler(_context,
    515                                                   "/", _webAppsDir + ROUTERCONSOLE + ".war");
    516520            File tmpdir = new SecureDirectory(workDir, ROUTERCONSOLE + "-" +
    517521                                                       (_listenPort != null ? _listenPort : _sslListenPort));
    518522            tmpdir.mkdir();
    519             rootWebApp.setTempDirectory(tmpdir);
    520             rootWebApp.setExtractWAR(false);
    521             rootWebApp.setSessionHandler(new SessionHandler());
    522523            rootServletHandler = new ServletHandler();
    523             rootWebApp.setServletHandler(rootServletHandler);
    524             initialize(_context, rootWebApp);
     524            rootWebApp = new LocaleWebAppHandler(_context,
     525                                                  "/", _webAppsDir + ROUTERCONSOLE + ".war",
     526                                                 tmpdir, rootServletHandler);
     527            initialize(_context, (WebAppContext)(rootWebApp.getHandler()));
    525528            chColl.addHandler(rootWebApp);
    526529
     
    732735     */
    733736    static void initialize(RouterContext ctx, WebAppContext context) {
    734         SecurityHandler sec = new SecurityHandler();
     737        ConstraintSecurityHandler sec = new ConstraintSecurityHandler();
    735738        List<ConstraintMapping> constraints = new ArrayList(4);
    736739        ConsolePasswordManager mgr = new ConsolePasswordManager(ctx);
     
    742745                ctx.router().saveConfig(PROP_CONSOLE_PW, "false");
    743746            } else {
    744                 HashUserRealm realm = new HashUserRealm(JETTY_REALM);
    745                 sec.setUserRealm(realm);
     747                HashLoginService realm = new HashLoginService(JETTY_REALM);
     748                sec.setLoginService(realm);
    746749                sec.setAuthenticator(authenticator);
    747750                for (Map.Entry<String, String> e : userpw.entrySet()) {
    748751                    String user = e.getKey();
    749752                    String pw = e.getValue();
    750                     realm.put(user, MD5.__TYPE + pw);
    751                     realm.addUserToRole(user, JETTY_ROLE);
     753                    realm.putUser(user, Credential.getCredential(MD5.__TYPE + pw), new String[] {JETTY_ROLE});
    752754                    Constraint constraint = new Constraint(user, JETTY_ROLE);
    753755                    constraint.setAuthenticate(true);
     
    848850     * @since Jetty 6
    849851     */
    850     private static class CustomThreadPoolExecutor extends ThreadPool {
     852    private static class CustomThreadPoolExecutor extends ExecutorThreadPool {
    851853        public CustomThreadPoolExecutor() {
    852854             super(MIN_THREADS, MAX_THREADS, MAX_IDLE_TIME, TimeUnit.MILLISECONDS,
    853                    new SynchronousQueue(), new CustomThreadFactory(),
    854                    new ThreadPoolExecutor.CallerRunsPolicy());
     855                   new SynchronousQueue()  /** ,  following args not available in Jetty 7
     856                   new CustomThreadFactory(),
     857                   new ThreadPoolExecutor.CallerRunsPolicy() **/
     858                  );
    855859        }
    856860    }
  • apps/routerconsole/java/src/net/i2p/router/web/WebAppConfiguration.java

    rbe8697c rf1dd779  
    1111import net.i2p.I2PAppContext;
    1212
    13 import org.mortbay.jetty.webapp.Configuration;
    14 import org.mortbay.jetty.webapp.WebAppClassLoader;
    15 import org.mortbay.jetty.webapp.WebAppContext;
     13import org.eclipse.jetty.webapp.Configuration;
     14import org.eclipse.jetty.webapp.WebAppClassLoader;
     15import org.eclipse.jetty.webapp.WebAppContext;
    1616
    1717
     
    134134    }
    135135
    136     public void configureDefaults() {}
    137     public void configureWebApp() {}
     136    /** @since Jetty 7 */
     137    public void deconfigure(WebAppContext context) {}
    138138
    139     /** @since Jetty 6 */
    140     public void deconfigureWebApp() {}
    141 
    142     /** @since Jetty 6 */
    143     public void configureClassLoader() throws Exception {
     139    /** @since Jetty 7 */
     140    public void configure(WebAppContext context) throws Exception {
    144141        configureClassPath();
    145142    }
     143
     144    /** @since Jetty 7 */
     145    public void cloneConfigure(WebAppContext template, WebAppContext context) {
     146        throw new UnsupportedOperationException();
     147    }
     148
     149    /** @since Jetty 7 */
     150    public void destroy(WebAppContext context) {}
     151
     152    /** @since Jetty 7 */
     153    public void preConfigure(WebAppContext context) {}
     154
     155    /** @since Jetty 7 */
     156    public void postConfigure(WebAppContext context) {}
    146157}
  • apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java

    rbe8697c rf1dd779  
    1111import net.i2p.util.SecureDirectory;
    1212
    13 import org.mortbay.jetty.Handler;
    14 import org.mortbay.jetty.Server;
    15 import org.mortbay.jetty.webapp.WebAppContext;
    16 import org.mortbay.jetty.handler.ContextHandler;
    17 import org.mortbay.jetty.handler.ContextHandlerCollection;
     13import org.eclipse.jetty.server.Handler;
     14import org.eclipse.jetty.server.Server;
     15import org.eclipse.jetty.server.handler.ContextHandler;
     16import org.eclipse.jetty.server.handler.ContextHandlerCollection;
     17import org.eclipse.jetty.webapp.WebAppContext;
    1818
    1919
     
    5757         WebAppContext wac = addWebApp(ctx, server, appName, warPath, tmpdir);     
    5858         //_log.debug("Loading war from: " + warPath);
    59          wac.setInitParams(INIT_PARAMS);
     59         LocaleWebAppHandler.setInitParams(wac, INIT_PARAMS);
    6060         wac.start();
    6161    }
  • apps/routerconsole/jsp/error.jsp

    rbe8697c rf1dd779  
    55<%
    66    // Let's make this easy...
    7     final Integer ERROR_CODE = (Integer) request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_STATUS_CODE);
    8     final String ERROR_URI = (String) request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_REQUEST_URI);
    9     final String ERROR_MESSAGE = (String) request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_MESSAGE);
     7    final Integer ERROR_CODE = (Integer) request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_STATUS_CODE);
     8    final String ERROR_URI = (String) request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_REQUEST_URI);
     9    final String ERROR_MESSAGE = (String) request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_MESSAGE);
    1010    if (ERROR_CODE != null && ERROR_MESSAGE != null) {
    1111        // this is deprecated but we don't want sendError()
  • apps/routerconsole/jsp/error500.jsp

    rbe8697c rf1dd779  
    44<%
    55    // Let's make this easy...
    6     final Integer ERROR_CODE = (Integer) request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_STATUS_CODE);
    7     final String ERROR_URI = (String) request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_REQUEST_URI);
    8     final String ERROR_MESSAGE = (String) request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_MESSAGE);
    9     final Class ERROR_CLASS = (Class)request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_EXCEPTION_TYPE);
    10     final Throwable ERROR_THROWABLE = (Throwable)request.getAttribute(org.mortbay.jetty.servlet.ServletHandler.__J_S_ERROR_EXCEPTION);
     6    final Integer ERROR_CODE = (Integer) request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_STATUS_CODE);
     7    final String ERROR_URI = (String) request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_REQUEST_URI);
     8    final String ERROR_MESSAGE = (String) request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_MESSAGE);
     9    final Class ERROR_CLASS = (Class)request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_EXCEPTION_TYPE);
     10    final Throwable ERROR_THROWABLE = (Throwable)request.getAttribute(org.eclipse.jetty.server.Dispatcher.ERROR_EXCEPTION);
    1111    if (ERROR_CODE != null && ERROR_MESSAGE != null) {
    1212        // this is deprecated but we don't want sendError()
Note: See TracChangeset for help on using the changeset viewer.