Examples of StateFactory


Examples of com.almende.eve.state.StateFactory

   * .eve.config.Config, java.lang.String)
   */
  @Override
  public StateFactory getStateFactoryFromConfig(final Config config,
      String configName) {
    StateFactory result = null;
    // get the class name from the config file
    // first read from the environment specific configuration,
    // if not found read from the global configuration
   
    String className = config.get(configName, "class");
    if (className == null) {
      if (!configName.equals("state")) {
        // Provide fallback to state if other type doesn't exist;
        configName = "state";
        className = config.get(configName, "class");
      }
      if (className == null) {
        throw new IllegalArgumentException("Config parameter '"
            + config + ".class' missing in Eve configuration.");
      }
    }
   
    try {
      // get the class
      final Class<?> stateClass = Class.forName(className);
      if (!ClassUtil.hasInterface(stateClass, StateFactory.class)) {
        throw new IllegalArgumentException("State factory class "
            + stateClass.getName() + " must extend "
            + State.class.getName());
      }
     
      // instantiate the state factory
      final Map<String, Object> params = config.get(configName);
      result = (StateFactory) stateClass.getConstructor(Map.class)
          .newInstance(params);
     
      LOG.info("Initialized state factory: " + result.toString());
    } catch (final Exception e) {
      LOG.log(Level.WARNING, "", e);
    }
    return result;
  }
View Full Code Here

Examples of com.almende.eve.state.StateFactory

            " must extend " + State.class.getName());
      }
 
      // instantiate the state factory
      Map<String, Object> params = config.get(configName);
      StateFactory stateFactory = (StateFactory) stateClass
          .getConstructor(AgentFactory.class, Map.class )
          .newInstance(this, params);

      setStateFactory(stateFactory);
      logger.info("Initialized state factory: " + stateFactory.toString());
    }
    catch (Exception e) {
      e.printStackTrace();
    }   
  }
View Full Code Here

Examples of com.almende.eve.state.StateFactory

   * .eve.config.Config, java.lang.String)
   */
  @Override
  public StateFactory getStateFactoryFromConfig(final Config config,
      String configName) {
    StateFactory result = null;
    // get the class name from the config file
    // first read from the environment specific configuration,
    // if not found read from the global configuration
   
    String className = config.get(configName, "class");
    if (className == null) {
      if (!configName.equals("state")) {
        // Provide fallback to state if other type doesn't exist;
        configName = "state";
        className = config.get(configName, "class");
      }
      if (className == null) {
        throw new IllegalArgumentException("Config parameter '"
            + config + ".class' missing in Eve configuration.");
      }
    }
   
    try {
      // get the class
      final Class<?> stateClass = Class.forName(className);
      if (!ClassUtil.hasInterface(stateClass, StateFactory.class)) {
        throw new IllegalArgumentException("State factory class "
            + stateClass.getName() + " must extend "
            + State.class.getName());
      }
     
      // instantiate the state factory
      final Map<String, Object> params = config.get(configName);
      result = (StateFactory) stateClass.getConstructor(Map.class)
          .newInstance(params);
     
      LOG.info("Initialized state factory: " + result.toString());
    } catch (final Exception e) {
      LOG.log(Level.WARNING, "", e);
    }
    return result;
  }
View Full Code Here

Examples of com.almende.eve.state.StateFactory

     *
     * @throws IOException Signals that an I/O exception has occurred.
     */
    MyCookieStore() throws IOException {
      final AgentHost host = AgentHost.getInstance();
      StateFactory factory = null;
      if (host.getConfig() != null) {
        factory = host.getStateFactoryFromConfig(host.getConfig(),
            "cookies");
      }
      if (factory == null) {
        factory = host.getStateFactory();
      }
      if (factory.exists(COOKIESTORE)) {
        myState = factory.get(COOKIESTORE);
      } else {
        myState = factory.create(COOKIESTORE);
        myState.setAgentType(CookieStore.class);
      }
    }
View Full Code Here

