diff options
author | Greg Wilkins | 2012-10-15 11:05:33 +0000 |
---|---|---|
committer | Greg Wilkins | 2012-10-15 11:05:33 +0000 |
commit | f5d3fec4f817cb0f669294e10912c59a0f14c9ad (patch) | |
tree | c607e94f2b666293d8d7ef6da2d30ecc0ce8806b /jetty-deploy/src | |
parent | 9d62229dec84bfb5a2a652bb353abe6e82ec4ac8 (diff) | |
download | org.eclipse.jetty.project-f5d3fec4f817cb0f669294e10912c59a0f14c9ad.tar.gz org.eclipse.jetty.project-f5d3fec4f817cb0f669294e10912c59a0f14c9ad.tar.xz org.eclipse.jetty.project-f5d3fec4f817cb0f669294e10912c59a0f14c9ad.zip |
jetty-9 removed context deployer and merged context and webapps directory
Diffstat (limited to 'jetty-deploy/src')
16 files changed, 201 insertions, 320 deletions
diff --git a/jetty-deploy/src/main/config/etc/jetty-contexts.xml b/jetty-deploy/src/main/config/etc/jetty-contexts.xml deleted file mode 100644 index caa7270dc3..0000000000 --- a/jetty-deploy/src/main/config/etc/jetty-contexts.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> - -<!-- =============================================================== --> -<!-- Add a ContextProvider to the deployment manager --> -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> -<!-- This scans the webapps directory for war files and directories --> -<!-- to deploy. --> -<!-- This configuration must be used with jetty-deploy.xml, which --> -<!-- creates the deployment manager instance --> -<!-- =============================================================== --> -<Configure id="Server" class="org.eclipse.jetty.server.Server"> - <Ref id="DeploymentManager"> - <Call name="addAppProvider"> - <Arg> - <New class="org.eclipse.jetty.deploy.providers.ContextProvider"> - <Set name="monitoredDirName"><Property name="jetty.home" default="." />/contexts</Set> - <Set name="scanInterval">1</Set> - </New> - </Arg> - </Call> - </Ref> -</Configure> diff --git a/jetty-deploy/src/main/config/etc/jetty-deploy.xml b/jetty-deploy/src/main/config/etc/jetty-deploy.xml index 1b3fd66dcd..5316b500dd 100644 --- a/jetty-deploy/src/main/config/etc/jetty-deploy.xml +++ b/jetty-deploy/src/main/config/etc/jetty-deploy.xml @@ -6,43 +6,48 @@ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- The deplyment manager handles the lifecycle of deploying web --> <!-- applications. Apps are provided by instances of the --> -<!-- AppProvider interface. Typically these are provided by --> -<!-- one or more of: --> -<!-- jetty-webapps.xml - monitors webapps for wars and dirs --> -<!-- jetty-contexts.xml - monitors contexts for context xml --> -<!-- jetty-templates.xml - monitors contexts and templates --> +<!-- AppProvider interface. --> <!-- =============================================================== --> <Configure id="Server" class="org.eclipse.jetty.server.Server"> - <Call name="addBean"> - <Arg> - <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager"> - <Set name="contexts"> - <Ref id="Contexts" /> - </Set> - <Call name="setContextAttribute"> - <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg> - <Arg>.*/servlet-api-[^/]*\.jar$</Arg> - </Call> - - - <!-- Add a customize step to the deployment lifecycle --> - <!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class - <Call name="insertLifeCycleNode"> - <Arg>deployed</Arg> - <Arg>starting</Arg> - <Arg>customise</Arg> - </Call> - <Call name="addLifeCycleBinding"> - <Arg> - <New class="org.eclipse.jetty.deploy.bindings.DebugBinding"> - <Arg>customise</Arg> - </New> - </Arg> - </Call> - --> - - </New> - </Arg> - </Call> + <Call name="addBean"> + <Arg> + <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager"> + <Set name="contexts"> + <Ref id="Contexts" /> + </Set> + <Call name="setContextAttribute"> + <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg> + <Arg>.*/servlet-api-[^/]*\.jar$</Arg> + </Call> + + <!-- Add a customize step to the deployment lifecycle --> + <!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class + <Call name="insertLifeCycleNode"> + <Arg>deployed</Arg> + <Arg>starting</Arg> + <Arg>customise</Arg> + </Call> + <Call name="addLifeCycleBinding"> + <Arg> + <New class="org.eclipse.jetty.deploy.bindings.DebugBinding"> + <Arg>customise</Arg> + </New> + </Arg> + </Call> --> + + <Call id="webappprovider" name="addAppProvider"> + <Arg> + <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> + <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set> + <Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set> + <Set name="scanInterval">1</Set> + <Set name="extractWars">true</Set> + </New> + </Arg> + </Call> + + </New> + </Arg> + </Call> </Configure> diff --git a/jetty-deploy/src/main/config/etc/jetty-webapps.xml b/jetty-deploy/src/main/config/etc/jetty-webapps.xml deleted file mode 100644 index 1071ae52d4..0000000000 --- a/jetty-deploy/src/main/config/etc/jetty-webapps.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> - -<!-- =============================================================== --> -<!-- Add a WebAppProvider to the deployment manager --> -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> -<!-- This scans the webapps directory for war files and directories --> -<!-- to deploy. --> -<!-- This configuration must be used with jetty-deploy.xml, which --> -<!-- creates the deployment manager instance --> -<!-- =============================================================== --> -<Configure id="Server" class="org.eclipse.jetty.server.Server"> - <Ref id="DeploymentManager"> - <Call id="webappprovider" name="addAppProvider"> - <Arg> - <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> - <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set> - <Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set> - <Set name="scanInterval">1</Set> - <Set name="contextXmlDir"><Property name="jetty.home" default="." />/contexts</Set> - <Set name="extractWars">true</Set> - </New> - </Arg> - </Call> - </Ref> -</Configure> diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java deleted file mode 100644 index 2c6b36d0c5..0000000000 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java +++ /dev/null @@ -1,94 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2012 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.deploy.providers; - -import java.io.File; -import java.io.FilenameFilter; - -import org.eclipse.jetty.deploy.App; -import org.eclipse.jetty.deploy.ConfigurationManager; -import org.eclipse.jetty.deploy.util.FileID; -import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.util.annotation.ManagedObject; -import org.eclipse.jetty.util.resource.Resource; -import org.eclipse.jetty.xml.XmlConfiguration; - -/** Context directory App Provider. - * <p>This specialization of {@link ScanningAppProvider} is the - * replacement for the old (and deprecated) <code>org.eclipse.jetty.deploy.ContextDeployer</code> and it will scan a directory - * only for context.xml files. - */ -@ManagedObject("Provider for starting webapps originating from context.xml files") -public class ContextProvider extends ScanningAppProvider -{ - private ConfigurationManager _configurationManager; - - public ContextProvider() - { - super( new FilenameFilter() - { - public boolean accept(File dir, String name) - { - if (!dir.exists()) - return false; - String lowername = name.toLowerCase(); - if (lowername.startsWith(".")) - return false; - - return (lowername.endsWith(".xml") && !new File(dir,name).isDirectory()); - } - }); - } - - - /* ------------------------------------------------------------ */ - public ConfigurationManager getConfigurationManager() - { - return _configurationManager; - } - - /* ------------------------------------------------------------ */ - /** Set the configurationManager. - * @param configurationManager the configurationManager to set - */ - public void setConfigurationManager(ConfigurationManager configurationManager) - { - _configurationManager = configurationManager; - } - - /* ------------------------------------------------------------ */ - public ContextHandler createContextHandler(App app) throws Exception - { - Resource resource = Resource.newResource(app.getOriginId()); - File file = resource.getFile(); - - if (resource.exists() && FileID.isXmlFile(file)) - { - XmlConfiguration xmlc = new XmlConfiguration(resource.getURL()); - - xmlc.getIdMap().put("Server",getDeploymentManager().getServer()); - if (getConfigurationManager() != null) - xmlc.getProperties().putAll(getConfigurationManager().getProperties()); - return (ContextHandler)xmlc.configure(); - } - - throw new IllegalStateException("App resouce does not exist "+resource); - } - -} diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java index 5ebecbfb4e..8d8ef3e528 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java @@ -20,9 +20,13 @@ package org.eclipse.jetty.deploy.providers; import java.io.File; import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.jetty.deploy.App; import org.eclipse.jetty.deploy.AppProvider; @@ -45,8 +49,8 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A private Map<String, App> _appMap = new HashMap<String, App>(); private DeploymentManager _deploymentManager; - protected final FilenameFilter _filenameFilter; - private Resource _monitoredDir; + protected FilenameFilter _filenameFilter; + private final List<Resource> _monitored= new CopyOnWriteArrayList<>(); private boolean _recursive = false; private int _scanInterval = 10; private Scanner _scanner; @@ -74,12 +78,25 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A }; /* ------------------------------------------------------------ */ + protected ScanningAppProvider() + { + } + + /* ------------------------------------------------------------ */ protected ScanningAppProvider(FilenameFilter filter) { _filenameFilter = filter; } /* ------------------------------------------------------------ */ + protected void setFilenameFilter(FilenameFilter filter) + { + if (isRunning()) + throw new IllegalStateException(); + _filenameFilter = filter; + } + + /* ------------------------------------------------------------ */ /** * @return The index of currently deployed applications. */ @@ -110,15 +127,16 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A { if (LOG.isDebugEnabled()) LOG.debug(this.getClass().getSimpleName() + ".doStart()"); - if (_monitoredDir == null) - { + if (_monitored.size()==0) throw new IllegalStateException("No configuration dir specified"); - } - File scandir = _monitoredDir.getFile(); - LOG.info("Deployment monitor " + scandir + " at interval " + _scanInterval); + LOG.info("Deployment monitor " + _monitored + " at interval " + _scanInterval); + List<File> files = new ArrayList<>(); + for (Resource resource:_monitored) + files.add(resource.getFile()); + _scanner = new Scanner(); - _scanner.setScanDirs(Collections.singletonList(scandir)); + _scanner.setScanDirs(files); _scanner.setScanInterval(_scanInterval); _scanner.setRecursive(_recursive); _scanner.setFilenameFilter(_filenameFilter); @@ -138,6 +156,12 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A _scanner = null; } } + + /* ------------------------------------------------------------ */ + protected boolean exists(String path) + { + return _scanner.exists(path); + } /* ------------------------------------------------------------ */ protected void fileAdded(String filename) throws Exception @@ -195,13 +219,18 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A /* ------------------------------------------------------------ */ public Resource getMonitoredDirResource() { - return _monitoredDir; + if (_monitored.size()==0) + return null; + if (_monitored.size()>1) + throw new IllegalStateException(); + return _monitored.get(0); } /* ------------------------------------------------------------ */ public String getMonitoredDirName() { - return _monitoredDir.toString(); + Resource resource=getMonitoredDirResource(); + return resource==null?null:resource.toString(); } /* ------------------------------------------------------------ */ @@ -219,30 +248,35 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A } /* ------------------------------------------------------------ */ + @Override public void setDeploymentManager(DeploymentManager deploymentManager) { _deploymentManager = deploymentManager; } /* ------------------------------------------------------------ */ - public void setMonitoredDirResource(Resource contextsDir) + public void setMonitoredResources(List<Resource> resources) { - _monitoredDir = contextsDir; + _monitored.clear(); + _monitored.addAll(resources); } - + /* ------------------------------------------------------------ */ - public void addScannerListener(Scanner.Listener listener) + public List<Resource> getMonitoredResources() { - _scanner.addListener(listener); + return Collections.unmodifiableList(_monitored); + } + + /* ------------------------------------------------------------ */ + public void setMonitoredDirResource(Resource resource) + { + setMonitoredResources(Collections.singletonList(resource)); } /* ------------------------------------------------------------ */ - /** - * @deprecated Use {@link #setMonitoredDirName(String)} - */ - public void setMonitoredDir(String dir) + public void addScannerListener(Scanner.Listener listener) { - setMonitoredDirName(dir); + _scanner.addListener(listener); } /* ------------------------------------------------------------ */ @@ -252,16 +286,25 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A */ public void setMonitoredDirName(String dir) { + setMonitoredDirectories(Collections.singletonList(dir)); + } + + /* ------------------------------------------------------------ */ + public void setMonitoredDirectories(Collection<String> directories) + { try { - setMonitoredDirResource(Resource.newResource(dir)); + List<Resource> resources = new ArrayList<>(); + for (String dir:directories) + resources.add(Resource.newResource(dir)); + setMonitoredResources(resources); } catch (Exception e) { throw new IllegalArgumentException(e); } } - + /* ------------------------------------------------------------ */ protected void setRecursive(boolean recursive) { diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java index 00550aec99..61aa16509d 100644 --- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java +++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/WebAppProvider.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.MalformedURLException; import org.eclipse.jetty.deploy.App; +import org.eclipse.jetty.deploy.ConfigurationManager; import org.eclipse.jetty.deploy.util.FileID; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.URIUtil; @@ -31,31 +32,45 @@ import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.xml.XmlConfiguration; /* ------------------------------------------------------------ */ -/** Context directory App Provider. - * <p>This specialization of {@link ScanningAppProvider} is the - * replacement for old (and deprecated) <code>org.eclipse.jetty.deploy.WebAppDeployer</code> and it will scan a directory - * only for war files or directories files.</p> +/** The webapps directory scanning provider. * <p> - * Webapps with names root or starting with root- are deployed at /. - * If the name is in the format root-hostname, then the webapp is deployed - * at / in the virtual host hostname. + * This provider scans one or more directories (typically "webapps") for contexts to + * deploy, which may be:<ul> + * <li>A standard WAR file (must end in ".war")</li> + * <li>A directory containing an expanded WAR file</li> + * <li>A directory containing static content</li> + * <li>An XML descriptor in {@link XmlConfiguration} format that configures a {@link ContextHandler} instance</li> + * </ul> + * <p> + * To avoid double deployments and allow flexibility of the content of the scanned directories, the provider + * implements some heuristics to ignore some files found in the scans: <ul> + * <li>Hidden files (starting with ".") are ignored</li> + * <li>Directories with names ending in ".d" are ignored</li> + * <li>If a directory and a WAR file exist ( eg foo/ and foo.war) then the directory is assumed to be + * the unpacked WAR and only the WAR is deployed (which may reused the unpacked directory)</li> + * <li>If a directory and a matching XML file exist ( eg foo/ and foo.xml) then the directory is assumed to be + * an unpacked WAR and only the XML is deployed (which may used the directory in it's configuration)</li> + * <li>If a WAR file and a matching XML exist (eg foo.war and foo.xml) then the WAR is assumed to + * be configured by the XML and only the XML is deployed. + * </ul> + * */ @ManagedObject("Provider for start-up deployement of webapps based on presence in directory") public class WebAppProvider extends ScanningAppProvider { private boolean _extractWars = false; private boolean _parentLoaderPriority = false; + private ConfigurationManager _configurationManager; private String _defaultsDescriptor; - private Filter _filter; private File _tempDirectory; private String[] _configurationClasses; - public static class Filter implements FilenameFilter + public class Filter implements FilenameFilter { - private File _contexts; - + @Override public boolean accept(File dir, String name) { if (!dir.exists()) @@ -65,53 +80,59 @@ public class WebAppProvider extends ScanningAppProvider String lowername = name.toLowerCase(); File file = new File(dir,name); - // is it not a directory and not a war ? - if (!file.isDirectory() && !lowername.endsWith(".war")) - { - return false; - } - //ignore hidden files + // ignore hidden files if (lowername.startsWith(".")) return false; - + + // Ignore some directories if (file.isDirectory()) { - // is it a directory for an existing war file? - if (new File(dir,name+".war").exists() || - new File(dir,name+".WAR").exists()) - + // is it a nominated config directory + if (lowername.endsWith(".d")) + return false; + + // is it an unpacked directory for an existing war file? + if (exists(name+".war")||exists(name+".WAR")) return false; + // is it a directory for an existing xml file? + if (exists(name+".xml")||exists(name+".XML")) + return false; + //is it a sccs dir? if ("cvs".equals(lowername) || "cvsroot".equals(lowername)) return false; + + // OK to deploy it then + return true; } - // is there a contexts config file - if (_contexts!=null) + // else is it a war file + if (lowername.endsWith(".war")) { - String context=name; - if (!file.isDirectory()) - { - context=context.substring(0,context.length()-4); - } - if (new File(_contexts,context+".xml").exists() || - new File(_contexts,context+".XML").exists() ) - { + String base=name.substring(0,name.length()-4); + // ignore if it is a war for an existing xml file? + if (exists(base+".xml")||exists(base+".XML")) return false; - } + + // OK to deploy it then + return true; } + + // else is it a context XML file + if (lowername.endsWith(".xml")) + return true; - return true; + return false; } } /* ------------------------------------------------------------ */ public WebAppProvider() { - super(new Filter()); - _filter=(Filter)_filenameFilter; + super(); + setFilenameFilter(new Filter()); setScanInterval(0); } @@ -173,40 +194,20 @@ public class WebAppProvider extends ScanningAppProvider } /* ------------------------------------------------------------ */ - @ManagedAttribute("directory to scan for context.xml files") - public String getContextXmlDir() + public ConfigurationManager getConfigurationManager() { - return _filter._contexts==null?null:_filter._contexts.toString(); + return _configurationManager; } - + /* ------------------------------------------------------------ */ - /** - * Set the directory in which to look for context XML files. - * <p> - * If a webapp call "foo/" or "foo.war" is discovered in the monitored - * directory, then the ContextXmlDir is examined to see if a foo.xml - * file exists. If it does, then this deployer will not deploy the webapp - * and the ContextProvider should be used to act on the foo.xml file. - * @see ContextProvider - * @param contextsDir + /** Set the configurationManager. + * @param configurationManager the configurationManager to set */ - public void setContextXmlDir(String contextsDir) + public void setConfigurationManager(ConfigurationManager configurationManager) { - try - { - _filter._contexts=Resource.newResource(contextsDir).getFile(); - } - catch (MalformedURLException e) - { - throw new RuntimeException(e); - } - catch (IOException e) - { - throw new RuntimeException(e); - } + _configurationManager = configurationManager; } - /* ------------------------------------------------------------ */ /** * @param configurations The configuration class names. @@ -250,6 +251,7 @@ public class WebAppProvider extends ScanningAppProvider } /* ------------------------------------------------------------ */ + @Override public ContextHandler createContextHandler(final App app) throws Exception { Resource resource = Resource.newResource(app.getOriginId()); @@ -258,8 +260,17 @@ public class WebAppProvider extends ScanningAppProvider throw new IllegalStateException("App resouce does not exist "+resource); String context = file.getName(); - - if (file.isDirectory()) + + if (resource.exists() && FileID.isXmlFile(file)) + { + XmlConfiguration xmlc = new XmlConfiguration(resource.getURL()); + + xmlc.getIdMap().put("Server",getDeploymentManager().getServer()); + if (getConfigurationManager() != null) + xmlc.getProperties().putAll(getConfigurationManager().getProperties()); + return (ContextHandler)xmlc.configure(); + } + else if (file.isDirectory()) { // must be a directory } diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java index 79e837193a..d2031ffe21 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/bindings/GlobalWebappConfigBindingTest.java @@ -55,7 +55,7 @@ public class GlobalWebappConfigBindingTest jetty.addConfiguration("jetty.xml"); // Setup initial context - jetty.copyContext("foo.xml","foo.xml"); + jetty.copyWebapp("foo.xml","foo.xml"); jetty.copyWebapp("foo-webapp-1.war","foo.war"); } diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java index 17ffd94b9f..6008c5aa44 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderRuntimeUpdatesTest.java @@ -112,7 +112,7 @@ public class ScanningAppProviderRuntimeUpdatesTest public void testAfterStartupContext() throws IOException { jetty.copyWebapp("foo-webapp-1.war","foo.war"); - jetty.copyContext("foo.xml","foo.xml"); + jetty.copyWebapp("foo.xml","foo.xml"); waitForDirectoryScan(); waitForDirectoryScan(); @@ -127,14 +127,14 @@ public class ScanningAppProviderRuntimeUpdatesTest public void testAfterStartupThenRemoveContext() throws IOException { jetty.copyWebapp("foo-webapp-1.war","foo.war"); - jetty.copyContext("foo.xml","foo.xml"); + jetty.copyWebapp("foo.xml","foo.xml"); waitForDirectoryScan(); waitForDirectoryScan(); jetty.assertWebAppContextsExists("/foo"); - jetty.removeContext("foo.xml"); + jetty.removeWebapp("foo.xml"); waitForDirectoryScan(); waitForDirectoryScan(); @@ -155,7 +155,7 @@ public class ScanningAppProviderRuntimeUpdatesTest jetty.copyWebapp("foo-webapp-1.war","foo.war"); - jetty.copyContext("foo.xml","foo.xml"); + jetty.copyWebapp("foo.xml","foo.xml"); waitForDirectoryScan(); waitForDirectoryScan(); @@ -167,7 +167,7 @@ public class ScanningAppProviderRuntimeUpdatesTest waitForDirectoryScan(); //System.err.println("Updating war files"); - jetty.copyContext("foo.xml","foo.xml"); // essentially "touch" the context xml + jetty.copyWebapp("foo.xml","foo.xml"); // essentially "touch" the context xml jetty.copyWebapp("foo-webapp-2.war","foo.war"); // This should result in the existing foo.war being replaced with the new foo.war diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java index a468771358..c117332248 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/ScanningAppProviderStartupTest.java @@ -42,7 +42,7 @@ public class ScanningAppProviderStartupTest jetty.addConfiguration("jetty-deploymgr-contexts.xml"); // Setup initial context - jetty.copyContext("foo.xml","foo.xml"); + jetty.copyWebapp("foo.xml","foo.xml"); jetty.copyWebapp("foo-webapp-1.war","foo.war"); // Should not throw an Exception diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java index 65fbf73187..8e31c17786 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/providers/WebAppProviderTest.java @@ -43,7 +43,6 @@ public class WebAppProviderTest jetty.addConfiguration("jetty-deploy-wars.xml"); // Setup initial context - jetty.copyContext("foo.xml","foo.xml"); jetty.copyWebapp("foo-webapp-1.war","foo.war"); // Should not throw an Exception diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java index 2afd52841f..5bb3c2a46d 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/test/XmlConfiguredJetty.java @@ -87,13 +87,6 @@ public class XmlConfiguredJetty IO.copyFile(MavenTestingUtils.getTestResourceFile("etc/realm.properties"),new File(etcDir,"realm.properties")); IO.copyFile(MavenTestingUtils.getTestResourceFile("etc/webdefault.xml"),new File(etcDir,"webdefault.xml")); - File contextsDir = new File(_jettyHome,"contexts"); - if (contextsDir.exists()) - { - deleteContents(contextsDir); - } - contextsDir.mkdirs(); - File webappsDir = new File(_jettyHome,"webapps"); if (webappsDir.exists()) { @@ -182,7 +175,7 @@ public class XmlConfiguredJetty public void assertResponseContains(String path, String needle) throws IOException { - System.err.println("Issuing request to " + path); + // System.err.println("Issuing request to " + path); String content = getResponse(path); Assert.assertTrue("Content should contain <" + needle + ">, instead got <" + content + ">",content.contains(needle)); } @@ -220,18 +213,6 @@ public class XmlConfiguredJetty } } - public void copyContext(String srcName, String destName) throws IOException - { - System.err.printf("Copying Context: %s -> %s%n",srcName,destName); - File srcDir = MavenTestingUtils.getTestResourceDir("contexts"); - File destDir = new File(_jettyHome,"contexts"); - - File srcFile = new File(srcDir,srcName); - File destFile = new File(destDir,destName); - - copyFile("Context",srcFile,destFile); - } - private void copyFile(String type, File srcFile, File destFile) throws IOException { PathAssert.assertFileExists(type + " File",srcFile); @@ -255,7 +236,7 @@ public class XmlConfiguredJetty private void deleteContents(File dir) { - System.err.printf("Delete (dir) %s/%n",dir); + // System.err.printf("Delete (dir) %s/%n",dir); if (!dir.exists()) { return; @@ -319,7 +300,6 @@ public class XmlConfiguredJetty { List<WebAppContext> contexts = new ArrayList<>(); HandlerCollection handlers = (HandlerCollection)_server.getHandler(); - System.err.println(_server.dump()); Handler children[] = handlers.getChildHandlers(); for (Handler handler : children) @@ -379,13 +359,13 @@ public class XmlConfiguredJetty this._server.setStopTimeout(10); } - public void removeContext(String name) + public void removeWebapp(String name) { - File destDir = new File(_jettyHome,"contexts"); + File destDir = new File(_jettyHome,"webapps"); File contextFile = new File(destDir,name); if (contextFile.exists()) { - Assert.assertTrue("Delete of Context file: " + contextFile.getAbsolutePath(),contextFile.delete()); + Assert.assertTrue("Delete of Webapp file: " + contextFile.getAbsolutePath(),contextFile.delete()); } } diff --git a/jetty-deploy/src/test/resources/binding-test-contexts-1.xml b/jetty-deploy/src/test/resources/binding-test-contexts-1.xml index 38979a28ab..1614056f43 100644 --- a/jetty-deploy/src/test/resources/binding-test-contexts-1.xml +++ b/jetty-deploy/src/test/resources/binding-test-contexts-1.xml @@ -46,8 +46,8 @@ <Set name="appProviders"> <Array type="org.eclipse.jetty.deploy.AppProvider"> <Item> - <New class="org.eclipse.jetty.deploy.providers.ContextProvider"> - <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/contexts</Set> + <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> + <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set> <Set name="scanInterval">1</Set> <Set name="configurationManager"> <New class="org.eclipse.jetty.deploy.FileConfigurationManager"> @@ -58,13 +58,6 @@ </Set> </New> </Item> - <Item> - <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> - <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set> - <Set name="scanInterval">1</Set> - <Set name="contextXmlDir"><SystemProperty name="jetty.home" />/contexts</Set> - </New> - </Item> </Array> </Set> </New> diff --git a/jetty-deploy/src/test/resources/jetty-deploy-wars.xml b/jetty-deploy/src/test/resources/jetty-deploy-wars.xml index 859887b555..8ef3a1792f 100644 --- a/jetty-deploy/src/test/resources/jetty-deploy-wars.xml +++ b/jetty-deploy/src/test/resources/jetty-deploy-wars.xml @@ -17,7 +17,7 @@ <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set> <Set name="scanInterval">1</Set> - <Set name="tempDir"><Property name="jetty.home" default="target" />/workish</Set> + <Set name="tempDir"><Property name="jetty.home" default="target" />/workish</Set> </New> </Item> </Array> diff --git a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml index 9442aab418..acf69585ff 100644 --- a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml +++ b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml @@ -13,9 +13,9 @@ <Set name="appProviders"> <Array type="org.eclipse.jetty.deploy.AppProvider"> <Item> - <New class="org.eclipse.jetty.deploy.providers.ContextProvider"> - <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/contexts</Set> - <Set name="scanInterval">1</Set> + <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> + <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set> + <Set name="scanInterval">1</Set> <Set name="configurationManager"> <New class="org.eclipse.jetty.deploy.FileConfigurationManager"> <Set name="file"> @@ -25,13 +25,6 @@ </Set> </New> </Item> - <Item> - <New class="org.eclipse.jetty.deploy.providers.WebAppProvider"> - <Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set> - <Set name="scanInterval">1</Set> - <Set name="contextXmlDir"><SystemProperty name="jetty.home" />/contexts</Set> - </New> - </Item> </Array> </Set> </New> diff --git a/jetty-deploy/src/test/resources/jetty-logging.properties b/jetty-deploy/src/test/resources/jetty-logging.properties index 9bad879708..9d7bbe4489 100644 --- a/jetty-deploy/src/test/resources/jetty-logging.properties +++ b/jetty-deploy/src/test/resources/jetty-logging.properties @@ -1,3 +1,3 @@ org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog org.eclipse.jetty.deploy.LEVEL=WARN - +org.eclipse.jetty.util.Scanner=WARN diff --git a/jetty-deploy/src/test/resources/contexts/foo.xml b/jetty-deploy/src/test/resources/webapps/foo.xml index 4c730f0b49..4c730f0b49 100644 --- a/jetty-deploy/src/test/resources/contexts/foo.xml +++ b/jetty-deploy/src/test/resources/webapps/foo.xml |