/**
   * Lance l'environnement et attend indéfiniment.
   *
   * @param args "Usage: java kasper.kernel.Starter managers.xml <conf.properties>"
   */
  public static void main(final String[] args) {
    final String usageMsg =
        "Usage: java io.analytica.spies.impl.logs.LogSpyStandaloneParser \"http://analyticaServer:port/analytica/rest/process\" confPattern.json logFile.out";
    Assertion.checkArgument(
        args.length == 3, usageMsg + " (nombre d'arguments incorrect : " + args.length + ")");
    Assertion.checkArgument(args[0].contains("http://"), usageMsg + " (" + args[0] + ")");
    Assertion.checkArgument(args[1].endsWith(".json"), usageMsg + " (" + args[1] + ")");
    // ---------------------------------------------------------------------
    final String managersXmlFileName = "./managers.xml";
    final Option<String> propertiesFileName =
        args.length == 2 ? Option.<String>some(args[1]) : Option.<String>none();
    final Properties defaultProperties = new Properties();
    defaultProperties.setProperty("serverUrl", args[0]);
    defaultProperties.setProperty("confFileUrl", args[1]);
    defaultProperties.setProperty("logFileUrl", args[2]);

    final Starter starter =
        new Starter(
            managersXmlFileName,
            propertiesFileName,
            LogSpyStandaloneParser.class,
            Option.some(defaultProperties),
            0);
    starter.start();
    try {
      // final Container container = new DualContainer(Home.getComponentSpace(), new
      // ParamsContainer((Map) defaultProperties));
      final AgentManager agentManager = Home.getComponentSpace().resolve(AgentManager.class);
      final ResourceManager resourceManager =
          Home.getComponentSpace().resolve(ResourceManager.class);
      final String logFileUrl = defaultProperties.getProperty("logFileUrl");
      final String confFileUrl = defaultProperties.getProperty("confFileUrl");
      final LogSpyReader logSpyReader =
          new LogSpyReader(agentManager, resourceManager, logFileUrl, confFileUrl);
      // INJECTOR.newInstance(LogSpyReader.class, Home.getComponentSpace());
      try {
        logSpyReader.start();
      } finally {
        flushAgentToServer();
      }
    } finally {
      starter.stop();
    }
  }
Пример #2
0
 // On teste un preparestatement mappé sur un type statique (Class famille)
 @Test
 public void testSelectObject() throws Exception {
   // On crée les données
   createDatas();
   // ----
   final Domain domain = Home.getDefinitionSpace().resolve("DO_DT_MOVIE_DTO", Domain.class);
   final SqlQueryResult result = executeQuery(domain, "select * from movie where id=1");
   Assert.assertEquals(1, result.getSQLRowCount());
   final Movie movie = (Movie) result.getValue();
   Assert.assertEquals("citizen kane", movie.getTitle());
 }
Пример #3
0
 /**
  * Permet pour les types composites (Beans et collections de beans) de connaitre leur définition.
  * Ne peut pas être appelé pour des types primitifs. (ex : BigDecimal, String....) Fonctionne
  * uniquement avec les domaines de type DtList et DtObject.
  *
  * @return dtDefinition des domaines de type DtList et DtObject.
  */
 public DtDefinition getDtDefinition() {
   if (dtDefinitionName == null) {
     // On fournit un message d'erreur explicite
     if (getDataType().isPrimitive()) {
       throw new RuntimeException("Le domain " + getName() + " n'est ni un DTO ni une DTC");
     }
     throw new RuntimeException(
         "Le domain "
             + getName()
             + " est un DTO/DTC mais typé de façon dynamique donc sans DtDefinition.");
   }
   return Home.getDefinitionSpace().resolve(dtDefinitionName, DtDefinition.class);
 }
Пример #4
0
  // On teste un preparestatement mappé sur un type statique (Class famille)
  @Test
  public void testSelectList() throws Exception {
    // On crée les données
    createDatas();
    // ----
    final Domain domain = Home.getDefinitionSpace().resolve("DO_DT_MOVIE_DTC", Domain.class);
    final SqlQueryResult result = executeQuery(domain, "select * from movie");

    Assert.assertEquals(3, result.getSQLRowCount());

    final DtList<Movie> movies = (DtList<Movie>) result.getValue();
    Assert.assertEquals(3, movies.size());

    for (final Movie movie : movies) {
      final long id = movie.getId();
      final String title = movie.getTitle();
      checkTitle(id, title);
    }
  }