Hello,

Yesterday I commited a BeanShell (BSH, www.beanshell.org) sub-deployer in
HEAD. It is in module varia and you can find its lib in
varia/output/lib/bsh-deployer.sar.

It allows you to hot-deploy *.bsh files in /deploy.

SIMPLE USAGE: client-only
=========================
In its simple usage, the script will act as a simple client-script making
invocations on other objects. Each script can follow the
org.jboss.system.Service interface i.e. the create, start, stop and destroy
calls. You can implement only a subset of those. Thus, a very simply
one-line script can be: Simple.bsh:

        void start() { System.out.println ("I'm called!"); }

that's it.


ADVANCED USAGE: server script!
==============================
But it is almost as easy to make your script a JBoss service fully
invocable/administrable through JMX! For this, your script can implement any
of the methods of the following interface:

        public interface ScriptService
           extends org.jboss.system.Service
        {
           public String objectName ();
           public String[] dependsOn ();
           public Class[] getInterfaces ();

           public void setCtx (ServiceMBeanSupport wrapper);
        }

You can implement the objectName method to choose your own MBean ObjectName.
You can implement the dependsOn method to return a set of JMX MBean
ObjectName (as string) on which you depends (for service lifecyle).
You can implement the getInterfaces method to return the set of interfaces
that you *say* your script do implement. Your wrapper will analyse these
interfaces and fully generate the associated JMX MBeanInfo (the script
wrapper is a Dynamic MBean).

Example, let's say you have this interface:

        public interface MyIntf
        {
           public void doThat();

           public String getRWString ();
           public void setRWString (String val);

           public String getROString ();
        }

You could then provide this script:

   String name = "bla";

   String objectName () { return "jboss.scripts:service=myService"; }
   Class[] getInterfaces () { return new Class[] {MyIntf.class}; }

   void create () { System.out.println ("Create called on me"); }

   void doThat () { System.out.println ("doThat called"); }

   String getRWString() { return super.name; }
   void setRWString(String bla) { super.name = bla; }

   String getROString() { return "I am read-only!"; }


Then, not only can you invoke methods and get/set attributes on your script
using JMX, you can also browse your scripts using the
http://localhost:8080/jmx-console/ and see all available methods/attributes
(MBeanInfo is generated by the DynamicMBean script wrapper)

Infos on BeanShell are available here: www.beanshell.org

Do you want this feature on 3.2?

Cheers,


                        Sacha


P.S.: This e-mail is cross-posted to the beanshell-users ML.



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to