Refine search
if (null == parentResourceManager) { rsrcMgr = UIMAFramework.newDefaultResourceManager(); } else { rsrcMgr = ((ResourceManager_impl) parentResourceManager).copy(); rsrcMgr.setExtensionClassPath(sp.classPath, true); if (parentResourceManager != null) { rsrcMgr.setCasManager(parentResourceManager.getCasManager()); // shares the same merged type system UIMAFramework.getLogger(this.getClass()).logrb( Level.CONFIG, this.getClass().getName(), rsrcMgr.setDataPath(sp.dataPath); UIMAFramework.getLogger(this.getClass()).logrb( Level.CONFIG, this.getClass().getName(),
private ClassLoader getExtensionClassLoader() { if (resMgr == null) { return null; } else { return resMgr.getExtensionClassLoader(); } }
classifierJarURL = classifierJarFile.toURI().toURL(); } else { ResourceManager rm = UIMAFramework.newDefaultResourceManager(); if (additionalSearchPaths != null) { List<String> dpElements = Lists.newLinkedList(); dpElements.add(rm.getDataPath()); dpElements.addAll(Arrays.asList(additionalSearchPaths)); rm.setDataPath(dataPathJoiner.join(dpElements)); classifierJarURL = rm.resolveRelativePath(classifierJarPath); if (classifierJarURL == null) { throw new IllegalStateException(String.format(
MetaDataCacheKey(ResourceSpecifier resourceSpecifier, ResourceManager resourceManager) { this.resourceSpecifier = resourceSpecifier; this.rmClassLoader = (null == resourceManager) ? null : resourceManager.getExtensionClassLoader(); // can be null this.rmDataPath = (null == resourceManager) ? null : resourceManager.getDataPath(); }
/** * Creates the resource manager. * * @return the resource manager */ public ResourceManager createResourceManager() { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); if (classPath != null && classPath.trim().length() > 0) { try { resourceManager.setExtensionClassPath(this.getClass().getClassLoader(), classPath, true); } catch (MalformedURLException e1) { error.newError(IError.ERROR, getString("Internal Error", null), e1); } } else { resourceManager.setExtensionClassLoader(this.getClass().getClassLoader(), true); } return resourceManager; }
if (this.dataPathName != null) { try { rsrcMgr = UIMAFramework.newDefaultResourceManager(); rsrcMgr.setDataPath(this.dataPathName); } catch (MalformedURLException e) { StringBuffer msg = new StringBuffer(); ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in); this.ae = UIMAFramework.produceAnalysisEngine(specifier); } else { this.ae = UIMAFramework.produceAnalysisEngine(specifier, rsrcMgr, null);
private TypeSystemDescription getLocalTSD(String toLoad) throws InvalidXMLException, IOException { TypeSystemDescription localTSD = localTSDMap.get(toLoad); if (localTSD == null) { String locateTSD = locate(toLoad, descriptorPaths, "TypeSystem.xml", true); if (locateTSD != null) { localTSD = UIMAFramework.getXMLParser().parseTypeSystemDescription( new XMLInputSource(locateTSD)); ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); resMgr.setDataPath(getDataPath()); localTSD.resolveImports(resMgr); localTSDMap.put(toLoad, localTSD); } } return localTSD; }
aResourceManager = UIMAFramework.newDefaultResourceManager(); uimaContext = UIMAFramework.newUimaContext(UIMAFramework.getLogger(), aResourceManager, UIMAFramework.newConfigurationManager()); resMgrCfg = UIMAFramework.getXMLParser().parseResourceManagerConfiguration( new XMLInputSource(descriptorPath)); aResourceManager.initializeExternalResources(resMgrCfg, "/", null);
ResourceSpecifierFactory resourceSpecifierFactory = UIMAFramework.getResourceSpecifierFactory(); extensionTypeSystemFile.getLocation().toFile()); XMLParser xmlParser = UIMAFramework.getXMLParser(); resourceManager = new ResourceManager_impl(classLoader); } else { resourceManager = UIMAFramework.newDefaultResourceManager(); .getPersistentProperty((new QualifiedName("", "CDEdataPath"))); if (dataPath != null) { resourceManager.setDataPath(dataPath);
resMgr = UIMAFramework.newDefaultResourceManager(); Logger logger = UIMAFramework.getLogger(this.getClass()); logger.setResourceManager(resMgr); configMgr = UIMAFramework.newConfigurationManager(); mUimaContextAdmin.getResourceManager().initializeExternalResources(resMgrCfg, mUimaContextAdmin.getQualifiedContextName(), aAdditionalParmsForExtResources); } finally { if (resourceDependencies != null) { mUimaContextAdmin.getResourceManager().resolveAndValidateResourceDependencies( resourceDependencies, mUimaContextAdmin.getQualifiedContextName());
public static void main(String[] args) throws Exception { String dictionaryResourceName = DICTIONARY_RESOURCE_NAME; if (args.length == 2) { // do nothing } else if (args.length == 3) { dictionaryResourceName = args[2]; } else { usage(); System.exit(17); } AnalysisEngineDescription conceptMapperDesc = UIMAFramework.getXMLParser() .parseAnalysisEngineDescription(new XMLInputSource(args[0])); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(conceptMapperDesc); DictionaryResource_impl dict = (DictionaryResource_impl) ae.getResourceManager().getResource( dictionaryResourceName); OutputStream output = new BufferedOutputStream(new FileOutputStream(args[1])); dict.serializeEntries(output); output.close(); ae.destroy(); // for some reason JVM won't exit normally, // probably because CPM threads are alive? System.exit(0); }
public void initCPM() throws DictionaryLoaderException { try { ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); String dp = System.getProperty("uima.datapath"); if (null != dp) { resMgr.setDataPath(dp); } ae = UIMAFramework.produceAnalysisEngine(aeSpecifier); cas = ae.newCAS(); } catch (ResourceInitializationException e) { throw new DictionaryLoaderException(e); } catch (MalformedURLException e) { throw new DictionaryLoaderException(e); } }
public ResourceManager createResourceManager() { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); try { resourceManager.setExtensionClassPath(this.getClass().getClassLoader(), classPath, true); } catch (MalformedURLException e1) { error.newError(IError.ERROR, getString("Internal Error", null), e1); } return resourceManager; }
ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); resourceManager.setExtensionClassPath( cachedRMcl = new SoftReference<UIMAClassLoader>((UIMAClassLoader) resourceManager.getExtensionClassLoader()); resourceManager.setDataPath(dataPath); } catch (MalformedURLException e1) { throw new InternalErrorCDE(Messages.getString("MultiPageEditor.14"), e1); //$NON-NLS-1$
private void initializeComponentCasPool(int aComponentCasPoolSize, long anInitialCasHeapSize, boolean disableJCasCache) { if (aComponentCasPoolSize > 0) { EECasManager_impl cm = (EECasManager_impl) getResourceManager().getCasManager(); cm.setInitialCasHeapSize(anInitialCasHeapSize); cm.setPoolSize(getUimaContextAdmin().getUniqueName(), aComponentCasPoolSize); if ( disableJCasCache ) { cm.disableJCasCaching(); } if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) { UIMAFramework.getLogger(CLASS_NAME).logrb( Level.INFO, CLASS_NAME.getName(), "initializeComponentCasPool", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_cas_pool_config_INFO", new Object[] { getComponentName(), getUimaContextAdmin().getQualifiedContextName(), aComponentCasPoolSize, anInitialCasHeapSize / 4, disableJCasCache }); } } }
/** * returns a valid ResourceManager with the information from the PackageBrowser object. * * @param pkgBrowser * packageBrowser object of an installed PEAR package * * @return a ResourceManager object with the information from the PackageBrowser object. * * @throws IOException passthru */ private static ResourceManager getResourceManager(PackageBrowser pkgBrowser) throws IOException { ResourceManager resourceMgr = UIMAFramework.newDefaultResourceManager(); // set component data path if (pkgBrowser.getComponentDataPath() != null) { resourceMgr.setDataPath(pkgBrowser.getComponentDataPath()); } // set component classpath if (pkgBrowser.buildComponentClassPath() != null) { resourceMgr.setExtensionClassPath(pkgBrowser.buildComponentClassPath(), true); } return resourceMgr; }
public static File resolveFile(String path, ResourceManager resMgr) throws URISyntaxException, MalformedURLException { Preconditions.checkArgument(path != null); if (resMgr == null) { resMgr = UIMAFramework.newDefaultResourceManager(); } URL modelBaseURL = resMgr.resolveRelativePath(path); if (modelBaseURL == null) throw new IllegalStateException(format( "Can't resolve path %s using an UIMA relative path resolver", path)); return new File(modelBaseURL.toURI()); }
private Set<String> getTypes(IFolder folder, String filePath) throws InvalidXMLException, IOException { Set<String> types = new HashSet<String>(); IFile iFile = getFile(folder, filePath); URL url; try { url = iFile.getLocationURI().toURL(); ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); resMgr.setDataPath(folder.getLocation().toPortableString()); types = getTypes(url, resMgr); } catch (MalformedURLException e) { e.printStackTrace(); } return types; }
/** * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getResourceURL(java.lang.String, * java.lang.String[]) */ public URL getResourceURL(String aKey, String[] aParams) throws ResourceAccessException { URL result = getResourceManager().getResourceURL(makeQualifiedName(aKey), aParams); if (result != null) { return result; } else { // try as an unmanaged resource (deprecated) URL unmanagedResourceUrl = null; try { unmanagedResourceUrl = getResourceManager().resolveRelativePath(aKey); } catch (MalformedURLException e) { // if key is not a valid path then it cannot be resolved to an unmanged resource } if (unmanagedResourceUrl != null) { UIMAFramework.getLogger().logrb(Level.WARNING, this.getClass().getName(), "getResourceURL", LOG_RESOURCE_BUNDLE, "UIMA_unmanaged_resource__WARNING", new Object[] { aKey }); return unmanagedResourceUrl; } return null; } }
/** * Acquires Resource InputStreams using the ResourceManager. * * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getResourceAsStream(java.lang.String) */ public InputStream getResourceAsStream(String aKey) throws ResourceAccessException { InputStream result = getResourceManager().getResourceAsStream(makeQualifiedName(aKey)); if (result != null) { return result; } else { // try as an unmanaged resource (deprecated) URL unmanagedResourceUrl = null; try { unmanagedResourceUrl = getResourceManager().resolveRelativePath(aKey); } catch (MalformedURLException e) { // if key is not a valid path then it cannot be resolved to an unmanged resource } if (unmanagedResourceUrl != null) { UIMAFramework.getLogger().logrb(Level.WARNING, this.getClass().getName(), "getResourceAsStream", LOG_RESOURCE_BUNDLE, "UIMA_unmanaged_resource__WARNING", new Object[] { aKey }); try { return unmanagedResourceUrl.openStream(); } catch (IOException e) { throw new ResourceAccessException(e); } } return null; } }