@Override public void run() { ((EntityInternal)application).destroy(); mgmt.getEntityManager().unmanage(application); } });
/** * Attempts to stop, destroy, and unmanage the given entity. * <p> * Actual actions performed will depend on the entity type and its current state. */ public static void destroy(Entity e) { if (isManaged(e)) { if (isReadOnly(e)) { unmanage(e); log.debug("destroyed and unmanaged read-only copy of "+e); } else { if (e instanceof Startable) Entities.invokeEffector(e, e, Startable.STOP).getUnchecked(); // if destroying gracefully we might also want to do this (currently gets done by GC after unmanage, // which is good enough for leaks, but not sure if that's ideal for subscriptions etc) // ((LocalEntityManager)e.getApplication().getManagementContext().getEntityManager()).stopTasks(e, null); if (e instanceof EntityInternal) ((EntityInternal)e).destroy(); unmanage(e); log.debug("destroyed and unmanaged "+e+"; mgmt now "+ (e.getApplicationId()==null ? "(no app)" : e.getApplication().getManagementContext())+" - managed? "+isManaged(e)); } } else { log.debug("skipping destroy of "+e+": not managed"); } }