Greetings,
I patched XSLTransform.java in my project
about a week ago so that it could use xsl files outside the ear file. probably,
loading of mav config file can be changed in a similar way. as far as i
remember, there were problems with using "resURL =
servletCtx.getResource(path);" when path starts from "file" in my environment.
the patch works fine with w2k/sun_jdk 1.4.1/jboss-3.0.3/tomcat-4.1.12, but
i can't say anything about other platforms.
it is effective in
my project because my designers do not have to rebuild ear each time they change
something in design. but, as 4 me, it's hacky, so i didn't post it here earlier.
maybe u can suggest another, more
intelligent solution. can u?
the refactored code is below. i hope
it's clear what it's about.
hope this
helps,
yurazlin.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
107 protected Templates loadTemplate(String
path, ServletContext servletCtx) throws ConfigException
108 {
109
// Make sure we have leading /,
'cause it's needed.
110
if (!path.startsWith("/"))
111
path =
"/" + path;
112
113
try
114
{
115
TransformerFactory tFactory = TransformerFactory.newInstance();
116
if (this.uriResolver != null)
117
tFactory.setURIResolver(this.uriResolver);
118
return
tFactory.newTemplates(getTemplateStreamSource(path, servletCtx));
119
}
120
catch
(TransformerException ex)
121 {
122
log.fatal("Error
loading template " + path + ": " + ex.toString());
123
throw new ConfigException(ex);
124
}
125
catch (IOException ex)
126
{
127
log.fatal("Eror
loading template " + path + ": " + ex.toString());
128
throw new ConfigException(ex);
129
}
130 }
131
private StreamSource
getTemplateStreamSource(String path, ServletContext servletCtx)
132
throws IOException, ConfigException
133
{
134 URL resURL
= null;
135
String xslDir =
servletCtx.getInitParameter("xslDir");
136
if (xslDir!=null)
137
{
138
String
fullPath = xslDir+path;
139
File f
= new File(fullPath);
140
path =
"file://"+fullPath;
141
if (f.exists())
142
{
143
resURL = new URL(path);
144
}
145
}
146
else
147
{
148
resURL
= servletCtx.getResource(path);
149 }
150
151
if (resURL == null)
152
{
153
log.fatal("Resource not found: " + path);
154
throw new ConfigException("Resource not found: " + path);
155
}
156
log.debug("Template url is:
" + resURL.toString());
157
return new StreamSource(resURL.openStream(), resURL.toString());
158
}
-----------------------------------------------------------------------------------------------------------------------------
-----
Original Message -----
From: "Schnitzer, Jeff" <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
To:
<[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
Sent:
Friday, January 24, 2003 11:48 PM
Subject: RE: [Mav-user] Specifying external
maverick.xml
> You can specify a url to the maverick config file as an
init param to
> the Dispatcher servlet (see
> http://mav.sourceforge.net/maverick-manual.html#N100CB <http://mav.sourceforge.net/maverick-manual.html>). This url
gets
> passed to ServletContext.getResource().
>
> I'm really
not entirely certain what you can get away with - try putting
> <file://path/to/wherever.xml> in there.
>
> If
that doesn't work, perhaps we should add code to fallback to
>
Class.getResource() if ServletContext.getResource() fails? Dan, if you
>
want to test this out, Dispatcher.loadConfigDocument() is trivial to
>
modify. If you find something that works, I will be happy to commit a
>
patch.
>
> Jeff Schnitzer
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>
> -----Original Message-----
> > From: Dan Finkelstein [mailto:[EMAIL PROTECTED]]
> > Sent:
Thursday, January 23, 2003 7:33 PM
> > To:
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
> Subject: [Mav-user] Specifying external maverick.xml
> >
>
> Hi --
> >
> > I'm interested in being able to specify a
maverick.xml file that is
> > located
> > outside the war
file. Right now, it is pulled from within the war and
> I
> >
want to specify a different one "on-the-fly" so to speak. For
> example,
is
> > there a call that I could make, like
> >
Maverick.iniitalize(maverick_xml_file)? Or another way to do this?
>
>
> > Thanks in advance,
> > Dan
> >
>
>
> >
> >
> >
-------------------------------------------------------
> > This SF.NET
email is sponsored by:
> > SourceForge Enterprise Edition + IBM +
LinuxWorld = Something 2 See!
> > <http://www.vasoftware.com>
> > [INVALID
FOOTER]
>
>
>
>
-------------------------------------------------------
> This SF.NET
email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld
<http://www.vasoftware.com>
> [INVALID
FOOTER]
>
