当前位置: 首页>>代码示例>>Java>>正文


Java AllowableValue类代码示例

本文整理汇总了Java中org.apache.nifi.components.AllowableValue的典型用法代码示例。如果您正苦于以下问题:Java AllowableValue类的具体用法?Java AllowableValue怎么用?Java AllowableValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AllowableValue类属于org.apache.nifi.components包,在下文中一共展示了AllowableValue类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createResources

import org.apache.nifi.components.AllowableValue; //导入依赖的package包/类
/**
 * This method creates all resources needed for the script processor to function, such as script engines,
 * script file reloader threads, etc.
 */
public void createResources() {
    descriptors = new ArrayList<>();
    // The following is required for JRuby, should be transparent to everything else.
    // Note this is not done in a ScriptEngineConfigurator, as it is too early in the lifecycle. The
    // setting must be there before the factories/engines are loaded.
    System.setProperty("org.jruby.embed.localvariable.behavior", "persistent");

    // Create list of available engines
    ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
    List<ScriptEngineFactory> scriptEngineFactories = scriptEngineManager.getEngineFactories();
    if (scriptEngineFactories != null) {
        scriptEngineFactoryMap = new HashMap<>(scriptEngineFactories.size());
        List<AllowableValue> engineList = new LinkedList<>();
        for (ScriptEngineFactory factory : scriptEngineFactories) {
            engineList.add(new AllowableValue(factory.getLanguageName()));
            scriptEngineFactoryMap.put(factory.getLanguageName(), factory);
        }

        // Sort the list by name so the list always looks the same.
        Collections.sort(engineList, (o1, o2) -> {
            if (o1 == null) {
                return o2 == null ? 0 : 1;
            }
            if (o2 == null) {
                return -1;
            }
            return o1.getValue().compareTo(o2.getValue());
        });

        AllowableValue[] engines = engineList.toArray(new AllowableValue[engineList.size()]);

        SCRIPT_ENGINE = new PropertyDescriptor.Builder()
                .name("Script Engine")
                .required(true)
                .description("The engine to execute scripts")
                .allowableValues(engines)
                .defaultValue(engines[0].getValue())
                .required(true)
                .expressionLanguageSupported(false)
                .build();
        descriptors.add(SCRIPT_ENGINE);
    }

    descriptors.add(ScriptingComponentUtils.SCRIPT_FILE);
    descriptors.add(ScriptingComponentUtils.SCRIPT_BODY);
    descriptors.add(ScriptingComponentUtils.MODULES);

    isInitialized.set(true);
}
 
开发者ID:mattyb149,项目名称:nifi-script-tester,代码行数:54,代码来源:ScriptingComponentHelper.java


注:本文中的org.apache.nifi.components.AllowableValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。