I don't think you should do all that in the configuration jsp page... 
Somewhere..fine..   I'm pretty opposed to using getRealPath() on whole.  Its evil.  It 
would seem rather there should be an index reader that can take a war file directory 
as input for exactly this case...  It can do the stream and all under the covers...

-Andy

Original Message:
-----------------
From: Doug Cutting [EMAIL PROTECTED]
Date: Thu, 14 Feb 2002 10:00:24 -0800
To: [EMAIL PROTECTED]
Subject: RE: Indexes in WAR files


> From: Les Hughes [mailto:[EMAIL PROTECTED]]
>
> Reading the servlet spec again it says that calls such as
> servletcontext.getRealPath() will *possibly* return null if
> the content is
> being served from a war as opposed the physical path on disk
> - I'm informed
> that weblogic actually returns the name of the warfile and
> not the exploded
> location. But you're right, Tomcat works differently.

What kind of URL does weblogic return for
servletContext.getResource("//index/segments")?
Is it a file: URL?

Keeping the index in files and using FSDirectory will be much more
efficient.  If all the major servlet containers support this it would be a
shame not to take advantage of it.  You might look at the result of
getResource and use an FSDirectory if a file: url is returned, and do
something else when it's not.

> So in order to isolate from different interpretations of the
> spec, I'm going
> to knock up a WARDirectory that probably will wrap a
> RAMDirectory (going
> back to the servlet container to getResourceAsStream seems
> awfully expensive
> to me) as a first go.
> I'll post my efforts in a couple of days.

One technique you might consider is, when the index is not available as a
file, use getResourceAsStream to copy it to a temporary directory in
System.getProperty("java.io.tmpdir"), then use FSDirectory.  Storing the
whole index in a RAMDirectory will make searches really fast, but could also
chew up a lot of memory.  If the index isn't that big anyway, maybe this
isn't an issue.

Doug

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to