Changeset 50df4b5


Ignore:
Timestamp:
Nov 22, 2012 9:17:50 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
9fc7258
Parents:
02ad4d5
Message:
  • Clean up WebAppconfiguration?
  • Fix eepsite xml files
  • First cut at updating migration code (untested)
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • apps/jetty/build.xml

    r02ad4d5 r50df4b5  
    9090              start.jar: Needed for clients.config startup of eepsites
    9191              jetty-util-xxx.jar: LifeCycle (base class for stuff), URIUtil (used in i2psnark)
    92               jetty-sslengine-xxx.jar: SSL NIO Connector for console
    93               jetty-java5-threadpool-xxx.jar: Concurrent thread pool for eepsite
     92              jetty-deploy, -http, -io, -security, -servlet, -webapp: All split out from main server jar in Jetty 7
     93              jetty-continuation-xxx.jar: Needed? Useful?
     94              jetty-servlets-xxx.jar: Needed for CGI for eepsite
     95              jetty-sslengine-xxx.jar: Old Jetty 6, now a dummy
     96              jetty-java5-threadpool-xxx.jar: Old Jetty 6, now a dummy
    9497              glassfish 2.1: Not used, too old, see Tomcat below.
    9598              jetty-rewrite-handler: Not used by I2P, but only 20KB and could be useful for eepsites
  • apps/routerconsole/java/src/net/i2p/router/web/WebAppConfiguration.java

    r02ad4d5 r50df4b5  
    3939 */
    4040public class WebAppConfiguration implements Configuration {
    41     private WebAppContext _wac;
    4241
    4342    private static final String CLASSPATH = ".classpath";
    4443
    4544    /**
    46      *  This was the interface in Jetty 5, now it's configureClassLoader()
     45     *  This was the interface in Jetty 5, in Jetty 6 was configureClassLoader(),
     46     *  now it's configure()
    4747     */
    48     private void configureClassPath() throws Exception {
    49         String ctxPath = _wac.getContextPath();
     48    private void configureClassPath(WebAppContext wac) throws Exception {
     49        String ctxPath = wac.getContextPath();
    5050        //System.err.println("Configure Class Path " + ctxPath);
    5151        if (ctxPath.equals("/"))
     
    103103        if (buf.length() <= 0)
    104104            return;
    105         ClassLoader cl = _wac.getClassLoader();
     105        ClassLoader cl = wac.getClassLoader();
    106106        if (cl != null && cl instanceof WebAppClassLoader) {
    107107            WebAppClassLoader wacl = (WebAppClassLoader) cl;
     
    111111            // and it calls getExtraClasspath in its constructor
    112112            // Not sure why WACL already exists...
    113             _wac.setExtraClasspath(buf.toString());
     113            wac.setExtraClasspath(buf.toString());
    114114        }
    115115    }
     
    131131    /** @since Jetty 7 */
    132132    public void configure(WebAppContext context) throws Exception {
    133         _wac = context;
    134         configureClassPath();
     133        configureClassPath(context);
    135134    }
    136135
    137136    /** @since Jetty 7 */
    138137    public void cloneConfigure(WebAppContext template, WebAppContext context) {
    139         throw new UnsupportedOperationException();
     138        // no state, nothing to be done
    140139    }
    141140
  • build.xml

    r02ad4d5 r50df4b5  
    11031103              can't overwrite an existing eepsite dir in a non-split configuration.
    11041104          -->
    1105         <copy todir="pkg-temp/eepsite-jetty6" >
     1105        <copy todir="pkg-temp/eepsite-jetty7" >
    11061106            <fileset dir="installer/resources/eepsite" includes="*.xml contexts/* etc/*" />
    11071107        </copy>
     
    11091109
    11101110    <target name="delete-j6-update">
    1111         <delete dir="pkg-temp/eepsite-jetty6" />
     1111        <delete dir="pkg-temp/eepsite-jetty7" />
    11121112    </target>
    11131113
  • installer/resources/eepsite/contexts/base-context.xml

    r02ad4d5 r50df4b5  
    55Configure a custom context for the eepsite.
    66
    7 This context contains only a Context with a default servlet
     7This context contains only a ServletContextHandler with a default servlet
    88to serve static html files and images.
    99-->
    1010
    11 <Configure class="org.mortbay.jetty.servlet.Context">
     11<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
    1212  <Set name="contextPath">/</Set>
    1313  <Set name="resourceBase">./eepsite/docroot/</Set>
    14   <Call name="setInitParams">
    15     <Arg>
    16       <Map>
    17         <Entry>
    18           <Item>org.mortbay.jetty.servlet.Default.cacheControl</Item>
    19           <Item>max-age=3600,public</Item>
    20         </Entry>
    21       </Map>
    22     </Arg>
     14  <Call name="setInitParameter">
     15    <Arg>cacheControl</Arg>
     16    <Arg>max-age=3600,public</Arg>
    2317  </Call>
    2418  <Call name="setMimeTypes">
    2519    <Arg>
    26       <New class="org.mortbay.jetty.MimeTypes">
     20      <New class="org.eclipse.jetty.http.MimeTypes">
    2721        <Call name="addMimeMapping">
    2822          <Arg>sud</Arg>
     
    4135  </Call>
    4236  <Call name="addServlet">
    43     <Arg>org.mortbay.jetty.servlet.DefaultServlet</Arg>
     37    <Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
    4438    <Arg>/</Arg>
    4539  </Call>
  • installer/resources/eepsite/contexts/cgi-context.xml

    r02ad4d5 r50df4b5  
    2323-->
    2424
    25 <Configure class="org.mortbay.jetty.servlet.Context">
     25<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
    2626  <Set name="contextPath">/cgi-bin</Set>
    2727  <Set name="resourceBase">./eepsite/cgi-bin/</Set>
    28   <Call name="setInitParams">
    29     <Arg>
    30       <Map>
    31         <Entry>
    32           <Item>Path</Item>
    33           <Item>/usr/local/bin:/bin:/usr/bin</Item>
    34         </Entry>
    35       </Map>
    36     </Arg>
     28  <Call name="setInitParameter">
     29    <Arg>Path</Arg>
     30    <Arg>/usr/local/bin:/bin:/usr/bin</Arg>
    3731  </Call>
    3832  <Call name="addServlet">
    39     <Arg>org.mortbay.servlet.CGI</Arg>
     33    <Arg>org.eclipse.jetty.servlets.CGI</Arg>
    4034    <Arg>/</Arg>
    4135  </Call>
  • installer/resources/eepsite/etc/webdefault.xml

    r02ad4d5 r50df4b5  
    3636  <!-- UNCOMMENT TO ACTIVATE
    3737  <context-param>
    38     <param-name>org.mortbay.jetty.servlet.SessionDomain</param-name>
     38    <param-name>org.eclipse.jetty.servlet.SessionDomain</param-name>
    3939    <param-value>127.0.0.1</param-value>
    4040  </context-param>
    4141
    4242  <context-param>
    43     <param-name>org.mortbay.jetty.servlet.SessionPath</param-name>
     43    <param-name>org.eclipse.jetty.servlet.SessionPath</param-name>
    4444    <param-value>/</param-value>
    4545  </context-param>
    4646
    4747  <context-param>
    48     <param-name>org.mortbay.jetty.servlet.MaxAge</param-name>
     48    <param-name>org.eclipse.jetty.servlet.MaxAge</param-name>
    4949    <param-value>-1</param-value>
    5050  </context-param>
     
    5252
    5353  <context-param>
    54     <param-name>org.mortbay.jetty.webapp.NoTLDJarPattern</param-name>
     54    <param-name>org.eclipse.jetty.webapp.NoTLDJarPattern</param-name>
    5555    <param-value>start.jar|ant-.*\.jar|dojo-.*\.jar|jetty-.*\.jar|jsp-api-.*\.jar|junit-.*\.jar|servlet-api-.*\.jar|dnsns\.jar|rt\.jar|jsse\.jar|tools\.jar|sunpkcs11\.jar|sunjce_provider\.jar|xerces.*\.jar</param-value>
    5656  </context-param>
     
    113113  <servlet>
    114114    <servlet-name>default</servlet-name>
    115     <servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
     115    <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
    116116    <init-param>
    117117      <param-name>acceptRanges</param-name>
     
    307307  <servlet>
    308308    <servlet-name>invoker</servlet-name>
    309     <servlet-class>org.mortbay.jetty.servlet.Invoker</servlet-class>
     309    <servlet-class>org.eclipse.jetty.servlet.Invoker</servlet-class>
    310310    <init-param>
    311311      <param-name>verbose</param-name>
  • installer/resources/eepsite/jetty.xml

    r02ad4d5 r50df4b5  
    1919<!--   * Uncomment the line to allow Jetty to follow symlinks                  -->
    2020<!--                                                                           -->
    21 <!-- I2P uses Jetty 6.1.26. If you need web server features not found          -->
    22 <!-- in Jetty 6, you may install and run Jetty 7 or 8 in a different JVM       -->
     21<!-- I2P uses Jetty 7. If you need web server features not found               -->
     22<!-- in Jetty 7, you may install and run Jetty 7 or 8 in a different JVM       -->
    2323<!-- or run any other web server such as Apache. If you do run another web     -->
    2424<!-- server instead, be sure and disable the Jetty 6 server for your           -->
     
    4545
    4646
    47 <Configure id="Server" class="org.mortbay.jetty.Server">
     47<Configure id="Server" class="org.eclipse.jetty.server.Server">
    4848
    4949    <!-- =========================================================== -->
     
    5858       -->
    5959     <!--
    60       <New class="org.mortbay.thread.QueuedThreadPool">
     60      <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
    6161        <Set name="minThreads">1</Set>
    6262        <Set name="maxThreads">16</Set>
     
    7474           See RouterConsoleRunner.
    7575       -->
    76       <New class="org.mortbay.thread.concurrent.ThreadPool">
    77         <Arg type="int">0</Arg>
    78         <Set name="corePoolSize">1</Set>
    79         <Set name="maximumPoolSize">24</Set>
     76      <New class="org.eclipse.jetty.util.thread.ExecutorThreadPool">
     77        <!-- corePoolSize (must be at least 2) -->
     78        <Arg type="int">2</Arg>
     79        <!-- maximumPoolSize -->
     80        <Arg type="int">16</Arg>
     81        <!-- keepAliveTime (milliseconds) -->
     82        <Arg type="long">60000</Arg>
    8083      </New>
    8184    </Set>
     
    98101    <Call name="addConnector">
    99102      <Arg>
    100           <New class="org.mortbay.jetty.nio.SelectChannelConnector">
     103          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
    101104            <Set name="host">127.0.0.1</Set>
    102105            <Set name="port">7658</Set>
     
    107110            <Set name="lowResourcesConnections">5000</Set>
    108111            <Set name="lowResourcesMaxIdleTime">5000</Set>
    109             <Set name="useDirectBuffers">false</Set>
     112            <Set name="useDirectBuffers">false</Set>
    110113          </New>
    111114      </Arg>
     
    118121    <Call name="addConnector">
    119122      <Arg>
    120           <New class="org.mortbay.jetty.bio.SocketConnector">
     123          <New class="org.eclipse.jetty.server.bio.SocketConnector">
    121124            <Set name="host">127.0.0.1</Set>
    122125            <Set name="port">7658</Set>
     
    156159    <!--
    157160    <Set name="sessionIdManager">
    158       <New class="org.mortbay.jetty.servlet.HashSessionIdManager">
     161      <New class="org.eclipse.jetty.server.session.HashSessionIdManager">
    159162        <Set name="workerName">node1</Set>
    160163      </New>
     
    166169    <!-- =========================================================== -->
    167170    <Set name="handler">
    168       <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
     171      <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
    169172        <Set name="handlers">
    170          <Array type="org.mortbay.jetty.Handler">
     173         <Array type="org.eclipse.jetty.server.Handler">
    171174           <Item>
    172              <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
     175             <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
    173176           </Item>
    174177           <Item>
    175              <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
     178             <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
    176179           </Item>
    177180           <Item>
    178              <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
     181             <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
    179182           </Item>
    180183         </Array>
     
    182185      </New>
    183186    </Set>
    184    
     187
     188    <!-- =============================================================== -->
     189    <!-- Create the deployment manager                                   -->
     190    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
     191    <!-- The deplyment manager handles the lifecycle of deploying web    -->
     192    <!-- applications. Apps are provided by instances of the             -->
     193    <!-- AppProvider interface.  Typically these are provided by         -->
     194    <!-- one or more of:                                                 -->
     195    <!--   jetty-webapps.xml       - monitors webapps for wars and dirs  -->
     196    <!--   jetty-contexts.xml      - monitors contexts for context xml   -->
     197    <!--   jetty-templates.xml     - monitors contexts and templates     -->
     198    <!-- =============================================================== -->
     199    <Call name="addBean">
     200      <Arg>
     201        <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
     202          <Set name="contexts">
     203            <Ref id="Contexts" />
     204          </Set>
     205          <Call name="setContextAttribute">
     206            <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
     207            <Arg>.*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$</Arg>
     208          </Call>
     209        </New>
     210      </Arg>
     211    </Call>
     212
    185213    <!-- =========================================================== -->
    186214    <!-- Configure the context deployer                              -->
     
    194222    <!--                                                             -->
    195223    <!-- =========================================================== -->
    196     <Call name="addLifeCycle">
    197       <Arg>
    198         <New class="org.mortbay.jetty.deployer.ContextDeployer">
    199           <Set name="contexts"><Ref id="Contexts"/></Set>
    200           <Set name="configurationDir">./eepsite/contexts</Set>
    201           <!-- set to 60 to have it check for changes once a minute -->
    202           <Set name="scanInterval">0</Set>
    203         </New>
    204       </Arg>
    205     </Call>
     224    <Ref id="DeploymentManager">
     225      <Call name="addAppProvider">
     226        <Arg>
     227          <New class="org.eclipse.jetty.deploy.providers.ContextProvider">
     228            <Set name="monitoredDirName">./eepsite/contexts</Set>
     229            <Set name="scanInterval">30</Set>
     230          </New>
     231        </Arg>
     232      </Call>
     233    </Ref>
    206234
    207235    <!-- =========================================================== -->
     
    220248    <Call name="addLifeCycle">
    221249      <Arg>
    222         <New class="org.mortbay.jetty.deployer.WebAppDeployer">
     250        <New class="org.eclipse.jetty.deploy.WebAppDeployer">
    223251          <Set name="contexts"><Ref id="Contexts"/></Set>
    224252          <Set name="webAppDir">./eepsite/webapps</Set>
     
    232260    </Call>
    233261
     262<!-- FIXME Above is deprecated, but this doesn't work
     263     java.lang.IllegalStateException: No Method: <Call name="addAppProvider"><New class="org.eclipse.jetty.deploy.providers.WebAppProvider"><Set name="monitoredDirName">./eepsite/webapps</Set><Set name="parentLoaderPriority">false</Set><Set name="extractWars">false</Set><Set name="defaultsDescriptor">./eepsite/etc/webdefault.xml</Set></New></Call> on class org.eclipse.jetty.deploy.DeploymentManager
     264    <Ref id="DeploymentManager">
     265      <Call id="webappprovider" name="addAppProvider">
     266        <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
     267          <Set name="monitoredDirName">./eepsite/webapps</Set>
     268          <Set name="parentLoaderPriority">false</Set>
     269          <Set name="extractWars">false</Set>
     270          <Set name="defaultsDescriptor">./eepsite/etc/webdefault.xml</Set>
     271        </New>
     272      </Call>
     273    </Ref>
     274-->
     275
    234276    <!-- =========================================================== -->
    235277    <!-- Configure Authentication Realms                             -->
     
    241283  <!-- UNCOMMENT TO ACTIVATE
    242284    <Set name="UserRealms">
    243       <Array type="org.mortbay.jetty.security.UserRealm">
     285      <Array type="org.eclipse.jetty.security.LoginService">
    244286        <Item>
    245           <New class="org.mortbay.jetty.security.HashUserRealm">
     287          <New class="org.eclipse.jetty.security.HashLoginService">
    246288            <Set name="name">Test Realm</Set>
    247289            <Set name="config">./eepsite/etc/realm.properties</Set>
  • router/java/src/net/i2p/router/startup/MigrateJetty.java

    r02ad4d5 r50df4b5  
    3636abstract class MigrateJetty {
    3737    private static boolean _wasChecked;
    38     private static boolean _hasJetty6;
     38    private static boolean _hasLatestJetty;
    3939
    4040    private static final String OLD_CLASS = "org.mortbay.jetty.Server";
    41     private static final String NEW_CLASS = "org.mortbay.start.Main";
    42     private static final String BACKUP = "jetty5.xml";
    43     private static final String JETTY6_TEMPLATE_DIR = "eepsite-jetty6";
    44     private static final String JETTY6_TEMPLATE_PKGDIR = "eepsite";
     41    private static final String OLD_CLASS_6 = "org.mortbay.start.Main";
     42    private static final String NEW_CLASS = "net.i2p.jetty.JettyStart";
     43    private static final String TEST_CLASS = "org.eclipse.jetty.server.Server";
     44    private static final String BACKUP = "jetty6.xml";
     45    private static final String JETTY_TEMPLATE_DIR = "eepsite-jetty7";
     46    private static final String JETTY_TEMPLATE_PKGDIR = "eepsite";
    4547    private static final String BASE_CONTEXT = "contexts/base-context.xml";
    4648    private static final String CGI_CONTEXT = "contexts/cgi-context.xml";
     
    5052        for (int i = 0; i < apps.size(); i++) {
    5153            ClientAppConfig app = apps.get(i);
    52             if (!app.className.equals(OLD_CLASS))
     54            if (!(app.className.equals(OLD_CLASS) || app.className.equals(OLD_CLASS_6)))
    5355                continue;
    5456            String client = "client application " + i + " [" + app.clientName +
    55                             "] from Jetty 5 " + OLD_CLASS +
    56                             " to Jetty 6 " + NEW_CLASS;
    57             if (!hasJetty6()) {
    58                 System.err.println("WARNING: Jetty 6 unavailable, cannot migrate " + client);
     57                            "] from Jetty 5/6 " + app.className +
     58                            " to Jetty 7 " + NEW_CLASS;
     59            if (!hasLatestJetty()) {
     60                System.err.println("WARNING: Jetty 7 unavailable, cannot migrate " + client);
    5961                continue;
    6062            }
     
    8486                continue;
    8587            }
    86             File baseEep = new File(ctx.getBaseDir(), JETTY6_TEMPLATE_DIR);
     88            File baseEep = new File(ctx.getBaseDir(), JETTY_TEMPLATE_DIR);
    8789            // in packages, or perhaps on an uninstall/reinstall, the files are in eepsite/
    8890            if (!baseEep.exists())
    89                 baseEep = new File(ctx.getBaseDir(), JETTY6_TEMPLATE_PKGDIR);
     91                baseEep = new File(ctx.getBaseDir(), JETTY_TEMPLATE_PKGDIR);
    9092            if (baseEep.equals(eepsite)) {
    9193                // non-split directory yet not an upgrade? shouldn't happen
     
    133135        if (shouldSave) {
    134136            File cfgFile = ClientAppConfig.configFile(ctx);
    135             File backup = new File(cfgFile.getAbsolutePath() + ".jetty5");
     137            File backup = new File(cfgFile.getAbsolutePath() + ".jetty6");
    136138            if (backup.exists())
    137139                backup = new File(cfgFile.getAbsolutePath() + ctx.random().nextInt());
     
    140142                ClientAppConfig.writeClientAppConfig(ctx, apps);
    141143                System.err.println("WARNING: Migrated clients config file " + cfgFile +
    142                                " from Jetty 5 " + OLD_CLASS +
    143                                " to Jetty 6 " + NEW_CLASS + "\n" +
     144                               " from Jetty 5/6 " + OLD_CLASS + '/' + OLD_CLASS_6 +
     145                               " to Jetty 7 " + NEW_CLASS + "\n" +
    144146                               "Your old clients config file was saved as " + backup);
    145147            }
     
    147149    }
    148150
    149     private static boolean hasJetty6() {
     151    /** do we have Jetty 7? */
     152    private static boolean hasLatestJetty() {
    150153        if (!_wasChecked) {
    151154            try {
    152                 LoadClientAppsJob.testClient(NEW_CLASS, null);
    153                 _hasJetty6 = true;
     155                LoadClientAppsJob.testClient(TEST_CLASS, null);
     156                _hasLatestJetty = true;
    154157            } catch (ClassNotFoundException cnfe) {}
    155158            _wasChecked = true;
    156159        }
    157         return _hasJetty6;
     160        return _hasLatestJetty;
    158161    }
    159162}
Note: See TracChangeset for help on using the changeset viewer.