| Name | Bean Shell Macro |
|---|---|
| Plugin | Java Scripting Plugin |
Description | Documentation | Common parameters | Pre-defined variables | Additional parameters | Usage | Other examples | Security | Open Issues with this component
Description
Java scripting using BeanShell
- This is a newer implementation and replacement for the script macro
- The script macro is retained for upward compatibility with existing source - it is exactly the same as beanshell
- The beanshell implementation level has been updated with this release of the macro
Documentation
- Help available in the notation guide.
Common parameters
Pre-defined variables
Additional parameters
- showJava - Default is false. Set to true to show a panel with the java source. Requires output=wiki.
- strictJava - Default is false. Set to true to restrict what is considered valid source. This mode attempts to make BeanShell syntax behave as Java syntax, eliminating conveniences like loose variables, etc. When enabled, variables are required to be declared or initialized before use and method arguments are reqired to have types. This mode will become more strict in a future release when classes are interpreted and there is an alternative to scripting objects as method closures.
Usage
{beanshell}
out.println("Hello world");
{beanshell}
{beanshell:output=wiki|script=#userByGroup.bsh|group=confluence-users}
{beanshell}
{beanshell:output=wiki|script=^userByGroup.bsh|showjava=true}
{beanshell}
{script:output=html|script=^myjava.java}
{script}
Other examples
Security
This macro supports Macro Security Plugin.

Comments (1)
Jul 03
Andy Brook says:
Out of curiosity I tried this: {beanshell} System.exit(0); {beanshell} I w...Out of curiosity I tried this:
{beanshell} System.exit(0); {beanshell}I wondered if the Beanshell code was sparking a new JVM, apparently not, it takes down the application server!. Whilst this was a particularly daft thing to do, and granted, the page-editor needs to setup script security accordingly, I wonder if it possible to somehow keep beanshell code separate. This would isolate beanshell code entirely, which is good on the one hand, but not if for instance you wanted to make confluence API calls...