什么是BeanShell

BeanShell是一个小型的、免费的、可嵌入使用Java编写的具有对象脚本语言特性的Java源码解释器。BeanShell动态执行标准的Java语法并且扩展了诸如弱语言类型、指令以及像Perl和JavaScript的方法闭包的通用脚本。
    你可以使用交互式的BeanShell实现Java实验和调试,也可以使用新的方法扩展应用程序。脚本式Java使应用程序更加多样化,快速建模、用户脚本扩展、规则引擎、配置、测试、动态部署、嵌入式系统还有Java训练。
    BeanShell具有小型以及可嵌入的特征,所以你可以从你的应用程序中调用BeanShell在程序运行的时候来动态执行Java代码或者提供应用程序的可扩展性。你可以使用独立的BeanShell脚本操作Java应用程序;动态地与java对象和API一起工作,二者选一。既然BeanShell使用Java编写而且与你的应用程序运行在同一台虚拟机上,你可以自由地给脚本传递“实时”的对象并且作为结果返回。
    总之,BeanShell是动态解析的Java,加上脚本语言以及灵活的环境所有这一切组成一个完整的包。
功能摘要
  • 动态执行所有Java语句、Java代码片段以及弱类型Java和附加的脚本的便利
  • 透明地访问所有Java对象和API
  • 四种运行模式:命令行、控制台、Applet、远程会话服务
  • 可以在受安全限制的环境下工作,不需要类加载器或者绝大多数功能的字节码生成器
  • 程序只有大约150K的Jar文件
  • 纯Java
  • 免费
Java的求值功能:
    对所有的Java源码类和独立的Java方法、声明和表达式进行动态求值。
脚本功能:
  • 可选类型的变量
  • 可选类型的参数和返回值的脚本方法
  • 脚本对象(方法闭包)
  • 脚本接口和事件处理
  • 使用JavaBean属性,哈希表以及原始的包装类型这些便利的语法
  • 自动分配变量来模拟Java属性文件
  • 可扩展的公共程序集以及类似shell的命令
  • 动态的classpath管理包括重装微粒类
  • 动态的加载命令和用户命令路径
  • 复杂的命名空间以及堆栈调用管理
  • 详细的错误报告
BeanShell的使用:
  • 交互式的Java——尝试对象功能,API以及GUI小部件——“亲身实践”
  • 应用程序脚本扩展——允许你使用直观而且简单的方法通过脚本扩展应用程序
  • 宏语言——作为宏来生成脚本并且在你的虚拟机中容易得执行
  • 教育——亲自教授Java,在在线的环境下
  • 科学、金融应用程序和规则引擎的表达式求值者——通过条件和循环求出复杂的表达式的值
  • 远程调试——在你的应用程序中只要几行代码嵌入一个实时、远程访问的shell/命令
  • 声名式地使用BeanShell来代替属性文件和启动配置文件,(这些配置文件)完全使用Java语法处理执行复杂的初始化以及启动的脚本


What is BeanShell?

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript.

You can use BeanShell interactively for Java experimentation and debugging as well as to extend your applications in new ways. Scripting Java  itself to a wide variety of applications including rapid prototyping, user scripting extension, rules engines, configuration, testing, dynamic deployment, embedded systems, and even Java education.

BeanShell is small and embeddable, so you can call BeanShell from your Java applications to execute Java code dynamically at run-time or to provide extensibility in your applications. Alternatively, you can use standalone BeanShell scripts to manipulate Java applications; working with Java objects and APIs dynamically. Since BeanShell is written in Java and runs in the same VM as your application, you can freely pass references to "live" objects into scripts and return them as results.

In short, BeanShell is dynamically interpreted Java, plus a scripting language and flexible environment all rolled into one clean package. 
Summary of features
  • Dynamic execution of the full Java syntax, Java code fragments, as well as loosely typed Java and additional scripting conveniences.
  • Transparent access to all Java objects and APIs.
  • Runs in four modes: Command Line, Console, Applet, Remote Session Server.
  • Can work in security constrained environments without a classloader or bytecode generation for most features.
  • The interpreter is small ~150K jar file.
  • Pure Java.
  • It's Free!!
Java evaluation features:
  • Evaluate full Java source classes dynamically as well as isolated Java methods, statements, and expressions.
Scripting features:
  • Optionally typed variables.
  • Scripted methods with optionally typed arguments and return values
  • Scripted objects (method closures)
  • Scripted interfaces and event handlers.
  • Convenience syntax for working with JavaBean properties, hashtables, and primitive wrapper types.
  • Auto-allocation of variables to emulate Java properties files.
  • Extensible set of utility and shell-like commands
  • Dynamic classpath management including find grained class reloading
  • Dynamic command loading and user command path
  • Sophisticated namespace and callstack management
  • Detailed error reporting
BeanShell Uses
  • Interactive Java - try out object features, APIs and GUI widgets - "hands on".
  • Scripting extension for applications - Allow your applications to be extended via scripts in an intuitive and simple way.
  • Macro Languages - Generate scripts as macros and execute them live in your VM easily.
  • Education - Teach Java in a hands-on, live environment
  • Expression evaluator for scientific, financial apps and rules engines - evaluate complex expressions with conditions and loops.
  • Remote debugging - Embed a live, remotely accessible shell / command line in your application with just a few lines of code.
  • Use BeanShell declaratively to replace properties files and replace startup config files with real scripts that perform complex initialization and setup with the full Java syntax at their disposal.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值