Github user andreaturli commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/760#discussion_r35546650
  
    --- Diff: 
core/src/main/java/brooklyn/management/internal/EntityManagementUtils.java ---
    @@ -82,55 +79,36 @@
             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);
    +        EntitySpec<T> spec = createEntitySpec(mgmt, yaml);
    +        return createUnstarted(mgmt, spec);
         }
         
    -    /** as {@link #createApplication(ManagementContext, EntitySpec)} but 
for an assembly template */
    -    @SuppressWarnings("unchecked")
    -    public static <T extends Application> T 
createUnstarted(ManagementContext mgmt, AssemblyTemplate at) {
    -        CampPlatform camp = getCampPlatform(mgmt).get();
    -        AssemblyTemplateInstantiator instantiator;
    -        try {
    -            instantiator = at.getInstantiator().newInstance();
    -        } catch (Exception e) {
    -            throw Exceptions.propagate(e);
    +    public static <T extends Application> EntitySpec<T> 
createEntitySpec(ManagementContext mgmt, String yaml) {
    +        Collection<String> types = new ArrayList<String>();
    +        for(PlanToSpecTransformer c : PlanToSpecFactory.all(mgmt)) {
    +            try {
    +                return c.createApplicationSpec(yaml);
    +            } catch (PlanNotRecognizedException e) {
    +                types.add(c.getName());
    +            }
             }
    -        Assembly assembly;
    -        if (instantiator instanceof AssemblyTemplateSpecInstantiator) {
    -            BrooklynClassLoadingContext loader = 
JavaBrooklynClassLoadingContext.create(mgmt);
    -            
    -            EntitySpec<?> spec = ((AssemblyTemplateSpecInstantiator) 
instantiator).createSpec(at, camp, loader, true);
    -            Entity app = mgmt.getEntityManager().createEntity(spec);
    -            Entities.startManagement((Application)app, mgmt);
    -            return (T) app;
    -        } else {
    -            // currently, all brooklyn plans should produce the above; 
currently this will always throw Unsupported  
    +        throw new PlanNotRecognizedException("Invalid plan, tried parsing 
with " + types);
    +    }
    +
    +    public static AbstractBrooklynObjectSpec<?, ?> 
createCatalogSpec(ManagementContext mgmt, CatalogItem<?, ?> item) {
    +        Collection<String> types = new ArrayList<String>();
    +        for(PlanToSpecTransformer c : PlanToSpecFactory.all(mgmt)) {
    --- End diff --
    
    [minor] add trailing space after for


---
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.
---

Reply via email to