org.apache.uima.util.Logger Java Examples
The following examples show how to use
org.apache.uima.util.Logger.
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: Misc.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Issues message at warning or fine level (fine if enabled, includes stack trace) * @param errorCount the count of errors used to decrease the frequency * @param message the message * @param logger the logger to use */ public static void decreasingWithTrace(AtomicInteger errorCount, String message, Logger logger) { if (logger != null) { final int c = errorCount.incrementAndGet(); final int cTruncated = Integer.highestOneBit(c); // log with decreasing frequency if (cTruncated == c) { if (logger.isLoggable(Level.FINE)) { try { throw new Throwable();} catch (Throwable e) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); e.printStackTrace(ps); message = "Message count: " + c + "; " + message + " Message count indicates messages skipped to avoid potential flooding.\n" + baos.toString(); logger.log(Level.FINE, message); } } else { message = "Message count: " + c + "; " + message + " Message count indicates messages skipped to avoid potential flooding."; logger.log(Level.WARNING, message); } } } }
Example #2
Source File: UIMAFramework.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Gets a new instance of a {@link UimaContext}. Applications do not generally need to call this * method. * * @param aLogger * the logger that will be returned by this UimaContext's {@link #getLogger()} method. * @param aResourceManager * the ResourceManager that will be used by this UimaContext to locate and access * external resource. * @param aConfigManager * the ConfigurationManager that will be used by this UimaContext to manage Configuration * Parameter settings. * * @return a new UIMA Context to be used by the application. */ public static UimaContextAdmin newUimaContext(Logger aLogger, ResourceManager aResourceManager, ConfigurationManager aConfigManager) { // We use an ugly trick to make the 3 values available to the new UIMA context during its initialization - // we put them in threadlocals for this class (UIMAFramework). UimaContextAdmin context; try { newContextResourceManager.set(aResourceManager); newContextConfigManager.set(aConfigManager); context = getInstance()._newUimaContext(); } finally { newContextResourceManager.set(null); newContextConfigManager.set(null); } context.initializeRoot(aLogger, aResourceManager, aConfigManager); return context; }
Example #3
Source File: UimacppAnalysisComponent.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Get the logging level of the logger for TAFAnnotator. TAF only supports three levels of * logging. All logging levels INFO and below are mapped to the TAF message level. * @return the logging level */ public static int getLoggingLevel() { Logger uimacppLogger = UIMAFramework.getLogger(UimacppAnalysisComponent.class); if (uimacppLogger.isLoggable(Level.FINEST) || uimacppLogger.isLoggable(Level.FINER) || uimacppLogger.isLoggable(Level.FINE) || uimacppLogger.isLoggable(Level.CONFIG) || uimacppLogger.isLoggable(Level.INFO)) { return TAF_LOGLEVEL_MESSAGE; } else if (uimacppLogger.isLoggable(Level.WARNING)) { return TAF_LOGLEVEL_WARNING; } else if (uimacppLogger.isLoggable(Level.SEVERE)) { return TAF_LOGLEVEL_ERROR; } else { return TAF_LOGLEVEL_OFF; } }
Example #4
Source File: UimacppAnalysisComponent.java From uima-uimaj with Apache License 2.0 | 6 votes |
public static void log(int msglevel, String sourceClass, String sourceMethod, String message) { Logger uimacppLogger = UIMAFramework.getLogger(UimacppAnalysisComponent.class); Level level = Level.INFO; // default if (msglevel == TAF_LOGLEVEL_MESSAGE) { level = Level.INFO; } else if (msglevel == TAF_LOGLEVEL_WARNING) { level = Level.WARNING; } else if (msglevel == TAF_LOGLEVEL_ERROR) { level = Level.SEVERE; } if (sourceMethod.length() > 0) uimacppLogger.log(level, sourceClass + "::" + sourceMethod + ": " + message); else uimacppLogger.log(level, sourceClass + ": " + message); // TODO: add Logger method log(level, sourceClass, sourceMethod, message); }
Example #5
Source File: GuiErrorImpl.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public void newError(int severity, String message, Exception exception) { Logger log = UIMAFramework.getLogger(); log.log(logLevels[severity], GUI.theGUI.pnG.showInStatus("JCasGen " + sevMsg[severity] + ": " + message), exception); if (null != exception) { ByteArrayOutputStream b = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(b); exception.printStackTrace(ps); ps.flush(); GUI.theGUI.pnG.showInStatus(b.toString()); ps.close(); } if (IError.WARN < severity) throw new ErrorExit(); }
Example #6
Source File: FSClassRegistry.java From uima-uimaj with Apache License 2.0 | 6 votes |
private static void reportErrors() { boolean throwWhenDone = false; List<ErrorReport> es = errorSet.get(); if (es != null) { StringBuilder msg = new StringBuilder(100); // msg.append('\n'); // makes a break in the message at the beginning, unneeded for (ErrorReport f : es) { msg.append(f.e.getMessage()); throwWhenDone = throwWhenDone || f.doThrow; msg.append('\n'); } errorSet.set(null); // reset after reporting if (throwWhenDone) { throw new CASRuntimeException(CASException.JCAS_INIT_ERROR, "\n" + msg); } else { Logger logger = UIMAFramework.getLogger(); if (null == logger) { throw new CASRuntimeException(CASException.JCAS_INIT_ERROR, "\n" + msg); } else { logger.log(Level.WARNING, msg.toString()); } } } }
Example #7
Source File: AggregateAnalysisEngine_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * @see AnalysisEngine#processAndOutputNewCASes(CAS) */ public CasIterator processAndOutputNewCASes(CAS aCAS) throws AnalysisEngineProcessException { // logging and instrumentation String resourceName = getMetaData().getName(); Logger logger = getLogger(); logger.logrb(Level.FINE, CLASS_NAME.getName(), "process", LOG_RESOURCE_BUNDLE, "UIMA_analysis_engine_process_begin__FINE", resourceName); try { CasIterator iterator = _getASB().process(aCAS); // log end of event logger.logrb(Level.FINE, CLASS_NAME.getName(), "process", LOG_RESOURCE_BUNDLE, "UIMA_analysis_engine_process_end__FINE", resourceName); return iterator; } catch (Exception e) { // log and rethrow exception logger.log(Level.SEVERE, "", e); if (e instanceof AnalysisEngineProcessException) throw (AnalysisEngineProcessException) e; else throw new AnalysisEngineProcessException(e); } }
Example #8
Source File: PearAnalysisEngineWrapper.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public CasIterator processAndOutputNewCASes(CAS aCAS) throws AnalysisEngineProcessException { Logger logger = UIMAFramework.getLogger(this.getClass()); if (logger.isLoggable(Level.FINE)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.FINE, this.getClass().getName(), "processAndOutputNewCASes", LOG_RESOURCE_BUNDLE, "UIMA_analysis_engine_process_begin__FINE", new Object[] { this.ae.getAnalysisEngineMetaData().getName() }); } CasIterator result = this.ae.processAndOutputNewCASes(aCAS); if (logger.isLoggable(Level.FINE)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.FINE, this.getClass().getName(), "processAndOutputNewCASes", LOG_RESOURCE_BUNDLE, "UIMA_analysis_engine_process_end__FINE", new Object[] { this.ae.getAnalysisEngineMetaData().getName() }); } return result; }
Example #9
Source File: LoggingTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void testDefaultLoggerCreation() throws Exception { try { // get default logger Logger logger = UIMAFramework.getLogger(); Assert.assertNotNull(logger); // create another logger Logger logger1 = UIMAFramework.getLogger(); // both loggers must reference the same instance Assert.assertEquals(logger, logger1); // test base logging functions logger.log(Level.SEVERE, "Log test messege with Level SEVERE"); // https://issues.apache.org/jira/browse/UIMA-5719 logger.logrb(Level.WARNING, "testClass", "testMethod", "org.apache.uima.impl.log_messages", "UIMA_external_override_ignored__CONFIG", new Object[] { "n1", "${abc}" }); } catch (Exception ex) { JUnitExtension.handleException(ex); } }
Example #10
Source File: AnalysisEnginePool.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Sets logger for all AnalysisEngines in pool. * @param aLogger - */ public synchronized void setLogger(Logger aLogger) { List<AnalysisEngine> toRelease = new ArrayList<>(); try { for (int i = 0; i < mPool.getSize(); i++) { // get an Analysis Engine from the pool AnalysisEngine ae = (AnalysisEngine) mPool.getResource(0); // wait forever // store AE instance on List to be released later toRelease.add(ae); // reconfigure ae.setLogger(aLogger); } } finally { // release all AnalysisEngines back to pool Iterator<AnalysisEngine> it = toRelease.iterator(); while (it.hasNext()) { mPool.releaseResource(it.next()); } } }
Example #11
Source File: LogThrowErrorImpl.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void newError(int severity, String message, Exception exception) { Logger log = UIMAFramework.getLogger(); log.log(logLevels[severity], "JCasGen: " + message, exception); if (IError.WARN < severity) throw new ErrorExit(); }
Example #12
Source File: LoggingTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testClassLoggerCreation() throws Exception { try { // get class logger Logger logger = UIMAFramework.getLogger(this.getClass()); Assert.assertNotNull(logger); // create another class logger Logger logger1 = UIMAFramework.getLogger(this.getClass()); // create default logger Logger defaultLogger = UIMAFramework.getLogger(); // both loggers must reference the same instance Assert.assertEquals(logger, logger1); // should not be the same Assert.assertNotSame(defaultLogger, logger1); // test base logging functions logger.log(Level.SEVERE, "Log test messege with Level SEVERE"); // https://issues.apache.org/jira/browse/UIMA-5719 logger.logrb(Level.WARNING, "testClass", "testMethod", "org.apache.uima.impl.log_messages", "UIMA_external_override_ignored__CONFIG", new Object[] { "n1", "${abc}" }); } catch (Exception ex) { JUnitExtension.handleException(ex); } }
Example #13
Source File: MultiPageEditor.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void newError(int severity, String message, Exception ex) { Logger log = UIMAFramework.getLogger(); log.log(logLevels[severity], "JCasGen: " + message); //$NON-NLS-1$ System.out.println(Messages.getString("MultiPageEditor.JCasGenErr") //$NON-NLS-1$ + message); if (null != ex) ex.printStackTrace(); if (IError.WARN < severity) { m_message = message; throw new Jg.ErrorExit(); } }
Example #14
Source File: LoggingTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testSetLevel() throws Exception { Logger uimaLogger = UIMAFramework.getLogger(); // should affect everything in // org.apache.uima.* try { // get class logger Logger logger = UIMAFramework.getLogger(this.getClass()); // set level to WARNING uimaLogger.setLevel(Level.WARNING); Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING)); Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE)); Assert.assertFalse(uimaLogger.isLoggable(Level.INFO)); Assert.assertTrue(logger.isLoggable(Level.WARNING)); Assert.assertTrue(logger.isLoggable(Level.SEVERE)); Assert.assertFalse(logger.isLoggable(Level.INFO)); // set level to FINE uimaLogger.setLevel(Level.FINE); Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING)); Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE)); Assert.assertTrue(uimaLogger.isLoggable(Level.INFO)); Assert.assertFalse(uimaLogger.isLoggable(Level.FINER)); Assert.assertFalse(uimaLogger.isLoggable(Level.ALL)); Assert.assertTrue(logger.isLoggable(Level.WARNING)); Assert.assertTrue(logger.isLoggable(Level.SEVERE)); Assert.assertTrue(logger.isLoggable(Level.INFO)); Assert.assertFalse(logger.isLoggable(Level.FINER)); Assert.assertFalse(logger.isLoggable(Level.ALL)); } catch (Exception ex) { JUnitExtension.handleException(ex); } finally { uimaLogger.setLevel(Level.INFO); // otherwise, is stuck at INFO, too much logging } }
Example #15
Source File: NoOpAnnotator.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); if (getContext().getConfigParameterValue("FailDuringInitialization") != null) { throw new ResourceInitializationException(new FileNotFoundException("Simulated Exception")); } if (getContext().getConfigParameterValue("ErrorFrequency") != null) { errorFrequency = (Integer) getContext().getConfigParameterValue("ErrorFrequency"); countDown = errorFrequency; } if (getContext().getConfigParameterValue("CpCDelay") != null) { cpcDelay = (Integer) getContext().getConfigParameterValue("CpCDelay"); System.out.println("NoOpAnnotator.initialize() Initializing With CpC Delay of " + cpcDelay + " millis"); } if (getContext().getConfigParameterValue("ProcessDelay") != null) { processDelay = (Integer) getContext().getConfigParameterValue("ProcessDelay"); System.out.println("NoOpAnnotator.initialize() Initializing With Process Delay of " + processDelay + " millis"); } if (getContext().getConfigParameterValue("FinalCount") != null) { finalCount = (Integer) getContext().getConfigParameterValue("FinalCount"); } // write log messages Logger logger = getContext().getLogger(); logger.log(Level.CONFIG, "NAnnotator initialized"); }
Example #16
Source File: UimaContext_ImplBase.java From uima-uimaj with Apache License 2.0 | 5 votes |
protected Logger maybeThrottleLogger(Logger logger) { final int limit = ((UimaContext_ImplBase)getRootContext()).loggingThrottleLimit; if (limit == Integer.MAX_VALUE || !logger.isAnnotatorLogger()) { return logger; } return logger.getLimitedLogger(limit); }
Example #17
Source File: RootUimaContext_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void initializeRoot(Logger aLogger, ResourceManager aResourceManager, ConfigurationManager aConfigurationManager) { mLogger = aLogger; // mResourceManager = aResourceManager; // mConfigurationManager = aConfigurationManager; mSession = new Session_impl(); }
Example #18
Source File: LanguageDetectorResource.java From newsleak with GNU Affero General Public License v3.0 | 5 votes |
/** * Log language statistics. * * @param logger * the logger */ public synchronized void logLanguageStatistics(Logger logger) { if (!statisticsLogged) { StringBuilder sb = new StringBuilder(); sb.append("Languages detected in current collection\n"); sb.append("-------------------------------------\n"); for (String language : languageCounter.keySet()) { sb.append(language + ": " + languageCounter.get(language) + "\n"); } logger.log(Level.INFO, sb.toString()); statisticsLogged = true; } }
Example #19
Source File: TypeSystemImpl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * ******** OBSOLETE - only left in for supporting some jcas style in alpha level ************* * This code is run when a JCas class is loaded and resolved, for the first time, as part of type system commit, or * as part of statically loading the FSClassRegister class (where this is done for all the built-ins, once). * It looks up the offset value in the type system (via a thread-local) * * hidden parameter: threadLocal value: referencing this type * @param featName - * @return the offset in the int or ref data arrays for the named feature */ // ******** OBSOLETE - only left in for supporting some jcas style in alpha level ************* public static synchronized int getAdjustedFeatureOffset(String featName) { /* The JCas class being loaded was generated for the "alpha" level of UIMA v3, * and is not supported for Beta and later levels. * * This can be fixed by regenerating this using the current v3 version of UIMA tooling * (JCasgen, or the migration tooling to migrate from v2). */ Logger logger = UIMAFramework.getLogger(TypeSystemImpl.class); logger.warn(() -> logger.rb_ue(CASRuntimeException.JCAS_ALPHA_LEVEL_NOT_SUPPORTED)); return -1; }
Example #20
Source File: Resource_ImplBase.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Set the logger in the current UimaContext for use by user annotators. */ @Override public void setLogger(Logger aLogger) { if (getUimaContext() != null) { getUimaContextAdmin().setLogger(aLogger); } }
Example #21
Source File: JSR47Logger_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * create a new LogWrapper class for the specified source class * * @param component * specified source class */ private JSR47Logger_impl(Class<?> component) { super(component); logger = java.util.logging.Logger.getLogger( (component != null) ? component.getName() : "org.apache.uima"); }
Example #22
Source File: Log4jLogger_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * create a new LogWrapper class for the specified source class * * @param component * specified source class */ private Log4jLogger_impl(Class<?> component) { super(component); coreLogger = (org.apache.logging.log4j.core.Logger) LogManager.getLogger( (null == component) ? "org.apache.uima" : component.getName()); mf = coreLogger.getMessageFactory(); logger = new ExtendedLoggerWrapper((AbstractLogger) coreLogger, coreLogger.getName(), mf); }
Example #23
Source File: Slf4jLogger_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * creates a new Logger instance for the specified source class * * @param component * current source class * * @return Logger - returns the Logger object for the specified class */ public static synchronized Logger getInstance(Class<?> component) { if (isJul) { return JSR47Logger_impl.getInstance(component); } if (isLog4j) { return Log4jLogger_impl.getInstance(component); } return new Slf4jLogger_impl(component); }
Example #24
Source File: ChildUimaContext_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public void setLogger(Logger aLogger) { mLogger = maybeThrottleLogger(aLogger); }
Example #25
Source File: AnalysisEngineDescription_implTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void testMulticoreInitialize() throws Exception { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); ConfigurationManager configManager = UIMAFramework.newConfigurationManager(); Logger logger = UIMAFramework.getLogger(this.getClass()); logger.setResourceManager(resourceManager); UimaContext uimaContext = UIMAFramework.newUimaContext(logger, resourceManager, configManager); final Map<String, Object> p = new HashMap<>(); p.put(UIMAFramework.CAS_INITIAL_HEAP_SIZE, 200); p.put(Resource.PARAM_CONFIG_MANAGER, configManager); p.put(Resource.PARAM_RESOURCE_MANAGER, UIMAFramework.newDefaultResourceManager()); p.put(Resource.PARAM_UIMA_CONTEXT, uimaContext); int numberOfThreads = Math.min(50, Misc.numberOfCores * 5); final AnalysisEngine[] aes = new AnalysisEngine[numberOfThreads]; System.out.format("test multicore initialize with %d threads%n", numberOfThreads); MultiThreadUtils.Run2isb run2isb = new MultiThreadUtils.Run2isb() { public void call(int i, int r, StringBuilder sb) throws Exception { Random random = new Random(); for (int j = 0; j < 2; j++) { aes[i] = UIMAFramework.produceAnalysisEngine(primitiveDesc, p); // System.out.println(sb.toString()); // System.out.print('.'); if ((i % 2) == 0) { Thread.sleep(0, random.nextInt(2000)); } } } }; MultiThreadUtils.tstMultiThread("MultiCoreInitialize", numberOfThreads, 100, run2isb, MultiThreadUtils.emptyReset); assertTrue(!aes[0].equals(aes[1])); run2isb = new MultiThreadUtils.Run2isb() { public void call(int i, int r, StringBuilder sb) throws Exception { Random random = new Random(); for (int j = 0; j < 2; j++) { aes[i] = UIMAFramework.produceAnalysisEngine(aggregateDesc, p); // System.out.println(sb.toString()); // System.out.print('.'); if ((i % 2) == 0) { Thread.sleep(0, random.nextInt(5000)); } } } }; MultiThreadUtils.tstMultiThread("MultiCoreInitialize", numberOfThreads, 100, run2isb, MultiThreadUtils.emptyReset); assertTrue(!aes[0].equals(aes[1])); // System.out.println(""); }
Example #26
Source File: PrimitiveAnalysisEngine_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @see org.apache.uima.resource.Resource#initialize(ResourceSpecifier, Map) */ public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { try { // Primitive AnalysisEngine can be build from any ResourceCreationSpecifier- // this includes CollectionReader, and CasConsumer descriptors // as well as AnalysisEngine descriptors. if (!(aSpecifier instanceof ResourceCreationSpecifier)) { return false; } // BUT, for AnalysisEngineDescriptions, must not be an aggregate if (aSpecifier instanceof AnalysisEngineDescription && !((AnalysisEngineDescription) aSpecifier).isPrimitive()) { return false; } mDescription = (ResourceCreationSpecifier) aSpecifier; // also framework implementation must start with org.apache.uima.java final String fwImpl = mDescription.getFrameworkImplementation(); if (!fwImpl.startsWith(Constants.JAVA_FRAMEWORK_NAME)) { return false; } super.initialize(aSpecifier, aAdditionalParams); ProcessingResourceMetaData md = (ProcessingResourceMetaData) mDescription.getMetaData(); if (null == md) { md = UIMAFramework.getResourceSpecifierFactory().createProcessingResourceMetaData(); md.setName("(null)"); } // Get logger for this class Logger logger = getLogger(); logger.logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_analysis_engine_init_begin__CONFIG", md.getName()); // Normalize language codes. Need to do this since a wide variety of // spellings are acceptable according to ISO. normalizeIsoLangCodes(md); // clone this metadata and assign a UUID if not already present ResourceMetaData mdCopy = (ResourceMetaData) md.clone(); if (mdCopy.getUUID() == null) { mdCopy.setUUID(UUIDGenerator.generate()); } setMetaData(mdCopy); // validate the AnalysisEngineDescription and throw a // ResourceInitializationException if there is a problem mDescription.validate(getResourceManager()); // Read parameters from the aAdditionalParams map. if (aAdditionalParams == null) { aAdditionalParams = Collections.emptyMap(); } // determine if verification mode is on mVerificationMode = aAdditionalParams.containsKey(PARAM_VERIFICATION_MODE); // determine if this component is Sofa-aware (based on whether it // declares any input or output sofas in its capabilities) mSofaAware = getAnalysisEngineMetaData().isSofaAware(); initializeAnalysisComponent(aAdditionalParams); // Initialize ResultSpec based on output capabilities // TODO: should only do this for outermost AE resetResultSpecificationToDefault(); logger.logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_analysis_engine_init_successful__CONFIG", md.getName()); return true; } catch (ResourceConfigurationException e) { throw new ResourceInitializationException( ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] { getMetaData().getName(), aSpecifier.getSourceUrlString() }); } }
Example #27
Source File: JSR47Logger_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
public static synchronized Logger getInstance(JSR47Logger_impl l, int limit) { if (limit == Integer.MAX_VALUE) { return l; } return new JSR47Logger_impl(l, limit); }
Example #28
Source File: FlowControllerContainer.java From uima-uimaj with Apache License 2.0 | 4 votes |
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { UimaContext prevContext = setContextHolder(); // Get this early so the restore in correct try { // specifier must be a FlowControllerDescription. (Eventually, we // might support remote specifiers, but not yet) if (!(aSpecifier instanceof FlowControllerDescription)) { throw new ResourceInitializationException( ResourceInitializationException.NOT_A_FLOW_CONTROLLER_DESCRIPTOR, new Object[] { aSpecifier.getSourceUrlString(), aSpecifier.getClass().getName() }); } ResourceCreationSpecifier desc = (ResourceCreationSpecifier) aSpecifier; // also framework implementation must start with org.apache.uima.java final String fwImpl = desc.getFrameworkImplementation(); if (fwImpl == null || !fwImpl.equalsIgnoreCase(Constants.JAVA_FRAMEWORK_NAME)) { throw new ResourceInitializationException( ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION, new Object[] { fwImpl, aSpecifier.getSourceUrlString() }); } super.initialize(aSpecifier, aAdditionalParams); // validate the descriptor desc.validate(getResourceManager()); // instantiate FlowController mFlowController = instantiateFlowController(desc); // record metadata setMetaData(desc.getMetaData()); // add our metadata to the CasManager, so that it will pick up our // type system, priorities, and indexes getCasManager().addMetaData(getProcessingResourceMetaData()); // determine if this component is Sofa-aware (based on whether it // declares any input or output sofas in its capabilities) mSofaAware = getProcessingResourceMetaData().isSofaAware(); // Set Logger, to enable component-specific logging configuration UimaContextAdmin uimaContext = getUimaContextAdmin(); Logger logger = UIMAFramework.getLogger(mFlowController.getClass()); logger.setResourceManager(this.getResourceManager()); uimaContext.setLogger(logger); Logger classLogger = getLogger(); classLogger.logrb(Level.CONFIG, this.getClass().getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_flow_controller_init_begin__CONFIG", getMetaData().getName()); // initialize FlowController mFlowController.initialize(getFlowControllerContext()); mMBeanServer = null; String mbeanNamePrefix = null; if (aAdditionalParams != null) { mMBeanServer = aAdditionalParams.get(AnalysisEngine.PARAM_MBEAN_SERVER); mbeanNamePrefix = (String)aAdditionalParams.get(AnalysisEngine.PARAM_MBEAN_NAME_PREFIX); } // update MBean with the name taken from metadata getMBean().setName(getMetaData().getName(), getUimaContextAdmin(), mbeanNamePrefix); // register MBean with MBeanServer. If no MBeanServer specified in the // additionalParams map, this will use the platform MBean Server // (Java 1.5 only) JmxMBeanAgent.registerMBean(getMBean(), mMBeanServer); classLogger.logrb(Level.CONFIG, this.getClass().getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_flow_controller_init_successful__CONFIG", getMetaData().getName()); initialized = true; return true; } catch (ResourceConfigurationException e) { throw new ResourceInitializationException(e); } finally { UimaContextHolder.setContext(prevContext); } }
Example #29
Source File: AnnotatorContext_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getLogger() */ public Logger getLogger() { return mUimaContext.getLogger(); }
Example #30
Source File: ChildUimaContext_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @see org.apache.uima.analysis_engine.annotator.AnnotatorContext#getLogger() */ @Override public Logger getLogger() { return mLogger; }