/** * Undeploy object from the given registry * * @param reg Registry instance * @param aspectObj Aspect object */ public void $undeployFrom(AspectRegistryIfc reg, Object aspectObj) { if (reg == null) { /* tolerate non crosscutting objects */ return; } AspectContainerIfc curCont = reg.$getAspectContainer(); AspectContainerIfc myCont = null; if (curCont == null) { return; // ignore } else if (curCont.$getContainerType() == getContId()) { myCont = curCont; undeployFromContainer(myCont, aspectObj, reg); if (myCont.isEmpty()) { reg.$setAspectContainer(null); reg.$setSingleAspect(null); } else { reg.$setSingleAspect(myCont.getSingleInstance()); } } else if (curCont.$getContainerType() == AspectContainerIfc.COMPOSITE_CONTAINER) { CompositeAspectContainer composite = (CompositeAspectContainer) curCont; myCont = composite.findContainer(getContId()); if (myCont != null) { undeployFromContainer(myCont, aspectObj, reg); if (myCont.isEmpty()) { composite.getList().remove(myCont); if (composite.getList().size() < 2) { reg.$setAspectContainer((AspectContainerIfc) composite.getList().get(0)); reg.$setSingleAspect(reg.$getAspectContainer().getSingleInstance()); } } } } }