Examples of com.almende.eve.state.StateFactory

            + State.class.getName());
      }

      // instantiate the state factory
      Map<String, Object> params = config.get(configName);
      StateFactory stateFactory = (StateFactory) stateClass
          .getConstructor(AgentFactory.class, Map.class).newInstance(
              this, params);

      setStateFactory(stateFactory);
      logger.info("Initialized state factory: " + stateFactory.toString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of com.almende.eve.state.StateFactory

            + State.class.getName());
      }
     
      // instantiate the state factory
      Map<String, Object> params = config.get(configName);
      StateFactory sf = (StateFactory) stateClass.getConstructor(
          Map.class).newInstance(params);
     
      setStateFactory(sf);
      LOG.info("Initialized state factory: " + sf.toString());
    } catch (Exception e) {
      LOG.log(Level.WARNING, "", e);
    }
  }
View Full Code Here

Examples of com.almende.eve.state.StateFactory

   * .eve.config.Config, java.lang.String)
   */
  @Override
  public StateFactory getStateFactoryFromConfig(final Config config,
      String configName) {
    StateFactory result = null;
    // get the class name from the config file
    // first read from the environment specific configuration,
    // if not found read from the global configuration
   
    String className = config.get(configName, "class");
    if (className == null) {
      if (!configName.equals("state")) {
        // Provide fallback to state if other type doesn't exist;
        configName = "state";
        className = config.get(configName, "class");
      }
      if (className == null) {
        throw new IllegalArgumentException("Config parameter '"
            + config + ".class' missing in Eve configuration.");
      }
    }
   
    try {
      // get the class
      final Class<?> stateClass = Class.forName(className);
      if (!ClassUtil.hasInterface(stateClass, StateFactory.class)) {
        throw new IllegalArgumentException("State factory class "
            + stateClass.getName() + " must extend "
            + State.class.getName());
      }
     
      // instantiate the state factory
      final Map<String, Object> params = config.get(configName);
      result = (StateFactory) stateClass.getConstructor(Map.class)
          .newInstance(params);
     
      LOG.info("Initialized state factory: " + result.toString());
    } catch (final Exception e) {
      LOG.log(Level.WARNING, "", e);
    }
    return result;
  }
View Full Code Here

Examples of com.almende.eve.state.StateFactory

            " must extend " + State.class.getName());
      }
 
      // instantiate the state factory
      Map<String, Object> params = config.get(configName);
      StateFactory stateFactory = (StateFactory) stateClass
          .getConstructor(AgentFactory.class, Map.class )
          .newInstance(this, params);

      setStateFactory(stateFactory);
      logger.info("Initialized state factory: " + stateFactory.toString());
    }
    catch (Exception e) {
      e.printStackTrace();
    }   
  }
View Full Code Here

Examples of com.tomgibara.pronto.state.StateFactory

    return editor.getGraph();
  }


  static StateEngine<State, Label, Object> createEngine() {
    StateFactory factory = StateFactory.getInstance();
    StateEngine<State, Label, Object> engine = factory.newEngine(graph, new Activator());
    engine.setState(State.constructed);
    return engine;
  }
View Full Code Here

Examples of com.tomgibara.pronto.state.StateFactory

    assertFalse( ControlFactory.getInstance().isSettingsIfaceSupported(DudSettings.class) );
  }
 
  public void testBadIface() {
    DudSettings settings = new DudSettings() {};
    StateFactory factory = StateFactory.getInstance();
    StateGraph graph = factory.emptyStateGraph();
    StateActivator activator = new StateActivator() {
      public void changeState(Object arg0) throws com.tomgibara.pronto.state.ProntoStateException ,RuntimeException {};
      public void transitionState(com.tomgibara.pronto.state.StateTransition arg0, Object arg1) throws com.tomgibara.pronto.state.ProntoStateException ,RuntimeException {};
    };
    StateEngine engine = factory.newEngine(graph, activator);
    EngineControlAdapter adapter = new EngineControlAdapter() {
      public Object labelFromName(String name) { return null; };
      public String nameFromLabel(Object label) { return null; };
      public Object parseParameter(String string) { return null; };
    };
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.