/** * Scan the context and initialize external resources injected into other external resources. * * @param aContext * the UIMA context. */ private static void initializeNestedResources(UimaContext aContext) throws ResourceInitializationException { List<ExternalResourceAware> awareResources = new ArrayList<ExternalResourceAware>(); // Initialize the resources - each resource must only be initialized once. We remember // if a resource has already been initialized in a weak hash map, so we automatically // forget about resources that are garbage collected. for (Object r : getResources(aContext)) { synchronized (initializedResources) { if (r instanceof ExternalResourceAware && !initializedResources.containsKey(r)) { // Already mark the resource as initialized so we do not run into an // endless recursive loop when initialize() is called again. initializedResources.put(r, INITIALIZED); initialize(r, aContext); awareResources.add((ExternalResourceAware) r); } } } // Notify the resources after everything has been configured for (ExternalResourceAware res : awareResources) { res.afterResourcesInitialized(); } }
String prefix = ((ExternalResourceAware) object).getResourceName(); if (prefix != null) { key = prefix + PREFIX_SEPARATOR + key;