Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-2862

For BSH scripts, expose all methods/variables as JMX operations and attributes

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Obsolete
    • Major
    • No Release
    • None
    • Deployers
    • None

    Description

      The ScriptService.java interface allows .bsh authors to return MBean interfaces for their .bsh script in an array of classes.

      Unfortunately, this requires coding an external Java interface class, which sort of precludes its usefulness.

      I think what might be better, instead is to proactively expose all the defined methods in the script namespace as MBean operations and attributes:

      http://www.beanshell.org/javadoc/bsh/Interpreter.html#getNameSpace()
      http://www.beanshell.org/javadoc/bsh/NameSpace.html#getVariableNames()
      http://www.beanshell.org/javadoc/bsh/NameSpace.html#getMethods()

      This violates any safety of encapsulation but if you're coding a .bsh why would you care? *

      • okay, if you do, maybe there should be some way to turn it off?

      Example script:


      String name = "joe";
      void invoke() {
      System.out.println("invoke " + name);
      }
      ------
      would expose an "invoke" operation and "name" as an read/write attribute.

      In some ways, this would make creating MBeans very quick and easy to do. It would also lower the barrier to most people, who think that making an MBean is a lot of repetitive work or requires tools such as xdoclet to be efficient.

      Something else that comes to mind is doing something like:

      <server>
      <mbean name="example:service=Test">
      <depends> ...
      <code language="bsh">
      String name = "joe";
      void invoke() {
      System.out.println("invoke " + name);
      }
      </code>
      </mbean>

      The "language" tag sort of enables the potential for other scripts, such as Groovy or JScript.

      Attachments

        Activity

          People

            Unassigned Unassigned
            genman_jira Elias Ross (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: