[ 
https://issues.apache.org/jira/browse/NIFI-5673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16671891#comment-16671891
 ] 

ASF GitHub Bot commented on NIFI-5673:
--------------------------------------

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

    https://github.com/apache/nifi/pull/3119#discussion_r230117182
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-nar-loading-utils/src/main/java/org/apache/nifi/nar/NarLoader.java
 ---
    @@ -0,0 +1,160 @@
    +/*
    + * 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.nifi.nar;
    +
    +import org.apache.nifi.bundle.Bundle;
    +import org.apache.nifi.bundle.BundleCoordinate;
    +import org.apache.nifi.bundle.BundleDetails;
    +import org.apache.nifi.documentation.DocGenerator;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.File;
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Set;
    +import java.util.jar.Attributes;
    +import java.util.jar.JarFile;
    +import java.util.jar.Manifest;
    +
    +/**
    + * Loads a set of NARs from the file system into the running application.
    + *
    + * NOTE: Initially this will only be used from the NarAutoLoader which is 
watching a directory for new files, but eventually
    + * this may also be used for loading a NAR that was downloaded from the 
extension registry, and thus the load method
    + * is synchronized to ensure only one set of NARs can be in process of 
loading at a given time.
    + */
    +public class NarLoader {
    +
    +    private static Logger LOGGER = 
LoggerFactory.getLogger(NarLoader.class);
    +
    +    private File extensionsWorkingDir;
    +    private File docsWorkingDir;
    +    private NarClassLoaders narClassLoaders;
    +    private ExtensionDiscoveringManager extensionManager;
    +    private ExtensionMapping extensionMapping;
    +    private ExtensionUiLoader extensionUiLoader;
    +
    +    public NarLoader(final File extensionsWorkingDir,
    +                     final File docsWorkingDir,
    +                     final NarClassLoaders narClassLoaders,
    +                     final ExtensionDiscoveringManager extensionManager,
    +                     final ExtensionMapping extensionMapping,
    +                     final ExtensionUiLoader extensionUiLoader) {
    +        this.extensionsWorkingDir = extensionsWorkingDir;
    +        this.docsWorkingDir = docsWorkingDir;
    +        this.narClassLoaders = narClassLoaders;
    +        this.extensionManager = extensionManager;
    +        this.extensionMapping = extensionMapping;
    +        this.extensionUiLoader = extensionUiLoader;
    +    }
    +
    +    public synchronized NarLoadResult load(final List<File> narFiles, 
final Set<BundleDetails> previouslySkippedBundles) {
    --- End diff --
    
    The `Set<BundleDetails>`, I feel, is really internal state that should be 
maintained by this class, rather than having another Object responsible for 
maintaining the previously skipped bundles and then having it tell this 
component which ones it has already skipped.
    I would also recommend accepting a `Collection<File>` instead of 
`List<File>` because the ordering of the given Files does not matter, and 
`List` implies (or at least hints that) the order is relevant


> Support auto loading of new NARs
> --------------------------------
>
>                 Key: NIFI-5673
>                 URL: https://issues.apache.org/jira/browse/NIFI-5673
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Bryan Bende
>            Assignee: Bryan Bende
>            Priority: Minor
>
> We should be able to detect when new NARs have been added to any of the NAR 
> directories and automatically load them and make the components available for 
> use without restarting the whole NiFi instance.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to