Merge remote-tracking branch 'origin/jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
971044fe31
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||
|
||||
<Configure id="Stop" class="org.eclipse.jetty.util.component.StopLifeCycle">
|
||||
<Arg><Ref refid="Server"/></Arg>
|
||||
</Configure>
|
|
@ -0,0 +1,72 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2017 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.util.component;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* A LifeCycle that when started will stop another LifeCycle
|
||||
*/
|
||||
public class StopLifeCycle extends AbstractLifeCycle implements LifeCycle.Listener
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(StopLifeCycle.class);
|
||||
|
||||
private final LifeCycle _lifecycle;
|
||||
|
||||
public StopLifeCycle(LifeCycle lifecycle)
|
||||
{
|
||||
_lifecycle = lifecycle;
|
||||
addLifeCycleListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStarting(LifeCycle lifecycle)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStarted(LifeCycle lifecycle)
|
||||
{
|
||||
try
|
||||
{
|
||||
_lifecycle.stop();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleFailure(LifeCycle lifecycle, Throwable cause)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStopping(LifeCycle lifecycle)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStopped(LifeCycle lifecycle)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ import java.security.AccessController;
|
|||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -1479,7 +1480,7 @@ public class XmlConfiguration
|
|||
|
||||
// For all arguments, parse XMLs
|
||||
XmlConfiguration last = null;
|
||||
Object[] obj = new Object[args.length];
|
||||
List<Object> objects = new ArrayList<>(args.length);
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
if (!args[i].toLowerCase(Locale.ENGLISH).endsWith(".properties") && (args[i].indexOf('=')<0))
|
||||
|
@ -1496,17 +1497,20 @@ public class XmlConfiguration
|
|||
}
|
||||
configuration.getProperties().putAll(props);
|
||||
}
|
||||
obj[i] = configuration.configure();
|
||||
|
||||
Object obj = configuration.configure();
|
||||
if (obj!=null && !objects.contains(obj))
|
||||
objects.add(obj);
|
||||
last = configuration;
|
||||
}
|
||||
}
|
||||
|
||||
// For all objects created by XmlConfigurations, start them if they are lifecycles.
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
if (obj[i] instanceof LifeCycle)
|
||||
for (Object obj : objects)
|
||||
{
|
||||
if (obj instanceof LifeCycle)
|
||||
{
|
||||
LifeCycle lc = (LifeCycle)obj[i];
|
||||
LifeCycle lc = (LifeCycle)obj;
|
||||
if (!lc.isRunning())
|
||||
lc.start();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue