本文整理了Java中org.apache.brooklyn.api.entity.Entity.getApplication()
方法的一些代码示例,展示了Entity.getApplication()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getApplication()
方法的具体详情如下:
包路径:org.apache.brooklyn.api.entity.Entity
类名称:Entity
方法名:getApplication
暂无
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-docker
@Override
public Application apply(Entity input) {
return input.getApplication();
}
}));
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-mesos
@Override
public String apply(@Nullable Entity input) {
return input.getApplication().getDisplayName() + ":" + input.getApplicationId();
}
})
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-mesos
@Override
public Application apply(Entity input) { return input.getApplication(); }
}));
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Override
public String apply(@Nullable Entity input) {
return input.getApplication().getDisplayName() + ":" + input.getApplicationId();
}
})
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Override
public Application apply(Entity input) {
return input.getApplication();
}
}));
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Override
protected synchronized void setApplication(Application app) {
if (app.getId().equals(getId())) {
application = getProxy()!=null ? (Application)getProxy() : app;
} else {
application = app;
// Alex, Mar 2013: added some checks;
// i *think* these conditions should not happen,
// and so should throw but don't want to break things (yet)
if (getParent()==null) {
log.warn("Setting application of "+this+" to "+app+", but "+this+" is not parented");
} else if (getParent().getApplicationId().equals(app.getParent())) {
log.warn("Setting application of "+this+" to "+app+", but parent "+getParent()+" has different app "+getParent().getApplication());
}
}
super.setApplication(app);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-rest-resources
private Application findTopLevelApplication(Entity e) {
// For nested apps, e.getApplication() can return its direct parent-app rather than the root app
// (particularly if e.getApplication() was called before the parent-app was wired up to its parent,
// because that call causes the application to be cached).
// Therefore we continue to walk the hierarchy until we find an "orphaned" application at the top.
Application app = e.getApplication();
while (app != null && !app.equals(app.getApplication())) {
app = app.getApplication();
}
return app;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* Attempts to stop, destroy, and unmanage the given entity.
* <p>
* Actual actions performed will depend on the entity type and its current state.
*/
public static void destroy(Entity e) {
if (isManaged(e)) {
if (isReadOnly(e)) {
unmanage(e);
log.debug("destroyed and unmanaged read-only copy of "+e);
} else {
if (e instanceof Startable) Entities.invokeEffector(e, e, Startable.STOP).getUnchecked();
// if destroying gracefully we might also want to do this (currently gets done by GC after unmanage,
// which is good enough for leaks, but not sure if that's ideal for subscriptions etc)
// ((LocalEntityManager)e.getApplication().getManagementContext().getEntityManager()).stopTasks(e, null);
if (e instanceof EntityInternal) ((EntityInternal)e).destroy();
unmanage(e);
log.debug("destroyed and unmanaged "+e+"; mgmt now "+
(e.getApplicationId()==null ? "(no app)" : e.getApplication().getManagementContext())+" - managed? "+isManaged(e));
}
} else {
log.debug("skipping destroy of "+e+": not managed");
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testSetParentInConstructorArgument() {
Entity e = new AbstractEntity(app) {};
assertEquals(e.getParent(), app);
assertEqualsIgnoringOrder(app.getChildren(), ImmutableList.of(e));
assertEquals(e.getApplication(), app);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Override
public Application getApplication() {
if (application!=null) {
if (application.getId().equals(getId()))
return (Application) getProxyIfAvailable();
return application;
}
if (getParent()==null) return (Application)getProxyIfAvailable();
return getParent().getApplication();
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* Returns the application, looking it up if not yet known (registering if necessary)
*/
@Override
public Application getApplication() {
if (application != null) return application;
Entity parent = getParent();
Application app = (parent != null) ? parent.getApplication() : null;
if (app != null) {
if (getManagementSupport().isFullyManaged())
// only do this once fully managed, in case root app becomes parented
setApplication(app);
}
return app;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Override public void run() {
Task<?> entityTask = Iterables.getOnlyElement(entity.getApplication().getManagementContext().getExecutionManager().getTasksWithAllTags(
ImmutableList.of(BrooklynTaskTags.EFFECTOR_TAG, BrooklynTaskTags.tagForContextEntity(entity))));
String blockingDetails = getBlockingDetails(entityTask);
assertTrue(blockingDetails.contains(blockingDetailsSnippet));
}});
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testSetOwnerInConstructorMap() {
Entity e = new AbstractEntity(MutableMap.of("owner", app)) {};
assertEquals(e.getParent(), app);
assertEqualsIgnoringOrder(app.getChildren(), ImmutableList.of(e));
assertEquals(e.getApplication(), app);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testCreatesEntity() throws Exception {
EntitySpec<TestApplication> spec = EntitySpec.create(TestApplication.class);
TestApplicationImpl app = (TestApplicationImpl) factory.createEntity(spec, Optional.absent());
Entity proxy = app.getProxy();
assertTrue(proxy instanceof Application, "proxy="+app);
assertFalse(proxy instanceof TestApplicationImpl, "proxy="+app);
assertEquals(proxy.getParent(), null);
assertSame(proxy.getApplication(), proxy);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testDslTemplateRebind() throws Exception {
Entity testEntity = entityWithTemplatedString();
Application app2 = rebind(testEntity.getApplication());
Entity e2 = Iterables.getOnlyElement(app2.getChildren());
Assert.assertEquals(getConfigInTask(e2, TestEntity.CONF_NAME), "hello world");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/** adds entities from the given yaml, under the given parent; but does not start them */
public static List<Entity> addChildrenUnstarted(final Entity parent, String yaml) {
log.debug("Creating child of "+parent+" from yaml:\n{}", yaml);
ManagementContext mgmt = parent.getApplication().getManagementContext();
EntitySpec<? extends Application> specA = createEntitySpecForApplication(mgmt, yaml);
// see whether we can promote children
List<EntitySpec<?>> specs = MutableList.of();
if (!canUnwrapEntity(specA)) {
// if not promoting, set a nice name if needed
if (Strings.isEmpty(specA.getDisplayName())) {
int size = specA.getChildren().size();
String childrenCountString = size+" "+(size!=1 ? "children" : "child");
specA.displayName("Dynamically added "+childrenCountString);
}
}
specs.add(unwrapEntity(specA));
final List<Entity> children = MutableList.of();
for (EntitySpec<?> spec: specs) {
Entity child = parent.addChild(spec);
children.add(child);
}
return children;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testSetParentInSetterMethod() {
Entity e = mgmt.getEntityManager().createEntity(EntitySpec.create(TestEntity.class));
e.setParent(app);
assertEquals(e.getParent(), app);
assertEqualsIgnoringOrder(app.getChildren(), ImmutableList.of(e));
assertEquals(e.getApplication(), app);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testAddChild() {
Entity e = mgmt.getEntityManager().createEntity(EntitySpec.create(TestEntity.class));
app.addChild(e);
assertEquals(e.getParent(), app);
assertEqualsIgnoringOrder(app.getChildren(), ImmutableList.of(e));
assertEquals(e.getApplication(), app);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testCatalogParameterFromSuperYamlTypeInCluster() throws Exception {
addCatalogItems( loadYaml("config-nested-test.bom") );
Entity cluster = makeBlueprint("services: [ { type: test-cluster-with-map-parameter } ]");
Entities.dumpInfo(cluster.getApplication());
Entity parentInCluster = Iterables.getOnlyElement( ((DynamicCluster)cluster).getMembers() );
Entity target = Iterables.getOnlyElement(parentInCluster.getChildren());
checkEntity( target, false );
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-rest-resources
/** finds the entity indicated by the given ID or name
* <p>
* prefers ID based lookup in which case appId is optional, and if supplied will be enforced.
* optionally the name can be supplied, for cases when paths should work across versions,
* in which case names will be searched recursively (and the application is required).
*
* @throws 404 or 412 (unless input is null in which case output is null) */
public Entity getEntity(String application, String entity) {
if (entity==null) return null;
Application app = application!=null ? getApplication(application) : null;
Entity e = mgmt.getEntityManager().getEntity(entity);
if (e!=null) {
if (!Entitlements.isEntitled(mgmt.getEntitlementManager(), Entitlements.SEE_ENTITY, e)) {
throw WebResourceUtils.notFound("Cannot find entity '%s': no known ID and application not supplied for searching", entity);
}
if (app==null || app.equals(findTopLevelApplication(e))) return e;
throw WebResourceUtils.preconditionFailed("Application '%s' specified does not match application '%s' to which entity '%s' (%s) is associated",
application, e.getApplication()==null ? null : e.getApplication().getId(), entity, e);
}
if (application==null)
throw WebResourceUtils.notFound("Cannot find entity '%s': no known ID and application not supplied for searching", entity);
assert app!=null : "null app should not be returned from getApplication";
e = searchForEntityNamed(app, entity);
if (e!=null) return e;
throw WebResourceUtils.notFound("Cannot find entity '%s' in application '%s' (%s)", entity, application, app);
}
内容来源于网络,如有侵权,请联系作者删除!