369214: HotSwapHandler uses AggregateLifeCycles.addBean()

This commit is contained in:
Thomas Becker 2012-01-20 19:27:00 +01:00
parent ab5592daf0
commit 9f68c6e6bf
1 changed files with 11 additions and 18 deletions

View File

@ -66,31 +66,26 @@ public class HotSwapHandler extends AbstractHandlerContainer
*/ */
public void setHandler(Handler handler) public void setHandler(Handler handler)
{ {
if (handler == null)
throw new IllegalArgumentException("Parameter handler is null.");
try try
{ {
Handler old_handler = _handler; Handler old_handler = _handler;
_handler = handler; _handler = handler;
if (handler != null) Server server = getServer();
{ handler.setServer(server);
handler.setServer(getServer()); addBean(handler);
if (isStarted())
handler.start();
}
if (getServer() != null) if (server != null)
getServer().getContainer().update(this,old_handler,handler,"handler"); server.getContainer().update(this,old_handler,handler,"handler");
// if there is an old handler and it was started, stop it // if there is an old handler and it was started, stop it
if (old_handler != null && isStarted()) if (old_handler != null)
{ {
old_handler.stop(); removeBean(old_handler);
} }
} }
catch (RuntimeException e)
{
throw e;
}
catch (Exception e) catch (Exception e)
{ {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -104,8 +99,6 @@ public class HotSwapHandler extends AbstractHandlerContainer
@Override @Override
protected void doStart() throws Exception protected void doStart() throws Exception
{ {
if (_handler != null)
_handler.start();
super.doStart(); super.doStart();
} }
@ -117,8 +110,6 @@ public class HotSwapHandler extends AbstractHandlerContainer
protected void doStop() throws Exception protected void doStop() throws Exception
{ {
super.doStop(); super.doStop();
if (_handler != null)
_handler.stop();
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -155,6 +146,8 @@ public class HotSwapHandler extends AbstractHandlerContainer
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@SuppressWarnings(
{ "rawtypes", "unchecked" })
@Override @Override
protected Object expandChildren(Object list, Class byClass) protected Object expandChildren(Object list, Class byClass)
{ {