List<InstallMetaData> uninstalls = metaData.getUninstalls();
if (uninstalls != null && uninstalls.isEmpty() == false)
{
for (int i = index; i >= 0; --i)
{
InstallMetaData uninstall = uninstalls.get(i);
if (getState().equals(uninstall.getState()))
{
ControllerContext target = context;
if (uninstall.getBean() != null)
{
target = controller.getContext(uninstall.getBean(), uninstall.getDependentState());
if (target == null)
{
log.warn("Ignoring uninstall action on target in incorrect state " + uninstall.getBean());
continue;
}
}
if (target instanceof InvokeDispatchContext)
{
ClassLoader previous = null;
try
{
previous = SecurityActions.setContextClassLoader(context);
InvokeDispatchHelper.invoke(
configurator,
target.getTarget(),
(InvokeDispatchContext)target,
uninstall.getMethodName(),
uninstall.getParameters()
);
}
catch (Throwable t)
{
log.warn("Ignoring uninstall action on target " + uninstall, t);
}
finally
{
if (previous != null)
SecurityActions.resetContextClassLoader(previous);
}
}
else
{
log.warn("Cannot uninstall, context " + target + " does not implement InvokeDispatchContext for " + uninstall.getBean());
}
}
}
}
}