/** * Workaround for https://code.google.com/p/cleartk/issues/detail?id=346 * * Not intended for external use */ static void allowClassifierModelOnClasspath(UimaContext context) { String modelPathParam = GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH; String modelPath = (String) context.getConfigParameterValue(modelPathParam); if (modelPath != null) { URL modelClasspathURL = RelationExtractorAnnotator.class.getResource(modelPath); if (modelClasspathURL != null) { UimaContextAdmin contextAdmin = (UimaContextAdmin) context; ConfigurationManager manager = contextAdmin.getConfigurationManager(); String qualifiedModelPathParam = contextAdmin.getQualifiedContextName() + modelPathParam; manager.setConfigParameterValue(qualifiedModelPathParam, modelClasspathURL.toString()); } } }
/** * Gets the ResourceManager used by this UimaContext to locate and access external resources * * @return the ResourceManager */ public ResourceManager getResourceManager() { if (null == mPearResourceManager) { return parentContext.getResourceManager(); } return mPearResourceManager; }
/** * Initialize a component from a map. * * @param component * the component to initialize. * @param map * a UIMA context with configuration parameters. * @see #initialize(Object, UimaContext) * @throws ResourceInitializationException * if a failure occurs during initialization. */ public static void initialize(final Object component, final Map<String, Object> map) throws ResourceInitializationException { UimaContextAdmin context = UIMAFramework.newUimaContext(UIMAFramework.getLogger(), ResourceManagerFactory.newResourceManager(), UIMAFramework.newConfigurationManager()); ConfigurationManager cfgMgr = context.getConfigurationManager(); cfgMgr.setSession(context.getSession()); for (Entry<String, Object> e : map.entrySet()) { cfgMgr.setConfigParameterValue(context.getQualifiedContextName() + e.getKey(), e.getValue()); } initialize(component, context); }
public ChildUimaContext_impl(UimaContextAdmin aParentContext, String aContextName, Map<String, String> aSofaMappings) { super(aParentContext.getQualifiedContextName() + aContextName + '/', aSofaMappings); mRootContext = aParentContext.getRootContext(); mLogger = aParentContext.getRootContext().getLogger(); mSessionNamespaceView = new SessionNamespaceView_impl(mRootContext.getSession(), mQualifiedContextName); parentContext = aParentContext; }
public void dumpContext(UimaContextAdmin ctx) { if ( !(ctx instanceof RootUimaContext_impl) ) { dumpContext(ctx.getRootContext()); } else { Map<String, AnalysisEngineManagement> m = ctx.getManagementInterface().getComponents(); for( Entry<String, AnalysisEngineManagement> e : m.entrySet()) { System.out.println(">>>>>>>> "+e.getKey()+" "+e.getValue().getUniqueMBeanName()); } } } public void initializeAnalysisEngine() throws ResourceInitializationException {
logger.setResourceManager(mUimaContextAdmin.getResourceManager()); mUimaContextAdmin.setLogger(logger); (Settings) aAdditionalParams.get(Resource.PARAM_EXTERNAL_OVERRIDE_SETTINGS); if (externalOverrides != null) { mUimaContextAdmin.setExternalOverrides(externalOverrides); } else { if (mUimaContextAdmin.getExternalOverrides() == null) { mUimaContextAdmin.setExternalOverrides(externalOverrides); mUimaContextAdmin.getConfigurationManager().createContext( mUimaContextAdmin.getQualifiedContextName(), getMetaData(), mUimaContextAdmin.getExternalOverrides()); mUimaContextAdmin.getConfigurationManager().setSession(mUimaContextAdmin.getSession()); } catch (ResourceConfigurationException e) { throw new ResourceInitializationException( aAdditionalParams.put(PARAM_RESOURCE_MANAGER, mUimaContextAdmin.getResourceManager()); } else { if (!aAdditionalParams.containsKey(PARAM_RESOURCE_MANAGER)) { aAdditionalParams.put(PARAM_RESOURCE_MANAGER, mUimaContextAdmin.getResourceManager()); mUimaContextAdmin.getResourceManager().initializeExternalResources(resMgrCfg, mUimaContextAdmin.getQualifiedContextName(), aAdditionalParmsForExtResources); } finally { UimaContextHolder.setContext(prevContext);
private String getDelegateServiceName() { String svcName = null; try { UimaContext childContext = parentController.getChildUimaContext(endpointName); svcName = ((UimaContextAdmin) childContext).getQualifiedContextName(); if (svcName != null) { if (svcName.startsWith("/")) { svcName = svcName.substring(1); svcName = svcName.replaceAll("/", "_"); // normalize if (svcName.endsWith("_")) { svcName = svcName.substring(0, serviceName.length() - 1); } } } } catch (Exception e) { svcName = delegateKey; } return svcName; } private String getTopLevelServiceName() {
.getRootContext().getManagementInterface(); if (rootMBean.getUniqueMBeanName() == null) { prefix += rootName + " Components,"; uniqueMBeanName = makeMBeanName(prefix, aContext.getQualifiedContextName().substring(1), 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 }); } } }
initialize(resourceSpecifier, paramsMap); AnalysisEngineManagementImpl mbean = (AnalysisEngineManagementImpl) getUimaContextAdmin() .getManagementInterface(); if (this instanceof AggregateAnalysisEngineController) { "UIMAEE_multiplier_cas_pool_config_INFO", new Object[] { getComponentName(), aComponentCasPoolSize, anInitialCasHeapSize,getUimaContextAdmin().getQualifiedContextName() }); UimaContext childContext = parentController.getChildUimaContext(endpointName); if ( childContext != null && childContext instanceof UimaContextAdmin ) { String qualifiedContextName = ((UimaContextAdmin)childContext).getQualifiedContextName();
ResourceManager resourceManager = aParentContext.getRootContext().getResourceManager(); XMLInputSource input = resolveImportByName(aFlowControllerDescriptor, resourceManager);
annotatorClass = Class_TCCL.forName(annotatorClassName, getUimaContextAdmin().getResourceManager()); } catch (ClassNotFoundException e) { throw new ResourceInitializationException( Logger logger = UIMAFramework.getLogger(annotatorClass); logger.setResourceManager(this.getResourceManager()); uimaContext.setLogger(logger); mAnalysisComponent.initialize(getUimaContext()); getUimaContextAdmin().defineCasPool(mAnalysisComponent.getCasInstancesRequired(), getPerformanceTuningSettings(), mSofaAware); } catch (Exception e) {
UimaContextAdmin childContext = aParentContext.createChild(key, sofamap); mInitParams.put(Resource.PARAM_UIMA_CONTEXT, childContext);
public ConfigurationManager getConfigurationManager() { return getRootContext().getConfigurationManager(); }
/** * Gets the MBean that provides the management interface to this AE. Returns the same object as * UimaContext.getManagementInterface() but casted to the AnalysisEngineManagement type. * @return the MBean for the management interface to this AE */ protected AnalysisEngineManagementImpl getMBean() { return (AnalysisEngineManagementImpl) mAggregateUimaContext.getManagementInterface(); }
casList[i].setCurrentComponentInfo(context.getComponentInfo()); try { if (sofaUnaware) { String absSofaName = context.getComponentInfo().mapToSofaID(CAS.NAME_DEFAULT_SOFA); if (!CAS.NAME_DEFAULT_SOFA.equals(absSofaName)) { casList[i].createView(CAS.NAME_DEFAULT_SOFA);
public Session getSession() { // must update root session first, in case it has been changed, for example by the deployment // wrapper mSessionNamespaceView.setRootSession(getRootContext().getSession()); return mSessionNamespaceView; }
if ( getUimaContext() != null ) { // getUimaContext() = null for TLA String ctxName = ((UimaContextAdmin)this.getUimaContext()).getQualifiedContextName();
pServiceInfo.setServiceKey(getUimaContextAdmin().getQualifiedContextName()); pServiceInfo.setCmRegisteredName(getUimaContextAdmin().getUniqueName());
UimaContextAdmin childContext = rootContext.createChild("WSSeparator", sofamappings); Map<String,Object> additionalParams = new HashMap<String,Object>(); additionalParams.put(Resource.PARAM_UIMA_CONTEXT, childContext);