@Override public Location manage(Location loc) { if (isInitialManagementContextReal()) { return initialManagementContext.getLocationManager().manage(loc); } else { throw new IllegalStateException("Non-deployment context "+this+" is not valid for this operation: cannot manage "+loc); } }
/** * Registers the given location (and all its children) with the management context. * @throws IllegalStateException if the parent location is not already managed * * @since 0.6.0 (added only for backwards compatibility, where locations are being created directly). * @deprecated in 0.6.0; use {@link LocationManager#createLocation(LocationSpec)} instead. */ public static void manage(Location loc, ManagementContext managementContext) { if (!managementContext.getLocationManager().isManaged(loc)) { log.warn("Deprecated use of unmanaged location ("+loc+"); will be managed automatically now but not supported in future versions"); // FIXME this occurs MOST OF THE TIME e.g. including BrooklynLauncher.location(locationString) // not sure what is the recommend way to convert from locationString to locationSpec, or the API we want to expose; // deprecating some of the LocationRegistry methods seems sensible? log.debug("Stack trace for location of: Deprecated use of unmanaged location; will be managed automatically now but not supported in future versions", new Exception("TRACE for: Deprecated use of unmanaged location")); managementContext.getLocationManager().manage(loc); } }
public void addChild(Location child) { // Previously, setParent delegated to addChildLocation and we sometimes ended up with // duplicate entries here. Instead this now uses a similar scheme to // AbstractLocation.setParent/addChild (with any weaknesses for distribution that such a // scheme might have...). // // We continue to use a list to allow identical-looking locations, but they must be different // instances. synchronized (childLocations) { for (Location contender : childLocations) { if (contender == child) { // don't re-add; no-op return; } } childLocations.add(child); } child.setParent(this); if (isManaged()) { managementContext.getLocationManager().manage(child); } }
managementContext.getLocationManager().manage(location);