Github user neykov commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/545#discussion_r25959597
--- Diff:
core/src/main/java/brooklyn/management/internal/EntityManagementUtils.java ---
@@ -82,41 +100,90 @@
return app;
}
- /** convenience for accessing camp */
- public static Maybe<CampPlatform> getCampPlatform(ManagementContext
mgmt) {
- return BrooklynServerConfig.getCampPlatform(mgmt);
- }
-
/** as {@link #createApplication(ManagementContext, EntitySpec)} but
for a YAML spec */
- public static <T extends Application> T
createUnstarted(ManagementContext mgmt, String yaml) {
- AssemblyTemplate at =
getCampPlatform(mgmt).get().pdp().registerDeploymentPlan( new
StringReader(yaml) );
- return createUnstarted(mgmt, at);
+ public static Application createUnstarted(ManagementContext mgmt,
String yaml) {
+ return createUnstarted(mgmt, new StringReader(yaml));
}
-
- /** as {@link #createApplication(ManagementContext, EntitySpec)} but
for an assembly template */
+
+ public static Application createUnstarted(ManagementContext mgmt,
Reader yaml) {
+ EntitySpec<? extends Application> spec = createEntitySpec(mgmt,
yaml);
+ return createUnstarted(mgmt, spec);
+ }
+
+ public static EntitySpec<? extends Application>
createEntitySpec(ManagementContext mgmt, String yaml) {
+ return createEntitySpec(mgmt, new StringReader(yaml));
+ }
+
+ public static EntitySpec<? extends Application>
createEntitySpec(ManagementContext mgmt, Reader yaml) {
+ BrooklynClassLoadingContext loader = createDefaultLoader(mgmt);
+ return createEntitySpec(mgmt, yaml, loader);
+ }
+
@SuppressWarnings("unchecked")
- public static <T extends Application> T
createUnstarted(ManagementContext mgmt, AssemblyTemplate at) {
- CampPlatform camp = getCampPlatform(mgmt).get();
- AssemblyTemplateInstantiator instantiator;
+ public static EntitySpec<? extends Application>
createEntitySpec(ManagementContext mgmt, Reader yaml,
BrooklynClassLoadingContext loader) {
+ return (EntitySpec<? extends Application>) createSpec(mgmt, yaml,
loader);
+ }
+
+ private static <T, SpecT> SpecT createEntitySpec(String symbolicName,
CampPlatform camp,
--- End diff --
No need for the generics, can return `EntitySpec<? extends Application>`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---