uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Lally" <ala...@alum.rpi.edu>
Subject Re: Questions about using a "customResourceSpecifier"
Date Wed, 02 Jul 2008 13:40:44 GMT
On Tue, Jul 1, 2008 at 10:44 AM, Christoph B├╝scher
<christoph.buescher@neofonie.de> wrote:
> Hi,
>
> I have a few questions about binding to external resources that are no file
> resources. The documentation mentions the option to use a
> "customResourceSpecifier" as described in
>
> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.custom_resource_specifiers
>
> I would like to use the resource mechanism to bind to an interface for read
> access to a database. The database connection parameters would be parameters
> in the "customResourceSpecifier".
>
> I have a few questions concerning this.
>
> 1. How do I include a custom resource specifier in e.g. a CPEs resource
> binding? It's not exactly clear to me from the documentation, but I would
> try something like:
>
> <externalResource>
>      <name>MyDBResource</name>
>      <description>a resource that provides read access to a
> database</description>
>      <customResourceSpecifier>
>          pathToCustomresourceSpecifier/myCustomResourceSpecifier.xml
>      </customResourceSpecifier>
> </externalResource>
>
> Can I find examples for the correct syntax here somewhere in the
> documentation?
>

It should be possible to do what you want (In his email, Michael is
referring to another use for custom resource specifiers, but they
should work for this as well).

This is basically right, but you need to put the
<customResourceSpecifier> inline, like this (excuse my lack of
indentation):
    <externalResource>
      <name>[String]</name>
      <description>[String]</description>

<customResourceSpecifier xmlns="http://uima.apache.org/resourceSpecifier">
  <resourceClassName>[Java Class Name]</resourceClassName>
  <parameters>
    <parameter name="[String]" value="[String]"/>
    <parameter name="[String]" value="[String]"/>
  </parameters>
</customResourceSpecifier>

    </externalResource>


Documentation for the <externalResouceElement> is in
http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.aes.primitive
(scroll down to 2.4.1.11).  I just replaced the
<fileResourceSpecifier> with the custom resource specifier.

> 2. The documentation mentions the implementation class must implement the
> "Resource" interface. Is there any existing implementation of "Resource"
> that is safe to extend to use in an external resource binding?
>

You can extend Resource_ImplBase, and just override the initialize
method.  There's a trivial example of a custom resource in the
uimaj-core unit tests - org.apache.uima.impl.SomeCustomResource.

 -Adam

Mime
View raw message