Package org.apache.uima.adapter.jms.service

Examples of org.apache.uima.adapter.jms.service.UIMA_Service


    // use security allowing all clients to connect.
    processJmxUrl = super.getProcessJmxUrl();
    System.out.println("Connect jConsole to this process using JMX URL:"
        + processJmxUrl);

    UIMA_Service service = new UIMA_Service();

    StringBuffer sb = new StringBuffer("Deploying UIMA AS with args:\n");

    for (String arg : args) {
      sb.append(arg + "\n");
    }
    System.out.println(sb.toString());
    String[] serviceArgs = getServiceArgs(args);

    sb.setLength(0);
    sb.append("Service Args:\n");
    for (String arg : serviceArgs) {
      sb.append(" " + arg);
    }
    System.out.println(sb.toString());

    System.out.println("ManagedUimaService initializing...");

    // parse command args and run dd2spring to generate spring context
    // files from deployment descriptors
    String[] contextFiles = service.initialize(serviceArgs);
    if (contextFiles == null) {
      throw new Exception(
          "Spring Context Files Not Generated. Unable to Launch Uima AS Service");
    }
    // Make sure that the dd2spring generated file exists
    File generatedFile = new File(contextFiles[0]);
    while (!generatedFile.exists()) {
      synchronized (generatedFile) {
        generatedFile.wait(500);
      }
    }
    System.out
        .println("ManagedUimaService initialized - ready to process. Agent State Update endpoint:"
            + agentStateUpdateEndpoint);
    System.out
        .println(".... Verified dd2spring generated spring context file:"
            + contextFiles[0]);
    // Let the Agent know that the service is entering Initialization
    // state. This is an initial state of a service, covering
    // process bootstrapping(startup) and initialization of UIMA
    // components.
    super.notifyAgentWithStatus(ProcessState.Initializing, processJmxUrl);

    ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(
        1);
    executor.prestartAllCoreThreads();
    // Instantiate a UIMA AS jmx monitor to poll for status of the AE.
    // This monitor checks if the AE is initializing or ready.
    UimaAEJmxMonitor monitor = new UimaAEJmxMonitor(this, serviceArgs);
    /*
     * This will execute the UimaAEJmxMonitor continuously for every 15
     * seconds with an initial delay of 20 seconds. This monitor polls
     * initialization status of AE deployed in UIMA AS.
     */
    executor.scheduleAtFixedRate(monitor, 20, 30, TimeUnit.SECONDS);
    // Future<Integer> future = executor.submit(callable);

    // Deploy components defined in Spring context files.
    // !!!! NOTE:This method blocks until the container is fully
    // initialized and all UIMA-AS components are successfully deployed
    // or there is a failure.
    try {
      serviceDeployer = service.deploy(contextFiles, this);
    } catch (Throwable t) {
      t.printStackTrace();
    }
    // Stop executor. It was only needed to poll AE initialization status.
    // Since deploy() completed
View Full Code Here

TOP

Related Classes of org.apache.uima.adapter.jms.service.UIMA_Service

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.