本文整理汇总了Java中clojure.java.api.Clojure类的典型用法代码示例。如果您正苦于以下问题:Java Clojure类的具体用法?Java Clojure怎么用?Java Clojure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Clojure类属于clojure.java.api包,在下文中一共展示了Clojure类的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");
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例6: invoke
import clojure.java.api.Clojure; //导入依赖的package包/类
@Override
public Object invoke(Object arg1) {
Object arg2 = Deref.invoke(Clojure.var("clojure.core/*out*"));
DynamicObject dynamicObject = (DynamicObject) arg1;
Writer writer = (Writer) arg2;
String tag = recordTagCache.getOrDefault(dynamicObject.getType(), null);
try {
if (tag != null) {
writer.write("#");
writer.write(tag);
}
SimpleDispatch.invoke(dynamicObject.getMap());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return null;
}
示例7: 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;
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: 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();
}
}
}
示例11: 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);
}
示例12: 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);
}
示例13: 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);
}
示例14: registerComparator
import clojure.java.api.Clojure; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected final void registerComparator() {
if (rule == FunnyQTBenchmarkLogic.POS_LENGTH) {
comparator = (Comparator<Object>) FunnyQTBenchmarkLogic.MAKE_MATCH_COMPARATOR
.invoke(Clojure.read(":segment"));
} else if (rule == FunnyQTBenchmarkLogic.SWITCH_SENSOR) {
comparator = (Comparator<Object>) FunnyQTBenchmarkLogic.MAKE_MATCH_COMPARATOR
.invoke(Clojure.read(":sw"));
} else if (rule == FunnyQTBenchmarkLogic.SWITCH_SET) {
comparator = (Comparator<Object>) FunnyQTBenchmarkLogic.MAKE_MATCH_COMPARATOR
.invoke(Clojure.read(":semaphore"), Clojure.read(":route"),
Clojure.read(":swp"), Clojure.read(":sw"));
} else if (rule == FunnyQTBenchmarkLogic.ROUTE_SENSOR) {
comparator = (Comparator<Object>) FunnyQTBenchmarkLogic.MAKE_MATCH_COMPARATOR
.invoke(Clojure.read(":route"), Clojure.read(":sensor"),
Clojure.read(":swp"), Clojure.read(":sw"));
} else if (rule == FunnyQTBenchmarkLogic.SEMAPHORE_NEIGHBOR) {
comparator = (Comparator<Object>) FunnyQTBenchmarkLogic.MAKE_MATCH_COMPARATOR
.invoke(Clojure.read(":semaphore"),
Clojure.read(":route1"), Clojure.read(":route2"),
Clojure.read(":sensor1"), Clojure.read(":sensor2"),
Clojure.read(":te1"), Clojure.read(":te2"));
} else {
throw new RuntimeException("Unknown rule " + rule);
}
}
示例15: 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();
}
}