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


Java Clojure.var方法代码示例

本文整理汇总了Java中clojure.java.api.Clojure.var方法的典型用法代码示例。如果您正苦于以下问题:Java Clojure.var方法的具体用法?Java Clojure.var怎么用?Java Clojure.var使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clojure.java.api.Clojure的用法示例。


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

示例1: onLoad

import clojure.java.api.Clojure; //导入方法依赖的package包/类
@Override
public void onLoad() {
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    instance = this;
    logger = getLogger();
    try (InputStream stream = getResource("clojure.yml")) {
        clojureConfig = YamlConfiguration.loadConfiguration(stream);
        mainNs = clojureConfig.getString("clojure");
        if (mainNs == null) {
            setEnabled(false);
            throw new RuntimeException("The plugin couldn't be enabled due to Clojure ns missing.");
        }
        require.invoke(Clojure.read(mainNs));
    } catch (IOException e) {
        e.printStackTrace();
    }

    IFn setData = Clojure.var(mainNs, "setData");
    if (setData == null) {
        setEnabled(false);
        throw new RuntimeException("The clojure plugin couldn't be enabled due to missing setData method.");
    }
    setData.invoke(this, getDataFolder(), getConfig(), getDescription(), getServer(), getLogger());
    callIfExists("onLoad");
}
 
开发者ID:Proximyst,项目名称:Bukkit4Clojure,代码行数:26,代码来源:Main.java

示例2: importNsDeclarations

import clojure.java.api.Clojure; //导入方法依赖的package包/类
public static ArrayList<Symbol> importNsDeclarations(List<String> namespaces)
    throws ClassNotFoundException{
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    if (require == null)
        require = Clojure.var("clojure.core", "require");

    require.invoke(Clojure.read("coa.droid-test.internal.util"));
    if (getImports == null)
        getImports = Clojure.var("coa.droid-test.internal.util",
                                 "extract-imports");

    ArrayList<Symbol> namespaceSymbols = new ArrayList<Symbol>();
    for (String ns : TestRunner.getTestNamespaces()) {
        processNs(ns, loader, namespaceSymbols);
    }
    return namespaceSymbols;
}
 
开发者ID:clojure-android,项目名称:droid-test,代码行数:18,代码来源:Util.java

示例3: expectationsRunner

import clojure.java.api.Clojure; //导入方法依赖的package包/类
@Test
public void expectationsRunner() {
    try {
        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read("expectations"));
        IFn disableRun = Clojure.var("expectations", "disable-run-on-shutdown");
        disableRun.invoke();

        List<Symbol> namespaces = Util.importNsDeclarations(TestRunner.getTestNamespaces());
        Util.tryInitNeko();

        IFn runTests = Clojure.var("expectations", "run-all-tests");
        Object result = runTests.invoke();

        IFn shutdownAgents = Clojure.var("clojure.core", "shutdown-agents");
        shutdownAgents.invoke();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:clojure-android,项目名称:droid-test,代码行数:21,代码来源:ExpectationsWrapper.java

示例4: specljRunner

import clojure.java.api.Clojure; //导入方法依赖的package包/类
@Test
public void specljRunner() {
    try {
        List<Symbol> namespaces = Util.importNsDeclarations(TestRunner.getTestNamespaces());
        Util.tryInitNeko();

        IFn require = Clojure.var("clojure.core", "require");

        require.invoke(Clojure.read("speclj.cli"));
        require.invoke(Clojure.read("speclj.run.standard"));

        IFn runSpecs = Clojure.var("speclj.run.standard", "run-specs");
        runSpecs.invoke();

        IFn shutdownAgents = Clojure.var("clojure.core", "shutdown-agents");
        shutdownAgents.invoke();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:clojure-android,项目名称:droid-test,代码行数:21,代码来源:SpecljWrapper.java

示例5: nreplStarter

import clojure.java.api.Clojure; //导入方法依赖的package包/类
@Test
public void nreplStarter() {
    try {
        Util.importNsDeclarations(TestRunner.getTestNamespaces());
        Util.tryInitNeko();

        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read("clojure.tools.nrepl.server"));
        IFn startServer = Clojure.var("clojure.tools.nrepl.server",
                                      "start-server");
        startServer.invoke(Clojure.read(":port"), 8888);
        System.out.println("Started nREPL server on port " + 8888);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:clojure-android,项目名称:droid-test,代码行数:17,代码来源:ReplWrapper.java

示例6: reduce

import clojure.java.api.Clojure; //导入方法依赖的package包/类
@Override
public Object reduce(Object o, Iterator<Object> objectIterator) {

    if(fn == null) {
        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read(ns));
        fn = Clojure.var(ns, sym);
    }

    Object result = seed;
    while(objectIterator.hasNext()){
        Object x = objectIterator.next();
        result = fn.invoke(o, result, x);
    }
    return result;
}
 
开发者ID:danstone,项目名称:immutant-mr,代码行数:17,代码来源:InfinispanReducer.java

示例7: map

import clojure.java.api.Clojure; //导入方法依赖的package包/类
public void map(Object key, Object value, Collector<Object, Object> collector){

        if(fn == null) {
            IFn require = Clojure.var("clojure.core", "require");
            require.invoke(Clojure.read(ns));
            fn = Clojure.var(ns, sym);
        }

        for (Object o : (Iterable)fn.invoke(key, value)){
            Seqable s = (Seqable)o;
            ISeq seq = s.seq();
            Object k = seq.first();
            Object v = seq.next().first();
            collector.emit(k, v);
        }
    }
 
开发者ID:danstone,项目名称:immutant-mr,代码行数:17,代码来源:InfinispanMapper.java

示例8: loadClojureFn

import clojure.java.api.Clojure; //导入方法依赖的package包/类
private static void loadClojureFn() {
    ClassLoader previous = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(IcepickProcessor.class.getClassLoader());
    try {
        Object ns = Clojure.read("icepick.processor");
        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(ns);
        PROCESS = Clojure.var("icepick.processor", "process");
    } finally {
        Thread.currentThread().setContextClassLoader(previous);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:IcepickProcessor.java

示例9: callIfExists

import clojure.java.api.Clojure; //导入方法依赖的package包/类
public void callIfExists(String namespace, String name, Object... args) {
    require.invoke(namespace);
    IFn method = Clojure.var(namespace, name);
    if (method != null) {
        if (args != null && args.length != 0) {
            method.invoke(args);
        } else {
            method.invoke();
        }
    }
}
 
开发者ID:Proximyst,项目名称:Bukkit4Clojure,代码行数:12,代码来源:Main.java

示例10: invoke

import clojure.java.api.Clojure; //导入方法依赖的package包/类
public static <T> T invoke(String namespace, String name, Object... args) {
    if (!"clojure.core".equals(namespace)) {
        IFn symbol = Clojure.var("clojure.core", "symbol");
        IFn require = Clojure.var("clojure.core", "require");

        Object sym = symbol.invoke(namespace);
        require.invoke(sym);
    }

    IFn apply = Clojure.var("clojure.core", "apply");
    return (T) apply.invoke(Clojure.var(namespace, name), args);
}
 
开发者ID:ajoberstar,项目名称:jovial,代码行数:13,代码来源:SimpleClojure.java

示例11: selectNamespace

import clojure.java.api.Clojure; //导入方法依赖的package包/类
public static NamespaceSelector selectNamespace(String namespace) {
    IFn symbol = Clojure.var("clojure.core", "symbol");
    IFn require = Clojure.var("clojure.core", "require");
    IFn findNs = Clojure.var("clojure.core", "find-ns");

    Object sym = symbol.invoke(namespace);
    require.invoke(sym);

    Namespace ns = (Namespace) findNs.invoke(sym);

    return new NamespaceSelector(ns);
}
 
开发者ID:ajoberstar,项目名称:jovial,代码行数:13,代码来源:NamespaceSelector.java

示例12: callClojureFn

import clojure.java.api.Clojure; //导入方法依赖的package包/类
public static void callClojureFn(String fn, Object... args) {
  Symbol var = (Symbol)Clojure.read(fn);
  IFn require = Clojure.var("clojure.core", "require");
  require.invoke(Symbol.create(var.getNamespace()));
  ISeq argsSeq = ArraySeq.create(args);
  Clojure.var(var.getNamespace(), var.getName()).applyTo(argsSeq);
}
 
开发者ID:alda-lang,项目名称:alda-client-java,代码行数:8,代码来源:Util.java

示例13: cloverageRunner

import clojure.java.api.Clojure; //导入方法依赖的package包/类
@Test
public void cloverageRunner() {
    try {
        List<Symbol> namespaces = Util.importNsDeclarations(TestRunner.getTestNamespaces());
        Util.tryInitNeko();
        ArrayList<String> cloverageArgs = new ArrayList<String>();

        for (Symbol ns : namespaces) {
            cloverageArgs.add("-x");
            cloverageArgs.add(ns.getName());
        }
        cloverageArgs.addAll(TestRunner.getSourceNamespaces());

        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read("cloverage.coverage"));

        IFn coverage = Clojure.var("cloverage.coverage", "-main");
        IFn apply = Clojure.var("clojure.core", "apply");
        IFn concat = Clojure.var("clojure.core", "concat");
        apply.invoke(coverage, "--coveralls", cloverageArgs);

        IFn shutdownAgents = Clojure.var("clojure.core", "shutdown-agents");
        shutdownAgents.invoke();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:clojure-android,项目名称:droid-test,代码行数:28,代码来源:CloverageWrapper.java

示例14: info

import clojure.java.api.Clojure; //导入方法依赖的package包/类
/**
 * Passes the contents as an info level message to the log.
 * @param message An object containing an info level message to be passed to the log
 */
public static void info(Object message){
    IFn requireFn = Clojure.var(CORE, Require);
    requireFn.invoke(Clojure.read(TIMBRE));
    IFn messageFn = Clojure.var(TIMBRE, MessageFn);
    messageFn.invoke(message);
}
 
开发者ID:onyx-platform,项目名称:onyx-java,代码行数:11,代码来源:Timbre.java

示例15: debug

import clojure.java.api.Clojure; //导入方法依赖的package包/类
/**
 * Passes the contents as a debug level message to the log.
 * @param message An object containing a debug level message to be passed to the log
 */
public static void debug(Object message){
    IFn requireFn = Clojure.var(CORE, Require);
    requireFn.invoke(Clojure.read(TIMBRE));
    IFn debugFn = Clojure.var(TIMBRE, DebugFn);
    debugFn.invoke(message);
}
 
开发者ID:onyx-platform,项目名称:onyx-java,代码行数:11,代码来源:Timbre.java


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