/** * Constructs a new location, passing to its constructor the location id and all of memento.getFlags(). */ protected Location newLocation(String locationId, String locationType) { Class<? extends Location> locationClazz = loadClass(locationType, Location.class); if (InternalFactory.isNewStyle(locationClazz)) { // Not using loationManager.createLocation(LocationSpec) because don't want init() to be called // TODO Need to rationalise this to move code into methods of InternalLocationFactory. // But note that we'll change all locations to be entities at some point! // See same code approach used in #newEntity(EntityMemento, Reflections) InternalLocationFactory locationFactory = managementContext.getLocationFactory(); Location location = locationFactory.constructLocation(locationClazz); FlagUtils.setFieldsFromFlags(ImmutableMap.of("id", locationId), location); managementContext.prePreManage(location); ((AbstractLocation)location).setManagementContext(managementContext); return location; } else { LOG.warn("Deprecated rebind of location without no-arg constructor; " + "this may not be supported in future versions: id=" + locationId + "; type="+locationType); // There are several possibilities for the constructor; find one that works. // Prefer passing in the flags because required for Application to set the management context // TODO Feels very hacky! Map<String,?> flags = MutableMap.of("id", locationId, "deferConstructionChecks", true); return invokeConstructor(reflections, locationClazz, new Object[] {flags}); } // note 'used' config keys get marked in BasicLocationRebindSupport }
location.setManagementContext(managementContext); location.configure(ConfigBag.newInstance().putAll(spec.getFlags()).putAll(spec.getConfig()).getAllConfig());
it.setManagementContext(managementContext); if (mode.isPrimary()) { it.onManagementStarted();