° An app is now mounted as / on the embedded webserver if the
app name is "base", not when it scripts Helma self. This means that it is now possible to have more than one applications scripting the Helma server itself (e.g. a simple overview app in / and a sophisticated admin app in /admin). ° Removed self boolean parameter from start() and register(), since this is now determined just once and doesn't have to be carried around. Also, callers of these methods from outside didn't really know about this parameter.
This commit is contained in:
parent
f7ec5f3bbd
commit
5b7495dca3
1 changed files with 9 additions and 12 deletions
|
@ -47,10 +47,9 @@ 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 ();
|
||||||
boolean self = "self".equalsIgnoreCase (props.getProperty (appName));
|
|
||||||
if (applications.get (appName) == null) {
|
if (applications.get (appName) == null) {
|
||||||
start (appName, self);
|
start (appName);
|
||||||
register (appName, self);
|
register (appName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// then stop deleted ones
|
// then stop deleted ones
|
||||||
|
@ -68,15 +67,16 @@ public class ApplicationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void start (String appName, boolean self) {
|
void start (String appName) {
|
||||||
Server.getLogger().log ("Building application "+appName);
|
Server.getLogger().log ("Building application "+appName);
|
||||||
try {
|
try {
|
||||||
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 && !self)
|
if (server.websrv != null && !"base".equalsIgnoreCase (appName))
|
||||||
app.setBaseURI ("/"+java.net.URLEncoder.encode (appName));
|
app.setBaseURI ("/"+java.net.URLEncoder.encode (appName));
|
||||||
// check if the root object of the application is the Server itself
|
// check if the root object of the application is the Server itself
|
||||||
|
boolean self = "self".equalsIgnoreCase (props.getProperty (appName));
|
||||||
if (self)
|
if (self)
|
||||||
app.setDataRoot (server);
|
app.setDataRoot (server);
|
||||||
// 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
|
||||||
|
@ -105,16 +105,15 @@ public class ApplicationManager {
|
||||||
applications.remove (appName);
|
applications.remove (appName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void register (String appName, boolean self) {
|
void register (String appName) {
|
||||||
try {
|
try {
|
||||||
Server.getLogger().log ("Binding application "+appName);
|
Server.getLogger().log ("Binding application "+appName);
|
||||||
Application app = (Application) applications.get (appName);
|
Application app = (Application) applications.get (appName);
|
||||||
// app.start ();
|
|
||||||
if (server.websrv == null) {
|
if (server.websrv == null) {
|
||||||
Naming.rebind ("//:"+port+"/"+appName, app);
|
Naming.rebind ("//:"+port+"/"+appName, app);
|
||||||
} else {
|
} else {
|
||||||
AcmeServletClient servlet = new AcmeServletClient (app);
|
AcmeServletClient servlet = new AcmeServletClient (app);
|
||||||
if (self)
|
if ("base".equalsIgnoreCase (appName))
|
||||||
server.websrv.setDefaultServlet (servlet);
|
server.websrv.setDefaultServlet (servlet);
|
||||||
else {
|
else {
|
||||||
server.websrv.addServlet ("/"+appName+"/", servlet);
|
server.websrv.addServlet ("/"+appName+"/", servlet);
|
||||||
|
@ -131,13 +130,11 @@ 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 ();
|
||||||
boolean self = "self".equalsIgnoreCase (props.getProperty (appName));
|
start (appName);
|
||||||
start (appName, self);
|
|
||||||
}
|
}
|
||||||
for (Enumeration e = props.keys(); e.hasMoreElements (); ) {
|
for (Enumeration e = props.keys(); e.hasMoreElements (); ) {
|
||||||
String appName = (String) e.nextElement ();
|
String appName = (String) e.nextElement ();
|
||||||
boolean self = "self".equalsIgnoreCase (props.getProperty (appName));
|
register (appName);
|
||||||
register (appName, self);
|
|
||||||
}
|
}
|
||||||
if (server.websrv != null) {
|
if (server.websrv != null) {
|
||||||
File staticContent = new File (server.getHopHome(), "static");
|
File staticContent = new File (server.getHopHome(), "static");
|
||||||
|
|
Loading…
Add table
Reference in a new issue