/** * Adds the given entity as a child of the application being built. * To be called during {@link #doBuild()}. */ protected final <T extends Entity> T addChild(T entity) { checkDuringManage(); return app.addChild(entity); }
DynamicTasks.queue("launch", new Runnable() { public void run() { getEntity().setAttribute(Attributes.SERVICE_STATE, Lifecycle.STARTING); launch(); }}); DynamicTasks.queue("post-launch", new Runnable() { public void run() {
@Override public void refreshInheritedConfig() { if (getParent() != null) { configsInternal.setInheritedConfig(((EntityInternal)getParent()).getAllConfig()); } else { configsInternal.clearInheritedConfig(); } refreshInheritedConfigOfChildren(); }
@Override public void onManagementStarted() { super.onManagementStarted(); Lifecycle state = getAttribute(SERVICE_STATE); if (state != null && state != Lifecycle.CREATED) { postRebind(); } }
/** * Creates a new {@link ManagementContext}, and then builds and manages the application. * * @see #manage(ManagementContext) */ public final StartableApplication manage() { return manage(Entities.newManagementContext()); }
DynamicTasks.queue("post-restart", new Runnable() { public void run() { postStartCustom(); if (entity().getAttribute(Attributes.SERVICE_STATE) == Lifecycle.STARTING) entity().setAttribute(Attributes.SERVICE_STATE, Lifecycle.RUNNING); }}); }
public static Map<String, ConfigKey<?>> getDefinedConfigKeys(Class<? extends Entity> entityClass) { return getDefinedEntityType(entityClass).getConfigKeys(); } @SuppressWarnings("unchecked")
public static Map<String, Sensor<?>> getDefinedSensors(Class<? extends Entity> entityClass) { return getDefinedEntityType(entityClass).getSensors(); } @SuppressWarnings("unchecked")
@Override public boolean removeChild(Entity child) { boolean result = super.removeChild(child); if (getConfig(CHILDREN_AS_MEMBERS)) { removeMember(child); } return result; } }
@Override public void init() { super.init(); setAttribute(Changeable.GROUP_SIZE, 0); }
public static <T> Supplier<T> attributeSupplier(final EntityAndAttribute<T> tuple) { return Entities.attributeSupplier(tuple.getEntity(), tuple.getAttribute()); }
@Override public void init() { super.init(); setAttribute(RUNNING, true); }
void refreshInheritedConfigOfChildren() { for (Entity it : getChildren()) { ((EntityInternal)it).refreshInheritedConfig(); } }
@Override public void onManagementStopped() { super.onManagementStopped(); recordApplicationEvent(Lifecycle.DESTROYED); }
@Override protected Map<String, Object> obtainProvisioningFlags(final MachineProvisioningLocation<?> location) { return entity().obtainProvisioningFlags(location); }
/** convenience to create an effector supplying a closure; annotations are preferred, * and subclass here would be failback, but this is offered as * workaround for bug GROOVY-5122, as discussed in test class CanSayHi */ public static <I,T> ExplicitEffector<I,T> create(String name, Class<T> type, List<ParameterType<?>> parameters, String description, Closure body) { return new ExplicitEffectorFromClosure(name, type, parameters, description, body); }