Formatting fixes
This commit is contained in:
parent
8c4e0ed609
commit
b49b50449e
1 changed files with 65 additions and 72 deletions
|
@ -480,20 +480,20 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
// check if we ought to create a rootObject from its class name
|
// check if we ought to create a rootObject from its class name
|
||||||
if (rootObjectClass != null) {
|
if (rootObjectClass != null) {
|
||||||
// create custom root element.
|
// create custom root element.
|
||||||
if (rootObject == null) {
|
if (rootObject == null) {
|
||||||
try {
|
try {
|
||||||
if ( classMapping.containsKey("root.factory.class") && classMapping.containsKey("root.factory.method") ) {
|
if ( classMapping.containsKey("root.factory.class") && classMapping.containsKey("root.factory.method") ) {
|
||||||
Class c = Class.forName( classMapping.getProperty("root.factory.class") );
|
Class c = Class.forName( classMapping.getProperty("root.factory.class") );
|
||||||
Method m = c.getMethod( classMapping.getProperty("root.factory.method"), null );
|
Method m = c.getMethod( classMapping.getProperty("root.factory.method"), null );
|
||||||
rootObject = m.invoke(c,null);
|
rootObject = m.invoke(c, null);
|
||||||
} else {
|
} else {
|
||||||
Class c = Class.forName( classMapping.getProperty("root") );
|
Class c = Class.forName( classMapping.getProperty("root") );
|
||||||
rootObject = c.newInstance();
|
rootObject = c.newInstance();
|
||||||
}
|
}
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
throw new RuntimeException ( "Error creating root object: " + e.toString() );
|
throw new RuntimeException ( "Error creating root object: " + e.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rootObject;
|
return rootObject;
|
||||||
}
|
}
|
||||||
// no custom root object is defined - use standard helma objectmodel
|
// no custom root object is defined - use standard helma objectmodel
|
||||||
|
@ -561,17 +561,17 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
* a registered or an anonymous user.
|
* a registered or an anonymous user.
|
||||||
*/
|
*/
|
||||||
public User getUser (String sessionID) {
|
public User getUser (String sessionID) {
|
||||||
if (sessionID == null)
|
if (sessionID == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
User u = (User) sessions.get (sessionID);
|
User u = (User) sessions.get (sessionID);
|
||||||
if (u != null) {
|
if (u != null) {
|
||||||
u.touch ();
|
u.touch ();
|
||||||
} else {
|
} else {
|
||||||
u = new User (sessionID, this);
|
u = new User (sessionID, this);
|
||||||
sessions.put (sessionID, u);
|
sessions.put (sessionID, u);
|
||||||
}
|
}
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -579,8 +579,8 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
* Register a user with the given user name and password.
|
* Register a user with the given user name and password.
|
||||||
*/
|
*/
|
||||||
public INode registerUser (String uname, String password) {
|
public INode registerUser (String uname, String password) {
|
||||||
// Register a user who already has a user object
|
// Register a user who already has a user object
|
||||||
// (i.e. who has been surfing around)
|
// (i.e. who has been surfing around)
|
||||||
if (uname == null)
|
if (uname == null)
|
||||||
return null;
|
return null;
|
||||||
uname = uname.toLowerCase ().trim ();
|
uname = uname.toLowerCase ().trim ();
|
||||||
|
@ -619,8 +619,8 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
* Log in a user given his or her user name and password.
|
* Log in a user given his or her user name and password.
|
||||||
*/
|
*/
|
||||||
public boolean loginUser (String uname, String password, ESUser u) {
|
public boolean loginUser (String uname, String password, ESUser u) {
|
||||||
// Check the name/password of a user who already has a user object
|
// Check the name/password of a user who already has a user object
|
||||||
// (i.e. who has been surfing around)
|
// (i.e. who has been surfing around)
|
||||||
if (uname == null)
|
if (uname == null)
|
||||||
return false;
|
return false;
|
||||||
uname = uname.toLowerCase ().trim ();
|
uname = uname.toLowerCase ().trim ();
|
||||||
|
@ -637,7 +637,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
activeUsers.put (unode.getName (), u.user);
|
activeUsers.put (unode.getName (), u.user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -829,35 +829,35 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
/// this is useful for scripting and url-building in the base-app.
|
/// this is useful for scripting and url-building in the base-app.
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathElement getChildElement(String name) {
|
public IPathElement getChildElement(String name) {
|
||||||
// as Prototype and the helma.scripting-classes don't offer enough information
|
// as Prototype and the helma.scripting-classes don't offer enough information
|
||||||
// we use the classes from helma.doc-pacakge for introspection.
|
// we use the classes from helma.doc-pacakge for introspection.
|
||||||
// the first time an url like /appname/api/ is parsed, the application is read again
|
// the first time an url like /appname/api/ is parsed, the application is read again
|
||||||
// parsed for comments and exposed as an IPathElement
|
// parsed for comments and exposed as an IPathElement
|
||||||
if ( name.equals("api") ) {
|
if (name.equals("api")) {
|
||||||
if ( docApp==null ) {
|
if ( docApp==null ) {
|
||||||
try {
|
try {
|
||||||
docApp = new DocApplication( this.name,appDir.toString() );
|
docApp = new DocApplication( this.name,appDir.toString() );
|
||||||
} catch ( DocException e ) {
|
} catch ( DocException e ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return docApp;
|
return docApp;
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public IPathElement getParentElement() {
|
public IPathElement getParentElement() {
|
||||||
return helma.main.Server.getServer();
|
return helma.main.Server.getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrototype() {
|
public String getPrototype() {
|
||||||
return "application";
|
return "application";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -917,7 +917,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
|
|
||||||
try {
|
try {
|
||||||
eval.invokeFunction ((INode) null, "onStart", new Object[0]);
|
eval.invokeFunction ((INode) null, "onStart", new Object[0]);
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
|
|
||||||
while (Thread.currentThread () == worker) {
|
while (Thread.currentThread () == worker) {
|
||||||
// get session timeout
|
// get session timeout
|
||||||
|
@ -958,7 +958,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
Object val = null;
|
Object val = null;
|
||||||
try {
|
try {
|
||||||
val = eval.invokeFunction ((INode) null, "scheduler", new Object[0]);
|
val = eval.invokeFunction ((INode) null, "scheduler", new Object[0]);
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
try {
|
try {
|
||||||
int ret = ((Number) val).intValue ();
|
int ret = ((Number) val).intValue ();
|
||||||
if (ret < 1000)
|
if (ret < 1000)
|
||||||
|
@ -1059,12 +1059,12 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the directory of this application
|
* Return the directory of this application
|
||||||
*/
|
*/
|
||||||
public File getAppDir() {
|
public File getAppDir() {
|
||||||
return appDir;
|
return appDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the DbMapping associated with a prototype name in this application
|
* Get the DbMapping associated with a prototype name in this application
|
||||||
|
@ -1158,7 +1158,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
*/
|
*/
|
||||||
public void printThreadStats () {
|
public void printThreadStats () {
|
||||||
logEvent ("Thread Stats for "+name+": "+threadgroup.activeCount()+" active");
|
logEvent ("Thread Stats for "+name+": "+threadgroup.activeCount()+" active");
|
||||||
Runtime rt = Runtime.getRuntime ();
|
Runtime rt = Runtime.getRuntime ();
|
||||||
long free = rt.freeMemory ();
|
long free = rt.freeMemory ();
|
||||||
long total = rt.totalMemory ();
|
long total = rt.totalMemory ();
|
||||||
logEvent ("Free memory: "+(free/1024)+" kB");
|
logEvent ("Free memory: "+(free/1024)+" kB");
|
||||||
|
@ -1172,15 +1172,6 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
xmlrpcAccess.checkAccess (proto, method);
|
xmlrpcAccess.checkAccess (proto, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Decides whether subnode condition should be checked for cached nodes. This is on by default
|
|
||||||
* and can be switched off by adding "subnodeChecking=false" in the app.properties file.
|
|
||||||
* It is recommended to leave it on except you suffer severe performance problems and know what you do.
|
|
||||||
*/
|
|
||||||
/* public boolean doesSubnodeChecking () {
|
|
||||||
return checkSubnodes;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1188,13 +1179,13 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, IPat
|
||||||
* XML-RPC handler class for this application.
|
* XML-RPC handler class for this application.
|
||||||
*/
|
*/
|
||||||
class XmlRpcInvoker implements XmlRpcHandler {
|
class XmlRpcInvoker implements XmlRpcHandler {
|
||||||
|
|
||||||
Application app;
|
Application app;
|
||||||
|
|
||||||
public XmlRpcInvoker (Application app) {
|
public XmlRpcInvoker (Application app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object execute (String method, Vector argvec) throws Exception {
|
public Object execute (String method, Vector argvec) throws Exception {
|
||||||
|
|
||||||
app.xmlrpcCount += 1;
|
app.xmlrpcCount += 1;
|
||||||
|
@ -1238,9 +1229,11 @@ class XmlRpcAccess {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create internal representation of XML-RPC-Permissions. They're encoded in the app property
|
* create internal representation of XML-RPC-Permissions. They're encoded in the app property
|
||||||
* file like this:
|
* file like this:
|
||||||
|
*
|
||||||
* xmlrpcAccess = root.sayHello, story.countMessages, user.login
|
* xmlrpcAccess = root.sayHello, story.countMessages, user.login
|
||||||
* i.e. a prototype.method entry for each function callable via XML-RPC.
|
*
|
||||||
|
* i.e. a prototype.method entry for each function callable via XML-RPC.
|
||||||
*/
|
*/
|
||||||
private void init () {
|
private void init () {
|
||||||
String newAccessprop = app.props.getProperty ("xmlrpcaccess");
|
String newAccessprop = app.props.getProperty ("xmlrpcaccess");
|
||||||
|
|
Loading…
Add table
Reference in a new issue