399967 Destroyables destroyed on undeploy and shutdown hook

This commit is contained in:
Greg Wilkins 2013-03-08 09:48:58 +11:00
parent f714504acc
commit 4b58eae39b
3 changed files with 5 additions and 16 deletions

View File

@ -32,12 +32,14 @@ public class StandardUndeployer implements AppLifeCycle.Binding
{
private static final Logger LOG = Log.getLogger(StandardUndeployer.class);
@Override
public String[] getBindingTargets()
{
return new String[]
{ "undeploying" };
}
@Override
public void processBinding(Node node, App app) throws Exception
{
ContextHandler handler = app.getContextHandler();

View File

@ -452,7 +452,6 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
{
if (_beans.remove(bean))
{
boolean managed=bean.isManaged();
unmanage(bean);
for (Container.Listener l:_listeners)
@ -474,18 +473,6 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
}
}
if (managed && bean._bean instanceof Destroyable)
{
try
{
((Destroyable)bean._bean).destroy();
}
catch(Exception e)
{
LOG.warn(e);
}
}
return true;
}
return false;

View File

@ -118,17 +118,17 @@ public class ContainerLifeCycleTest
a0.destroy();
Assert.assertEquals(3,started.get());
Assert.assertEquals(2,stopped.get());
Assert.assertEquals(2,destroyed.get());
Assert.assertEquals(1,destroyed.get());
a1.stop();
Assert.assertEquals(3,started.get());
Assert.assertEquals(3,stopped.get());
Assert.assertEquals(2,destroyed.get());
Assert.assertEquals(1,destroyed.get());
a1.destroy();
Assert.assertEquals(3,started.get());
Assert.assertEquals(3,stopped.get());
Assert.assertEquals(3,destroyed.get());
Assert.assertEquals(2,destroyed.get());
}