Java Code Examples for org.apache.uima.resource.ResourceManager#destroy()

The following examples show how to use org.apache.uima.resource.ResourceManager#destroy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceManager_impl.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
public void destroy() {
  boolean alreadyDestroyed = isDestroyed.getAndSet(true);
  if (alreadyDestroyed) {
    return;
  }
  
  for (ResourceRegistration rr : mInternalResourceRegistrationMap.values()) {
    if (rr.resource instanceof Resource) {
      ((Resource)rr.resource).destroy();
    }
  }
  
  for (Object r : mParameterizedResourceInstanceMap.values()) {
    if (r instanceof Resource) {
      ((Resource)r).destroy();
    }
  }
  
  if (uimaCL != null) {
    try {
      uimaCL.close();
    } catch (IOException e) {
      UIMAFramework.getLogger().logrb(Level.WARNING, ResourceManager_impl.class.getName(),
          "destroy", LOG_RESOURCE_BUNDLE, "UIMA_Classloader_close_exception", e);
    }      
  }
  
  // https://issues.apache.org/jira/browse/UIMA-5935
  Map<ResourceManager, Map<PearAnalysisEngineWrapper.StringPair, ResourceManager>> cachedResourceManagers =
      PearAnalysisEngineWrapper.getCachedResourceManagers();
  synchronized(cachedResourceManagers) {
    Map<StringPair, ResourceManager> c1 = cachedResourceManagers.get(this);
    if (c1 != null) {
      for (ResourceManager rm : c1.values()) {
        rm.destroy();
      }
    }
  }
  
  // not clearing mResourcMap, mInternalResourceRegistrationMap, mParameterizedResourceImplClassMap, 
  //   mInternalParameterizedResourceImplClassMap, mParameterizedResourceInstanceMap
  //   because these could be shared with other resource managers
  // not clearing importCache, importUrlsCache - might be in used by other Resource Managers (shared) 
  
     
  // no destroy of caspool at this time
  
}
 
Example 2
Source File: LifeCycleUtil.java    From uima-uimafit with Apache License 2.0 2 votes vote down vote up
/**
 * Destroy a set of {@link ResourceManager resource manager}.
 * 
 * @param aResMgr
 *          the resource manager to destroy
 */
public static void destroy(final ResourceManager aResMgr) {
  if (aResMgr != null) {
    aResMgr.destroy();
  }
}