uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marshall Schor (JIRA)" <uima-...@incubator.apache.org>
Subject [jira] Commented: (UIMA-386) Switching to use correct class loader
Date Wed, 02 May 2007 19:48:15 GMT

    [ https://issues.apache.org/jira/browse/UIMA-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12493189

Marshall Schor commented on UIMA-386:

The view support creates one (or more) CAS objects which are "views" of the base CAS.  The
JCas support (current design) keeps a set of generators for each view.  Thus, the design for
this implies loading not just the right set of generators, but repeating this for each view,
that was being used by the component.  For some components (which are not view-aware) it is
possible to load only 2 views (base and the view being used by the component).  For view-aware,
there is no way to tell (I think) what views it will be using - so the only "safe" thing would
be to load generators for all the views.  
We might consider changing this design to avoid this issue.  One change that would allow using
the same generator for all views would require changing the generated JCasGen classes for
the ..._Type classes, so the generator code made use of the passed-in CAS view argument. 
That would impact current users, however, at least requiring them to re-generate their JCas
classes.  But maybe this isn't necessary, if a good caching design makes loading generator
sets fast.  

> Switching to use correct class loader
> -------------------------------------
>                 Key: UIMA-386
>                 URL: https://issues.apache.org/jira/browse/UIMA-386
>             Project: UIMA
>          Issue Type: Improvement
>          Components: Core Java Framework
>    Affects Versions: 2.1
>            Reporter: Marshall Schor
>         Assigned To: Marshall Schor
>             Fix For: 2.2
> The current design presumes one classloader is used for all components in an application.
 This shows up in the implementation when using JCas - the class loader used to load the JCas
cover classes is set up in the CAS, and there is only one there.  This works, unless the analysis
engine component is loaded by a different class loader.  This causes strange class-cast exceptions,
where the source and target classes look to be identical (what's happening is that the classes
are named the same, including having the same package names, but are loaded with different
class loaders).  A fix is needed that insures the class loader used for JCas can be switched
when an analysis engine component is run.  This should be time-efficient because the flow
controller could be under a different class loader than the delegates it's controlling, so
the class loader could be switching back and forth twice per delegate dispatch.
> A proposed approach is to add an internal method to the CAS, useClassLoader(xxx), which
will be called by the framework just before the processCas call, passing in the class loader
that was used to load the analysis engine class.  The framework will check to see if this
is the current in-use class loader, and if it is, do nothing.  If it isn't, if the JCas is
instantiated, it will call a new JCas method, switchClassLoader(xxx). This method will (a)
reset the cache JCas uses to reduce object creation for JCas objects, and do what's needed
to load or switch to the right set of iterator generators.  Where possible, re-loading will
be avoided, to make the switch fast.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message