@@ -0,0 +1,3724 @@
+/**%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage io.fabric8.forge.camel.commands.project;%0A%0Aimport java.io.InputStream;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0Aimport javax.enterprise.event.Observes;%0Aimport javax.inject.Inject;%0A%0Aimport org.apache.maven.archetype.catalog.ArchetypeCatalog;%0Aimport org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Reader;%0Aimport org.jboss.forge.addon.dependencies.Coordinate;%0Aimport org.jboss.forge.addon.dependencies.Dependency;%0Aimport org.jboss.forge.addon.dependencies.DependencyResolver;%0Aimport org.jboss.forge.addon.dependencies.builder.CoordinateBuilder;%0Aimport org.jboss.forge.addon.dependencies.builder.DependencyQueryBuilder;%0Aimport org.jboss.forge.addon.maven.archetype.ArchetypeCatalogFactory;%0Aimport org.jboss.forge.addon.maven.archetype.ArchetypeCatalogFactoryRegistry;%0Aimport org.jboss.forge.addon.parser.xml.resources.XMLResource;%0Aimport org.jboss.forge.furnace.container.cdi.events.Local;%0Aimport org.jboss.forge.furnace.event.PostStartup;%0Aimport org.jboss.forge.furnace.services.Imported;%0A%0A/**%0A * The Fabric8 archetypes%0A */%0Apublic class FabricArchetypeCatalogFactory implements ArchetypeCatalogFactory %7B%0A%0A    private final Logger logger = Logger.getLogger(getClass().getName());%0A%0A    @Inject%0A    Imported%3CDependencyResolver%3E resolver;%0A%0A    private ArchetypeCatalog cachedArchetypes;%0A%0A    void startup(@Observes @Local PostStartup startup, ArchetypeCatalogFactoryRegistry registry) %7B%0A        // must use this to trigger startup event so we can add ourselves%0A        if (registry.getArchetypeCatalogFactory(%22fabric8%22) == null) %7B%0A            registry.addArchetypeCatalogFactory(this);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public String getName() %7B%0A        return %22fabric8%22;%0A    %7D%0A%0A    @Override%0A    public ArchetypeCatalog getArchetypeCatalog() %7B%0A       if (cachedArchetypes == null) %7B%0A            // TODO: version should be not hardcoded%0A            // use the camel catalog to load the archetypes%0A            Coordinate coordinate = CoordinateBuilder.create()%0A                    .setGroupId(%22io.fabric8.archetypes%22)%0A                    .setArtifactId(%22archetypes-catalog%22)%0A                    .setVersion(%222.2-SNAPSHOT%22)%0A                    .setClassifier(%22archetype-catalog%22)%0A                    .setPackaging(%22xml%22);%0A%0A            Dependency dependency = resolver.get().resolveArtifact(DependencyQueryBuilder.create(coordinate));%0A            if (dependency != null) %7B%0A                XMLResource xml = (XMLResource) dependency.getArtifact();%0A                if (xml != null) %7B%0A                    try (InputStream is = xml.getResourceInputStream()) %7B%0A                        cachedArchetypes = new ArchetypeCatalogXpp3Reader().read(is);%0A                    %7D catch (Exception e) %7B%0A                        logger.log(Level.SEVERE, %22Error while retrieving archetypes%22, e);%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return cachedArchetypes;%0A    %7D%0A%0A%7D%0A

Add fabric8 archetypes to camel forge commands.