public Task<?> destroy(final Application application) { return mgmt.getExecutionManager().submit(new Runnable() { @Override public void run() { ((EntityInternal)application).destroy(); mgmt.getEntityManager().unmanage(application); } }); }
@Override public T get() { return task.asTask().getUnchecked(); } };
@Override public Response canManageEntity(Entity entity) { return (entityManagementAllowed ? Response.allowed() : Response.disallowed("entity management disabled")); } }
@Override public Entity getEntity(String id) { if (isInitialManagementContextReal()) { return initialManagementContext.getEntityManager().getEntity(id); } else { return null; } }
@Override public void run() { ((EntityInternal)application).destroy(); mgmt.getEntityManager().unmanage(application); } });
/** blocks for the task to be completed * <p> * needed in any context where subsequent commands assume the task has completed. * not needed in a context where the task is simply being built up and queued. * <p> * throws if there are any errors */ public void andWaitForSuccess() { task.getUnchecked(); } }
protected final <T extends Entity> T createEntity(EntitySpec<T> spec) { checkDuringManage(); EntityManager entityManager = managementContext.getEntityManager(); return entityManager.createEntity(spec); }
@Override public int compare(Task<?> t1, Task<?> t2) { long end1 = t1.isDone() ? t1.getEndTimeUtc() : Long.MAX_VALUE; long end2 = t2.isDone() ? t2.getEndTimeUtc() : Long.MAX_VALUE; return (end1 < end2) ? -1 : ((end1 == end2) ? 0 : 1); } });
@Override public Location getLocation(String id) { if (isInitialManagementContextReal()) { return initialManagementContext.getLocationManager().getLocation(id); } else { return null; } }
public LocationRegistry getLocationRegistry() { return mgmt.getLocationRegistry(); }
protected void assertNotYetManaged() { if (!inConstruction && (managementContext != null && managementContext.getLocationManager().isManaged(this))) { LOG.warn("Configuration being made to {} after deployment; may not be supported in future versions", this); } //throw new IllegalStateException("Cannot set configuration "+key+" on active location "+this) }
private static Task<?>[] asTasks(TaskAdaptable<?> ...tasks) { Task<?>[] result = new Task<?>[tasks.length]; for (int i=0; i<tasks.length; i++) result[i] = tasks[i].asTask(); return result; }
/** @see SubscriptionManager#publish(SensorEvent) */ @Override public <T> void publish(SensorEvent<T> event) { manager.publish(event); }
/** Return the subscriptions associated with this context */ @Override public Set<SubscriptionHandle> getSubscriptions() { return manager.getSubscriptionsForSubscriber(subscriber); }
public static Response disallowed(String msg) { return new Response(false, msg); }
/** submits the given task if needed, and gets the result (unchecked) * only permitted in a queueing context (ie a DST main job) */ // things get really confusing if you try to queueInTaskHierarchy -- easy to cause deadlocks! public static <T> T get(TaskAdaptable<T> t) { return queueIfNeeded(t).asTask().getUnchecked(); }
@Override public void run() { ((EntityInternal)application).destroy(); mgmt.getEntityManager().unmanage(application); } });
@Override public Response canProvisionLocation(Location provisioner) { return (locationProvisioningAllowed ? Response.allowed() : Response.disallowed("location provisioning disabled")); }
private TaskQueueingResult(TaskAdaptable<T> task, boolean wasQueued) { this.task = task.asTask(); this.wasQueued = wasQueued; } @Override
@Override public Response canManageLocation(Location loc) { return (locationManagementAllowed ? Response.allowed() : Response.disallowed("location management disabled")); }