Re: Sandbox OSGi runtime

2010-03-10 Thread Tommaso Teofili
2010/3/6 Marshall Schor 

>
>
> On 3/4/2010 3:00 AM, Tommaso Teofili wrote:
> > Hi Marshall
> >
> > 2010/3/3 Marshall Schor 
> >
> >
> >> would it make sense to have individual osgi packaging of sandbox
> >> annotators?
> >>
> >>
> > Do you mean you prefer not to have a single module aggregating all
> > annotators in a single bundle and you'd prefer each annotator having its
> own
> > individual OSGi bundle?
> >
>
> Yes.  Some of the annotators have very large (could be 100's of
> megabytes, for instance) statistical models.
>

I just made myself a multi module Maven project containing one module for
each of the Sandbox annotators so that one can select which annotators to
install on an OSGi runtime but at the same time they are tied together
inside a unique project.
Each module contains only the POM which uses the Maven Felix plugin to
produce the annotator bundle (more or less like in uimaj-ep-runtime).
I am doing some tests with this approach using some of these bundled
annotators with Apache Clerezza.
Tommaso


Potential problems in the XmlInputSource class...

2010-03-10 Thread Baptiste Gaillard

Hi, 

I've read multiple messages about UIMA and OSGI on this forum.  

On our project we have successfully integrated UIMA components inside OSGI 
Bundle (our solution provides an automatic OSGI Bundle genration system which 
take PEAR files so developpers do not have to worry about OSGI). 

We have encountered a JAR locking problem inside the XmlInputSource class, the 
problem comes from this instruction (WmlInputSource line 90) :
  
 mInputStream = mURL.openStream()

When we do that with a URL which refers to a file inside a JAR file a 
JarURLConnection is used. 

JarURLConnection seems to have a bug because in the destroy method of 
XmlInputSource those instruction do not close the ZipFile associated to the 
JARUrlConnection. 

if (mInputStream != null)
{
mInputStream.close();   // DO NOT CLOSE THE ASSOCIATED ZipFile !!!
}


The bug has been reported in the SUN Bug Database: // see 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4386865

This is problematic with OSGI because we can unload our Bundles (UIMA 
components in our case ;-) ) but never delete theme from the file system 
after... 

The solution to close the ZipFiles in XmlInputSource is to add the following 
instructions in the constructor and destroy method: 

private URLConnection urlConnection;

  public XMLInputSource(String aUrlOrFileName) throws IOException {
//try as URL first, then as file name
try {
  mURL = new URL(aUrlOrFileName);
}
catch (MalformedURLException e) {
  mURL = new File(aUrlOrFileName).toURL();
}

this.urlConnection = mURL.openConnection();

mInputStream = mURL.openStream();
  }


public void close()
  throws IOException
  {
  if (mInputStream != null)
  {
  mInputStream.close();
  }
  
  if((this.urlConnection != null) && (this.urlConnection instanceof 
JarURLConnection))
  {
  ((JarURLConnection)urlConnection).getJarFile().close();
  }

  mURL = null;
  }

Is it possible to include those modifications in the next UIMA release ? 

Thanks,

Baptiste Gaillard




  
_
Hotmail arrive sur votre téléphone ! Compatible Iphone, Windows Phone, 
Blackberry, …
http://www.messengersurvotremobile.com/?d=Hotmail