uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marshall Schor <...@schor.com>
Subject Re: messed up the impl of UIMA-2977 - calling destroy() method on External Resources
Date Thu, 20 Oct 2016 19:27:08 GMT
The evidence that implementation classes for External Resource must implement
Resource comes from the line in resolveAndValidateResourceDependencies, where it
is seeing if the interface specified in the dependency is implemented by the
named External resource.

In the process of doing this, the code calls getResourceClass in
ResourceManager_impl, passing in the qualified dependency name, which looks up
the binding and returns the class of the shared external resource instance, if
found.

The interesting part is the Java type of the returned value - it is specified as

Class<? extends Resource>

which will throw a cast exception if the implementing class can't be cast to
Resource. 

The Reference book docs, for "Custom Resource Specifiers" does say that the
implementation class must implement the Resource interface.

-Marshall


On 10/20/2016 3:01 PM, Marshall Schor wrote:
> Well, now further up the learning curve.
>
> I was mislead by finding some examples of External Resource impl which
> implemented SharedResourceObject, but did not implement Resource. 
>
> More careful reading of the code shows it assumes that resource impls *are*
> instances of Resource.
>
> So- back to work...
>
> -Marshall
>
> On 10/20/2016 10:58 AM, Marshall Schor wrote:
>> I had an incorrect understanding of the UIMA model for this, and confused an
>> instance of Resource with an instance of its implementation.
>>
>> A Resource in UIMA is an Interface implemented by framework code parts that are
>> specializations for the many kinds of resources managed by UIMA.
>>
>> These resources are created from Resource Specifiers using produceResource.
>>
>> One aspect of Resource instances is that they contain a reference to an
>> "implementation" - another Java class, which is *not* an instance of Resource.
>>
>> This aspect is only present in some kinds of resources.  For External Resources,
>> the descriptor for this, and its internal Java class
>> (ExternalResourceDescription) have an element, "implementationName", which is
>> name of the Java class implementing the resource.  This class doesn't implement
>> the Resource API.
>>
>> I incorrectly switched several parts of ResourceManager_impl from Object to
>> Resource based on my misunderstanding, and will now revert that.
>>
>> -Marshall
>>
>>
>


Mime
View raw message