Moved files to helma.main package.
This commit is contained in:
parent
2cb4d8dbc3
commit
1f3373a9e0
4 changed files with 0 additions and 281 deletions
|
@ -1,15 +0,0 @@
|
||||||
// INodeListener.java
|
|
||||||
// Copyright (c) Hannes Wallnöfer 1998-2000
|
|
||||||
|
|
||||||
package helma.objectmodel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An interface for objects that wish to be notified when certain nodes are
|
|
||||||
* modified. This is not used in the HOP as much as it used to be.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface INodeListener {
|
|
||||||
|
|
||||||
public void nodeChanged (NodeEvent event);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
// IServer.java
|
|
||||||
// Copyright (c) Hannes Wallnöfer 1998-2000
|
|
||||||
|
|
||||||
package helma.objectmodel;
|
|
||||||
|
|
||||||
import helma.util.*;
|
|
||||||
import helma.xmlrpc.WebServer;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract Server class. Defines the methods all servers have to implement.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public abstract class IServer {
|
|
||||||
|
|
||||||
// public static final Object sync = new Object ();
|
|
||||||
public static SystemProperties sysProps, dbProps;
|
|
||||||
public static Hashtable dbSources;
|
|
||||||
|
|
||||||
protected static File hopHome = null;
|
|
||||||
|
|
||||||
private static Logger logger;
|
|
||||||
|
|
||||||
protected static WebServer xmlrpc;
|
|
||||||
|
|
||||||
|
|
||||||
/* public abstract INode getAppRoot (String appID);
|
|
||||||
|
|
||||||
public abstract INode getAppNode (String appID, Vector path, String name);
|
|
||||||
|
|
||||||
public abstract INode getSubnode (String path); */
|
|
||||||
|
|
||||||
public static void throwNodeEvent (NodeEvent evt) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addNodeListener (String id, INodeListener listener) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeNodeListener (String node, INodeListener listener) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Logger getLogger () {
|
|
||||||
if (logger == null) {
|
|
||||||
String logDir = sysProps.getProperty ("logdir");
|
|
||||||
if (logDir == null || "console".equalsIgnoreCase (logDir)) {
|
|
||||||
logger = new Logger (System.out);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
File helper = new File (logDir);
|
|
||||||
if (hopHome != null && !helper.isAbsolute ())
|
|
||||||
helper = new File (hopHome, logDir);
|
|
||||||
logDir = helper.getAbsolutePath ();
|
|
||||||
logger = new Logger (logDir, "hop");
|
|
||||||
} catch (IOException iox) {
|
|
||||||
System.err.println ("Could not create Logger for log/hop: "+iox);
|
|
||||||
// fallback to System.out
|
|
||||||
logger = new Logger (System.out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getHopHome () {
|
|
||||||
return hopHome;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WebServer getXmlRpcServer() {
|
|
||||||
return xmlrpc;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
// ApplicationManager.java
|
|
||||||
// Copyright (c) Hannes Wallnöfer 1998-2000
|
|
||||||
|
|
||||||
package helma.objectmodel.db;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.io.*;
|
|
||||||
import java.lang.reflect.*;
|
|
||||||
import java.rmi.*;
|
|
||||||
import java.rmi.server.*;
|
|
||||||
import helma.framework.*;
|
|
||||||
import helma.framework.core.*;
|
|
||||||
import helma.objectmodel.*;
|
|
||||||
import helma.servlet.*;
|
|
||||||
import helma.util.SystemProperties;
|
|
||||||
import Acme.Serve.*;
|
|
||||||
import javax.servlet.Servlet;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is responsible for starting and stopping HOP applications.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ApplicationManager {
|
|
||||||
|
|
||||||
private Hashtable applications;
|
|
||||||
private int port;
|
|
||||||
private File hopHome;
|
|
||||||
private SystemProperties props;
|
|
||||||
private Server server;
|
|
||||||
private long lastModified;
|
|
||||||
|
|
||||||
public ApplicationManager (int port, File hopHome, SystemProperties props, Server server) {
|
|
||||||
this.port = port;
|
|
||||||
this.hopHome = hopHome;
|
|
||||||
this.props = props;
|
|
||||||
this.server = server;
|
|
||||||
applications = new Hashtable ();
|
|
||||||
lastModified = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// regularely check applications property file to create and start new applications
|
|
||||||
protected void checkForChanges () {
|
|
||||||
if (props.lastModified () > lastModified) {
|
|
||||||
try {
|
|
||||||
for (Enumeration e = props.keys(); e.hasMoreElements (); ) {
|
|
||||||
String appName = (String) e.nextElement ();
|
|
||||||
if (applications.get (appName) == null) {
|
|
||||||
start (appName);
|
|
||||||
register (appName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// then stop deleted ones
|
|
||||||
for (Enumeration e = applications.keys(); e.hasMoreElements (); ) {
|
|
||||||
String appName = (String) e.nextElement ();
|
|
||||||
if (!props.containsKey (appName)) {
|
|
||||||
stop (appName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception mx) {
|
|
||||||
IServer.getLogger().log ("Error starting applications: "+mx);
|
|
||||||
}
|
|
||||||
|
|
||||||
lastModified = System.currentTimeMillis ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void start (String appName) {
|
|
||||||
IServer.getLogger().log ("Building application "+appName);
|
|
||||||
try {
|
|
||||||
Application app = new Application (appName, Server.sysProps, Server.dbProps, hopHome);
|
|
||||||
applications.put (appName, app);
|
|
||||||
// if we're running with the embedded web server, set app base uri to /appname
|
|
||||||
if (server.websrv != null)
|
|
||||||
app.setBaseURI ("/"+java.net.URLEncoder.encode (appName));
|
|
||||||
app.start ();
|
|
||||||
} catch (Exception x) {
|
|
||||||
IServer.getLogger().log ("Error creating application "+appName+": "+x);
|
|
||||||
x.printStackTrace ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stop (String appName) {
|
|
||||||
IServer.getLogger().log ("Stopping application "+appName);
|
|
||||||
try {
|
|
||||||
Application app = (Application) applications.get (appName);
|
|
||||||
if (server.websrv == null) {
|
|
||||||
Naming.unbind ("//:"+port+"/"+appName);
|
|
||||||
} else {
|
|
||||||
server.websrv.removeServlet ("/"+appName+"/");
|
|
||||||
server.websrv.removeServlet ("/"+appName+"/*");
|
|
||||||
}
|
|
||||||
app.stop ();
|
|
||||||
IServer.getLogger().log ("Unregistered application "+appName);
|
|
||||||
} catch (Exception x) {
|
|
||||||
IServer.getLogger().log ("Couldn't unregister app: "+x);
|
|
||||||
}
|
|
||||||
applications.remove (appName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void register (String appName) {
|
|
||||||
try {
|
|
||||||
IServer.getLogger().log ("Binding application "+appName);
|
|
||||||
Application app = (Application) applications.get (appName);
|
|
||||||
if (server.websrv == null) {
|
|
||||||
Naming.rebind ("//:"+port+"/"+appName, app);
|
|
||||||
} else {
|
|
||||||
AcmeServletClient servlet = new AcmeServletClient (app);
|
|
||||||
server.websrv.addServlet ("/"+appName+"/", servlet);
|
|
||||||
server.websrv.addServlet ("/"+appName+"/*", servlet);
|
|
||||||
}
|
|
||||||
} catch (Exception x) {
|
|
||||||
IServer.getLogger().log ("Couldn't register app: "+x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startAll () {
|
|
||||||
try {
|
|
||||||
for (Enumeration e = props.keys(); e.hasMoreElements (); ) {
|
|
||||||
String appName = (String) e.nextElement ();
|
|
||||||
start (appName);
|
|
||||||
}
|
|
||||||
for (Enumeration e = props.keys(); e.hasMoreElements (); ) {
|
|
||||||
String appName = (String) e.nextElement ();
|
|
||||||
register (appName);
|
|
||||||
}
|
|
||||||
if (server.websrv != null) {
|
|
||||||
File staticContent = new File (server.getHopHome(), "static");
|
|
||||||
IServer.getLogger().log("Serving static content from "+staticContent.getAbsolutePath());
|
|
||||||
AcmeFileServlet fsrv = new AcmeFileServlet (staticContent);
|
|
||||||
server.websrv.addServlet ("/static/", fsrv);
|
|
||||||
server.websrv.addServlet ("/static/*", fsrv);
|
|
||||||
}
|
|
||||||
lastModified = System.currentTimeMillis ();
|
|
||||||
} catch (Exception mx) {
|
|
||||||
IServer.getLogger().log ("Error starting applications: "+mx);
|
|
||||||
mx.printStackTrace ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
// HopSocketFactory.java
|
|
||||||
// Copyright (c) Hannes Wallnöfer 1999-2000
|
|
||||||
|
|
||||||
|
|
||||||
package helma.objectmodel.db;
|
|
||||||
|
|
||||||
import helma.objectmodel.IServer;
|
|
||||||
import helma.util.*;
|
|
||||||
import java.net.*;
|
|
||||||
import java.rmi.server.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An RMI socket factory that has a "paranoid" option to filter clients.
|
|
||||||
* We only do direct connections, no HTTP proxy stuff, since this is
|
|
||||||
* server-to-server.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class HopSocketFactory extends RMISocketFactory {
|
|
||||||
|
|
||||||
private InetAddressFilter filter;
|
|
||||||
|
|
||||||
public HopSocketFactory () {
|
|
||||||
filter = new InetAddressFilter ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAddress (String address) {
|
|
||||||
try {
|
|
||||||
filter.addAddress (address);
|
|
||||||
} catch (IOException x) {
|
|
||||||
IServer.getLogger().log ("Could not add "+address+" to Socket Filter: invalid address.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Socket createSocket(String host, int port) throws IOException {
|
|
||||||
return new Socket (host, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerSocket createServerSocket(int port) throws IOException {
|
|
||||||
return new ParanoidServerSocket (port, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue