[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[jetty-commit] r1547 - in jetty/trunk: . jetty-webapp/src/main/java/org/eclipse/jetty/webapp jetty-webapp/src/test/java/org/eclipse/jetty/webapp
|
- From: genie@xxxxxxxxxxx
- Date: Thu, 22 Apr 2010 07:01:01 -0400 (EDT)
- Delivered-to: jetty-commit@eclipse.org
Author: jbartel
Date: 2010-04-22 07:01:01 -0400 (Thu, 22 Apr 2010)
New Revision: 1547
Added:
jetty/trunk/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java
Modified:
jetty/trunk/VERSION.txt
jetty/trunk/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
Log:
310051 - _configurationClasses now defaults to null in WebAppContext
Modified: jetty/trunk/VERSION.txt
===================================================================
--- jetty/trunk/VERSION.txt 2010-04-21 13:02:36 UTC (rev 1546)
+++ jetty/trunk/VERSION.txt 2010-04-22 11:01:01 UTC (rev 1547)
@@ -11,6 +11,7 @@
+ 308925 Protect the test webapp from remote access
+ 309466 Removed synchronization from StdErrLog
+ 309765 Added JSP module
+ + 310051 _configurationClasses now defaults to null in WebAppContext
+ JETTY-903 Stop both caches
+ JETTY-1200 SSL NIO Endpoint wraps non NIO buffers
+ JETTY-1202 Use platform default algorithm for SecureRandom
Modified: jetty/trunk/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
===================================================================
--- jetty/trunk/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java 2010-04-21 13:02:36 UTC (rev 1546)
+++ jetty/trunk/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java 2010-04-22 11:01:01 UTC (rev 1547)
@@ -19,7 +19,6 @@
import java.security.PermissionCollection;
import java.util.EventListener;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSessionActivationListener;
@@ -30,6 +29,7 @@
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HandlerContainer;
+import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.server.session.SessionHandler;
@@ -74,7 +74,7 @@
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.webapp.TagLibConfiguration"
} ;
- private String[] _configurationClasses=null;
+ private String[] _configurationClasses=__dftConfigurationClasses;
private Configuration[] _configurations;
private String _defaultsDescriptor=WEB_DEFAULTS_XML;
private String _descriptor=null;
@@ -113,6 +113,8 @@
private Map _resourceAliases;
private boolean _ownClassLoader=false;
private boolean _configurationDiscovered=true;
+ private boolean _configurationClassesSet=false;
+ private boolean _configurationsSet=false;
public static ContextHandler getCurrentWebAppContext()
{
@@ -644,21 +646,27 @@
return _parentLoaderPriority;
}
+
/* ------------------------------------------------------------ */
+ public String[] getDefaultConfigurationClasses ()
+ {
+ return __dftConfigurationClasses;
+ }
+
+
+ /* ------------------------------------------------------------ */
protected void loadConfigurations()
throws Exception
{
+ //if the configuration instances have been set explicitly, use them
if (_configurations!=null)
return;
- //look for a Server attribute with the list of names of Configuration classes
- //to apply to every web app. If not present, use our defaults.
- String[] serverConfigs = (String[])getServer().getAttribute(SERVER_CONFIG);
- if (serverConfigs != null)
- _configurationClasses = serverConfigs;
- if (_configurationClasses == null)
- _configurationClasses=__dftConfigurationClasses;
-
+ //if the configuration classnames have been set explicitly use them
+ if (!_configurationClassesSet){
+ System.err.println("DEFAULTS");
+ _configurationClasses=__dftConfigurationClasses;}
+
_configurations = new Configuration[_configurationClasses.length];
for (int i = 0; i < _configurationClasses.length; i++)
{
@@ -695,6 +703,7 @@
public void setConfigurationClasses(String[] configurations)
{
_configurationClasses = configurations==null?null:(String[])configurations.clone();
+ _configurationClassesSet = true;
}
/* ------------------------------------------------------------ */
@@ -704,6 +713,7 @@
public void setConfigurations(Configuration[] configurations)
{
_configurations = configurations==null?null:(Configuration[])configurations.clone();
+ _configurationsSet = true;
}
/* ------------------------------------------------------------ */
@@ -950,6 +960,24 @@
{
this._logUrlOnStart = logOnStart;
}
+
+
+ /* ------------------------------------------------------------ */
+ @Override
+ public void setServer(Server server)
+ {
+ super.setServer(server);
+ //if we haven't been given a set of configuration instances to
+ //use, and we haven't been given a set of configuration classes
+ //to use, use the configuration classes that came from the
+ //Server (if there are any)
+ if (!_configurationsSet && !_configurationClassesSet && server != null)
+ {
+ String[] serverConfigs = (String[])server.getAttribute(SERVER_CONFIG);
+ if (serverConfigs != null)
+ setConfigurationClasses(serverConfigs);
+ }
+ }
/* ------------------------------------------------------------ */
@Override
Added: jetty/trunk/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java
===================================================================
--- jetty/trunk/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java (rev 0)
+++ jetty/trunk/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java 2010-04-22 11:01:01 UTC (rev 1547)
@@ -0,0 +1,74 @@
+// ========================================================================
+// Copyright (c) 2010 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+package org.eclipse.jetty.webapp;
+
+import java.util.Arrays;
+
+import org.eclipse.jetty.server.Server;
+
+import junit.framework.TestCase;
+
+public class WebAppContextTest extends TestCase
+{
+ public void testConfigurationClassesFromDefault ()
+ {
+ Server server = new Server();
+ //test if no classnames set, its the defaults
+ WebAppContext wac = new WebAppContext();
+ assertNull(wac.getConfigurations());
+ String[] classNames = wac.getConfigurationClasses();
+ assertNotNull(classNames);
+
+ //test if no classname set, and none from server its the defaults
+ wac.setServer(server);
+ assertEquals(classNames, wac.getConfigurationClasses());
+ }
+
+ public void testConfigurationClassesExplicit ()
+ {
+ String[] classNames = {"x.y.z"};
+
+ Server server = new Server();
+ server.setAttribute(WebAppContext.SERVER_CONFIG, classNames);
+
+ //test an explicitly set classnames list overrides that from the server
+ WebAppContext wac = new WebAppContext();
+ String[] myClassNames = {"a.b.c", "d.e.f"};
+ wac.setConfigurationClasses(myClassNames);
+ wac.setServer(server);
+ String[] names = wac.getConfigurationClasses();
+ assertTrue(Arrays.equals(myClassNames, names));
+
+
+ //test if no explicit classnames, they come from the server
+ WebAppContext wac2 = new WebAppContext();
+ wac2.setServer(server);
+ assertTrue(Arrays.equals(classNames, wac2.getConfigurationClasses()));
+ }
+
+ public void testConfigurationInstances ()
+ {
+ Configuration[] configs = {new WebInfConfiguration()};
+ WebAppContext wac = new WebAppContext();
+ wac.setConfigurations(configs);
+ assertTrue(Arrays.equals(configs, wac.getConfigurations()));
+
+ //test that explicit config instances override any from server
+ String[] classNames = {"x.y.z"};
+ Server server = new Server();
+ server.setAttribute(WebAppContext.SERVER_CONFIG, classNames);
+ wac.setServer(server);
+ assertTrue(Arrays.equals(configs,wac.getConfigurations()));
+ }
+
+}
Property changes on: jetty/trunk/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/WebAppContextTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Author Id Revision HeadURL
Added: svn:eol-style
+ native