Get init parameters in in init method instead of a special constructor
the way servlets should.
This commit is contained in:
parent
4e7cc29a82
commit
20ea4b874f
1 changed files with 11 additions and 8 deletions
|
@ -22,22 +22,25 @@ public final class EmbeddedServletClient extends AbstractServletClient {
|
||||||
private String appName;
|
private String appName;
|
||||||
|
|
||||||
// The path where this servlet is mounted
|
// The path where this servlet is mounted
|
||||||
String servletPath;
|
String mountpoint;
|
||||||
|
|
||||||
public EmbeddedServletClient () {
|
public EmbeddedServletClient () {
|
||||||
super ();
|
super ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmbeddedServletClient (String appName, String servletPath) {
|
/* public EmbeddedServletClient (String appName, String servletPath) {
|
||||||
this.appName = appName;
|
this.appName = appName;
|
||||||
this.servletPath = servletPath;
|
this.servletPath = servletPath;
|
||||||
}
|
} */
|
||||||
|
|
||||||
public void init (ServletConfig init) throws ServletException {
|
public void init (ServletConfig init) throws ServletException {
|
||||||
super.init (init);
|
super.init (init);
|
||||||
String app = init.getInitParameter ("application");
|
appName = init.getInitParameter ("application");
|
||||||
if (app != null)
|
if (appName == null)
|
||||||
appName = app;
|
throw new ServletException ("Application name not set in init parameters");
|
||||||
|
mountpoint = init.getInitParameter ("mountpoint");
|
||||||
|
if (mountpoint == null)
|
||||||
|
mountpoint = "/"+appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRemoteApp getApp (String appID) {
|
IRemoteApp getApp (String appID) {
|
||||||
|
@ -58,9 +61,9 @@ public final class EmbeddedServletClient extends AbstractServletClient {
|
||||||
String getRequestPath (String path) {
|
String getRequestPath (String path) {
|
||||||
if (path == null)
|
if (path == null)
|
||||||
return "";
|
return "";
|
||||||
int pathMatch = path.indexOf (servletPath);
|
int pathMatch = path.indexOf (mountpoint);
|
||||||
if (pathMatch > -1)
|
if (pathMatch > -1)
|
||||||
return trim (path.substring (pathMatch+servletPath.length()));
|
return trim (path.substring (pathMatch+mountpoint.length()));
|
||||||
else
|
else
|
||||||
return trim (path);
|
return trim (path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue