Package clojure.lang

Examples of clojure.lang.IFn


        Assert.assertEquals("A", s);
    }

    @Test
    public void testEvalAllowsImports() {
        IFn obj = (IFn) ClojureIteratorUtils.eval(
                "(import '[java.util HashMap])" +
                        "(fn [] (HashMap.))"
        );

        HashMap m = (HashMap) obj.invoke();
        Assert.assertEquals(new HashMap(), m);
    }
View Full Code Here


  }

  @Override
  public void prepare(final Map stormConf, final TopologyContext context,
      final OutputCollector collector) {
    IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
    try {
      IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
      final Map<Keyword, Object> collectorMap = new PersistentArrayMap(
          new Object[] {
              Keyword.intern(Symbol.create("output-collector")),
              collector,
              Keyword.intern(Symbol.create("context")), context });
      List<Object> args = new ArrayList<Object>() {
        {
          add(stormConf);
          add(context);
          add(collectorMap);
        }
      };

      _bolt = (IBolt) preparer.applyTo(RT.seq(args));
      // this is kind of unnecessary for clojure
      try {
        _bolt.prepare(stormConf, context, collector);
      } catch (AbstractMethodError ame) {
View Full Code Here

    }
  }

  @Override
  public Map<String, Object> getComponentConfiguration() {
    IFn hof = Utils.loadClojureFn(_confSpec.get(0), _confSpec.get(1));
    try {
      return (Map) hof.applyTo(RT.seq(_params));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

  }

  @Override
  public void open(final Map conf, final TopologyContext context,
      final SpoutOutputCollector collector) {
    IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
    try {
      IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
      final Map<Keyword, Object> collectorMap = new PersistentArrayMap(
          new Object[] {
              Keyword.intern(Symbol.create("output-collector")),
              collector,
              Keyword.intern(Symbol.create("context")), context });
      List<Object> args = new ArrayList<Object>() {
        {
          add(conf);
          add(context);
          add(collectorMap);
        }
      };

      _spout = (ISpout) preparer.applyTo(RT.seq(args));
      // this is kind of unnecessary for clojure
      try {
        _spout.open(conf, context, collector);
      } catch (AbstractMethodError ame) {
View Full Code Here

    }
  }

  @Override
  public Map<String, Object> getComponentConfiguration() {
    IFn hof = Utils.loadClojureFn(_confSpec.get(0), _confSpec.get(1));
    try {
      return (Map) hof.applyTo(RT.seq(_params));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

TOP

Related Classes of clojure.lang.IFn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.