Issue #4003 Cleanup quickstart
* cleanup from review Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
289c70ec9b
commit
6a32fb0ca5
|
@ -42,10 +42,10 @@ import org.eclipse.jetty.util.StringUtil;
|
|||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
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.ResourceCollection;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.Configurations;
|
||||
import org.eclipse.jetty.webapp.MetaInfConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
|
@ -310,22 +310,27 @@ public class JettyWebAppContext extends WebAppContext
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void loadConfigurations()
|
||||
protected Configurations newConfigurations()
|
||||
{
|
||||
super.loadConfigurations();
|
||||
try
|
||||
Configurations configurations = super.newConfigurations();
|
||||
if (getJettyEnvXml() != null)
|
||||
{
|
||||
// inject configurations with config from maven plugin
|
||||
for (Configuration c : getConfigurations())
|
||||
try
|
||||
{
|
||||
if (c instanceof EnvConfiguration && getJettyEnvXml() != null)
|
||||
((EnvConfiguration)c).setJettyEnvResource(new PathResource(new File(getJettyEnvXml())));
|
||||
// inject configurations with config from maven plugin
|
||||
for (Configuration c : configurations)
|
||||
{
|
||||
if (c instanceof EnvConfiguration)
|
||||
((EnvConfiguration)c).setJettyEnvResource(Resource.newResource(getJettyEnvXml()));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return configurations;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
_configurations.clear();
|
||||
|
|
|
@ -997,12 +997,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
public <T> T getConfiguration(Class<? extends T> configClass)
|
||||
{
|
||||
loadConfigurations();
|
||||
for (Configuration configuration : _configurations)
|
||||
{
|
||||
if (configClass.isAssignableFrom(configuration.getClass()))
|
||||
return (T)configuration;
|
||||
}
|
||||
return null;
|
||||
return _configurations.get(configClass);
|
||||
}
|
||||
|
||||
public void removeConfiguration(Configuration... configurations)
|
||||
|
|
Loading…
Reference in New Issue