Given enough time I was able to figure it out ;)
Inheriting from InputRequestProcess gives access to the methods in the
AbstractRequestProcess superclass. This has a getServletConfig() method
which returns a ServletConfig. A ServletConfig has in turn a
getServletContext() method which does what I wanted.
So the solution, for anybody besides me who would ever need to do this
kind of thing:
ServletContext context = getServletConfig().getServletContext();
within a method in InputRequestProcess subclass.
I'll stop rambling now :)
Sidenote: The Ant buildfile for the Carrot project has no Javadoc
target. If anybody needs this documentation (as I did to figure out the
above problem), add:
<target name="javadoc" description="Make javadoc help files">
<javadoc destdir="${javadoc.dir}" source="${basedir}"
doctitle="${ant.project.name}" use="true"
windowtitle="${ant.project.name}" author="true"
version="true">
<fileset dir="${basedir}" includes="**/*.java" />
</javadoc>
</target>
somewhere in the bottom of /build.xml before </project>. Enjoy
/Laust
On 7/4-2004, at 12:02, Laust Rud Jensen wrote:
> Hi,
>
> Still trying to find my way around in the Carrot system. I am
> constructing a small search engine for Javadoc using LSI and I'm going
> to use Carrot for result clustering. Currently I'm trying to bridge
> the gap between the two systems.
>
> I have a running search-service using a small number of JSP-pages
> running within a Servlet (in Tomcat). The access data is through the
> context for the servlet. This works pretty well as data is loaded once
> when the webserver starts. All processing is going to take place on
> the same Tomcat server for now.
>
> On the Carrot end of things I have a Servlet which is built similarly
> to other Carrot input components. It is called javadoc-search and the
> class JavadocSearch extends InputRequestProcessor. This way I have
> easy access to the search string and the wanted number of results,
> plus everything is setup for easy output. Built using the Carrot build
> process it maps to /carrot2-javadoc-search/.
>
> Problem:
> How do I, within the JavadocSearch.processQuery(query, count, output,
> HttpServletRequest) method get the context for the current servlet so
> I can access the shared data? Or is there some other way I can create
> and access data easily between calls? The datafile is rather large (a
> serialized class of ~50MiB for the prototype), and should hopefully
> only be loaded once when the webserver starts. The data will not
> change so it can safely be accessed in parallel.
>
> Thanks for any help, ideas or pointers
>
> /Laust Rud
|