mx4j.tools.jython
Class JythonRunner
java.lang.Object
mx4j.tools.jython.JythonRunner
- JythonRunnerMBean, javax.management.MBeanRegistration, javax.management.NotificationListener
public class JythonRunner
extends java.lang.Object
implements JythonRunnerMBean, javax.management.NotificationListener, javax.management.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:
- from javax.management import *
- from javax.management.loading import *
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
- getCacheScript in interface JythonRunnerMBean
getPythonInterpreter
public static PythonInterpreter getPythonInterpreter()
getUseText
public boolean getUseText()
Indicates wether to use the script given in the ScripText variable or
the one given in the script File.
- getUseText in interface JythonRunnerMBean
handleNotification
public void handleNotification(javax.management.Notification notification,
Object handback)
- handleNotification in interface javax.management.NotificationListener
loadStream
protected static String loadStream(InputStream in)
throws IOException
postDeregister
public void postDeregister()
- postDeregister in interface javax.management.MBeanRegistration
postRegister
public void postRegister(Boolean registrationDone)
- postRegister in interface javax.management.MBeanRegistration
preDeregister
public void preDeregister()
throws java.lang.Exception
- preDeregister in interface javax.management.MBeanRegistration
preRegister
public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
throws java.lang.Exception
Gathers some basic data
- preRegister in interface javax.management.MBeanRegistration
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
- runScript in interface JythonRunnerMBean
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
- setCacheScript in interface JythonRunnerMBean
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
- setNotificationType in interface JythonRunnerMBean
setObservedObject
public void setObservedObject(javax.management.ObjectName targetMBeanName)
Sets the object being observed by this MBean. The MBean will register
itself as a listener of targetMBeanName
- setObservedObject in interface JythonRunnerMBean
setScript
public void setScript(String text)
Sets the content of the script. If you want to use a file, use ScriptFile
instead.
- setScript in interface JythonRunnerMBean
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
- setScriptURL in interface JythonRunnerMBean
unregisterListener
protected void unregisterListener()
Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.