399967 Destroyables destroyed on undeploy and shutdown hook

This commit is contained in:
Greg Wilkins 2013-03-08 09:48:58 +11:00
parent 778ee1411b
commit 97de9fc6be
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); private static final Logger LOG = Log.getLogger(StandardUndeployer.class);
@Override
public String[] getBindingTargets() public String[] getBindingTargets()
{ {
return new String[] return new String[]
{ "undeploying" }; { "undeploying" };
} }
@Override
public void processBinding(Node node, App app) throws Exception public void processBinding(Node node, App app) throws Exception
{ {
ContextHandler handler = app.getContextHandler(); ContextHandler handler = app.getContextHandler();

View File

@ -447,7 +447,6 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
{ {
if (_beans.remove(bean)) if (_beans.remove(bean))
{ {
boolean managed=bean.isManaged();
unmanage(bean); unmanage(bean);
for (Container.Listener l:_listeners) for (Container.Listener l:_listeners)
@ -469,18 +468,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 true;
} }
return false; return false;

View File

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