mx4j.tools.jython

Class JythonRunner

public class JythonRunner extends Object implements JythonRunnerMBean, NotificationListener, MBeanRegistration

This MBean enables you to run scripts written in jython. Scripts can be run using the managed operation runScript or by listening notifcations from another MBean. To us it you need to install jython 2.1 or higher from <a href="http://www.jython.org">here</a>

If you want to use a jython library remember to add the jython jar to the classpath in the right location or modify the python.path address

The scripts have always the "server" embedded variable which points to the current server. It also automatically import some JMX modules as:

Version: $Revision: 1.9 $

Method Summary
booleangetCacheScript()
Returns whether the script should be kept in the cache.
StringgetNotificationType()
Gets the specific notification type being listened
ObjectNamegetObservedObject()
Gets the object being observed by this MBean
static PythonInterpretergetPythonInterpreter()
StringgetScript()
Returns the script as text.
URLgetScriptURL()
Returns the URL pointing to the script source
booleangetUseText()
Indicates wether to use the script given in the ScripText variable or the one given in the script File.
voidhandleNotification(Notification notification, Object handback)
protected static StringloadStream(InputStream in)
voidpostDeregister()
voidpostRegister(Boolean registrationDone)
voidpreDeregister()
ObjectNamepreRegister(MBeanServer server, ObjectName name)
Gathers some basic data
protected voidregisterListener()
voidrunScript()
Executes a given script.
voidsetCacheScript(boolean useCache)
Sets whether the script should be kept in the cache.
voidsetNotificationType(String notificationName)
Sets the notification being listed.
voidsetObservedObject(ObjectName targetMBeanName)
Sets the object being observed by this MBean.
voidsetScript(String text)
Sets the content of the script.
voidsetScriptURL(URL file)
Sets the script source as URL.
protected voidunregisterListener()

Method Detail

getCacheScript

public boolean getCacheScript()
Returns whether the script should be kept in the cache. If true, no further attempts to read the script will be done afterwards. By default is false

getNotificationType

public String getNotificationType()
Gets the specific notification type being listened

getObservedObject

public ObjectName getObservedObject()
Gets the object being observed by this MBean

getPythonInterpreter

public static PythonInterpreter getPythonInterpreter()

getScript

public String getScript()
Returns the script as text.

getScriptURL

public URL getScriptURL()
Returns the URL pointing to the script source

getUseText

public boolean getUseText()
Indicates wether to use the script given in the ScripText variable or the one given in the script File.

handleNotification

public void handleNotification(Notification notification, Object handback)

loadStream

protected static String loadStream(InputStream in)

postDeregister

public void postDeregister()

postRegister

public void postRegister(Boolean registrationDone)

preDeregister

public void preDeregister()

preRegister

public ObjectName preRegister(MBeanServer server, ObjectName name)
Gathers some basic data

registerListener

protected void registerListener()

runScript

public void runScript()
Executes a given script. If useText is true the text passed will be run as a script otherwise the script will be loaded from the URL an executed

setCacheScript

public void setCacheScript(boolean useCache)
Sets whether the script should be kept in the cache. If true, no further attempts to read the script will be done afterwards. By default is false

setNotificationType

public void setNotificationType(String notificationName)
Sets the notification being listed. If null any notification will trigger the execution of the script. Otherwise only notifications matching notificationName will trigger it

setObservedObject

public void setObservedObject(ObjectName targetMBeanName)
Sets the object being observed by this MBean. The MBean will register itself as a listener of targetMBeanName

setScript

public void setScript(String text)
Sets the content of the script. If you want to use a file, use ScriptFile instead.

setScriptURL

public void setScriptURL(URL file)
Sets the script source as URL. If the cache script variable is true the file will be loaded only once, otherwise everytime the script is executed

unregisterListener

protected void unregisterListener()
Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.