XMLInputSource aeIputSource = new XMLInputSource(aeDescriptorPath); ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser() .parseResourceSpecifier(aeIputSource); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
/** * Create a new CPEFactory on which we will later call parse(String) to parse a CPE descriptor. * * @param aResourceManager the a resource manager */ public CPEFactory(ResourceManager aResourceManager) { if (aResourceManager == null) { aResourceManager = UIMAFramework.newDefaultResourceManager(); } uimaContext = UIMAFramework.newUimaContext(UIMAFramework.getLogger(), aResourceManager, UIMAFramework.newConfigurationManager()); }
/** * Creates the fs index key description. * * @return the fs index key description */ public FsIndexKeyDescription createFsIndexKeyDescription() { return UIMAFramework.getResourceSpecifierFactory().createFsIndexKeyDescription(); }
public static CollectionReader getCR(File collectionReaderDescriptorFile) throws ResourceInitializationException { try { XMLInputSource xmlInputSource = new XMLInputSource(collectionReaderDescriptorFile); XMLParser xmlParser = UIMAFramework.getXMLParser(); ResourceSpecifier resourceSpecifier = xmlParser.parseResourceSpecifier(xmlInputSource); CollectionReader collectionReader = UIMAFramework.produceCollectionReader(resourceSpecifier); return collectionReader; } catch (IOException ioe) { throw new ResourceInitializationException(ioe); } catch (InvalidXMLException ixe) { throw new ResourceInitializationException(ixe); } }
public void removeMessageOrigin(String aCasReferenceId) { if (originMap.containsKey(aCasReferenceId)) { originMap.remove(aCasReferenceId); if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST)) { UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(), "removeMessageOrigin", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_remove_msg_origin_entry__FINEST", new Object[] { getComponentName(), aCasReferenceId }); } } }
/** * Disable a CASProcessor in the processing pipeline. * * @param aCasProcessorName CASProcessor to be added to the processing pipeline */ public void enableCasProcessor(String aCasProcessorName) { for (int i = 0; i < annotatorList.size(); i++) { ProcessingContainer pc = ((ProcessingContainer) annotatorList.get(i)); if (pc.getName().equals(aCasProcessorName)) { if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_enabled_cp__FINEST", new Object[] { Thread.currentThread().getName(), aCasProcessorName }); } pc.setStatus(Constants.CAS_PROCESSOR_RUNNING); } } }
/** * Checks out a CAS from the pool. * * @return a CAS instance. Returns <code>null</code> if none are available (in which case the * client may {@link Object#wait()} on this object in order to be notified when an * instance becomes available). */ public synchronized CAS getCas() { if (!mFreeInstances.isEmpty()) { CAS cas = (CAS) mFreeInstances.remove(0); if (cas != null) { // Add the cas to a list of checked-out cases checkedOutInstances.add(cas); if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) { UIMAFramework.getLogger(this.getClass()).logrb( Level.FINEST, this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_add_cas_to_checkedout_list__FINEST", new Object[] { Thread.currentThread().getName(), String.valueOf(checkedOutInstances.size()) }); } } return cas; } else { // no instances available return null; } }
if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_add_consumer_to_list__CONFIG", ((List) consumerDeployList.get(listIndex)).add(aProcessor); } else { ArrayList newList = new ArrayList(); consumers.put(aCpName, newList); consumerDeployList.add(newList); if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_add_consumer_to_new_list__CONFIG",
public synchronized void saveTime(long aTime, String aCasReferenceId, String anEndpointName) { String key = aCasReferenceId + anEndpointName; if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) { UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(), "saveTime", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_save_time__FINE", new Object[] { aTime, aCasReferenceId, getComponentName(), anEndpointName, key }); } statsMap.put(key, Long.valueOf(aTime)); }
protected void stopTransportLayer() { if (transports.size() > 0) { Set<Entry<String, UimaTransport>> set = transports.entrySet(); for (Entry<String, UimaTransport> entry : set) { UimaTransport transport = entry.getValue(); try { transport.stopIt(); } catch (Exception e) { if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) { UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(), "stopTransportLayer", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_service_exception_WARNING", getComponentName()); UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "stopTransportLayer", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e); } } } } }
Object anObject = queue.remove(aQueueIndex); if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_chunk_state_false_timeout__FINEST",
aResourceManager = UIMAFramework.newDefaultResourceManager(); uimaContext = UIMAFramework.newUimaContext(UIMAFramework.getLogger(), aResourceManager, UIMAFramework.newConfigurationManager()); String descriptorPath = CPMUtils.convertToAbsolutePath(System.getProperty("CPM_HOME"), CPM_HOME, resMgrCfgDesc.get()); resMgrCfg = UIMAFramework.getXMLParser().parseResourceManagerConfiguration( new XMLInputSource(descriptorPath)); aResourceManager.initializeExternalResources(resMgrCfg, "/", null); throw new ResourceInitializationException(e); } catch (IOException e) { throw new ResourceInitializationException(e);
if (anObject instanceof UimaTimer) { timer = (UimaTimer) anObject; if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) { UIMAFramework.getLogger(TimerFactory.class).logrb(Level.CONFIG, TimerFactory.class.getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_show_timer_class__CONFIG", throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND, new Object[] { aClassName, "CPE" }, e); } catch (IllegalAccessException e) { throw new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { aClassName, "CPE" }, e); } catch (InstantiationException e) { throw new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { aClassName, "CPE" }, e); if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) { UIMAFramework.getLogger(TimerFactory.class).logrb(Level.CONFIG, TimerFactory.class.getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_java_timer__CONFIG", new Object[] { Thread.currentThread().getName() });
this.uimaLogger = UIMAFramework.getLogger(this.getClass()); this.aeDesc = aeDescriptorFileName; this.numInstances = numInstances; this.uimaLogger.log(Level.INFO, "Starting C++ service: " + commandArgs.toString()); this.uimaLogger.log(Level.INFO, " env params: " + envVarMap.toString()); startService(); throw new ResourceInitializationException(e); } catch (UIMAException e) { notifyInitializationStatus(e); throw new ResourceInitializationException(e);
throw new ResourceInitializationException(e1); UIMAFramework.getLogger().logrb(Level.CONFIG, ResourceManager_impl.class.getName(), "initializeExternalResources", LOG_RESOURCE_BUNDLE, "UIMA_overridden_resource__CONFIG", new Object[] { e.getKey(), aQualifiedContextName, definingContext }); } else { UIMAFramework.getLogger().logrb(Level.WARNING, ResourceManager_impl.class.getName(), "initializeExternalResources", LOG_RESOURCE_BUNDLE, "UIMA_duplicate_resource_name__WARNING", throw new ResourceInitializationException(e1);
/** * Creates a {@link TypeSystemDescription} from all type descriptions that can be found via the * default import pattern or via the {@code META-INF/org.apache.uima.fit/types.txt} files in the * classpath. * * @return the auto-scanned type system. * @throws ResourceInitializationException * if the collected type system descriptions cannot be merged. */ public static TypeSystemDescription createTypeSystemDescription() throws ResourceInitializationException { List<TypeSystemDescription> tsdList = new ArrayList<TypeSystemDescription>(); for (String location : scanTypeDescriptors()) { try { XMLInputSource xmlInputType1 = new XMLInputSource(location); tsdList.add(getXMLParser().parseTypeSystemDescription(xmlInputType1)); LogFactory.getLog(TypeSystemDescription.class).debug( "Detected type system at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(TypeSystemDescription.class).warn( "[" + location + "] is not a type file. Ignoring.", e); } } ResourceManager resMgr = ResourceManagerFactory.newResourceManager(); return mergeTypeSystems(tsdList, resMgr); }
/** * Creates a {@link FsIndexCollection} from all index descriptions that can be found via the * pattern specified in the system property {@code org.apache.uima.fit.fsindex.import_pattern} or * via the {@code META-INF/org.apache.uima.fit/fsindexes.txt} files in the classpath. * * @return the auto-scanned indexes. * @throws ResourceInitializationException * if the index collection could not be assembled */ public static FsIndexCollection createFsIndexCollection() throws ResourceInitializationException { List<FsIndexDescription> fsIndexList = new ArrayList<FsIndexDescription>(); for (String location : scanIndexDescriptors()) { try { XMLInputSource xmlInput = new XMLInputSource(location); FsIndexCollection fsIdxCol = getXMLParser().parseFsIndexCollection(xmlInput); fsIdxCol.resolveImports(); fsIndexList.addAll(asList(fsIdxCol.getFsIndexes())); LogFactory.getLog(FsIndexFactory.class).debug("Detected index at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(FsIndexFactory.class).warn( "[" + location + "] is not a index descriptor file. Ignoring.", e); } } return createFsIndexCollection(fsIndexList.toArray(new FsIndexDescription[fsIndexList.size()])); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); try { featureExtractors = new FeatureResourceLoader(tcModelLocation) .loadExternalResourceDescriptionOfFeatures(); mlAdapter = initMachineLearningAdapter(tcModelLocation); featureMode = initFeatureMode(tcModelLocation); learningMode = initLearningMode(tcModelLocation); validateUimaParameter(); AnalysisEngineDescription connector = getSaveModelConnector( tcModelLocation.getAbsolutePath(), mlAdapter, learningMode, featureMode, featureExtractors); engine = UIMAFramework.produceAnalysisEngine(connector, getModelFeatureAwareResourceManager(tcModelLocation), null); } catch (Exception e) { throw new ResourceInitializationException(e); } }
resMgr = UIMAFramework.newDefaultResourceManager(); Logger logger = UIMAFramework.getLogger(this.getClass()); logger.setResourceManager(resMgr); configMgr = UIMAFramework.newConfigurationManager(); mUimaContextAdmin = UIMAFramework.newUimaContext(logger, resMgr, configMgr); Logger logger = UIMAFramework.getLogger(this.getClass()); logger.setResourceManager(mUimaContextAdmin.getResourceManager()); mUimaContextAdmin.setLogger(logger); throw new ResourceInitializationException(e); externalOverrides = UIMAFramework.getResourceSpecifierFactory().createSettings(); // i.e. new Settings_impl() try { externalOverrides.loadSystemDefaults(); } catch (ResourceConfigurationException e) { throw new ResourceInitializationException(ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] { name, metadata.getSourceUrlString() }, e); mUimaContextAdmin.getConfigurationManager().setSession(mUimaContextAdmin.getSession()); } catch (ResourceConfigurationException e) { throw new ResourceInitializationException( ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] { name, metadata.getSourceUrlString() }, e);
throw new ResourceInitializationException( ResourceInitializationException.NOT_A_FLOW_CONTROLLER_DESCRIPTOR, new Object[] { aSpecifier.getSourceUrlString(), aSpecifier.getClass().getName() }); if (fwImpl == null || !fwImpl.equalsIgnoreCase(Constants.JAVA_FRAMEWORK_NAME)) { throw new ResourceInitializationException( ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION, new Object[] { fwImpl, aSpecifier.getSourceUrlString() }); Logger logger = UIMAFramework.getLogger(mFlowController.getClass()); logger.setResourceManager(this.getResourceManager()); uimaContext.setLogger(logger); classLogger.logrb(Level.CONFIG, this.getClass().getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_flow_controller_init_begin__CONFIG", getMetaData().getName()); classLogger.logrb(Level.CONFIG, this.getClass().getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_flow_controller_init_successful__CONFIG", getMetaData().getName()); return true; } catch (ResourceConfigurationException e) { throw new ResourceInitializationException(e); } finally { UimaContextHolder.setContext(prevContext);