Package org.apache.uima.util

Examples of org.apache.uima.util.CasPool


    Integer numInstances = (Integer) aResourceInitParams
            .get(AnalysisEngine.PARAM_NUM_SIMULTANEOUS_REQUESTS);
    if (numInstances == null) {
      numInstances = Integer.valueOf(1);
    }
    mCasPool = new CasPool(numInstances.intValue(), getAnalysisEngine());

    // also record timeout period to use for CAS pool
    Integer timeoutInteger = (Integer) aResourceInitParams.get(AnalysisEngine.PARAM_TIMEOUT_PERIOD);
    if (timeoutInteger != null) {
      mTimeout = timeoutInteger.intValue();
View Full Code Here


    Integer numInstances = (Integer) aResourceInitParams
            .get(AnalysisEngine.PARAM_NUM_SIMULTANEOUS_REQUESTS);
    if (numInstances == null) {
      numInstances = Integer.valueOf(1);
    }
    mCasPool = new CasPool(numInstances.intValue(), getAnalysisEngine());

    // also record timeout period to use for CAS pool
    Integer timeoutInteger = (Integer) aResourceInitParams.get(AnalysisEngine.PARAM_TIMEOUT_PERIOD);
    if (timeoutInteger != null) {
      mTimeout = timeoutInteger.intValue();
View Full Code Here

   * (non-Javadoc)
   *
   * @see org.apache.uima.resource.CasManager#getCAS(org.apache.uima.analysis_engine.AnalysisEngine)
   */
  public CAS getCas(String aRequestorContextName) {
    CasPool pool = (CasPool) mRequestorToCasPoolMap.get(aRequestorContextName);
    if (pool == null) {
      throw new UIMARuntimeException(UIMARuntimeException.REQUESTED_TOO_MANY_CAS_INSTANCES,
              new Object[] { aRequestorContextName, "1", "0" });
    }
    return pool.getCas(0);
  }
View Full Code Here

          new Object[] {aCAS.getClass()});
    }
    CASImpl baseCas = (aCAS instanceof JCas) ? ((JCas)aCAS).getCasImpl().getBaseCAS()
                                             : ((CASImpl)aCAS).getBaseCAS();

    CasPool pool = (CasPool) mCasToCasPoolMap.get(baseCas);
    if (pool == null) {
      // CAS doesn't belong to this CasManager!
      throw new UIMARuntimeException(UIMARuntimeException.CAS_RELEASED_TO_WRONG_CAS_MANAGER,
              new Object[0]);
    } else {
      //see if we have a UimaContext that we can notify that CAS was release
      UimaContextAdmin uc = (UimaContextAdmin)mCasToUimaContextMap.get(baseCas);
      if (uc != null) {
        uc.returnedCAS(aCAS);
      }
     
      //release the CAS
      pool.releaseCas((CAS) aCAS);
    }
  }
View Full Code Here

   */
  private void defineCasPool(UimaContext aRequestorContext, String aRequestorContextName, int aMinimumSize,
          Properties aPerformanceTuningSettings) throws ResourceInitializationException {
    int poolSize = getCasPoolSize(aRequestorContextName, aMinimumSize);
    if (poolSize > 0) {
      CasPool pool = (CasPool) mRequestorToCasPoolMap.get(aRequestorContextName);
      if (pool == null) {
        // this requestor hasn't requested a CAS before
        pool = new CasPool(poolSize, this, aPerformanceTuningSettings);
        populateCasToCasPoolAndUimaContextMaps(pool, aRequestorContext);
        mRequestorToCasPoolMap.put(aRequestorContextName, pool);
        //register with JMX
        registerCasPoolMBean(aRequestorContextName, pool);

View Full Code Here

 
  /* (non-Javadoc)
   * @see org.apache.uima.util.CasPoolManagement#getAvailableInstances()
   */
  public int getAvailableInstances() {
    CasPool casPool = mCasPoolRef.get();
    if (casPool != null) {
      return casPool.getNumAvailable();
    } else {
      return -1;
    }
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.uima.util.CasPoolManagement#getPoolSize()
   */
  public int getPoolSize() {
    CasPool casPool = mCasPoolRef.get();
    if (casPool != null) {
      return casPool.getSize();
    } else {
      return -1;
    }
  }
View Full Code Here

    Integer numInstances = (Integer) aResourceInitParams
            .get(AnalysisEngine.PARAM_NUM_SIMULTANEOUS_REQUESTS);
    if (numInstances == null) {
      numInstances = Integer.valueOf(1);
    }
    mCasPool = new CasPool(numInstances.intValue(), getAnalysisEngine());

    // also record timeout period to use for CAS pool
    Integer timeoutInteger = (Integer) aResourceInitParams.get(AnalysisEngine.PARAM_TIMEOUT_PERIOD);
    if (timeoutInteger != null) {
      mTimeout = timeoutInteger.intValue();
View Full Code Here

   * (non-Javadoc)
   *
   * @see org.apache.uima.resource.CasManager#getCAS(org.apache.uima.analysis_engine.AnalysisEngine)
   */
  public CAS getCas(String aRequestorContextName) {
    CasPool pool = (CasPool) mRequestorToCasPoolMap.get(aRequestorContextName);
    if (pool == null) {
      throw new UIMARuntimeException(UIMARuntimeException.REQUESTED_TOO_MANY_CAS_INSTANCES,
              new Object[] { aRequestorContextName, "1", "0" });
    }
    return pool.getCas(0);
  }
View Full Code Here

          new Object[] {aCAS.getClass()});
    }
    CASImpl baseCas = (aCAS instanceof JCas) ? ((JCas)aCAS).getCasImpl().getBaseCAS()
                                             : ((CASImpl)aCAS).getBaseCAS();

    CasPool pool = (CasPool) mCasToCasPoolMap.get(baseCas);
    if (pool == null) {
      // CAS doesn't belong to this CasManager!
      throw new UIMARuntimeException(UIMARuntimeException.CAS_RELEASED_TO_WRONG_CAS_MANAGER,
              new Object[0]);
    } else {
      //see if we have a UimaContext that we can notify that CAS was release
      UimaContextAdmin uc = (UimaContextAdmin)mCasToUimaContextMap.get(baseCas);
      if (uc != null) {
        uc.returnedCAS(aCAS);
      }
     
      //release the CAS
      pool.releaseCas((CAS) aCAS);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.util.CasPool

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.