/** * Adds the given entity as a child of the application being built. */ protected final <T extends Entity> T addChild(EntitySpec<T> spec) { checkDuringManage(); return addChild(createEntity(spec)); }
Constructor<?> constructor = clazz.getConstructor(); ApplicationBuilder appBuilder = (ApplicationBuilder) constructor.newInstance(); if (!Strings.isEmpty(name)) appBuilder.appDisplayName(name); if (entities.size() > 0) log.warn("Cannot supply additional entities when using an ApplicationBuilder; ignoring in spec {}", spec); appBuilder.configure( convertFlagsToKeys(appBuilder.getType(), configO) ); instance = appBuilder.manage(mgmt);
/** * Creates a new {@link ManagementContext}, and then builds and manages the application. * * @see #manage(ManagementContext) */ public final StartableApplication manage() { return manage(Entities.newManagementContext()); }
/** * Builds and manages the application, calling the user's {@link #doBuild()} method. * * @throws IllegalStateException If already managed, or if called during {@link #doBuild()}, or if * multiple concurrent calls */ public final StartableApplication manage(ManagementContext managementContext) { if (!inManage.compareAndSet(false, true)) { throw new IllegalStateException("Concurrent and re-entrant calls to manage() forbidden on "+this); } try { checkNotManaged(); this.app = managementContext.getEntityManager().createEntity(appSpec); this.managementContext = managementContext; doBuild(); Entities.startManagement(app, managementContext); managed = true; return app; } finally { inManage.set(false); } }
protected void configureRenderingMetadata(ApplicationSpec spec, ApplicationBuilder appBuilder) { appBuilder.configure(getRenderingConfigurationFor(spec.getType())); }
/** * 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); }
/** * @deprecated since 0.5.0-rc.1 (added in 0.5.0-M2); use {@link #addChild(EntitySpec)}, * for consistency with {@link AbstractEntity#addChild(EntitySpec)}. */ protected final <T extends Entity> T createChild(EntitySpec<T> spec) { return addChild(spec); }
Constructor<?> constructor = clazz.getConstructor(); ApplicationBuilder appBuilder = (ApplicationBuilder) constructor.newInstance(); if (!Strings.isEmpty(name)) appBuilder.appDisplayName(name); if (entities.size() > 0) log.warn("Cannot supply additional entities when using an ApplicationBuilder; ignoring in spec {}", spec); appBuilder.configure( convertFlagsToKeys(appBuilder.getType(), configO) ); configureRenderingMetadata(spec, appBuilder); instance = appBuilder.manage(mgmt);
StartableApplication app = appBuilder.manage(managementContext); apps.add(app);
protected final <T extends Entity> T createEntity(EntitySpec<T> spec) { checkDuringManage(); EntityManager entityManager = managementContext.getEntityManager(); return entityManager.createEntity(spec); }
/** * @deprecated since 0.5.0-rc.1 (added in 0.5.0-M2); use {@link #addChild(Map, Class)} */ protected final <T extends Entity> T createChild(Map<?,?> config, Class<T> type) { return addChild(config, type); }
protected final <T extends Entity> T addChild(Map<?,?> config, Class<T> type) { checkDuringManage(); EntitySpec<T> spec = EntitySpec.create(type).configure(config); return addChild(createEntity(spec)); }