@Override public void manage(Entity e) { getEntityManager().manage(e); }
@Deprecated @Override public void manage(Entity e) { getEntityManager().manage(e); }
/** * Starts managing the given (unmanaged) app, using the given management context. * * @see #startManagement(Entity) */ public static ManagementContext startManagement(Application app, ManagementContext mgmt) { if (isManaged(app)) { throw new IllegalStateException("Application "+app+" is already managed, so can't set brooklyn properties"); } mgmt.getEntityManager().manage(app); return mgmt; }
/** * Starts managing the given (unmanaged) app, setting the given brooklyn properties on the new * management context. * * @see #startManagement(Entity) */ public static ManagementContext startManagement(Application app, BrooklynProperties props) { if (isManaged(app)) { throw new IllegalStateException("Application "+app+" is already managed, so can't set brooklyn properties"); } ManagementContext mgmt = new LocalManagementContext(props); mgmt.getEntityManager().manage(app); return mgmt; }
public synchronized void attemptLegacyAutodeployment(String effectorName) { if (managementContext!=null) { log.warn("Autodeployment suggested but not required for "+entity+"."+effectorName); return; } if (entity instanceof Application) { log.warn("Autodeployment with new management context triggered for "+entity+"."+effectorName+" -- will not be supported in future. Explicit manage call required."); if (initialManagementContext != null) { initialManagementContext.getEntityManager().manage(entity); } else { Entities.startManagement(entity); } return; } if ("start".equals(effectorName)) { Entity e=entity; if (e.getParent()!=null && ((EntityInternal)e.getParent()).getManagementSupport().isDeployed()) { log.warn("Autodeployment in parent's management context triggered for "+entity+"."+effectorName+" -- will not be supported in future. Explicit manage call required."); ((EntityInternal)e.getParent()).getManagementContext().getEntityManager().manage(entity); return; } } log.warn("Autodeployment not available for "+entity+"."+effectorName); }
/** brings this entity under management, creating a local management context if necessary * (assuming root is an application). * returns existing management context if there is one (non-deployment), * or new local mgmt context if not, * or throwing exception if root is not an application * <p> * callers are recommended to use {@link #manage(Entity)} instead unless they know * a plain-vanilla non-root management context is sufficient (e.g. in tests) * <p> * this method may change, but is provided as a stop-gap to prevent ad-hoc things * being done in the code which are even more likely to break! */ public static ManagementContext startManagement(Entity e) { Entity o = e; Entity eum = e; //highest unmanaged ancestor while (o.getParent()!=null) { if (!isManaged(o)) eum = o; o = o.getParent(); } if (isManaged(o)) { ManagementContext mgmt = ((EntityInternal)o).getManagementContext(); mgmt.getEntityManager().manage(eum); return mgmt; } if (!(o instanceof Application)) throw new IllegalStateException("Can't manage "+e+" because it is not rooted at an application"); ManagementContext mgmt = new LocalManagementContext(); mgmt.getEntityManager().manage(o); return mgmt; }
/** brings this entity under management iff its ancestor is managed, returns true in that case; * otherwise returns false in the expectation that the ancestor will become managed, * or throws exception if it has no parent or a non-application root * (will throw if e is an Application; see also {@link #startManagement(Entity)} ) */ public static boolean manage(Entity e) { Entity o = e.getParent(); Entity eum = e; //highest unmanaged ancestor if (o==null) throw new IllegalStateException("Can't manage "+e+" because it is an orphan"); while (o.getParent()!=null) { if (!isManaged(o)) eum = o; o = o.getParent(); } if (isManaged(o)) { ((EntityInternal)o).getManagementContext().getEntityManager().manage(eum); return true; } if (!(o instanceof Application)) throw new IllegalStateException("Can't manage "+e+" because it is not rooted at an application"); return false; }