on 4/23/00 5:11 PM, Serge Knystautas <[EMAIL PROTECTED]> wrote:
> Also, I looked in JamesSpoolManager, and it seems we don't conveniently
> support using servlets from multiple packages. For instance, most of my
> servlets might be in the default org.apache.james.transport.servlet
> package, but a particular listserv I write might pull it's member list
> from an internal relational database, so I would want to put that in a
> com.lokitech.something package. I thought about supporting multiple
> servlets rootpath="...", but the order of servlets is significant, so
> this doesn't seem to work. Is the rootpath really helping things that
> much? I think anybody using this beyond initial testing will want to
> write their own servlets and end up removing the rootpath prefix.
> What's even worse is that if I altogether remove the rootpath attribute,
> JAMES crashes upon startup. Should we move to an aliasing approach
> where we define what classes map to what names and parameters, and then
> use aliases as we're defining routing information. As we start adding
> numerous servlets to a mail server, it might be nice to keep servlet
> configuration and ordering/matching separate. Any opinions?
Actually, we had this same issue with Turbine. We solved it by having a
"rootpath" as you suggested and then attempting to Class.forName() through
the path until we get something that matches...
check out:
<http://www.working-dogs.com/turbine/cvsweb/index.cgi/turbine/src/java/org/a
pache/turbine/modules/ScreenLoader.java?rev=1.9&content-type=text/x-cvsweb-m
arkup>
here is the code that does it (it loops on an Array so that you can define
the order of things)...
for (int i=0; i<instance.packages.size(); i++)
{
String className =
(String)instance.packages.elementAt(i) + ".screens." + name;
try
{
Class servClass = Class.forName( className );
screen = ( Screen ) servClass.newInstance();
addInstance ( name, screen );
return screen;
}
catch (ClassNotFoundException cnfe)
{
// do this so we loop through all the packages
}
catch (ClassCastException cce)
{
// do this so we know what class is having problems
throw new ClassCastException( className );
}
}
So, in your case, you would have rootpath + .servlet. + NAME.
Works great and is easy for people to understand.
-jon
--
Scarab -
Java Servlet Based - Open Source
Bug/Issue Tracking System
<http://scarab.tigris.org/>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/>
Problems?: [EMAIL PROTECTED]