Added appname.mountpoint option for entries in apps.properties

to define where an application should be mounted on the
embedded web server.
This commit is contained in:
hns 2002-07-02 15:16:08 +00:00
parent fa4fcef67e
commit c9707a83b8

View file

@ -9,6 +9,7 @@ import java.io.*;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.rmi.*; import java.rmi.*;
import java.rmi.server.*; import java.rmi.server.*;
import java.net.URLEncoder;
import helma.framework.*; import helma.framework.*;
import helma.framework.core.*; import helma.framework.core.*;
import helma.objectmodel.*; import helma.objectmodel.*;
@ -78,11 +79,13 @@ public class ApplicationManager {
void start (String appName) { void start (String appName) {
Server.getLogger().log ("Building application "+appName); Server.getLogger().log ("Building application "+appName);
try { try {
String mountpoint = props.getProperty (appName+".mountpoint",
"/"+URLEncoder.encode(appName));
Application app = new Application (appName, hopHome, Server.sysProps, Server.dbProps); Application app = new Application (appName, hopHome, Server.sysProps, Server.dbProps);
applications.put (appName, app); applications.put (appName, app);
// if we're running with the embedded web server, set app base uri to /appname // if we're running with the embedded web server, set app base uri to /appname
if (server.websrv != null && !"base".equalsIgnoreCase (appName)) if (server.websrv != null)
app.setBaseURI ("/"+java.net.URLEncoder.encode (appName)); app.setBaseURI (mountpoint);
// the application is started later in the register method, when it's bound // the application is started later in the register method, when it's bound
app.init (); app.init ();
} catch (Exception x) { } catch (Exception x) {
@ -98,11 +101,13 @@ public class ApplicationManager {
if (server.websrv == null) { if (server.websrv == null) {
Naming.unbind ("//:"+port+"/"+appName); Naming.unbind ("//:"+port+"/"+appName);
} else { } else {
String mountpoint = props.getProperty (appName+".mountpoint",
"/"+URLEncoder.encode(appName));
// server.websrv.removeServlet ("/"+appName+"/"); // server.websrv.removeServlet ("/"+appName+"/");
if ("base".equalsIgnoreCase (appName)) if ("/".equals (mountpoint))
server.websrv.removeDefaultServlet (); server.websrv.removeDefaultServlet ();
else else
server.websrv.removeServlet ("/"+appName+"/*"); server.websrv.removeServlet (mountpoint+"/*");
} }
app.stop (); app.stop ();
Server.getLogger().log ("Unregistered application "+appName); Server.getLogger().log ("Unregistered application "+appName);
@ -119,12 +124,14 @@ public class ApplicationManager {
if (server.websrv == null) { if (server.websrv == null) {
Naming.rebind ("//:"+port+"/"+appName, app); Naming.rebind ("//:"+port+"/"+appName, app);
} else { } else {
boolean isRoot = "base".equalsIgnoreCase (appName); String mountpoint = props.getProperty (appName+".mountpoint",
"/"+URLEncoder.encode(appName));
boolean isRoot = "/".equals (mountpoint);
EmbeddedServletClient servlet = new EmbeddedServletClient (appName, isRoot); EmbeddedServletClient servlet = new EmbeddedServletClient (appName, isRoot);
if (isRoot) if (isRoot)
server.websrv.setDefaultServlet (servlet); server.websrv.setDefaultServlet (servlet);
else { else {
server.websrv.addServlet ("/"+appName+"/*", servlet); server.websrv.addServlet (mountpoint+"/*", servlet);
} }
// tomcat.addApplication (appName); // tomcat.addApplication (appName);
} }
@ -138,10 +145,12 @@ public class ApplicationManager {
try { try {
for (Enumeration e = props.keys(); e.hasMoreElements (); ) { for (Enumeration e = props.keys(); e.hasMoreElements (); ) {
String appName = (String) e.nextElement (); String appName = (String) e.nextElement ();
if (appName.indexOf (".") == -1)
start (appName); start (appName);
} }
for (Enumeration e = props.keys(); e.hasMoreElements (); ) { for (Enumeration e = props.keys(); e.hasMoreElements (); ) {
String appName = (String) e.nextElement (); String appName = (String) e.nextElement ();
if (appName.indexOf (".") == -1)
register (appName); register (appName);
} }
if (server.websrv != null) { if (server.websrv != null) {