Issue #4003 Cleanup quickstart

* cleanup from review

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-09-18 16:29:19 +10:00
parent 289c70ec9b
commit 6a32fb0ca5
3 changed files with 39 additions and 18 deletions

View File

@ -42,10 +42,10 @@ import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection; import org.eclipse.jetty.util.resource.ResourceCollection;
import org.eclipse.jetty.webapp.Configuration; import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.Configurations;
import org.eclipse.jetty.webapp.MetaInfConfiguration; import org.eclipse.jetty.webapp.MetaInfConfiguration;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
@ -310,24 +310,29 @@ public class JettyWebAppContext extends WebAppContext
} }
@Override @Override
protected void loadConfigurations() protected Configurations newConfigurations()
{
Configurations configurations = super.newConfigurations();
if (getJettyEnvXml() != null)
{ {
super.loadConfigurations();
try try
{ {
// inject configurations with config from maven plugin // inject configurations with config from maven plugin
for (Configuration c : getConfigurations()) for (Configuration c : configurations)
{ {
if (c instanceof EnvConfiguration && getJettyEnvXml() != null) if (c instanceof EnvConfiguration)
((EnvConfiguration)c).setJettyEnvResource(new PathResource(new File(getJettyEnvXml()))); ((EnvConfiguration)c).setJettyEnvResource(Resource.newResource(getJettyEnvXml()));
} }
} }
catch (Exception e) catch (IOException e)
{ {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
return configurations;
}
@Override @Override
public void doStop() throws Exception public void doStop() throws Exception
{ {

View File

@ -279,6 +279,27 @@ public class Configurations extends AbstractList<Configuration> implements Dumpa
} }
} }
public <T> T get(Class<? extends T> configClass)
{
for (Configuration configuration : _configurations)
{
if (configClass.isAssignableFrom(configuration.getClass()))
return (T)configuration;
}
return null;
}
public <T> List<T> getConfigurations(Class<? extends T> configClass)
{
List<T> list = new ArrayList<>();
for (Configuration configuration : _configurations)
{
if (configClass.isAssignableFrom(configuration.getClass()))
list.add((T)configuration);
}
return list;
}
public void clear() public void clear()
{ {
_configurations.clear(); _configurations.clear();

View File

@ -997,12 +997,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
public <T> T getConfiguration(Class<? extends T> configClass) public <T> T getConfiguration(Class<? extends T> configClass)
{ {
loadConfigurations(); loadConfigurations();
for (Configuration configuration : _configurations) return _configurations.get(configClass);
{
if (configClass.isAssignableFrom(configuration.getClass()))
return (T)configuration;
}
return null;
} }
public void removeConfiguration(Configuration... configurations) public void removeConfiguration(Configuration... configurations)