This commit was generated by cvs2svn to compensate for changes in r2155,
which included commits to RCS files with non-trunk default branches.
This commit is contained in:
parent
72d15e11ab
commit
4a7616d5a0
51 changed files with 1885 additions and 0 deletions
36
Root/functions.js
Normal file
36
Root/functions.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
/**
|
||||
* lists all applications in appdir.
|
||||
* for active apps use this.getApplications() = helma.main.Server.getApplications()
|
||||
*/
|
||||
function getAllApplications() {
|
||||
var appsDir = this.getAppsHome();
|
||||
var dir = appsDir.list();
|
||||
var arr = new Array();
|
||||
for ( var i=0; i<dir.length; i++ ) {
|
||||
if ( dir[i].toLowerCase()!="cvs" && dir[i].indexOf(".")==-1 )
|
||||
arr[arr.length] = this.getApp(dir[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get application by name, constructs an hopobject of the prototype application
|
||||
* if the app is not running (and therefore can't be access through
|
||||
* helma.main.ApplicationManager).
|
||||
* ATTENTION: javascript should not overwrite helma.main.Server.getApplication() which
|
||||
* retrieves active applications.
|
||||
* @arg name of application
|
||||
*/
|
||||
function getApp(name) {
|
||||
if ( name==null || name=="" )
|
||||
return null;
|
||||
var appObj = this.getApplication(name);
|
||||
if ( appObj==null )
|
||||
appObj = new application(name);
|
||||
return appObj;
|
||||
}
|
||||
|
||||
|
||||
|
11
Root/image.hac
Normal file
11
Root/image.hac
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
/**
|
||||
* return the helma object publisher logo, built into hop core
|
||||
* to be independent of static html-paths
|
||||
*/
|
||||
|
||||
if ( checkAddress()==false ) return;
|
||||
|
||||
res.contentType = "image/gif";
|
||||
res.writeBinary ( Packages.helma.util.Logo.hop );
|
||||
|
240
Root/macros.js
Normal file
240
Root/macros.js
Normal file
|
@ -0,0 +1,240 @@
|
|||
/**
|
||||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
*/
|
||||
function skin_macro(par) {
|
||||
if ( par && par.name ) {
|
||||
this.renderSkin(par.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro-wrapper for href-function
|
||||
* @param action name of action to call on this prototype, default main
|
||||
*/
|
||||
function href_macro(par) {
|
||||
return this.href( (par&&par.action)?par.action:"main" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the total number of sessions on this server
|
||||
* @see global.formatCount
|
||||
*/
|
||||
function countSessions_macro(par) {
|
||||
var arr = this.getApplications();
|
||||
var sum = 0;
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
sum += arr[i].sessions.size();
|
||||
}
|
||||
return sum + formatCount(sum,par);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the total number of sessions on this server
|
||||
* @see global.formatCount
|
||||
*/
|
||||
function countRequests_macro(par) {
|
||||
var arr = this.getApplications();
|
||||
var sum = 0;
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
var obj = app.requestStat.get(arr[i].name);
|
||||
sum += obj.last5Min;
|
||||
}
|
||||
return sum + formatCount(sum,par);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning hostname of this machine
|
||||
*/
|
||||
function hostname_macro(par) {
|
||||
return java.net.InetAddress.getLocalHost().getHostName()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning address of this machine
|
||||
*/
|
||||
function hostaddress_macro(par) {
|
||||
return java.net.InetAddress.getLocalHost().getHostAddress()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning the number of running applications,
|
||||
* the manage application being excluded.
|
||||
*/
|
||||
function appCount_macro(par) {
|
||||
if ( par && par.filter=="active" ) {
|
||||
var ct = root.getApplications().length-1;
|
||||
} else if ( par && par.filter=="disabled" ) {
|
||||
var ct = root.getAllApplications().length - root.getApplications().length;
|
||||
} else {
|
||||
var ct = root.getAllApplications().length-1;
|
||||
}
|
||||
return ct + formatCount(ct,par);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that lists all running applications,
|
||||
* the manage application being excluded (-1).
|
||||
* @param skin skin of application that will be used.
|
||||
*/
|
||||
function appList_macro(par) {
|
||||
var skin = (par && par.skin) ? par.skin : "navig_active";
|
||||
var apps = new Array();
|
||||
if ( par && par.filter=="active" ) {
|
||||
var arr = root.getApplications();
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
apps[apps.length] = arr[i];
|
||||
}
|
||||
} else if ( par && par.filter=="disabled" ) {
|
||||
var arr = root.getAllApplications();
|
||||
for ( var i in arr ) {
|
||||
if( arr[i].isActive()==false ) {
|
||||
apps[apps.length] = arr[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var apps = root.getAllApplications();
|
||||
}
|
||||
apps = apps.sort(sortByName);
|
||||
var html = "";
|
||||
var param = new Object();
|
||||
for (var n in apps) {
|
||||
var a = apps[n];
|
||||
if ( apps[n].name==app.__app__.getName() )
|
||||
continue;
|
||||
var item = a.renderSkinAsString(skin);
|
||||
html += item;
|
||||
}
|
||||
return(html);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the server's uptime nicely formatted
|
||||
*/
|
||||
function uptime_macro() {
|
||||
return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the server's version string
|
||||
*/
|
||||
function version_macro() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the home directory of the hop installation
|
||||
*/
|
||||
function home_macro() {
|
||||
return this.getHopHome().toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the free memory in the java virtual machine
|
||||
*/
|
||||
function jvmFreeMemory_macro() {
|
||||
var m = java.lang.Runtime.getRuntime().freeMemory();
|
||||
return formatBytes(m);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the total memory available to the java virtual machine
|
||||
*/
|
||||
function jvmTotalMemory_macro() {
|
||||
var m = java.lang.Runtime.getRuntime().totalMemory();
|
||||
return formatBytes(m);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the used memory in the java virtual machine
|
||||
*/
|
||||
function jvmUsedMemory_macro() {
|
||||
var m = java.lang.Runtime.getRuntime().totalMemory() - java.lang.Runtime.getRuntime().freeMemory();
|
||||
return formatBytes(m);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the version and type of the java virtual machine
|
||||
*/
|
||||
function jvm_macro() {
|
||||
return java.lang.System.getProperty("java.version") + " " + java.lang.System.getProperty("java.vendor");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the home directory of the java virtual machine
|
||||
*/
|
||||
function jvmHome_macro() {
|
||||
return java.lang.System.getProperty("java.home");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that greps all jar-files from the class path variable and lists them.
|
||||
* @param separator string that is printed between the items
|
||||
*/
|
||||
function jvmJars_macro(par) {
|
||||
var separator = (par && par.separator ) ? par.separator : ", ";
|
||||
var str = java.lang.System.getProperty("java.class.path");
|
||||
var arr = str.split(".jar");
|
||||
for ( var i in arr ) {
|
||||
var str = arr[i];
|
||||
var pos = ( str.lastIndexOf('\\') > str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/');
|
||||
res.write ( arr[i].substring(pos+1) + ".jar" );
|
||||
if ( i < arr.length-1 ) res.write ( separator );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the name and version of the server's os
|
||||
*/
|
||||
function os_macro() {
|
||||
return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns anything from server.properties
|
||||
*/
|
||||
function property_macro(par) {
|
||||
if ( par && par.key ) {
|
||||
return this.getProperty(key);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting server.properties
|
||||
*/
|
||||
function properties_macro(par) {
|
||||
formatProperties(this.getProperties(),par);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the timezone of this server
|
||||
*/
|
||||
function timezone_macro(par) {
|
||||
return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")";
|
||||
}
|
||||
|
||||
|
46
Root/main.hac
Normal file
46
Root/main.hac
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
/**
|
||||
* main action, show server-stats
|
||||
* perform start, stop, restart and flush-action
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if ( checkAddress()==false ) return;
|
||||
|
||||
if ( req.data.app!=null && req.data.app!="" && req.data.action!=null && req.data.action!="" ) {
|
||||
|
||||
var appObj = root.getApp(req.data.app);
|
||||
// check access for application. md5-encoded uname/pwd can also be put in
|
||||
// app.properties to limit access to a single app
|
||||
if ( checkAuth(appObj)==false ) return;
|
||||
|
||||
if ( req.data.action=="start" ) {
|
||||
this.startApplication(req.data.app);
|
||||
res.redirect ( appObj.href("main") );
|
||||
|
||||
} else if ( req.data.action=="stop" ) {
|
||||
if ( checkAuth()==false ) return;
|
||||
this.stopApplication(req.data.app);
|
||||
res.redirect ( root.href("main") );
|
||||
|
||||
} else if ( req.data.action=="restart" ) {
|
||||
this.stopApplication(req.data.app);
|
||||
this.startApplication(req.data.app);
|
||||
res.redirect ( appObj.href("main") );
|
||||
|
||||
} else if ( req.data.action=="flush" ) {
|
||||
appObj.clearAppCache();
|
||||
res.redirect ( appObj.href("main") );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// output only to root
|
||||
if ( checkAuth()==false ) return;
|
||||
|
||||
res.skin = "global";
|
||||
res.title = "Helma Object Publisher - Serverinfo";
|
||||
res.body = this.renderSkinAsString("main");
|
||||
|
101
Root/main.skin
Normal file
101
Root/main.skin
Normal file
|
@ -0,0 +1,101 @@
|
|||
<big><% this.hostname %> (<% this.hostaddress %>)</big><br/><br/>
|
||||
|
||||
<table border="0" cellspacing="0" cellpadding="3">
|
||||
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3">helma</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">uptime:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.uptime %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">version:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.version %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">homedir:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.home %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">total active sessions</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.countSessions %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">total request 5-min-avg</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.countRequests %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3">jre</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">free memory:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmFreeMemory %></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">used memory:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmUsedMemory %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">total memory:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmTotalMemory %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">java:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvm %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">javahome:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmHome %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">os:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.os %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">localtime:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% now %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">timezone:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.timezone %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">loaded Jars:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmJars %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3">server.properties</td>
|
||||
</tr>
|
||||
|
||||
<% this.properties prefix="<tr><td class=\"list_property\" align=\"right\" width=\"200\">" separator="</td><td class=\"list_property\" width=\"5\"> </td><td class=\"list_property\" align=\"left\">" suffix="</td></tr>" %>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
10
Root/makekey.hac
Normal file
10
Root/makekey.hac
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
if ( checkAddress()==false ) return;
|
||||
if ( checkAuth()==false ) return;
|
||||
|
||||
if ( req.data.value!=null ) {
|
||||
res.write ( calcMD5(req.data.value) );
|
||||
} else {
|
||||
res.write ( '<html><head></head><body><form method=post action=makekey><input type=password name=value><input type=submit></form></body></html>' );
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue