You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Fabio Mancinelli <fa...@gmail.com> on 2009/08/11 16:21:37 UTC
Passing java references to a UIMAJ component
Hi everybody,
I have a quick question about UIMAJ component initialization.
What I would like to do is to pass a Java reference to an object that
will be used by the "business logic" of a collection reader in the
context of a CPE. Since I cannot control the instantiation of the
collection reader, I was wondering if there is a quick and clean way
to pass that object reference or if this is not impossible at all
(like I am suspecting).
Thanks.
Fabio
Re: Passing java references to a UIMAJ component
Posted by Fabio Mancinelli <fa...@gmail.com>.
On Tue, Sep 8, 2009 at 4:26 PM, Jörn Kottmann<ko...@gmail.com> wrote:
>
> The externalResource definition now looks like this
>
> <externalResource>
> <name>SampleSearchQueryProvider</name>
> <customResourceSpecifier>
>
> <resourceClassName>org.apache.uima.lucas.SampleSearchQueryProvider</resourceClassName>
> </customResourceSpecifier>
> </externalResource>
>
> and the SampleSearchQueryProvider instance can be accessed by an
> AnalysisEngine.
>
> Thanks for your help,
> Jörn
>
Thanks for your help.
This is very interesting though it doesn't completely address my
original issue because the resourceClassName would be instantiated by
the UIMA infrastructure, while I wanted to pass an already existing
instance and exactly that instance.
Maybe with some tricks and using this infrastructure I might be able
to do this anyway.
Thanks again,
Fabio
Re: Passing java references to a UIMAJ component
Posted by Jörn Kottmann <ko...@gmail.com>.
Adam Lally wrote:
> On Tue, Sep 8, 2009 at 6:49 AM, Jörn Kottmann<ko...@gmail.com> wrote:
>
>> Marshall Schor wrote:
>>
>>> Fabio Mancinelli wrote:
>>>
>>>
>>>> Hi everybody,
>>>>
>>>> I have a quick question about UIMAJ component initialization.
>>>>
>>>> What I would like to do is to pass a Java reference to an object that
>>>> will be used by the "business logic" of a collection reader in the
>>>> context of a CPE. Since I cannot control the instantiation of the
>>>> collection reader, I was wondering if there is a quick and clean way
>>>> to pass that object reference or if this is not impossible at all
>>>> (like I am suspecting).
>>>>
>>>>
>>> There is no clean way to do this in general. This is because the
>>> components in general could be running in other contexts, for instance,
>>> in a remote machine, not the same JVM, etc.
>>>
>>> There is a way to share Java objects among annotators running in the
>>> same machine, using external resources; see
>>>
>>> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.aae.accessing_external_resource_files
>>>
>>> While that specifically addresses creating a Java object and then
>>> "loading" it from an external file, the loading part is optional.
>>>
>>>
>> What must be done to make the loading part optional ?
>>
>> If a resource is described without the fileResourceSpecifier element,
>> then the framework throws a NullPointerException.
>>
>> For example:
>> <externalResourceDependency>
>> <key>searchQueryProvider</key>
>> <interfaceName>org.apache.uima.lucas.SearchQueryProvider</interfaceName>
>> </externalResourceDependency>
>> ...
>> <externalResource>
>> <name>SampleSearchQueryProvider</name>
>> <implementationName>org.apache.uima.lucas.SampleSearchQueryProvider
>> </implementationName>
>> </externalResource>
>>
>>
>
>
> Instead of a fileResourceSpecifier you can use a customResourceSpecifier. See:
> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.custom_resource_specifiers
>
The externalResource definition now looks like this
<externalResource>
<name>SampleSearchQueryProvider</name>
<customResourceSpecifier>
<resourceClassName>org.apache.uima.lucas.SampleSearchQueryProvider</resourceClassName>
</customResourceSpecifier>
</externalResource>
and the SampleSearchQueryProvider instance can be accessed by an
AnalysisEngine.
Thanks for your help,
Jörn
Re: Passing java references to a UIMAJ component
Posted by Adam Lally <al...@alum.rpi.edu>.
On Tue, Sep 8, 2009 at 6:49 AM, Jörn Kottmann<ko...@gmail.com> wrote:
> Marshall Schor wrote:
>>
>> Fabio Mancinelli wrote:
>>
>>>
>>> Hi everybody,
>>>
>>> I have a quick question about UIMAJ component initialization.
>>>
>>> What I would like to do is to pass a Java reference to an object that
>>> will be used by the "business logic" of a collection reader in the
>>> context of a CPE. Since I cannot control the instantiation of the
>>> collection reader, I was wondering if there is a quick and clean way
>>> to pass that object reference or if this is not impossible at all
>>> (like I am suspecting).
>>>
>>
>> There is no clean way to do this in general. This is because the
>> components in general could be running in other contexts, for instance,
>> in a remote machine, not the same JVM, etc.
>>
>> There is a way to share Java objects among annotators running in the
>> same machine, using external resources; see
>>
>> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.aae.accessing_external_resource_files
>>
>> While that specifically addresses creating a Java object and then
>> "loading" it from an external file, the loading part is optional.
>>
>
> What must be done to make the loading part optional ?
>
> If a resource is described without the fileResourceSpecifier element,
> then the framework throws a NullPointerException.
>
> For example:
> <externalResourceDependency>
> <key>searchQueryProvider</key>
> <interfaceName>org.apache.uima.lucas.SearchQueryProvider</interfaceName>
> </externalResourceDependency>
> ...
> <externalResource>
> <name>SampleSearchQueryProvider</name>
> <implementationName>org.apache.uima.lucas.SampleSearchQueryProvider
> </implementationName>
> </externalResource>
>
Instead of a fileResourceSpecifier you can use a customResourceSpecifier. See:
http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.custom_resource_specifiers
-Adam
Re: Passing java references to a UIMAJ component
Posted by Jörn Kottmann <ko...@gmail.com>.
Marshall Schor wrote:
> Fabio Mancinelli wrote:
>
>> Hi everybody,
>>
>> I have a quick question about UIMAJ component initialization.
>>
>> What I would like to do is to pass a Java reference to an object that
>> will be used by the "business logic" of a collection reader in the
>> context of a CPE. Since I cannot control the instantiation of the
>> collection reader, I was wondering if there is a quick and clean way
>> to pass that object reference or if this is not impossible at all
>> (like I am suspecting).
>>
>>
>
> There is no clean way to do this in general. This is because the
> components in general could be running in other contexts, for instance,
> in a remote machine, not the same JVM, etc.
>
> There is a way to share Java objects among annotators running in the
> same machine, using external resources; see
> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.aae.accessing_external_resource_files
>
> While that specifically addresses creating a Java object and then
> "loading" it from an external file, the loading part is optional.
>
What must be done to make the loading part optional ?
If a resource is described without the fileResourceSpecifier element,
then the framework throws a NullPointerException.
For example:
<externalResourceDependency>
<key>searchQueryProvider</key>
<interfaceName>org.apache.uima.lucas.SearchQueryProvider</interfaceName>
</externalResourceDependency>
...
<externalResource>
<name>SampleSearchQueryProvider</name>
<implementationName>org.apache.uima.lucas.SampleSearchQueryProvider
</implementationName>
</externalResource>
Jörn
Re: Passing java references to a UIMAJ component
Posted by Marshall Schor <ms...@schor.com>.
Fabio Mancinelli wrote:
> Hi everybody,
>
> I have a quick question about UIMAJ component initialization.
>
> What I would like to do is to pass a Java reference to an object that
> will be used by the "business logic" of a collection reader in the
> context of a CPE. Since I cannot control the instantiation of the
> collection reader, I was wondering if there is a quick and clean way
> to pass that object reference or if this is not impossible at all
> (like I am suspecting).
>
There is no clean way to do this in general. This is because the
components in general could be running in other contexts, for instance,
in a remote machine, not the same JVM, etc.
There is a way to share Java objects among annotators running in the
same machine, using external resources; see
http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.aae.accessing_external_resource_files
While that specifically addresses creating a Java object and then
"loading" it from an external file, the loading part is optional.
HTH. -Marshall
> Thanks.
> Fabio
>
>
>