Fixed bugs and performance problems in StandaloneServletClient.
The Hop embedded into the servlet container is now the most performant way to run a Hop app.
This commit is contained in:
parent
af93d7b66a
commit
96393ea5eb
2 changed files with 49 additions and 38 deletions
|
@ -187,7 +187,7 @@ public abstract class AbstractServletClient extends HttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void writeResponse (HttpServletResponse res, ResponseTrans trans, Cookie[] cookies, String protocol) {
|
void writeResponse (HttpServletResponse res, ResponseTrans trans, Cookie[] cookies, String protocol) {
|
||||||
|
|
||||||
for (int i = 0; i < trans.countCookies(); i++) try {
|
for (int i = 0; i < trans.countCookies(); i++) try {
|
||||||
Cookie c = new Cookie(trans.getKeyAt(i), trans.getValueAt(i));
|
Cookie c = new Cookie(trans.getKeyAt(i), trans.getValueAt(i));
|
||||||
|
|
|
@ -16,34 +16,60 @@ import helma.util.*;
|
||||||
* This is a standalone Hop servlet client, running a Hop application by itself.
|
* This is a standalone Hop servlet client, running a Hop application by itself.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class StandaloneServletClient extends AbstractServletClient {
|
public final class StandaloneServletClient extends AbstractServletClient {
|
||||||
|
|
||||||
private Application app = null;
|
private Application app = null;
|
||||||
private String appName;
|
private String appName;
|
||||||
private String serverProps;
|
private String serverProps;
|
||||||
|
|
||||||
|
|
||||||
public void init (ServletConfig init) throws ServletException {
|
public void init (ServletConfig init) throws ServletException {
|
||||||
super.init (init);
|
super.init (init);
|
||||||
appName = init.getInitParameter ("application");
|
appName = init.getInitParameter ("application");
|
||||||
serverProps = init.getInitParameter ("serverprops");
|
serverProps = init.getInitParameter ("serverprops");
|
||||||
|
|
||||||
super.init (init);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized IRemoteApp getApp (String appID) throws Exception {
|
IRemoteApp getApp (String appID) {
|
||||||
if (app != null)
|
if (app == null)
|
||||||
|
createApp ();
|
||||||
return app;
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the application. Since we are synchronized only here, we
|
||||||
|
* do another check if the app already exists and immediately return if it does.
|
||||||
|
*/
|
||||||
|
synchronized void createApp () {
|
||||||
|
if (app != null)
|
||||||
|
return;
|
||||||
try {
|
try {
|
||||||
File propfile = new File (serverProps);
|
File propfile = new File (serverProps);
|
||||||
File hopHome = new File (propfile.getParent());
|
File hopHome = new File (propfile.getParent());
|
||||||
SystemProperties sysProps = new SystemProperties (propfile.getAbsolutePath());
|
SystemProperties sysProps = new SystemProperties (propfile.getAbsolutePath());
|
||||||
app = new Application (appName, hopHome, sysProps, null);
|
app = new Application (appName, hopHome, sysProps, null);
|
||||||
|
app.init ();
|
||||||
app.start ();
|
app.start ();
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
System.err.println ("Error starting Application "+appName+": "+x);
|
System.err.println ("Error starting Application "+appName+": "+x);
|
||||||
x.printStackTrace ();
|
x.printStackTrace ();
|
||||||
}
|
}
|
||||||
return app;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The servlet is being destroyed. Close and release the application if
|
||||||
|
* it does exist.
|
||||||
|
*/
|
||||||
|
public void destroy () {
|
||||||
|
if (app != null) {
|
||||||
|
try {
|
||||||
|
app.stop ();
|
||||||
|
} catch (Exception x) {
|
||||||
|
System.err.println ("Error shutting down app "+app.getName()+": ");
|
||||||
|
x.printStackTrace ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalidateApp (String appID) {
|
void invalidateApp (String appID) {
|
||||||
|
@ -85,23 +111,8 @@ public class StandaloneServletClient extends AbstractServletClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue