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

    https://github.com/apache/brooklyn-server/pull/608#discussion_r108382104
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleLoader.java
 ---
    @@ -0,0 +1,180 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.brooklyn.core.catalog.internal;
    +
    +import static 
org.apache.brooklyn.api.catalog.CatalogItem.CatalogItemType.TEMPLATE;
    +
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.net.URL;
    +import java.util.List;
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.catalog.CatalogItem;
    +import org.apache.brooklyn.api.mgmt.ManagementContext;
    +import org.apache.brooklyn.util.collections.MutableList;
    +import org.apache.brooklyn.util.exceptions.Exceptions;
    +import org.apache.brooklyn.util.stream.Streams;
    +import org.apache.brooklyn.util.text.Strings;
    +import org.apache.brooklyn.util.yaml.Yamls;
    +import org.osgi.framework.Bundle;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.yaml.snakeyaml.DumperOptions;
    +import org.yaml.snakeyaml.Yaml;
    +
    +import com.google.common.annotations.Beta;
    +import com.google.common.base.Predicate;
    +import com.google.common.collect.ImmutableMap;
    +import com.google.common.collect.Iterables;
    +
    +@Beta
    +public class CatalogBundleLoader {
    +
    +    private static final Logger LOG = 
LoggerFactory.getLogger(CatalogBundleLoader.class);
    +    private static final String CATALOG_BOM_URL = "catalog.bom";
    +    private static final String BROOKLYN_CATALOG = "brooklyn.catalog";
    +    private static final String BROOKLYN_LIBRARIES = "brooklyn.libraries";
    +
    +    private Predicate<Bundle> applicationsPermitted;
    +    private ManagementContext managementContext;
    +
    +    public CatalogBundleLoader(Predicate<Bundle> applicationsPermitted, 
ManagementContext managementContext) {
    +        this.applicationsPermitted = applicationsPermitted;
    +        this.managementContext = managementContext;
    +    }
    +
    +    /**
    +     * Scan the given bundle for a catalog.bom and adds it to the catalog.
    +     *
    +     * @param bundle The bundle to add
    +     * @return A list of items added to the catalog
    +     * @throws RuntimeException if the catalog items failed to be added to 
the catalog
    +     */
    +    public Iterable<? extends CatalogItem<?, ?>> scanForCatalog(Bundle 
bundle) {
    --- End diff --
    
    I'd prefer a name that makes clear the method will add the catalog items 
(as well as scanning + returning the items found). For example 
`addCatalogItemsFromBundle(...)`?
    
    (This method name was originally in `CatalogBomScanner`, and was refactored 
to here - but in CatalogBomScanner it was a private method so the name didn't 
need to be as clear.)


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