On 6/10/2013 2:43 PM, Marshall Schor wrote: > On 6/10/2013 12:44 PM, Richard Eckart de Castilho wrote: >> Am 10.06.2013 um 18:03 schrieb Marshall Schor <m...@schor.com>: >> >>> I'm not an expert here; I took a look at the code. >>> >>> It seems that the interface Resource includes the method >>> getResourceManager() >>> which returns the ResourceManager that was used to create this instance. >>> The implementations seem to inherit from the Resource_ImplBase which has the >>> getResourceManager method. >>> So it seems to me that Resources can find the ResourceManager they were >>> created in? >> I can offer two tests and a diagnosis, and at least a suggestion for one or >> two fixes. >> >> == Tests == >> >> Try this: >> >> - Set a breakpoint in TestResourceInterface_impl line 48 >> - Run ResourceManager_implTest in debug mode >> - when the breakpoint is hit, inspect aData.getResourceManager() (is "null") >> >> Admittedly, the external resource is not initialized in its natural >> environment (within an AE) here. >> >> Different test: >> >> - Set a breakpoint in Apache uimaFIT >> ExternalResourceFactoryTest$DummySharedResourceObject.load(DataResource) >> line: 558 >> - Run ExternalResourceFactoryTest.testScanBind() line: 103 in debug mode >> - when the breakpoint is hit, inspect aData.getResourceManager() (is "null") >> >> == Diagnosis == >> >> The ResourceManager_impl (line 567) would set a resource manager on the >> created external resource, if one had been specified in the >> aResourceInitParams which are handed down all the way from the creation of >> the analysis component to the resource. But if the original called did leave >> it to UIMA to set up a resource manager, this internally created manager is >> not passed through. Thus, Resource_ImplBase.initialize (line 88ff) creates a >> new resource manager for the resource. >> This could be fixed by adding the following code in Resource_ImplBase line >> 176: >> >> if (aAdditionalParams == null) { >> aAdditionalParams = new HashMap<String, Object>(); >> } >> if (!aAdditionalParams.containsKey(PARAM_RESOURCE_MANAGER)) { >> aAdditionalParams.put(PARAM_RESOURCE_MANAGER, >> mUimaContextAdmin.getResourceManager()); >> } > This seems reasonable to me. It says to share whatever resource manager is > passed in or created for this UIMA Context with external resource, unless a > specific additional param was passed in specifying a resource manager to use. > > >> Additionally, ConfigurableDataResource_impl seems never to call >> super.initialize(), so its mUimaContextAdmin is never initialized, hence any >> getResourceManager() call returns null. > This will take some more investigation / code research for me to offer any > (hopefully useful) opinions... ConfigurableDataResource seems to be an undocumented part of UIMA; I can't find any references to it in the tutorial or reference book. I see it has some implementation, and even a test case. It also has an entry in the "xsd" for UIMA component specifiers.
There are two things a call to super.initialize() can set: the MetaData and the UimaContext references. The initialize method, instead of calling super.initialize(), does an explicit call to set the MetaData reference, and leaves the UimaContext reference null. UimaContext (from the Javadocs) applies to a subset of all resources. The examples given are Annotators, Collection Readers, CAS Consumers, CAS Initializers; these are things which are pipeline components (I should add, Flow Controllers are included). The purpose of the UimaContext is to give these things access to data other than the CAS, including access to External Resources (of which ConfigurableDataResource is one kind). The ConfigurableDataResource seems to be a special case where its an External Resource, but has MetaData (most other ExternalResources do not have this); so it has a special way of setting up the metadata (outside of the UimaContext). UimaContext has a way to get various attributes associated with External Resources, but these methods all take a "key" (String) argument to identify the external resource. If ConfigurableDataResource_impl called super.initialize(), the Resource implementation of initialize() would think that the Resource was one which should have, itself, a UIMA Context (and, therefore, have things like External Resources, itself). I think this is the reason that the super method isn't called. -Marshall