<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.qzone.qq.com/rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://qzone.qq.com">
<channel>
<title><![CDATA[Ronger]]></title>
<description><![CDATA[ronger]]></description>
<link>http://281696143.qzone.qq.com</link>
<lastBuildDate>Mon, 23 Nov 2009 15:33:43 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, Tencent Tech. Co., Ltd.</copyright>
<pubDate>Fri, 26 Dec 2008 08:18:49 GMT</pubDate>

<item>
<title><![CDATA[Beanshell翻译27]]></title>
<link>http://281696143.qzone.qq.com/blog/1230279529</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.BeanShell Commands Beanshell命令 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.1.run </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">run ( String filename , Object runArgument ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">run ( String filename ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Run a command in its own in its own private global namespace, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">with its own class manager and interpeter context. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(kind of like unix &quot;chroot&quot; for a namespace). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">运行一个命令在它自己私有的全局名字空间中， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">通过它自己的类管理器和解释器环境。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(就像unix中名字空间中的&quot;chroot&quot;一样) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">The root bsh system object is extended (with the extend() command) and made visible here, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">so that general system info (e.g. current working directory) is effectively inherited. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Because the root bsh object is extended it is effectively read only / copy on write... e.g. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">you can change directories in the child context, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">do imports, change the classpath, etc. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">and it will not affect the calling context. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个根bsh系统对象是被继承的(通过extend()命令)并且在这儿是可见的， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">所以通常的系统信息(当前工作路径)是有效的继承而得到。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">因为根bsh对象是被继承出来的，所以它是只读的。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能在子类环境中修改目录， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">导入，修改类路径，等等。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">并且它将不会影响调用环境。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">run() is like source() except that it runs the command in a new, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">subordinate and prune()'d namespace. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">So it's like &quot;running&quot; a command instead of &quot;sourcing&quot; it. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">run() teturns the object context in which the command was run. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Returns the object context so that you can gather results. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Parameter runArgument an argument passed to the child context under the name runArgument. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">e.g. you might pass in the calling This context from which to draw variables, etc. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">run()和source()一样， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">除了它在一个新的下级的prune()的名字空间中运行这个命令。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">所以它就像&quot;running&quot;一个命令来代替&quot;sourcing&quot;它。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">run()返回命令正在运行的对象环境。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">返回这个对象环境，所以你能搜集结果。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">参数runArgument的一个参数在runArgument的下面通过子类环境。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">例如，你能通过调用定义变量的这个环境，等等。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.2.save </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">void save ( Object obj , String filename ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Save a serializable Java object to filename. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">存储一个能序列化的Java对象到一个文件中。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.3.server </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">void server ( int port ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Create a remote BeanShell listener service attached to the current interpreter, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">listening on the specified port. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">创建一个远程Beanshell监听器服务，这个服务隶属于当前解释器， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">监听特定的端口。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.4.setAccessibility </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">setAccessibility ( boolean b ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Setting accessibility on enables to private and other non.public fields and method. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">设置能操作私有和其他的非公有属性和方法的入口。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.5.setClassPath </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">void setClassPath( URL [] ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Change the classpath to the specified array of directories and/or archives. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">See &quot;Class Path Management&quot; for details. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">修改类路径为目录和URL的特定数组。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">请看&quot;Class Path Management&quot;的细节。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.6.setFont </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Font setFont ( Component comp , int ptsize ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Change the point size of the font on the specified component, to ptsize. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This is just a convenience for playing with GUI components. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在特定的组件上修改字体的大小。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这是使用GUI组件的一个便利。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.7.setNameCompletion </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">void setNameCompletion ( boolean bool ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Allow users to turn off name completion. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Turn name completion in the GUI console on or off. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Name competion is on by default. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Explicitly setting it to true </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">however can be used to prompt bsh to read the classpath and provide immediate feedback. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(Otherwise this may happen behind the scenes the first time name completion is attempted). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Setting it to false will disable name completion. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">允许用户关闭名字编辑。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在GUI平台上打开或者关闭名字编辑。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">名字编辑在默认的情况下是打开的。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">很明白的将它设置为true, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">但是能被用于促使bsh去读取类路径和提供直接的反应。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(其他的，这个能在第一次命名编辑被运行的时候发生)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">将它设置为false的时候将不允许名字编辑。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.8.setNameSpace </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">setNameSpace ( ns ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Set the namespace (context) of the current scope. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">The following example illustrates swapping the current namespace. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">设置当前作用域的名字空间(环境)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">下面的例子举例说明了交换当前名字空间。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">fooState = object(); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">barState = object(); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print(this.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">setNameSpace(fooState.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print(this.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">a=5; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">setNameSpace(barState.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print(this.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">a=6; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">setNameSpace(fooState.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print(this.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print(a); // 5 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">setNameSpace(barState.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print(this.namespace); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print(a); // 6 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You could use this to creates the effect of a static namespace for a method </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">by explicitly setting the namespace upon entry. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能使用这些为一个方法创建一个静态名字空间的效果， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">通过清晰地将名字空间设置到输入中。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.9.setStrictJava </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">void setStrictJava ( boolean val ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Enable or disable &quot;Strict Java Mode&quot;. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">When strict Java mode is enabled BeanShell will: </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.9.1. Require typed variable declarations, method arguments and return types. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.9.2. Modify the scoping of variables to look for the variable declaration first </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">in the parent namespace, as in a java method inside a java class. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">允许或者不允许&quot;严格Java模式&quot;。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">当严格Java模式开启的时候，Beanshell将会： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">需要定义类型变量，方法参数和返回类型。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">修改变量作用域去首先查找在父名字空间中变量的定义，就像一个java方法在一个java类中一样。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">e.g. if you can write a method called incrementFoo() that will </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">do the expected thing without referring to &quot;super.foo&quot;. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">See &quot;Strict Java Mode&quot; for more details. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note: Currently most standard BeanShell commands will not work in Strict Java mode simply </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">because they have not been written with full types, etc. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">例如，如果你能写一个名字为incrementFoo()的方法， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个方法不用指向&quot;super.foo&quot;， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">就能做预期的事情。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">请看&quot;Strict Java Mode&quot;来了解更多细节。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">注意：当前很多标准Beanshell命令将不能工作在Java严格模式下， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">仅仅因为他们没有被重写为所有的类型。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.10.show </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">show ( ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Toggle on or off displaying the results of expressions (off by default). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">When show mode is on bsh will </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print() the value returned by each expression you type on the command line. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">开启或关闭表达式的显示结果(默认状态为关闭)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">当显示模式开启的时候， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh将打印通过你定义在命令行上的每一个表达式的值。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.11.source </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Object source ( String filename ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Object source ( URL url ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Read filename into the interpreter and evaluate it in the current namespace. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Like the Bourne Shell &quot;.&quot; command. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This command acts exactly like the eval() command but reads from a file or URL source. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">将文件名读取到在当前的名字空间的解释器并且计算它。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">就像目的地的&quot;.&quot;命令。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个命令正确的行为应该像eval()命令一样，但是是从一个文件或者URL源读取。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.12.sourceRelative </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">sourceRelative ( String file ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Source a file relative to the callering script's directory. e.g. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">scripts A running in dir A sources script B in dir B. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Script B can use this command to load additional scripts </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(data, etc.) relative to its own location (dir B) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">without having to explicitly know its &quot;home&quot; directory (B). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">加载一个和调用脚本目录有关系的文件，例如， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">运行在目录A上的脚本A加载目录B上的脚本B。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">脚本B能使用这个命令，在没有清晰的知道它自己的&quot;home&quot;目录的情况下(B), </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">去加载和它自己位置(目录B)有关系的另外的脚本(数据等)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note: this only works for files currently. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">注意：这个仅仅运行在当前的文件上。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.13.super </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This super( String scopename ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Return a BeanShell 'this' reference to the enclosing scope (method scope) of the specified name. e.g. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">返回一个Beanshell的'this'引用到这个特定名字所在的作用域(方法作用域)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">foo() { </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">x=1; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bar() { </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">x=2; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">gee() { </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">x=3; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print( x ); // 3 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print( super.x ); // 2 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print( super(&quot;foo&quot;).x ); // 1 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">} </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">} </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">} </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This is an experimental command that is not intended to be of general use. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这是一个根据实验的命令，不能延伸到普通用户。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.13.unset </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">void unset ( String name ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">&quot;Undefine&quot; the variable specifed by 'name' (So that it tests == void). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note: there will be a better way to do this in the future. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This is currently equivalent to doing namespace.setVariable(name, null); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">&quot;不确定&quot;通过'名字'确定的变量(所以它测试==空的)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">注意：在未来将有一个更好的方法去做这些。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个在当前等价于使用名字空间来设置变量。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.14.which </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">which( classIdentifier | string | class ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Use classpath mapping to determine the source of the specified class file. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(Like the Unix which command for executables). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">使用映射到特定的类文件的源的类路径。(就像在Unix中，确定哪一个命令能执行)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This command maps the entire classpath and prints all of the occurrences of the class. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个命令映射完整的类路径并且打印所有出现的类。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">If you just want to find the first occurrence in the classpath </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(the one that will be used by Java) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">you can also get it by printing the URL of the resource. e.g.: </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">如果你正好在类路径中找到第一次出现 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(这个将被Java实现) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你也能够通过打印源文件的URL来取得它，例如： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">print( getResource(&quot;/com/foo/MyClass.class&quot;) ); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">// Same as... 等价于 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">// System.out.println( </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">// getClass().getResourceAsStream(&quot;/com/foo/MyClass.class&quot; ) ); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note: This is all a lie! </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This command is broken and only reports the currently first occurence! To be fixed! </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">注意：这完全是一个谎言！ </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个命令会被打断，并且仅仅报告当前的第一次出现！被确定！ </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">1.15.workspaceEditor </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">workspaceEditor( bsh.Interpreter parent, String name ) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Make a new workspaceEditor in the GUI. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在GUI中构造一个新的工作区间编辑器。</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1230279529#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Fri, 26 Dec 2008 08:18:49 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1230279529</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译26]]></title>
<link>http://281696143.qzone.qq.com/blog/1230195709</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.BeanShell Commands Beanshell命令<br>1.1.getClass <br>Class getClass ( String name ) <br>Get a class through the current namespace utilizing the current imports, <br>extended classloader, etc. <br>使用当前导入的类取得一个类到当前名字空间中，<br>扩展类加载器，等。<br>This is equivalent to the standard Class.forName() method for class loading,<br>however it takes advantage of <br>the BeanShell class manager so that added classpath will be taken into account. <br>You can also use Class.forName(), <br>however if you have modified the classpath or reloaded classes from within your script the <br>modifications will only appear if you use the getClass() command. <br>这个是和标准的用于类加载Class.forName()方法等价的，<br>但是它比Beanshell类管理器有优势，<br>以至于增加的类路径将被考虑。<br>你也能使用Class.forName(),<br>但是如果你已经修改类路径或者从你的脚本中重新加载类，<br>当你使用getClass()命令的时候，仅仅显示修改。<br>1.2.getClassPath <br>URL [ ] getClassPath ( ) <br>Get the current classpath including all user path, extended path, <br>and the bootstrap JAR file if possible. <br>取得的当前的类路径，这个路径包含所有的用户路径，扩充的路径，<br>和如果可能的JAR文件。<br>1.3.getResource <br>URL getResource ( String path ) <br>Get a resource from the BeanShell classpath. <br>This method takes into account modification to the BeanShell <br>class path via addClassPath() and setClassPath(); <br>从Beanshell类路径中取得一个源。<br>这个函数会通过addClassPath()和setClassPath()来计算Beanshell类路径的修改;<br>1.4.getSourceFileInfo <br>getSourceFileInfo ( ) <br>Return the name of the file or source from which the current interpreter is reading.<br>Note that if you use this within a method, <br>the result will not be the file from which the method was sourced,<br>but will be the file that the caller of the method is reading.<br>Methods are sourced once but can be called many times... <br>Each time the interpreter may be associated with a different file<br>and it is that calling interpreter that you are asking for information. <br>从当前解释器正在读取的东西中返回文件或者源的名字。<br>注意如果你通过一个方法来使用这些，<br>结果将不是这个函数来源的文件，<br>而是函数的调用者正在读取的文件。<br>函数只可以被加载一次，但是能被调用很多次...<br>每次解释器可以被和一个不同的文件相联系，<br>并且这是调用你正在要求的信息的解释器。<br>Note: although it may seems like this command would always return the getSourceFileInfo.bsh file, <br>it does not since it is being executed after sourcing by the caller's interpreter.<br>If one wanted to know the file from <br>which a bsh method was sourced one would have to either capture <br>that info when the file was sourced (by <br>saving the state of the getSourceFileInfo() in a variable outside of the method <br>or more generally we could add the info to the BshMethod class so <br>that bsh methods remember from what source they were created... <br>注意：虽然它看起来能一直返回这个getSourceFileInfo.bsh文件，<br>在调用者的解释器之后，它不能被执行。<br>如果一个人想去知道一个bsh函数被调用的源文件，<br>当文件被加载用来存储getSourceFileInfo()的状态到函数的一个外部变量中的时候，<br>这个人既可以去捕捉信息，<br>也可以更多的，我们能够追加信息到BshMethod类中，<br>这样bsh函数可以从他们创建的源中加载。<br>1.5.importCommands <br>void importCommands( resource path | package name )<br>Import scripted or compiled BeanShell commands in the following package in the classpath.<br>You may use either &quot;/&quot; path or &quot;.&quot; package notation. e.g. <br>导入脚本或者编译好的Beanshell命令在类路径的下面的包中。<br>你不仅能使用&quot;/&quot;路径，或者&quot;.&quot;包注释。等。<br> // equivalent 等价于<br>importCommands(&quot;/bsh/commands&quot;) <br>importCommands(&quot;bsh.commands&quot;)<br> When searching for a command each path will be checked for first, <br> a file named 'command'.bsh and second a class file named 'command'.class.<br>当查找一个命令，每一个路径都会被检查，<br>首先检查一个名字为'command'.bsh的文件，<br>其次检查一个名字为'command'.class的类文件。<br> You may add to the BeanShell classpath using the addClassPath()<br> or setClassPath() commands and then import them as usual.<br>你能使用addClassPath()或者setClassPath()来增加到Beanshell类路径中，<br>并且像通常一样导入他们。<br> addClassPath(&quot;mycommands.jar&quot;); <br>importCommands(&quot;/mypackage/commands&quot;); <br>If a relative path style specifier is used <br>then it is made into an absolute path by prepending &quot;/&quot;. <br>Later imports take precedence over earlier ones. <br>Imported commands are scoped just like imported clases. <br>如果一个相对在路径样式被使用，<br>那么它就通过预先考虑的&quot;/&quot;变成一个绝对路径。<br>后来导入的内容优先于较早的一个。<br>被导入的命令的作用域就像被导入的类一样。<br>1.6.javap <br>void javap( String | Object | Class | ClassIdentifier ) <br>Print the public fields and methods of the specified class <br>(output similar to the JDK javap command). <br>打印特殊类在公共的属性和方法<br>(输出到JDK的javap命令)。<br>If the argument is a string it is considered to be a class name. <br>If the argument is an object, the class of the object is used. <br>If the arg is a class, the class is used. <br>If the argument is a class identifier, <br>the class identified by the class identifier will be used.<br>e.g. If the argument is the empty string an error will be printed.<br>如果参数是一个字符串，它被考虑为一个类名字。<br>如果参数是一个对象，这个对象的类型会被使用。<br>如果这个参数是一个类型，这个类型就被使用。<br>如果这个参数是一个类标示符，<br>被这个类标示符标示的类型将被使用。<br>等等，如果这个参数是空字符串，一个错误将被打印。<br> // equivalent 等价<br>javap( java.util.Date ); // class identifier 类标示符<br>javap( java.util.Date.class ); // class 类<br>javap( &quot;java.util.Date&quot; ); // String name of class 类的字符串名<br>javap( new java.util.Date() ); // instance of class 类的实例<br>1.7.load <br>Object load ( String filename ) <br>Load a serialized Java object from filename. Returns the object. <br>从文件中加载一个被序列化的对象，返回这个对象。<br>1.8.makeWorkspace <br>makeWorkspace ( String name ) <br>Open a new workspace (JConsole) in the GUI desktop. <br>在GUI桌面上打开一个新的工作空间(JConsole)。<br>1.9.mv <br>mv ( String fromFile , String toFile ) <br>Rename a file (like Unix mv). <br>重命名一个文件(就像Unix中的mv一样)。<br>1.10.object <br>This object() <br>Return an &quot;empty&quot; BeanShell object context which can be used to hold data items. e.g. <br>返回一个&quot;empty&quot;Beanshell对象环境，这个对象能被用于保存数据项，等等。<br> myStuff = object(); <br>myStuff.foo = 42; <br>myStuff.bar = &quot;blah&quot;; <br>1.11.pathToFile <br>File pathToFile ( String filename ) <br>Create a File object corresponding to the specified file path name,<br>taking into account the bsh current working directory (bsh.cwd) .<br>创建一个符合特殊文件路径名称的文件对象，<br>计算这个bsh当前工作路径(bsh.cwd).<br>1.12.print <br>void print ( arg ) <br>Print the string value of the argument, which may be of any type. <br>If beanshell is running interactively, <br>the output will always go to the command line,<br>otherwise it will go to System.out. <br>打印参数的字符串值，可以为任何类型。<br>如果beanshell正在交互运行，<br>输出将一直到命令行中，<br>其他的将去System.out。<br>Most often the printed value of an object will simply be the Java toString() of the object. <br>However if the argument is an array the contents of the array <br>will be (recursively) listed in a verbose way. <br>最经常的情况，一个对象打印的值将简单的变成该对象的toString().<br>但是如果这个参数是一个数组，<br>数组的内容将(递归地)被列在一个详细清单上。<br>Note that you are always free to use System.out.println() instead of print(). <br>注意你可以一直自由的使用System.out.println()来代替print().<br>1.13.printBanner <br>printBanner ( ) <br>Print the BeanShell banner (version and author line) . GUI or non GUI. <br>打印Beanshell标语(版本和作者信息)。GUI模式或者非GUI模式。<br>1.14.pwd <br>pwd ( ) <br>Print the BeanShell working directory. <br>This is the cwd obeyed by all the unix.like bsh commands. <br>答应Beanshell工作目录。<br>这是cwd，被服从于所有的unix.like bsh命令。<br>1.15.reloadClasses <br>void reloadClasses( [ package name ] ) <br>Reload the specified class, package name, or all classes if no name is given. e.g.<br>重新加载特定的类，包名，或者如果没有名字被提到就加载所有的类，等等。<br> reloadClasses(); <br>reloadClasses(&quot;mypackage.*&quot;); <br>reloadClasses(&quot;.*&quot;) // reload unpackaged classes 重新加载没有打包的类<br>reloadClasses(&quot;mypackage.MyClass&quot;) <br>See &quot;Class Path Management&quot; 请看&quot;Class Path Management&quot;<br>1.16.rm <br>boolean rm ( String pathname ) <br>Remove a file (like Unix rm). <br>移除一个文件(就像Unix下面的rm一样)。</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1230195709#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Thu, 25 Dec 2008 09:01:49 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1230195709</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译25]]></title>
<link>http://281696143.qzone.qq.com/blog/1230102096</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.BeanShell Commands Beanshell命令<br>1.1.classBrowser <br>classBrowser ( ) <br>Open the class browser. <br>打开类浏览器。<br>1.2.clear <br>clear ( ) <br>Clear all variables, methods, and imports from this namespace. <br>If this namespace is the root, it will be reset to the default imports. <br>See NameSpace.clear();<br>清理所有的变量，方法，并且从这个名字空间中导入。<br>如果这个名字空间是根，它讲重新设置默认的导入。<br>请看NameSpace.clear();<br>1.3.cp <br>cp ( String fromFile , String toFile ) <br>Copy a file (like Unix cp). <br>复制一个文件(像Unix cp一样)。<br>1.4.debug <br>debug ( ) <br>Toggle on and off debug mode.<br>Debug output is verbose and generally useful only for developers. <br>打开和关闭调试模式。<br>调试输出是冗长的并且通常仅仅对开发者有用。<br>1.5.desktop <br>void desktop() <br>Start the BeanShell GUI desktop. <br>开始Beanshell GUI桌面。<br>1.6.dirname <br>String dirname ( String pathname ) <br>Return directory portion of path based on the system default file separator. <br>Note: you should probably use pathToFile() to localize the path relative to BeanShell's working directory <br>and then file.getAbsolutePath() to get back to a system localized string. <br>直接返回路径的一部分取决于系统默认文件隔离物。<br>注意：你能够使用pathToFile()去定位Beanshell的工作目录的路径关系<br>并且也可以使用file.getAbsolutePath()去返回一个系统当前字符串。<br>Example: to change to the directory that contains the script we're currently executing:<br>例如：改变包含脚本的目录，我们在当前可以执行：<br> // Change to the directory containing this script <br> 修改包含这个脚本的目录<br>path=pathToFile( getSourceFileInfo() ).getAbsolutePath(); <br>cd( dirname( path ) ); <br>1.7.editor <br>editor ( ) <br>Open a GUI editor from the command line or in the GUI desktop mode. <br>When run from the command line the editor is a simple standalone frame.<br>When run inside the GUI desktop it is a workspace editor.<br>See workspaceEditor() <br>从命令行中或者在GUI桌面模式下打开一个GUI编辑器。<br>当从命令行中运行的时候，编辑器是一个简单的孤立的框架。<br>当进入GUI内部运行的时候，它是一个工作空间编辑器。<br>请看workspaceEditor() <br>1.8.error <br>void error ( item ) <br>Print the item as an error. <br>In the GUI console the text will show up in (something like) red, <br>else it will be printed to standard error. <br>对待一个错误一样打印细节。<br>在GUI平台中，文本下面将显示为红色，<br>否则它将打印标准错误。<br>1.9.eval <br>Object eval ( String expression ) <br>Evaluate the string in the current interpreter (see source()).<br>Returns the result of the evaluation or null. <br>评价在当前解释器中的字符串(请看source())。<br>返回计算的结果或者null.<br>Evaluate a string as if it were written directly in the current scope, <br>with side effects in the current scope. <br>计算一个字符串就像它被直接的写入在当前作用域中，<br>在当前作用域中有同样的效果。<br>e.g. <br>a=5; <br>eval(&quot;b=a*2&quot;); <br>print(b); // 10<br>eval() acts just like invoked text except <br>that any exceptions generated by the code are captured in a bsh.EvalError. <br>This includes ParseException for syntactic errors <br>and TargetError for exceptions thrown by the evaluated code. <br>eval()功能就像调用文本，<br>除了一些通过代码产生的一场在bsh.EvalError中捕捉一样。<br>这个包含依据造句法的错误的ParseException<br>和被计算代码抛出来的TargetError异常。<br>e.g. <br>try { <br>eval(&quot;foo&gt;&gt;&gt;M&gt;JK$LJLK$&quot;); <br>} catch ( EvalError e ) { <br>// ParseException caught here <br>ParseException在这儿捕捉。<br>}<br> try { <br>eval(&quot;(Integer)true&quot;); // illegal cast  非法转换<br> } catch ( EvalError e ) { <br>// TargetException caught here <br>TargetException在这儿捕捉。<br>print( e.getTarget() ) // prints ClassCastException 打印ClassCastException<br> } <br>If you want eval() to throw target exceptions directly, <br>without wrapping them, you can simply redefine own eval like so:<br>如果你想eval()直接抛出target异常，<br>不用包装它们，你能简单重定义自己的eval，就像下面这样：<br> myEval( String expression ) { <br>try { <br>return eval( expression ); <br>} catch ( TargetError e ) { <br>throw e.getTarget(); <br>} <br>} <br>Here is a cute example of how to use eval to implement a dynamic cast. <br>i.e. to cast a script to an arbitrary type by name at run.time <br>where the type is not known when you are writing the script. <br>In this case the type is in the variable interfaceType.<br>这儿是一个好的例子，来说明如何使用eval去实现动态类型转换。<br>例如当你在写脚本的时候，并且这时候类型还未知，<br>通过在运行时通过名字将一个脚本转换为一个任意类型。<br>在这个例子中，类型是在变量接口类型中。<br>reference = eval( &quot;(&quot;+interfaceType+&quot;)this&quot; ); <br>Returns the value of the expression. <br>返回表达式的值。<br>Throws bsh.EvalError on error <br>在错误中抛出bsh.EvalError<br>1.10.exec执行 <br>exec ( String arg ) <br>Start an external application using the Java Runtime exec() method. <br>Display any output to the standard BeanShell output using print(). <br>使用Java运行时执行函数，开始一个第三方的应用程序。<br>使用print()函数显示一些输出到标准的Beanshell输出上去。<br>1.11.exit 退出<br>exit ( ) <br>Conditionally exit the virtual machine.<br>Call System.exit(0) unless bsh.system.shutdownOnExit == false. <br>有条件地退出虚拟机。<br>调用System.exit(0)直到bsh.system.shutdownOnExit==false.<br>1.12.extend 扩展<br>This extend( This object ) <br>Return a new object that is a child of the specified object. <br>Note: this command will likely change along <br>with a better inheritance mechanism for bsh in a future release. <br>返回一个新对象，这个对象是特定对象的一个孩子。<br>注意:这个命令在未来的版本中将因为bsh的一个更好的继承机制而改变。<br>extend() is like the object() command, <br>which creates a new bsh scripted object, <br>except that the namespace of the new object is a child of the parent object. <br>For example: <br>extend()类似于object()命令，<br>这个命令创建了一个新的bsh脚本对象，<br>除了新对象的名字空间是父对象的一个孩子之外。<br>例如：<br>foo=object(); <br>bar=extend(foo);<br> is equivalent to:  等同于：<br> foo() {<br>bar() { <br>return this; <br>} <br>}<br> foo=foo(); <br>bar=foo.bar();<br> and also:并且：<br> oo=object(); <br>ar=object(); <br>ar.namespace.bind( foo.namespace ); <br>The last example above is exactly what the extend() command does. <br>In each case the bar object inherits variables from foo in the usual way. <br>上面的最后一个例子完全是说明extend()命令可以做什么。<br>在每一个例子中，在通常的情形下，bar对象都是从foo中继承。<br>1.13.frame 框架<br>Frame | JFrame | JInternalFrame frame( Component component ) <br>Show component in a frame, centered and packed, <br>handling disposal with the close button. <br>在一个框架中显示组件，在中间并且打包，<br>通过关闭按钮来处理。<br>Display the component, centered and packed, in a Frame, JFrame, or JInternalFrame. <br>Returns the frame. <br>If the GUI desktop is running <br>then a JInternaFrame will be used and automatically added to the desktop. <br>Otherwise if Swing is available a top level JFrame will be created.<br>Otherwise a plain AWT Frame will be created. <br>显示组件，在中间打包，在一个框架中，JFrame,或者JInternalFrame.<br>返回这个框架。<br>如果GUI平台正在运行，<br>那么一个JInternaFrame将被使用并且自动加到平台中。<br>其他情况下，如果Swing是可用的，一个顶级JFrame将被创建。<br>同时一个AWT Frame也将被创建。<br>1.14.getBshPrompt <br>String getBshPrompt ( ) Get the value to display for the bsh interactive prompt. <br>This command checks for the variable bsh.prompt and uses it if set. <br>else returns &quot;bsh % &quot; Remember <br>that you can override bsh commands simply by defining the method in your namespace.<br>e.g. the following method displays the current working directory in your prompt:<br>字符串getBshPrompt()取得值去显示bsh的互动提示。<br>这个命令检查变量bsh.prompt并且使用它，如果有设置的话。<br>否则返回&quot;bsh % &quot;记得，<br>你能通过在你的名字空间中定义函数来简单的覆盖bsh命令。<br>例如下面的函数显示当前工作目录在你的提示中：<br> String getBshPrompt() {<br> return bsh.cwd + &quot; % &quot;;<br> } </span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1230102096#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Wed, 24 Dec 2008 07:01:36 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1230102096</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译24]]></title>
<link>http://281696143.qzone.qq.com/blog/1228467797</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.Here are some things that we can always use help with: <br>这儿是一些事情，我们能够常常这么做：<br>· Tests for the test suite . <br>.为测试案例进行测试。<br>We need more tests! BeanShell relies heavily on its test suite to guarantee <br>that changes don't break subtle aspects of the language. <br>Often tests are added for specific bug cases <br>(Developers: please add a test for any bug you fix!). <br>But it would be best if tests were generalized to <br>cover all of the &quot;corner cases&quot; too. <br>我们需要更多的测试！<br>Beanshell严重的依赖它的测试案例去保证，<br>修改一点也不能打破语言的外貌。<br>通常，测试被追加到特殊的缺陷案例中<br>(开发者：请为你选定的一些缺陷增加一个测试！)。<br>但是它会变得更好，如果测试也被推广到覆盖所有的&quot;边角案例&quot;。<br>· Bug fixes . Check the bugs list at the sourceforge site and dig into the code. <br>.选定的缺陷.在源文件欺骗站点上检查缺陷列表并且搜集代码。<br>Some bug fixes are easy, <br>some are deep. <br>一些确定的缺陷是容易的，<br>一些是深入的。<br>Feel free to contact me (</span><wbr />[email=[ft=,4,]pat@pat.net</span><wbr />]pat@pat.net[/email]<span style="font-size:18px;line-height:1.8em;">) directly <br>if you want help getting started on an issue.<br>很自由的能够直接联系我，<br>如果你想帮助在一个案例上开始。<br>· Docs . We can always use articles, <br>documentation and examples. <br>.Docs.我们能够通常使用文章，文档和例子。<br>· Integration and third party tools . <br>Have you integrated BeanShell into another tool or environment? <br>Let us know and we'll link to your site. <br>.综合和第三个工具.<br>你有讲Beanshell结合到其他的工具或者环境中去吗？<br>让我们了解并且我们讲链接到你的站点。<br>· Feedback from the World . <br>Despite BeanShell's relative popularity you would be amazed at how <br>little information we have about who is using the tool and how.<br>If you are using it or you know people using it please let us know! <br>.从世界上的回馈.<br>不管Beanshell的相关物多么流行，<br>你都会震惊在我们知道谁在使用和怎么使用这个工具方面有如此少的信息。<br>如果你正在使用它或者你知道有人在使用它，请让我们知道。<br>2.Credit and Acknowledgments 信任和感谢<br>Many people have contributed substantially to BeanShell over the years. <br>I will attempt to start crediting those individual here. <br>Please do not be offended if your name is missing.<br>This list will grow as I have time to work backwards through my email <br>and recover names. <br>很多人已经为Beanshell贡献了很多年。<br>在这里我将尝试着开始信任这些个人。<br>如果你的名字没有列入，请不要感到不愉快。<br>当我通过我的邮箱工作的时候，<br>这个列表就会增加，<br>并且覆盖对应的名字。<br>· Thanks to Daniel Leuck for his long time support and many contributions to the project. <br>.谢谢Daniel Leuck长时间的支持和对项目的很多贡献。<br>Me <br>Finally, I will put in a plug for myself: Pat Niemeyer (</span><wbr />[email=[ft=,4,]pat@pat.net</span><wbr />]pat@pat.net[/email]<span style="font-size:18px;line-height:1.8em;">)<br>我自己，最后，我将把一个插件给我自己:Pat Niemeyer (</span><wbr />[email=[ft=,4,]pat@pat.net</span><wbr />]pat@pat.net[/email]<span style="font-size:18px;line-height:1.8em;">) <br>If you like BeanShell check out my book: Learning Java, O'Reilly &amp; Associates, 2nd edition. <br>如果你喜欢Beanshell，请检验我的书:Learning Java, O'Reilly &amp; Associates, 2nd edition. <br>Winner of the Best Java Introductory Book . <br>JavaOne 2001. Learning Java (previously titled Exploring Java) <br>is available in nine languages world.wide. <br>It is a comprehensive overview of the Java language <br>and APIs including a brief introduction to BeanShell as well! <br>最好的Java介绍书籍的赢家。<br>JavaOne 2001。学习Java(最初标题为探索Java)<br>在全球的九种语言中是很有价值的。<br>它完全的展现了Java语言并且包含了一些对Beanshell有简单介绍的APIs.<br>3.License and Terms of Use 序列号和使用期限<br>You may freely use and reproduce this document <br>in its entirety as long as you preserve this license information <br>and a pointer to the original web site: </span><wbr /><a href="http://www.beanshell.org" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">. <br>You may integrate parts of this document into your own documentation <br>as long as you provide this same information at an appropriate place in your document. <br>你能很自由的使用和复制这些文档，<br>如果你能保存这些序列号信息和指向最初web站点:http://www.beanshell.org. <br>你能够将这个文档的一部分进入你自己的文档中去，<br>如果你在你的文档中在合适的位置提供这些同样的信息。<br>This document is copyright Pat Niemeyer, 2002. <br>Sections contributed by other authors are copyrighted to those individuals <br>and subject to the terms of use described above. <br>这个文档是Pat Niemeyer, 2002的版权。<br>其他作者做出贡献的章节的版权是那些个人和上面提到的主题的使用期限。<br>4.BeanShell Commands Documentation Beanshell命令文档<br>The following documentation was generated automatically by 'BshDoc'<br>from Javadoc style comments in the BeanShell command script files. <br>See &quot;BshDoc&quot; for more information. <br>下面的文档在Beanshell命令脚本文件中从Javadoc样式的注释中<br>被'BshDoc'自动产生。<br>请看&quot;BshDoc&quot;了解更多信息。<br>addClassPath void addClassPath( string | URL ) <br>bg Thread bg( String filename ) <br>bind bind ( bsh .This ths , bsh .NameSpace namespace ) <br>browseClass void browseClass( String | Object | Class ) <br>cat <br>cat ( String filename ) <br>cat ( URL url ) <br>cat ( InputStream ins ) <br>cat ( Reader reader ) <br>cd void cd ( String pathname ) <br>classBrowser classBrowser ( ) <br>clear clear ( ) <br>cp cp ( String fromFile , String toFile ) <br>debug debug ( ) <br>desktop void desktop() <br>dirname String dirname ( String pathname ) <br>editor editor ( ) <br>error void error ( item ) <br>eval Object eval ( String expression ) <br>exec exec ( String arg ) <br>exit exit ( ) <br>extend This extend( This object ) <br>frame Frame | JFrame | JInternalFrame frame( Component component ) <br>getBshPrompt String getBshPrompt ( ) <br>getClass Class getClass ( String name ) <br>getClassPath URL [ ] getClassPath ( ) <br>getResource URL getResource ( String path ) <br>getSourceFileInfo getSourceFileInfo ( ) <br>importCommands void importCommands( resource path | package name ) <br>javap void javap( String | Object | Class | ClassIdentifier ) <br>load Object load ( String filename ) <br>makeWorkspace makeWorkspace ( String name ) <br>mv mv ( String fromFile , String toFile ) <br>object This object() <br>pathToFile File pathToFile ( String filename ) <br>print void print ( arg ) <br>printBanner printBanner ( ) <br>pwd pwd ( ) <br>reloadClasses void reloadClasses( [ package name ] ) <br>rm boolean rm ( String pathname ) <br>run <br>run ( String filename , Object runArgument ) <br>run ( String filename ) <br>save void save ( Object obj , String filename ) <br>server void server ( int port ) <br>setAccessibility setAccessibility ( boolean b ) <br>setClassPath void setClassPath( URL [] ) <br>setFont Font setFont ( Component comp , int ptsize ) <br>setNameCompletion void setNameCompletion ( boolean bool ) <br>setNameSpace setNameSpace ( ns ) <br>setStrictJava void setStrictJava ( boolean val ) <br>show show ( ) <br>source <br>Object source ( String filename ) <br>Object source ( URL url ) <br>sourceRelative sourceRelative ( String file ) <br>super This super( String scopename ) <br>unset void unset ( String name ) <br>which which( classIdentifier | string | class ) <br>workspaceEditor workspaceEditor( bsh.Interpreter parent, String name ) <br>addClassPath <br>void addClassPath( string | URL ) <br>Add the specified directory or JAR file to the class path. e.g.<br>将特殊的路径或者JAR文件加到类路径中，例如。<br> addClassPath( &quot;/home/pat/java/classes&quot; ); <br>addClassPath( &quot;/home/pat/java/mystuff.jar&quot; ); <br>addClassPath( new URL(&quot;</span><wbr /><a href="http://myserver/~pat/somebeans.jar" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://myserver/~pat/somebeans.jar</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">&quot;) ); <br>See Class Path Management 请看类路径管理器<br>bg <br>Thread bg( String filename ) <br>Source a command in its own thread in the caller's namespace <br>This is like run() except that it runs the command in its own thread.<br>Returns the Thread object control. <br>在调用者的名字空间，在它自己的线程中加载一个命令，<br>这是类似与run()方法一样，<br>除了它运行命令在它自己的线程上面。<br>返回线程对象控制。<br>bind <br>bind ( bsh .This ths , bsh .NameSpace namespace ) <br>Bind a bsh object into a particular namespace and interpreter <br>绑定一个bsh对象进入一个特殊名字空间和解释器<br>browseClass <br>void browseClass( String | Object | Class ) <br>Open the class browser to view the specified class. <br>If the argument is a string it is considered to be a class name. <br>If the argument is an object, the class of the object is used. <br>If the arg is a class, the class is used. <br>打开这个类浏览器去查看这个特定的类。<br>如果参数是一个字符串，它是被认为一个类名。<br>如果参数是一个对象，对象的类型是被使用的。<br>如果参数是一个类型，这个类型被使用。<br>Note: To browse the String class you can't supply a String.<br>You'd have to do: browseClass( String.class ); <br>注意：浏览这个字符串类，你不能提供一个字符串。<br>你得这样去做：browseClass( String.class ); <br>cat <br>cat ( String filename ) <br>cat ( URL url ) <br>cat ( InputStream ins ) <br>cat ( Reader reader ) <br>Print the contents of filename, url, or stream (like Unix cat) <br>打印文件名,url,或者流(类似于Unix下的猫)的内容<br>cd <br>void cd ( String pathname ) <br>Change working directory for dir(), etc. commands (like Unix cd) <br>为dir()修改工作目录，等等。命令(类似于Unix下面的cd)</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1228467797#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Fri, 05 Dec 2008 09:03:17 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1228467797</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译23]]></title>
<link>http://281696143.qzone.qq.com/blog/1228359047</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.BshMethod <br>You can inspect a BshMethod object to determine its method name and argument types: <br>name = bshMethod.getName(); <br>Class [] types = bshMethod.getArgumentTypes(); <br>Class returnType = bshMethod.getReturnType(); <br>你能检查一个BshMethod对象去决定它的方法名字和参数类型：<br>To invoke the BshMethod, call its invoke() method, passing an array of arguments, <br>an interpreter reference, and a &quot;callstack&quot; reference. <br>调用BshMethod,调用它的invoke()方法，通过一个参数数组，<br>一个解释器引用，和一个&quot;callstack&quot;引用。<br>// invoke the method with arg 通过参数调用方法<br>bshMethod.invoke( new Object [] { new Integer(1), &quot;blah!&quot; }, this.interpreter, this.callstack ); <br>For the interpreter and callstack references <br>you can simply pass along the current context's values via <br>'this.interpreter' and 'this.callstack',as we did above. <br>The arguments array may be null or empty for no arguments. <br>对于解释器和堆栈调用引用，<br>你能简单的顺着当前环境的值连接'this.interpreter'和'this.callstack',<br>就像我们上面做到的一样。<br>这个参数数组能为null或者没有参数。<br>2.Uses 使用<br>Why would anyone want to do this? <br>Well, perhaps you are sourcing a script created by a user and want to <br>automatically begin using methods that they have defined.<br>Perhaps the user is allowed to define methods to <br>take control of various aspects of your application.<br>With the tools we've described in this section you can list <br>the methods they have defined and invoke them dynamically. <br>为何一些人想去做这些呢？<br>也许你正在加载一个被用户创建的脚本，<br>并且想去自动的使用他们已经定义的方法。<br>也许用户被允许去定义方法去控制你的应用程序的变量方面。<br>通过我们在本节描述的工具，<br>你能列出他们已经定义好的方法并且有力的调用他们。<br>3.Executable scripts under Unix 在Unix底下执行脚本<br>You can use BeanShell for writing scripts as you would any other shell under many Unixs: <br>你能使用Beanshell写脚本，<br>就像你可以在很多Unixs底下操作其他的一些shell一样：<br>#!/usr/java/bin/java bsh.Interpreter <br>print(&quot;foo&quot;); <br>However some flavors of Unix are more picky about what they will allow as a shell program. <br>For those you can use the following hack to make your BeanShell scripts executable. <br>但是有一些Unix在关于它们允许在一个shell程序中过分讲究，<br>那样，你能使用下面的黑客去使你的Beanshell脚本执行。<br>#!/bin/sh <br># The following hack allows java to reside anywhere in the PATH. <br>下面的黑客允许java在路径中的任何地方。<br>//bin/true; exec java bsh.Interpreter &quot;$0&quot; &quot;$@&quot; <br>print(&quot;foo&quot;); <br>The above trick presumes that /bin/true exists on your system and that //bin is the same as /bin. <br>The // causes BeanShell to ignore the line. <br>上面的骗局假定，<br>/bin/true存在你的系统中，并且//bin是和/bin一样的。<br>这个//是Beanshell忽视这个线。<br>The above has been tested on Solaris. It does not seem to work under Cygwin. <br>上面已经在Solaris中测试过了。<br>它看起来不能工作在Cygwin上面。<br>OSX <br>For OSX the path is a bit different: <br>对于OSX来说，路径有一点点的不同：<br>#!/Library/Java/home/bin/java bsh.Interpreter <br>print(&quot;foo&quot;); <br>On OSX /usr/bin/java is itself a shell script, which unfortunately won't work out.of.the.box. <br>在OSX /usr/bin/java上面是它自己的一个shell脚本，<br>这个脚本很不幸，不能工作在盒子的外面。<br>4.BSF Bean Scripting Framework BSF脚本框架<br>BSF is the Apache &quot;Bean Scripting Framework&quot;. <br>It is generic framework that allows many scripting <br>languages to be plugged into an application. <br>It shields the application from knowledge of how to invoke the <br>scripting languages and their APIs, via adapter &quot;engines&quot;. <br>BSF是Apache的&quot;Bean脚本框架&quot;。<br>它是普通的框架，<br>这个框架允许许多的脚本语言插入应用程序。<br>它从怎样调用脚本语言和它们的APIs来防护应用程序，<br>这些API是连接适配器的&quot;引擎&quot;。<br>BeanShell supports the BSF API by providing the necessary adapter. <br>This means that BeanShell can be used <br>as a scripting language for any BSF 2.3 capable application <br>simply by dropping the bsh JAR file into the classpath. <br>Beanshell通过提供需要的适配器来支持BSF的API.<br>这意味着，<br>Beanshell做为一个脚本语言能被用于对于BSF2.3有能力的应用程序，<br>这个应用程序能简单的将bsh的JAR文件推入类路径中。<br>Prior to version 2.3, BSF was maintained by IBM.<br>To get BeanShell to work with older versions of BSF<br>you must use the older bsh.bsf.1.2x.jar file <br>which includes the adapter class for the previous ibm packaged BSF API. <br>最初的版本2.3,BSF是被IBM主张的。<br>如果想让Beanshell和老版本的BSF一起工作，<br>你必须使用比较老的bsh.bsf.1.2x.jar文件，<br>这个文件包含最初的定义了BSF的API的IBM公司开发的适配器类。<br>You must also explicitly register the BeanShell adapter with older versions of BSF. <br>Here is an example of how to do that: <br>你也必须将BSF的比较老的版本清楚的注册在Beanshell适配器上面。<br>这儿是一个怎么去做那些的例子：<br>import com.ibm.bsf.*; <br>// register beanshell with the BSF framework <br>通过BSF框架注册beanshell<br>String [] extensions = { &quot;bsh&quot; }; <br>BSFManager.registerScriptingEngine( <br>&quot;beanshell&quot;, &quot;bsh.util.BeanShellBSFEngine&quot;, extensions ); <br>See </span><wbr /><a href="http://jakarta.apache.org/bsf/" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://jakarta.apache.org/bsf/</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;"> and <br></span><wbr /><a href="http://oss.software.ibm.com/developerworks/projects/bsf" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://oss.software.ibm.com/developerworks/projects/bsf</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;"> for more <br>请看</span><wbr /><a href="http://jakarta.apache.org/bsf/" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://jakarta.apache.org/bsf/</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;"> and <br></span><wbr /><a href="http://oss.software.ibm.com/developerworks/projects/bsf" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://oss.software.ibm.com/developerworks/projects/bsf</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">，<br>以了解更多<br>5.information about BSF. 关于BSF的信息<br>Ant 编译<br>This section needs to be updated. <br>I'm not sure what versionf of Ant use the new and which use the old BSF API. <br>这一节需要去更新。<br>我不能确定，<br>哪一种版本的Ant使用这些新特性，<br>哪些使用旧的BSF的API.<br>Ant 1.5+ has explicit support for BeanShell as a BSF scripting language. <br>The BeanShell JAR file includes the necessary BSF adapter.<br>You must simply specify language=&quot;beanshell&quot; in your script tags. <br>Ant 1.5+已经清楚的支持Beanshell为一个BSF脚本语言。<br>Beanshell JAR文件包含需要的BSF适配器。<br>你必须在你的脚本标签中简单的指定语言为&quot;beanshell&quot;.<br>6.Installation 安装<br>To use BeanShell within Ant you must do two things: <br>在Ant里面使用Beanshell，<br>你必须做两件事情：<br>1. Add the BSF bsf.jar file to ANT_HOME/lib or the classpath. <br>将BSF bsf.jar文件加入到ANT_HOME/lib或者类路径中。<br>2. Add the BeanShell bsh.jar file to ANT_HOME/lib or the classpath. <br>You can then run scripts from a file, or in.line like so: <br>将Beanshell bsh.jar文件加入到ANT_HOME/lib中或者类路径中。<br>你能够从一个文件中运行脚本，或者像下面这样：<br>&lt;project name=&quot;testbsh&quot; default=&quot;runscript&quot; basedir=&quot;.&quot;&gt; <br>&lt;target name=&quot;runscript&quot;&gt; <br>&lt;!.. Run script from a file ..&gt; 从一个文件中运行脚本<br>&lt;script language=&quot;beanshell&quot; src=&quot;myscript.bsh&quot;/&gt; <br>&lt;!.. Run script in.line ..&gt; 运行脚本in.line<br>&lt;script language=&quot;beanshell&quot;&gt;&amp;lt;![CDATA[ <br>for(int i=0; i&lt;10; i++ ) <br>print( &quot;i=&quot;+i ); <br>]]&amp;gt;&lt;/script&gt; <br> &lt;/target&gt; <br>&lt;/project&gt; <br>&lt;/target&gt; <br>&lt;/project&gt; <br>7.Learning More 学习更多<br>BeanShell is a simple tool but one with rapidly evolving capabilities. <br>To learn more about BeanShell <br>you are highly encouraged to download the source <br>and build it (using the Ant build file). <br>Even if you don't consider yourself a developer, <br>you can learn a lot from the source distribution <br>by looking at the implementation of the standard BeanShell commands and the test suite. <br>Beanshell是一个简单工具，同时也是具备快速进化能力的工具。<br>想更多的了解Beanshell，<br>你最好下载源文件并且编译它(使用Ant编译文件)。<br>甚至如果你没有把你自己当做一个开发者，<br>你能从源文件分类中了解到一些，<br>通过查看标准Beanshell命令和测试案例的实现。<br>Almost all of the built.in BeanShell commands are simply scripts stored <br>in the BeanShell JAR file under the path &quot;bsh/commands&quot;. <br>A good way to familiarize yourself with more of BeanShell <br>is to take a look at those commands.<br>Simply unpack bsh/commands/*.bsh from the JAR file.<br>The BeanShell test suite consists of many BeanShell scripts<br>that exercise all parts of the language. <br>几乎所有的built.in Beanshell命令，<br>是存在Beanshell JAR文件并且在路径&quot;bsh/commands&quot;下面的简单脚本。<br>简单的从JAR文件下面拆包bsh/commands/*.bsh.<br>这个Beanshell测试案例是由很多Beanshell脚本组成的，<br>这个脚本可以行使所有的语言。<br>In addition to the mailing list and mailing list archives, <br>an important source of information <br>is the &quot;recent changes&quot; file supplied with the source distribution <br>and online at: </span><wbr /><a href="http://www.beanshell.org/Changes.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/Changes.html</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">. <br>This file is one of the few documents <br>that is always up to date with the latest release (smile). <br>增加邮件列表和邮件列表保存，<br>一个重要的源文件方面的信息<br>是通过源文件分类支持的&quot;最近的修改&quot;并且在线信息在</span><wbr /><a href="http://www.beanshell.org/Changes.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/Changes.html</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">.<br>这个文件是文档中的一个，<br>这些文档是常常保存最后的释放。<br>8.Helping With the Project 通过项目帮助<br>BeanShell is an open source project which relies on people like you to get things done.<br>If you are excited about BeanShell there is undoubtedly some way for you to help. <br>If you are a developer, there is always work (sometimes boring, sometimes not) to be done. <br>If you are not a developer <br>you may still be able to help by writing new tests for the test suite, <br>or working on the documentation, web site, tutorials or examples. <br>Beanshell是一个开源项目，<br>这个项目依赖人们比如你去完成一些事情。<br>如果你是Beanshell的爱好者，<br>有一些方法对你是有帮助的，<br>这是不可怀疑的。<br>如果你是一位开发者，<br>也经常有一些工作需要去做(一些很无聊，一些不会)。<br>如果你不是一位开发者，<br>你仍然能帮助它，通过以下方式：为测试案例写一些新的测试，<br>工作在文档中，web站点，指南或例子中。</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1228359047#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Thu, 04 Dec 2008 02:50:47 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1228359047</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译22]]></title>
<link>http://281696143.qzone.qq.com/blog/1228196145</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.Using JConsole 使用JConsole<br>The bsh.util.JConsole is a light weight graphical shell console window, <br>with simple command editing and history capabilities. <br>BeanShell uses the JConsole for the GUI desktop mode again <br>in the JRemoteApplet for the remote server mode. <br>这个bsh.util.JConsole是一个轻量级绘画平台窗口，<br>通过简单的命令编辑。<br>Beanshell再一次为了GUI平台模式，<br>在远程服务器模式下的JRemoteApplet中，使用JConsole。<br>You can use the JConsole to provide an interactive BeanShell prompt in your own applications. <br>You are free to use the JConsole for your own purposes outside of BeanShell as well!<br>It is a fairly generic shell window <br>easily attached to any kind of streams or through the simple console interface. <br>你能在你的应用程序中，<br>使用JConsole去提供一个互动的Beanshell提示。<br>你能自由的为自己的在Beanshell之外的目的使用JConsole！<br>它是一个清楚的一般的窗口，很容易放到一些流中或者通过简单的平台接口。<br>JConsole is a Swing component. <br>Embed it in your application as you would any other swing component. For example: <br>JConsole是一个Swing类型的组件。<br>就像你使用的其他swing组件一样嵌入在你的应用程序中，例如：<br>JConsole console = new JConsole(); <br>myPanel.add(console); <br>You can connect an Interpreter to the console by specifying it in the Interpreter constructor,<br>like so: <br>你能通过在解释器构造函数中详细列出这些，<br>连接一个解释器到这个平台上，像这样：<br>Interpreter interpreter = new Interpreter( console ); <br>new Thread( interpreter ).start(); // start a thread to call the run() method 开始一个进程去调用这个run()方法<br>Or you can connect the JConsole to the Interpreter directly with Interpreter setConsole(). <br>或者你能通过解释器的setConsole()直接连接JConsole到解释器。<br>For external use, JConsole can supply a PrintWriter through its getOut() method <br>and has a full suite of direct print() methods. <br>其他多余的使用，JConsole能够通过它的getOut()方法提供一个PrintWriter<br>并且有一套完整的直接print()方法。<br>Tip: 提示：<br>When interacting with any Swing component from outside the Java event handling thread, <br>use the Swing thread safety facilities: <br>SwingUtilities.invokeNow() and invokeLater(). <br>当从Java事件处理进程的外部和Swing组件进行交互的时候，<br>使用Swing的安全进程工具：<br>SwingUtilities.invokeNow()和invokeLater()。<br>2.ConsoleInterface 平台接口<br>JConsole implements the bsh.ConsoleInterface interface, <br>which defines how the Interpreter interacts with a console object. <br>To the interpreter a console is simply a set of I/O streams with some optimized print methods: <br>JConsole实现bsh.ConsoleInterface接口，<br>这个接口定义了解释器怎样和一个平台对象进行交互。<br>对于解释器来说，一个平台是一个简单的和最优的打印方法一致的输入输出流：<br>Reader getIn(); <br>PrintStream getOut(); <br>PrintStream getErr(); <br>void println( String s ); <br>void print( String s ); <br>void error( String s ); <br>Any object that implements this interface can be attached to the Interpreter as a GUI console. <br>一些实现这个接口的对象能被隶属于一个GUI平台上的解释器。<br>The bsh.util.GUIConsoleInterface extends the ConsoleInterface <br>and adds methods for printing a string with a color attribute, <br>supplying wait feedback (the wait cursor) and name completion support. <br>JConsole implements this interface<br>and it is used indirectly via BeanShell commands when it is detected. <br>bsh.util.GUIConsoleInterface继承ConsoleInterface，<br>并且增加包含颜色属性的打印字符串的方法，<br>提供等待回馈(等待指针)和名字完成支持。<br>JConsole实现了这个接口，<br>并且当它被发现的时候，<br>它不是直接用于连接Beanshell命令。<br>3.AWTConsole AWT平台<br>The bsh.util.AWTConsole is a legacy implementation of the GUI Console using AWT instead of Swing.<br>This console does work, <br>but it is not as slick or pretty as the JConsole. <br>The primary reason it is still here is to <br>support remote access from generic web browsers using only Java 1.1. <br>bsh.util.AWTConsole是GUI平台使用AWT替代Swing的遗产实现物。<br>这个平台也可以工作，<br>但是它没有JConsole平台那么灵活那么好。<br>它仍然在这儿的初步的原因是从仅仅使用Java1.1的一般web浏览器中支持远程接受。<br>4。Reflective Style Access to Scripted Methods 脚本方法反射样式入口<br>The following examples show how to work with BeanShell methods dynamically from within scripts, using <br>the equivalent of reflective style access in Java. <br>This is an advanced topic primarily of interest to developers <br>who wish to do tight integration of BeanShell scripts with their application environment. <br>下面的例子表明，怎样从脚本中有力的同Beanshell方法一起工作，<br>反射样式的等价物在Java中被接受。<br>这是一个高级话题，最初是希望通过应用程序环境紧密综合Beanshell脚本的开发人员，<br>比较感兴趣的话题。<br>eval() <br>The simplest form of reflective style access to scripts is through the eval() command. <br>With eval() you can evaluate any text just as if it had appeared in the current scope. <br>For example: <br>接受脚本的反射样式的最简单模式是通过eval()命令。<br>通过eval(),你能够计算一些文本，就像它已经出现在当前的作用域中。<br>例如：<br>eval(&quot;a=5;&quot;); <br>print( a ); // 5 <br>So, if you know the signature (argument types) of a method you wish to work with <br>you can simply construct a method call as a string <br>and evaluate it with eval() as in the following: <br>于是，如果你知道这个你要一起工作的方法的签名(参数类型)，<br>你能简单的构造一个类似于调用字符串一样的方法<br>并且在接下来通过eval()来计算它。<br>// Declare methods foo() and bar( int, String ) 定义方法foo()和bar(int, String)<br>foo() { ... } <br>bar( int arg1, String arg2 ) { ... } <br>// Invoke a no.args method foo() by its name using eval()<br>通过名字使用eval()调用一个没有参数的方法foo()<br>name=&quot;foo&quot;; <br>// invoke foo() using eval() 使用eval()调用foo()<br>eval( name+&quot;()&quot;); <br>// Invoke two arg method bar(arg1,arg2) by name using eval() <br>通过名字使用eval()调用一个有两个参数的方法bar(arg1,arg2)<br>name=&quot;bar&quot;; <br>arg1=5; <br>arg2=&quot;stringy&quot;; <br>eval( name+&quot;(arg1,arg2)&quot;); <br>You can get the names of all of the methods defined in the current scope <br>using the 'this.methods' magic reference, <br>which returns an array of Strings: <br>你能够取到定义在当前作用域中的所有方法的名字，<br>使用&quot;this.methods&quot;这个神奇的参考，<br>这个参考翻译字符串的一个数组：<br>// Print the methods defined in this namespace <br>打印定义在这个名字空间中的方法<br>print( this.methods ); <br>We'll talk about more powerful forms of method lookup in a moment. <br>我们讲谈论更多有更强功能样式的方法，这些方法片刻之间就可以查找到。<br>invokeMethod() <br>You can explicitly invoke a method by name with arguments <br>through a 'this' type reference using the invokeMethod() method: <br>通过一个'this'类型引用并且使用invokeMethod()方法，<br>你能够明确的通过名字和参数调用一个方法：<br>this.invokeMethod( &quot;bar&quot;, new Object [] { new Integer(5), &quot;stringy&quot; } ); <br>Arguments are passed as an array of objects. <br>Primitive types must be wrapped in their appropriate wrappers. <br>BeanShell will select among overloaded methods <br>using the standard Java method resolution rules. (JLS 15.11.2). <br>参数可以看作一个对象的数组。<br>原始类型必须包装成与它们像适应的包装类型。<br>使用标准Java方法规则，<br>Beanshell将选择加载方法中的一个。<br>5.Reflective Style Access to Scripted Methods 接受脚本模式的反射模式<br>The previous section showed how to invoke a method by name when we know the argument types.<br>Of course, in general we'd like to be able to find out<br>what methods are defined in the current script or to look up a method by its signature. <br>前面的章节中提到了，<br>当我们知道参数类型的时候，<br>如果通过名字来调用一个方法。<br>当然，通常我们能够找到在当前的脚本中那些方法已经定义了，<br>或者通过方法签名找到它。<br>You can get &quot;handles&quot; to all of the methods defined in a context <br>using the namespace getMethods() method. <br>getMethods() returns an array of bsh.BshMethod objects, <br>which are wrappers for the internally parsed representation of BeanShell scripted methods: <br>使用名字空间中的getMethods()方法，<br>你能取得定义在环境中的所有方法的&quot;句柄&quot;。<br>getMethods()返回bsh.BshMethod对象的一个数组，<br>bsh.BshMethod对象是为Beanshell脚本方法的内在解析表示法包装的：<br>foo() { ... } <br>foo( int a ) { ... } <br>bar( int arg1, String arg2 ) { ... } <br>print ( this.namespace.getMethods() ); <br>// Array: [Lbsh.BshMethod;@291aff { <br>// Bsh Method: bar <br>// Bsh Method: foo <br>// Bsh Method: foo <br>// } <br>We'll talk about what you can do with a BshMethod in a moment. <br>我们一会儿将谈到通过BshMethod，你能做些什么。<br>Alternately, you can use the namespace getMethod() method <br>to search for a specific method signature. <br>The method signature is a set of argument types represented by an array of Classes: <br>交替地，你能使用名字空间的getMethod()方法去搜索一个特定的方法签名。<br>这个方法签名是一系列的被一个类型数组描绘的参数类型：<br>name=&quot;bar&quot;; <br>signature = new Class [] { Integer.TYPE, String.class }; <br>// Look up a method named bar with arg types int and String <br>通过参数类型int和String查找一个名字为bar的方法<br>bshMethod = this.namespace.getMethod( name, signature ); <br>print(&quot;Found method: &quot;+bshMethod); <br>Tip: 提示：<br>The Java reflection API uses special class values to represent primitive types such as int, <br>char, an boolean. <br>These types are static fields in the respective primitive wrapper classes. e.g. <br>Integer.TYPE, Character.TYPE, Boolean.TYPE. <br>Java反射API使用特定的类型值去描绘原始类型比如int,<br>char,boolean.<br>这些类型是静态的域，在分别的原始包装类型中.例如。<br>整型，字符型，布尔型。<br>In the above snippet we located the bar() method by its signature.<br>If there had been overloaded forms of bar() getMethod() <br>would have located the most specific one according <br>to the standard Java method resolution rules (JLS 15.11.2).<br>The result of the lookup is a bsh.BshMethod object, as before. <br>在上面的片段中，我们通过它们的签名定位bar()方法。<br>如果已经加载了bar()方法的样式，<br>getMethod()将定义最特别的一个协定到标准Java方法解决规则。<br>查找的结构是bsh.BshMethod对象，就像之前一样。</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1228196145#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 02 Dec 2008 05:35:45 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1228196145</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译21]]></title>
<link>http://281696143.qzone.qq.com/blog/1227754544</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.The bshcommands.xsl stylesheet bshcommands.xml样式表格<br>The bshcommands.xsl stylesheet <br>can be used to render the output of bshdoc.bsh <br>to an indexed HTML page describing BeanShell commands. <br>bshcommands.xsl样式表格能用于将bshdoc.bsh的输出着色为一个有索引的<br>通过Beanshell命令描述的HTML页面。<br>The bshcommands.xsl stylesheet is intended for scripts that serve as BeanShell commands. <br>These are script files containing one or more overloaded methods <br>which have the same name as the filename containing them. <br>这个bshcommands.xsl样式表格是指脚本，该脚本是服务于Beanshell命令的。<br>这些是包含一个或者更多超过负载方法的脚本文件，这些方法和包含脚本的文件有同样的名字。<br>The BshDoc script produces a complete description of any BeanShell script file. <br>However the supplied bshcommands.xsl stylesheet <br>does not necessarily use all of this information.<br>Specifically, it does not present all individual method comments. <br>BshDoc脚本提出一些Beanshell脚本文件的一个完整的描述。<br>但是被提供的bshcommands.xsl样式表格不需要使用所有的这些信息。<br>特别的是，它不是赠送的所有个人方法的注释。<br>Instead it tries to identify the comments pertaining to the command, <br>based upon the file name. <br>It (the XSL stylesheet) applies some logic to choose either the single File Comment if it <br>exists or the Method Comment of the first method matching the filename. <br>Another stylesheet could (and will) be easily created <br>for more general BeanShell file documentation.<br>Please check the web site for updates. <br>代替它尝试去确定适合命令的注释，<br>取决于文件名字。<br>它(XSL样式表格)应用一些逻辑去挑选单独的文件注释或者匹配文件名的第一个方法的方法注释。<br>另一个样式表格能够很容易的，被更多普通的Beanshell文件文档创建。<br>请检查web站点来更新。<br>Method signatures displayed for methods can be overridden for the bshcommands.xsl stylesheet <br>by explicitly supplying them in special javadoc @method tags within a Method Comment.<br>For example you might do this <br>to provide a more verbose description for loosely typed arguments to a BeanShell command. <br>The bshcommands.xsl stylesheet <br>will use the @method tag signatures in lieu of autogenerated ones<br>when they are present. <br>So you can also use this tag to determine exactly <br>which methods from a file are listed if you wish. e.g. <br>显示方法的方法签名，能够被bshcommands.xsl演示覆盖，<br>通过在方法注释中清楚的提供给他们特别的javadoc的method标签。<br>例如你能做这些，提供一个有详细注释的松散类型参数给Beanshell命令。<br>这个bshcommands.xsl样式表格<br>将使用方法标签在自动产生的场合。<br>所以你也能使用这些标签去完全的决定，<br>一个文件中的哪些方法可以被排列出来。例如：<br>/**<br>BshDoc for the foo() command.<br> Explicitly supply the signature to be displayed for the foo() method.<br> @method foo( int | Integer ) and other text... <br> foo()命令的BshDoc.清楚的提供标记去显示foo()方法。<br> @方法foo(基本整型/引用整型)和其他的文本...<br>*/ <br>foo( arg ) { ... } <br>Tip: 提示：<br>BshDoc uses the bsh.Parser API to parse the BeanShell script files <br>without actually running them. <br>bshdoc.bsh is not very complex. <br>Take a look at it to learn how to use the parser API. <br>BshDoc在没有实际上运行他们的情况下，<br>使用bsh.Parser接口去解析BeanShell脚本文件。<br>bshdoc.bsh并不是非常复杂。<br>看一看它去学习如何使用这个解析接口。<br>2.The BeanShell Parser  Beanshell解析器<br>This BeanShell parser class bsh.Parser is used internally by the BeanShell Interpreter. <br>It is responsible for the lexical parsing of the input text, <br>the application of the grammar structure, <br>and the building of an internal representation of the BeanShell script file<br>called an &quot;abstract syntax tree&quot; (AST). <br>BeanShell解析类bsh.Parser是用在Beanshell解析器内部的。<br>它是输入文本的词汇解析的责任，<br>语法结构的应用程序，<br>并且Beanshell脚本文件的一个中间表示法的构造称作一个&quot;抽象的语法树&quot;(AST).<br>The Parser just analyzes the language syntax. <br>It knows only how to parse the structure of the language .<br>it does not interpret names, or execute methods or commands.<br>You can use the Parser directly if you have a need to analyze the structure of BeanShell scripts<br>or Java methods and statements in general. <br>解析器仅仅解析语言符号。<br>他仅仅知道如何解析语言的结构。<br>它不能解释名字，或者执行方法或命令。<br>你能直接使用解析器，如果你有需要去分析Beanshell脚本或者Java方法和表达式的结构。<br>3.Validating Scripts With bsh.Parser  通过bsh.Parser验证脚本<br>You can use the Parser class from the command line <br>to do basic structural validation of BeanShell files without actually executing them. e.g. <br>你能从命令行中，在没有完整的执行他们的时候<br>，使用它去做Beanshell文件的基本结构验证。<br>java bsh.Parser [ .p ] file [ file ] [ ... ] <br>The .p option causes some of the abstract syntax to be printed. <br>这个.p选项使一些抽象标记能被打印。<br>The parser will detect any syntax errors in the script and print an error. <br>Note again that names, imports, and string evaluations are analyzed only for syntax . <br>not content or meaning. <br>解析器能够推测脚本中的一些符号错误并且打印一个错误。<br>注意重复的那些名字，导入，并且字符串赋值仅仅能为语法分析。<br>4.Parsing and Performance   解析和执行<br>It is useful to have a high level understanding <br>how BeanShell works with scripts to understand performance issues. <br>对于Beanshell通过脚本来工作去理解执行事件是有用的。<br>The first time a script is read or sourced into an interpreter, <br>BeanShell uses the parser to parse the script internally to an AST. <br>The AST consists of Java object representations of all of the language structures and objects.<br>The AST consists of Java classes, <br>but is not the same as compiled Java code. <br>When the script is <br>&quot;executed&quot; BeanShell steps through each element of the AST<br>and tells it to perform whatever it does <br>(e.g. a variable assignment, for.loop, etc.). <br>This execution of the ASTs is generally much faster than the original <br>parsing of the text of the method. <br>It is really only limited by the speed of the application calls that it is making, <br>the speed of the Java reflection API, <br>and the efficiency of the implementation of the structures in BeanShell. <br>开始的时候，一个脚本被读入或者进入解释器，<br>BeanShell使用解析器去解析中间的脚本变成一个AST。<br>这个AST已经存在的Java对象组成的。<br>这个AST是由Java类组成的，但是不是等同于经过编译的Java代码。<br>当脚本通过AST的每一个元素来执行脚本<br>并且告诉它去执行它要执行的对象(例如一个变量定义，for循环，等等.).<br>ASTs的执行通常通常比方法的最初解析更快。<br>When parsing &quot;line by line&quot; through a BeanShell script the ASTs are routinely executed <br>and then thrown away.<br>However the case of a BeanShell method declaration is different. <br>A BeanShell method is parsed only once:<br>when it is declared in the script. <br>It is then stored in the namespace like any variable. <br>Successive invocations of the method execute the ASTs again, <br>but do not re.parse the original text. <br>当通过Beanshell脚本&quot;线对线&quot;解析，ASTs是例行公事的执行并且马上抛弃这个脚本。<br>但是Beanshell方法定义的情况是不同的。<br>一个Beanshell方法仅仅被解析一次：<br>当它在脚本中被解析的时候。<br>它就像一些变量一样保存在名字空间中。<br>方法的连续调用再次执行ASTs,<br>但是不会重新编译最初的文本。<br>This means that successive calls to the same scripted method are as fast as possible . <br>much faster than re.parsing the script each time. <br>You can use this to your advantage <br>when running the same script many times simply <br>by wrapping your code in the form of a BeanShell scripted method <br>and executing the method repeatedly,<br>rather than sourcing the script repeatedly. For example: <br>这个意味着，对同样脚本方法的连续调用是越快越好。<br>比每次都重新编译脚本快。<br>你能使用这些反应你的优势，<br>当简单的通过包装你的代码在一个Beanshell脚本方法中并且重复的执行这个方法，<br>运行相同的脚本很多次的时候，<br>比重复的编译这些脚本要好，例如：<br>// From Java 从Java中<br>import bsh.Interpreter; <br>i=new Interpreter(); <br>// Declare method or source from file  从文件中定义方法或源脚本<br>i.eval(&quot;foo( args ) { ... }&quot;); <br>i.eval(&quot;foo(args)&quot;); // repeatedly invoke the method  重复的调用方法<br>i.eval(&quot;foo(args)&quot;); <br>... <br>In the above example we defined a method called foo() which holds our script. <br>Then we executed the method repeatedly.<br>The foo() method was parsed only once: <br>when its declaration was evaluated. <br>Subsequent invocations simply execute the AST. <br>在上面的例子中，我们定义一个称作foo()的方法，foo()支持我们的脚本。<br>那么我们重复的执行这个方法。<br>foo()方法仅仅被编译一次：<br>当它的定义被计算。<br>后面的祈祷简单的执行AST.<br>5.Parsing Scripts Procedurally 程序上解析脚本<br>If you are willing to learn about the BeanShell abstract syntax tree classes <br>you can use the Parser to parse a BeanShell script into its ASTs like this: <br>如果你准备去学习Beanshell抽象语法树类，<br>你能使用解析器去解析一个Beanshell脚本进入它的ASTs,就像下面这样:<br>in=new FileReader(&quot;somefile.bsh&quot;); <br>Parser parser = new Parser(in); <br>while( !(eof=parser.Line()) ) { <br>SimpleNode node = parser.popNode(); <br>// Use the node, etc. (See the bsh.BSH* classes) 使用这个节点，等等(请看这个bsh.BSH* 类)<br>... <br>} <br>To learn more about the abstract syntax tree <br>please download the source distribution and consult the source documentation. <br>学习抽象的语法树，请下载源分布状态并且考虑源文档。<br>Tip: 提示：<br>The BshDoc bshdoc.bsh script uses the parser to extract method signatures <br>and comments from a BeanShell file. <br>Check it out for a more realistic example. <br>这个BshDoc的bshdoc.bsh脚本<br>使用解析器去摘录方法标记并且对一个Beanshell文件进行注释。<br>为了一个更加现实的例子把它挑出来。<br>Note: Many components of the AST classes are not public at this time. <br>Use setAccessibility(true) to access them. <br>注意：这个AST类的许多组件在这是不是公开的。<br>使用setAccessibility(true)来接受他们。</span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1227754544#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Thu, 27 Nov 2008 02:55:44 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1227754544</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译20]]></title>
<link>http://281696143.qzone.qq.com/blog/1226911423</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;">1.Running Scripts 运行脚本 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">After deploying the servlet, test it by fetching the default page with your web browser. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在发布了servlet之后，测试它通过取到你的web浏览器的默认网页。 </span><wbr /><br><a href="http://localhost/bshservlet/eval" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://localhost/bshservlet/eval</span><wbr /></a><wbr /><br><span style="font-size:18px;line-height:1.8em;">You can use the servlet interactively through the form that it generates, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">or, more importantly, through the command line launcher bsh.Remote. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.Remote accepts a URL for a target bsh interpreter </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">and one or more file names to send to that server, printing the results. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能它产生的模式使用servlet交互， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">或者，更重要的，通过命令行发射台bsh.Remote. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">java bsh.Remote </span><wbr /><br><a href="http://localhost/bshservlet/eval" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://localhost/bshservlet/eval</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">test1.bsh </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You can execute remote scripts programmatically using the static method bsh.Remote.eval(). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">If bsh.Remote can parse the retun value as an integer </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">it will return it as the exit status to the command line. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能使用静态方法bsh.Remote.eval()来执行脚本程序。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">如果bsh.Remote能将返回值解析为一个整数， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">它将让它作为退出状态返回到命令行。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">2.The Script Environment 脚本环境 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Scripts have access to the servlet environment through two predefined variables: </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">通过两个事先定义好的变量,脚本可以接受servlet环境： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">· bsh.httpServletRequest </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">· bsh.httpServletResponse </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">which are the standard servlet request and response objects, respectively. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这两个分别是标准的servlet请求和响应对象。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">When set to &quot;raw&quot; output mode via the forms interface or servlet parameter </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(described in the next section) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">the script is expected to generate the complete response </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">using the httpServletResponse object. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This means that you can have your script generate HTML </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">or other output to be consumed by the client. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">For example: 例如： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">当通过接口类型或者servlet参数设置&quot;没有加工&quot;的输出模式的时候(在下一节中描述) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">脚本被期望使用httpServletResponse对象产生完整的响应。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个意思就是，你能用你的脚本产生HTML或者被客户端使用的其他输出。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">// Server side script generates HTML response page 服务器端的脚本产生HTML响应页面 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.httpServletResponse.setContentType(&quot;text/html&quot;); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">out = bsh.httpServletResponse.getWriter(); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">out.println(&quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello World!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;&quot;); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">More generally, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">you can use the httpServletRequest to get access to the server environment </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">such as the servlet session object. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You can also access all of the standard Java tools such as JNDI to fetch EJB homes,etc. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">and perform testing or script activities. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">更一般的， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能使用httpServletRequest，类似于servlet的会话对象一样，去接受服务器环境。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你也能接受所有标准的Java工具，类似于JNDI,去抓取EJB容器，等等。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">并且执行测试或者脚本活动。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">3.BshServlet Parameters BshServlet参数 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">The following parameters are recognized by BshServlet: </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">下面的参数被BshServlet重新提出： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Parameter Value 参数值 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.script The BeanShell Script Beanshell脚本 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.servlet.captureOutErr &quot;true&quot; . </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">capture standard out and standard error during the evaluation of the script. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note: this is inherently non.thread safe. All output from the VM will be captured. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.servlet.captureOutErr=&quot;true&quot;.在脚本的计算中，捕捉标准输出和标准错误。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">注意：这些是固有的线程安全的。所有从虚拟机中的输出都会被捕捉。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.servlet.output &quot;raw&quot; . </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Do not generate the servlet HTML result page. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Instead rely on the script to generate the complete result using the servlet response. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.servlet.output=&quot;raw&quot;.不要产生servlet的HTML结果页面。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">使用servlet响应来代替脚本去产生完整的结果。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.client &quot;remote&quot; . </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">set by the bsh.Remote launcher to indicate that results should be raw </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">and the return value should be encoded for transport back to the client. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.client=&quot;remote&quot; .设置bsh.Remote变量暗示了结果将是未被加工的， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">并且返回的值将被重新编码传送回客户端。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">4.The BeanShell Demo Applet Beanshell的Applet类型的Demo </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">The Beanshell Applet is primarily for demostration and educational purposes. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">It allows you to experiment with Beanshell live,directly in your web browser. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You can try the applet live at the following locations: </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Beanshell的Applet最初是为了做示范和教育目的的。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">它允许你去和Beanshell一起实验，直接用在你的web浏览器中。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能允许applet运行在下面的位置中： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;"><span style="line-height:1.8em;">5.Swing JConsole Applet Swing做平台的Applet </span><wbr /><br><span style="line-height:1.8em;">A Swing enabled JConsole usable with the Java plug.in (or other swing capable browser: </span><wbr /><br><span style="line-height:1.8em;">BeanShell Demo with Swing Console (</span><wbr /></span><wbr /><br><a href="http://www.beanshell.org/jbshdemo.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/jbshdemo.html</span><wbr /></a><wbr /><span style="line-height:1.8em;">) </span><wbr /><br><span style="line-height:1.8em;">Swing使平台可以和Java插件一起工作(或者其他的swing的可能的浏览器： </span><wbr /><br><span style="line-height:1.8em;">演示Swing平台的Beanshell示范(</span><wbr /><br><a href="http://www.beanshell.org/jbshdemo.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/jbshdemo.html</span><wbr /></a><wbr /><span style="line-height:1.8em;">)) </span><wbr /><br><span style="line-height:1.8em;">6.AWT Console Applet AWT作为平台的Applet </span><wbr /><br><span style="line-height:1.8em;">A minimal (not very good) AWT based console that should work in any browser. </span><wbr /><br><span style="line-height:1.8em;">BeanShell Demo with simple AWT Console (</span><wbr /><br><a href="http://www.beanshell.org/awtbshdemo.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/awtbshdemo.html</span><wbr /></a><wbr /><span style="line-height:1.8em;">) </span><wbr /><br><span style="line-height:1.8em;">一个最小限度的(不是最好的)AWT基础的平台，这个平台可以运行在所有的浏览器上面。 </span><wbr /><br><span style="line-height:1.8em;">通过简单AWT平台实现的Beanshell示例(</span><wbr /><br><a href="http://www.beanshell.org/awtbshdemo.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/awtbshdemo.html</span><wbr /></a><wbr /><span style="line-height:1.8em;">) </span><wbr /><br><span style="line-height:1.8em;">7.Signed JConsole Applet 有符号的平台Applet </span><wbr /><br><span style="line-height:1.8em;">There are many additional security restrictions on Applets </span><wbr /><br><span style="line-height:1.8em;">and this limits what you can do with BeanShell in this mode. </span><wbr /><br><span style="line-height:1.8em;">For unrestricted access try the signed version of the applet here. </span><wbr /><br><span style="line-height:1.8em;">It requires the Java 1.4 plug.in to function. </span><wbr /><br><span style="line-height:1.8em;">在Applet上面有很多额外的权限限制，并且这些会限制， </span><wbr /><br><span style="line-height:1.8em;">在这种模式下你能通过Beanshell来做些什么。 </span><wbr /><br><span style="line-height:1.8em;">在这儿对于没有限制的入口尝试applet有符号的版本。 </span><wbr /><br><span style="line-height:1.8em;">它需要Java1.4的函数插件。 </span><wbr /><br><span style="line-height:1.8em;">A Swing enabled JConsole as a signed applet with the Java plug.in </span><wbr /><br><span style="line-height:1.8em;">(or other swing capable browser). </span><wbr /><br><span style="line-height:1.8em;">The signed applet will allow you unrestricted access to your environment through scripting. </span><wbr /><br><span style="line-height:1.8em;">一个使平台变成一个有符号的通过Java内置插件开发的applet的Swing </span><wbr /><br><span style="line-height:1.8em;">(或者其他的支持swing的浏览器)。 </span><wbr /><br><span style="line-height:1.8em;">BeanShell Demo with Swing Console . </span><wbr /><br><span style="line-height:1.8em;">Signed Applet (</span><wbr /><br><a href="http://www.beanshell.org/signedjbshdemo.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/signedjbshdemo.html</span><wbr /></a><wbr /><span style="line-height:1.8em;">) </span><wbr /><br><span style="line-height:1.8em;">通过Swing平台演示的Beanshell示例 </span><wbr /><br><span style="line-height:1.8em;">有符号的Applet(</span><wbr /><br><a href="http://www.beanshell.org/signedjbshdemo.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/signedjbshdemo.html</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;"><span style="line-height:1.8em;">) </span><wbr /><br><span style="line-height:1.8em;">8.BeanShell Desktop Beanshell桌面平台 </span><wbr /><br><span style="line-height:1.8em;">The BeanShell Desktop is a simple GUI environment that provides multiple bsh shell windows(MDI), </span><wbr /><br><span style="line-height:1.8em;">a simple text editor, and a simple class browser. </span><wbr /><br><span style="line-height:1.8em;">The desktop is mostly implemented by BeanShell scripts, </span><wbr /><br><span style="line-height:1.8em;">launched by the desktop() command. </span><wbr /><br><span style="line-height:1.8em;">Beanshell桌面平台使一个简单的GUI环境，这个环境提供多个bsh的外形窗口(MDI), </span><wbr /><br><span style="line-height:1.8em;">一个简单的文本编辑器，和一个简单的类浏览器。 </span><wbr /><br><span style="line-height:1.8em;">这个桌面平台主要使通过Beanshell脚本实现的， </span><wbr /><br><span style="line-height:1.8em;">通过平台命令发起的。 </span><wbr /><br><span style="line-height:1.8em;">9。Shell Windows 外壳窗口 </span><wbr /><br><span style="line-height:1.8em;">The bsh console windows provide simple command line editing, history, cut &amp; paste, </span><wbr /><br><span style="line-height:1.8em;">and variable and class name completion. </span><wbr /><br><span style="line-height:1.8em;">bsh平台窗口提供简单的命令行编辑，历史，剪切和粘贴， </span><wbr /><br><span style="line-height:1.8em;">和变量和类名定义。 </span><wbr /><br><span style="line-height:1.8em;">10。Editor Windows 编辑窗口 </span><wbr /><br><span style="line-height:1.8em;">11.The Class Browser 类浏览器 </span><wbr /><br><span style="line-height:1.8em;">BshDoc . Javadoc Style Documentation BshDoc.JavaDoc样式的文档 </span><wbr /><br><span style="line-height:1.8em;">BshDoc requires JDK1.4 and BeanShell 1.2b6 or greater to run BshDoc需要JDK1.4和Beanshell1.2b6或者以上版本运行。 </span><wbr /><br><span style="line-height:1.8em;">BshDoc is a BeanShell script that supports javadoc style documentation of BeanShell scripts. </span><wbr /><br><span style="line-height:1.8em;">BshDoc parses one or more BeanShell script files for method information </span><wbr /><br><span style="line-height:1.8em;">and javadoc style formal comments. </span><wbr /><br><span style="line-height:1.8em;">BshDoc是一个Beanshell脚本，支持Beanshell脚本的javadoc样式的文档。 </span><wbr /><br><span style="line-height:1.8em;">BshDoc为函数解析一个或更多Beanshell脚本文件，并且解析javadoc样式的注释。 </span><wbr /><br><span style="line-height:1.8em;">Its output is an XML description of the files, </span><wbr /><br><span style="line-height:1.8em;">containing all of the method signature and comment information. </span><wbr /><br><span style="line-height:1.8em;">An XSL stylesheet, bshcommands.xsl, supplied with the user manual source, </span><wbr /><br><span style="line-height:1.8em;">can be used to render the XML </span><wbr /><br><span style="line-height:1.8em;">to a nicely indexed HTML document describing BeanShell commands. </span><wbr /><br><span style="line-height:1.8em;">它的输出是一个文件的XML描述， </span><wbr /><br><span style="line-height:1.8em;">包含所有函数和注释信息。 </span><wbr /><br><span style="line-height:1.8em;">一个XSL样式表格，bshcommands.xsl，提供用户手工资源， </span><wbr /><br><span style="line-height:1.8em;">能够用于将一个XML着色为一个精细的有索引的通过Beanshell命令描述的HTML文档。 </span><wbr /><br><span style="line-height:1.8em;">The bshdoc.bsh script is currently distributed with the source distribution. </span><wbr /><br><span style="line-height:1.8em;">An example of the styled output of </span><wbr /><br><span style="line-height:1.8em;">this command is the &quot;BeanShell Commands Documentation&quot; section of this user manual. </span><wbr /><br><span style="line-height:1.8em;">That section is automatically generated as part of the build process </span><wbr /><br><span style="line-height:1.8em;">by running bshdoc.bsh on bsh/commands/*.bsh. </span><wbr /><br><span style="line-height:1.8em;">See the source distribution Ant build file for an example of how to do this </span><wbr /><br><span style="line-height:1.8em;">and the user manual Ant build file for an </span><wbr /><br><span style="line-height:1.8em;">example of using a stylesheet to build your documents. </span><wbr /><br><span style="line-height:1.8em;">bshdoc.bsh脚本现在是被源来划分的。 </span><wbr /><br><span style="line-height:1.8em;">这个命令的样式输出的一个例子是这个用户手工的&quot;Beanshell命令文档&quot;章节。 </span><wbr /><br><span style="line-height:1.8em;">这个章节是通过运行bshdoc.bsh,作为构造过程的一部分自动产生的。 </span><wbr /><br><span style="line-height:1.8em;">请看源文件分类，Ant构造文件为一个如何去运行的例子， </span><wbr /><br><span style="line-height:1.8em;">用户手工Ant构造文件使用一个样式表格去构造你的文档的一个例子。 </span><wbr /><br><span style="line-height:1.8em;">12.BshDoc Comments BshDoc注释 </span><wbr /><br><span style="line-height:1.8em;">BshDoc comments look just like JavaDoc comments </span><wbr /><br><span style="line-height:1.8em;">and may include HTML markup and javadoc style @tags. </span><wbr /><br><span style="line-height:1.8em;">If you wish to use the associates XSL stylesheet, </span><wbr /><br><span style="line-height:1.8em;">you should use well formed XHTML for you documentation. </span><wbr /><br><span style="line-height:1.8em;">(Always close tags, etc.). e.g. </span><wbr /><br><span style="line-height:1.8em;">BshDoc注释看起来就像JavaDoc注释，并且能包含HTML标记和Javadoc式样标签。 </span><wbr /><br><span style="line-height:1.8em;">如果你希望使用相关的XSL样式表格， </span><wbr /><br><span style="line-height:1.8em;">你最好在你的文档中使用XHTML。(关闭标签，等等..).例如. </span><wbr /><br><span style="line-height:1.8em;">/** </span><wbr /><br><span style="line-height:1.8em;">This is a javadoc style comment. 这是一个javadoc样式注释。 </span><wbr /><br><span style="line-height:1.8em;">&lt;pre&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;b&gt;Here is some HTML markup.&lt;/b&gt; 这儿是一些HTML标记 </span><wbr /><br><span style="line-height:1.8em;">&lt;p/&gt; </span><wbr /><br><span style="line-height:1.8em;">Here is some more. 这儿是一些更多内容 </span><wbr /><br><span style="line-height:1.8em;">&lt;/pre&gt; </span><wbr /><br><span style="line-height:1.8em;">@author Pat Niemeyer </span><wbr /><br><span style="line-height:1.8em;">*/ </span><wbr /><br><span style="line-height:1.8em;">Javadoc style @tags are parsed by bshdoc for inclusion in the XML output. </span><wbr /><br><span style="line-height:1.8em;">Currently they are only recognized at the start of a line and they terminate the comment. </span><wbr /><br><span style="line-height:1.8em;">(i.e. they must come at the end of the comment). </span><wbr /><br><span style="line-height:1.8em;">javadoc样式标签是被包含在XML输出中解析出来的。 </span><wbr /><br><span style="line-height:1.8em;">现在，他们仅仅在开始的一行中被认出并且他们终止注释.(他们会在注释结束的时候到来)。 </span><wbr /><br><span style="line-height:1.8em;">BshDoc identifies two kinds of Javadoc style comments: File Comments and Method Comments. </span><wbr /><br><span style="line-height:1.8em;">Method comments are comments </span><wbr /><br><span style="line-height:1.8em;">that appear immediately before a method declaration with no statements intervening. </span><wbr /><br><span style="line-height:1.8em;">File comments are comments that appear as the first statement of a script </span><wbr /><br><span style="line-height:1.8em;">and are not method comments. </span><wbr /><br><span style="line-height:1.8em;">If a comment appears as the first statement in a script </span><wbr /><br><span style="line-height:1.8em;">and is also immediately followed by a method declaration it </span><wbr /><br><span style="line-height:1.8em;">is considered a method comment. </span><wbr /><br><span style="line-height:1.8em;">BshDoc识别两种类型的Javadoc样式注释：文件注释和方法注释。 </span><wbr /><br><span style="line-height:1.8em;">方法注释是这样一种注释，在一个方法定义之前并且没有表达式干预的时候，马上出现的注释。 </span><wbr /><br><span style="line-height:1.8em;">文件注释是这样一种注释，出现在一个脚本的第一个表达式并且不是方法注释。 </span><wbr /><br><span style="line-height:1.8em;">如果一个注释出现在一个脚本中的第一个声明中， </span><wbr /><br><span style="line-height:1.8em;">并且也是跟随在一个方法定义之后， </span><wbr /><br><span style="line-height:1.8em;">它被认为是一个方法注释。</span><wbr /><br><span style="line-height:1.8em;">13.BshDoc XML Output BshDoc的XML输出</span><wbr /><br><span style="line-height:1.8em;">To use BshDoc, run the bshdoc.bsh script on one or more BeanShell script files: </span><wbr /><br><span style="line-height:1.8em;">java bsh.Interpreter bshdoc.bsh myfile.bsh [ myfile2.bsh ] [ ... ] &gt; output.xml </span><wbr /><br><span style="line-height:1.8em;">The output goes to standard out. It looks something like this: </span><wbr /><br><span style="line-height:1.8em;">使用BshDoc,运行bshdoc.bsh脚本在一个或者更多的Beanshell脚本文件上面：</span><wbr /><br><span style="line-height:1.8em;">java bsh.Interpreter bshdoc.bsh myfile.bsh [ myfile2.bsh ] [ ... ] &gt; output.xml </span><wbr /><br><span style="line-height:1.8em;">这个输出到标准的输出上去。它看起来像这些：</span><wbr /><br><span style="line-height:1.8em;">14.BshDoc . Javadoc Style Documentation BshDoc-Javadoc样式文档</span><wbr /><br><span style="line-height:1.8em;">&lt;!.. This file was auto.generated by the bshdoc.bsh script ..&gt; </span><wbr /><br><span style="line-height:1.8em;">下面的文件是自动通过bshdoc.bsh脚本产生的..</span><wbr /><br><span style="line-height:1.8em;">&lt;BshDoc&gt;</span><wbr /><br><span style="line-height:1.8em;"> &lt;File&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;Name&gt;foo&lt;/Name&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;Method&gt;</span><wbr /><br><span style="line-height:1.8em;"> &lt;Name&gt;doFoo&lt;/Name&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;Sig&gt;doFoo ( int x )&lt;/Sig&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;Comment&gt;</span><wbr /><br><span style="line-height:1.8em;"> &lt;Text&gt;&amp;lt;![CDATA[ doFoo() method comment. ]]&amp;gt;&lt;/Text&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;Tags&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/Tags&gt;</span><wbr /><br><span style="line-height:1.8em;"> &lt;/Comment&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/Method&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;Comment&gt;</span><wbr /><br><span style="line-height:1.8em;"> &lt;Text&gt;&amp;lt;![CDATA[ foo file comment. ]]&amp;gt;&lt;/Text&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;Tags&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/Tags&gt;</span><wbr /><br><span style="line-height:1.8em;"> &lt;/Comment&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/File&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/BshDoc&gt; </span><wbr /></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1226911423#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Mon, 17 Nov 2008 08:43:43 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1226911423</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译19]]></title>
<link>http://281696143.qzone.qq.com/blog/1226474488</link>
<description><![CDATA[<span style="font-size:18px;line-height:1.8em;"><span style="line-height:1.8em;">1.Remote Server Mode 远程服务器模式 </span><wbr /><br><span style="line-height:1.8em;">Remote server mode lets you access a BeanShell Interpreter inside of a remote VM. </span><wbr /><br><span style="line-height:1.8em;">With remote server mode activated you can literally telnet into the running application </span><wbr /><br><span style="line-height:1.8em;">and type commands at the BeanShell shell prompt. </span><wbr /><br><span style="line-height:1.8em;">Or, even better, you can use any web browser to bring up a remote GUI console. </span><wbr /><br><span style="line-height:1.8em;">远程服务器模式让你接受一个远程虚拟机的解释器进入。 </span><wbr /><br><span style="line-height:1.8em;">通过运行远程服务器模式，你能慢慢的进入正在运行的应用程序和Beanshell的命令框中。 </span><wbr /><br><span style="line-height:1.8em;">或者，更好的，你能使用一些web浏览器进入一个远程GUI平台。 </span><wbr /><br><span style="line-height:1.8em;">Warning: 警告： </span><wbr /><br><span style="line-height:1.8em;">When activated remote server mode can provide unrestricted access to all parts of your </span><wbr /><br><span style="line-height:1.8em;">application and the host server. </span><wbr /><br><span style="line-height:1.8em;">This mode should not be used in production environments </span><wbr /><br><span style="line-height:1.8em;">or anywhere that server security is an issue. </span><wbr /><br><span style="line-height:1.8em;">当运行远程服务器模式对你的应用程序的所有部分和主机服务器，能提供没有限制的访问。 </span><wbr /><br><span style="line-height:1.8em;">这个模式将不能用在生产环境中，也不能用在要考虑权限的其他地方。 </span><wbr /><br><span style="line-height:1.8em;">To enable remote access simply issue the BeanShell server() command, </span><wbr /><br><span style="line-height:1.8em;">specifying a base port number: </span><wbr /><br><span style="line-height:1.8em;">使远程可以存取将简单的发布Beanshell的服务器命令， </span><wbr /><br><span style="line-height:1.8em;">列一个基础端口号码： </span><wbr /><br><span style="line-height:1.8em;">server(1234); </span><wbr /><br><span style="line-height:1.8em;">// Httpd started on port: 1234 Httpd在端口1234开始 </span><wbr /><br><span style="line-height:1.8em;">// Sessiond started on port: 1235 Sessiond在端口1235开始 </span><wbr /><br><span style="line-height:1.8em;">At this point BeanShell will run two services: </span><wbr /><br><span style="line-height:1.8em;">a tiny HTTP server on the port you specified </span><wbr /><br><span style="line-height:1.8em;">and the BeanShell telnet session server on the next port (the port you specified + 1). </span><wbr /><br><span style="line-height:1.8em;">在这里，Beanshell将运行两个服务： </span><wbr /><br><span style="line-height:1.8em;">在你列出的端口中的一个小的HTTP服务器和在下一个端口上的Beanshell的远程会议服务器 </span><wbr /><br><span style="line-height:1.8em;">(你定义的端口加上1). </span><wbr /><br><span style="line-height:1.8em;">2.Web Browser Access web浏览器接受 </span><wbr /><br><span style="line-height:1.8em;">After starting the server you can connect your web browser to the port you specified. </span><wbr /><br><span style="line-height:1.8em;">BeanShell will respond by sending an HTML page offering you a choice of the Swing based JConsole </span><wbr /><br><span style="line-height:1.8em;">or the older AWTConsole. </span><wbr /><br><span style="line-height:1.8em;">You may choose whichever is appropriate for your web browser. </span><wbr /><br><span style="line-height:1.8em;">在打开服务器之后，你能连接你的web浏览器到你定义的端口上面。 </span><wbr /><br><span style="line-height:1.8em;">Beanshell将响应给你，通过发送一个HTML网页提供给你Swing基础平台或者老的AWT平台的一个选择。 </span><wbr /><br><span style="line-height:1.8em;">你可以选择哪一个是适合你的web浏览器。 </span><wbr /><br><span style="line-height:1.8em;">You can skip this decision page by hitting one of the following URLs directly: </span><wbr /><br><span style="line-height:1.8em;">你能通过直接点击下面的URL中的一个，跳过这个选择界面。 </span><wbr /><br></span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">http://&lt;yourserver&gt;:&lt;port&gt;/remote/jconsole.htmlSwing based JConsole page 基于Swing的平台 </span><wbr /><br><br><span style="font-size:18px;line-height:1.8em;">http://&lt;yourserver&gt;:&lt;port&gt;/remote/awtconsole.htmlMinmal (old) AWT based Console page 基于AWT的平台页面 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">The httpd server then serves the remote console applet. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">When it starts you will have a BeanShell session that looks like the regular console, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">but is connected to the remote BeanShell VM. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个Httpd类型服务器于是保留远程平台的applet. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">当它启动的时候，你将有一个Beanshell会话，这个会话看起来像规则在平台， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">但是是和远程的Beanshell虚拟机连接的。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You can open as many sessions into that VM as you like in this way, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">but note that unlike the BeanShell desktop environment . </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">All remote sessions share the same global scope. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You are effectively working in the </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">same interpreter instance for all connections. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This is intended as a feature, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">as the primary usefulness of this mode is for debugging. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You can set variables and access components across many sessions. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能打开很多的会话进入虚拟机， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">但是注意不能是beanshell的桌面环境。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">所有的远程会话共享相同的全局作用域。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">对于所有的连接来说，你都是有效的工作在相同的解释器实例上面。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这些被扩展为一个特征， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这种模式的最初使用是为了调试。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能通过很多会话设置变量和入口组件。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Example 例子 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Let's look at a quick example of </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">how you might start a remote session from within your application: </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">让我们看一个快速例子，通过你的应用程序，如何开始一个远程会话： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">// Java code Java模式 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">import bsh.Interpreter; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">i = new Interpreter(); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">i.set( &quot;myapp&quot;, this ); // Provide a reference to your app 提供一个引用给你的应用程序 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">i.set( &quot;portnum&quot;, 1234 ); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">i.eval(&quot;setAccessibility(true)&quot;); // turn off access restrictions 关掉入口限制 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">i.eval(&quot;server(portnum)&quot;); </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Here we have set up the interpreter instance just as </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">we would to do any other kind of scripting . </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">passing in Java objects using set(). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">In this case we passed a general reference to our application using 'this', as well. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">We have turned on accessibility so </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">that we can access private and protected members of our classes </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(useful for debugging). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Finally we start the server on the desired port. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这儿我们已经构造解释器实例就像我们去处理其他类型的脚本一样。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">使用set()传递Java对象。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在这种情况下，我们使用'this'对象来传递一个普通引用到我们的应用程序中。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">我们已经可以打开入口，所以我们能接受我们的类中的私有的和受保护成员。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">最后我们可以在这个端口上打开服务器。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">3.Telnet Access 远程登录入口 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">We mentioned earlier that BeanShell starts its telnet session server </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">on the port next to the HTTP port. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You can use any telnet client to access a BeanShell command line directly, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">in text only.mode, without the use of a web browser. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">我们前面提到，Beanshell在HTTP端口的下一个端口上， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">开始它的远程会话服务器。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你能使用一些远程登录客户端去直接访问一个Beanshell命令， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">使用文本模式，没有web浏览器的使用。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">telnet &lt;myhost&gt; &lt;port+1&gt; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note that this command line is not very friendly. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">In particular it does not respond to gratuitous newlines with a new prompt </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(as the text only Interpreter command line does). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">注意这个命令行不识十分友好。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在特殊的情况下，它不会通过一个新的提示返回一个新行(就像只有解释器命令行的文本一样)。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">At the time of this writing there is no explicit way to close a session. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">BeanShell will simply detect the end of streams. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">此时，写那些对于关闭一个会话来说不是清楚的方法。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Beanshell将简单的察觉到流的结束。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">4.BshServlet and Servlet Mode Scripting BshServlet和Servlet模式脚本 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">BshServlet is a simple servlet </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">that can be used to evaluate BeanShell scripts inside of an application server </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">or servlet container. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">BshServlet accepts BeanShell scripts via the POST method, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">evaluates them capturing output (optionally including standard out and standard error) </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">and returns the results. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">BshServlet是一个简单的servlet,能在应用程序或者servlet容器中，计算Beanshell脚本。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">BshServlet通过POST方法来接受Beanshell脚本， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">计算他们捕获输出(有选择的包含标准输出和标准错误)并且返回结果。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">BshServlet has a simple form based interface for interactive experimentation </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">(analogous to the remote server mode). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">But more generally you can send standalone BeanShell scripts from the command line </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">to the BshServlet for evaluation using the bsh.Remote launcher. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.Remote complements bsh.Interpreter and bsh.Console as a launch point for BeanShell. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">BshServlet有一个简单的模式，基于接口的交互式体验(在远程服务器模式中也相似). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">但是更通常的做法是，你能从命令行发送单纯的Beanshell脚本， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">使用bsh.Remote发射台，到BshSerlet中去计算。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">bsh.Remote实现了bsh.Interpreter和bsh.Console，作为Beanshell的一个发射点。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Tip: 提示 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">You may find BshServlet useful for writing unit tests </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">that must run inside an application server environment. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">In this mode BshServlet can be used in the same way as </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">or in combination with the Jakarta project's cactus. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">你会发现BshServlet在写单元测试的时候很有用， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">当然必须在一个应用程序服务器环境中运行。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在这个模式中，BshServlet能以同样的方式使用， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">或者和Jakarta项目联合使用。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">5.Deploying BshServlet 发布BshServlet </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">To test drive BshServlet you can grab one of the following sample application WAR files here: </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">检验BshServlet的运行，你能抓住下面的样本应用程序WAR文件中的一个： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">· </span><wbr /><br><a href="http://www.beanshell.org/bshservlet.war" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/bshservlet.war</span><wbr /></a><wbr /><br><span style="font-size:18px;line-height:1.8em;">· </span><wbr /><br><a href="http://www.beanshell.org/bshservlet.wbsh.war" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/bshservlet.wbsh.war</span><wbr /></a><wbr /><br><span style="font-size:18px;line-height:1.8em;">Rename this file to &quot;bshservlet.war&quot; for use. 方便使用，重命名这个文件为&quot;bshservlet.war&quot; </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Tip: 提示： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">A WAR file is a Web Application Archive. It is a JAR file containing HTML, images, servlets, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">and configuration files comprising a complete web application. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Web applications can usually be deployed to a servlet container </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">by simply dropping the WAR file into a special directory. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">一个WAR文件是一个web应用程序的存档。它是一个JAR文件，包含HTML,图片，servlets, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">和由一个完全的web应用程序组成的配置文件。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">通过简单的把WAR推到一个特殊的目录下， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">web应用程序通常能部署到一个servlet容器中。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">The first file, bshservlet.war, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">assumes that BeanShell has been installed in your application server's classpath. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">It includes only the web.xml file necessary to deploy an instance of the test servlet </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">and an index.html README file. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">第一个文件，bshservlet.war, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">假设Beanshell已经安装在你的应用程序服务器的类路径下。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">需要发布测试servlet的实例，它仅仅需要web.xml文件和index.html说明文件。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note: 注意： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">To install BeanShell in the Tomcat server classpath place the bsh.jar file in common/lib. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">To use BeanShell in Weblogic you must upgrade its version of the package. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">See Upgrading BeanShell in Weblogic ( </span><wbr /><br><a href="http://www.beanshell.org/weblogic.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/weblogic.html</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在Tomcat服务器类路径中安装Beanshell要将bsh.jar文件放在common/lib文件夹底下。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">在Weblogic中使用Beanshell，你必须升级包的级别。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">请看在Weblogic中升级Beanshell( </span><wbr /><br><a href="http://www.beanshell.org/weblogic.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/weblogic.html</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">The second WAR, bshservlet.wbsh.war, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">includes a copy of the BeanShell application bsh.jar inside the WAR's lib directory. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">This WAR includes everything you need to just drop the WAR into an application server. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">第二个WAR，bshservlet.wbsh.war, </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">包括Beanshell应用程序bsh.jar进入WAR的lib目录的一个拷贝。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">这个WAR包括所有的内容，你需要去将WAR移除进入一个应用程序服务器的内容。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Note: 提示： </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">Using bshservlet.wbsh.war will still *not* work in Weblogic 6.x </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">unless you upgrade Weblogic's internal version of BeanShell first. </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">See Upgrading BeanShell in Weblogic. ( </span><wbr /><br><a href="http://www.beanshell.org/weblogic.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/weblogic.html</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">使用bshservlet.wbsh.war将不能运行在Weblogic6.x上面， </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">直到你首先升级Weblogic的Beanshell的内置版本。 </span><wbr /><br><span style="font-size:18px;line-height:1.8em;">请看在Weblogic中升级Beanshell. ( </span><wbr /><br><a href="http://www.beanshell.org/weblogic.html" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://www.beanshell.org/weblogic.html</span><wbr /></a><wbr /><span style="font-size:18px;line-height:1.8em;">). </span><wbr /><br><span style="font-size:18px;line-height:1.8em;"><span style="line-height:1.8em;">To use the servlet for testing your own applications </span><wbr /><br><span style="line-height:1.8em;">you will probably want to deploy an instance of the test servlet in your WAR file. </span><wbr /><br><span style="line-height:1.8em;">This will allow the test servlet to to share a classloader with your webapp so </span><wbr /><br><span style="line-height:1.8em;">that you can test things like application classes and EJB local homes. </span><wbr /><br><span style="line-height:1.8em;">Since the servlet is included in the standard BeanShell distribution, </span><wbr /><br><span style="line-height:1.8em;">all that is necessary to do this is to include bsh.jar </span><wbr /><br><span style="line-height:1.8em;">and add an entry to your wegapp's web.xml file. </span><wbr /><br><span style="line-height:1.8em;">Here is an example: </span><wbr /><br><span style="line-height:1.8em;">使用servlet来测试你自己的应用程序， </span><wbr /><br><span style="line-height:1.8em;">你将可能想去发布测试servlet的一个实例在你的WAR文件中。 </span><wbr /><br><span style="line-height:1.8em;">这个将允许这个测试的servlet和你的web应用共享一个类加载器， </span><wbr /><br><span style="line-height:1.8em;">所以你能像应用程序类和EJB容器一样测试。 </span><wbr /><br><span style="line-height:1.8em;">由于servlet是被包含在标准的Beanshell的分类中， </span><wbr /><br><span style="line-height:1.8em;">需要做的是去包含bsh.jar和增加一个入口到你的web应用的web.xml文件中。 </span><wbr /><br><span style="line-height:1.8em;">这儿是一个例子： </span><wbr /><br><span style="line-height:1.8em;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO.8859.1&quot;?&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;!DOCTYPE web.app </span><wbr /><br><span style="line-height:1.8em;">PUBLIC &quot;.//Sun Microsystems, Inc.//DTD Web Application 2.3//EN&quot; </span><wbr /><br><span style="line-height:1.8em;">&quot;</span><wbr /></span><wbr /><br><a href="http://java.sun.com/dtd/web.app_2_3.dtd" target="_blank"><span style="font-size:18px;line-height:1.8em;">http://java.sun.com/dtd/web.app_2_3.dtd</span><wbr /></a><wbr /><span style="line-height:1.8em;">&quot;&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;web.app&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;servlet&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;servlet.name&gt;bshservlet&lt;/servlet.name&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;servlet.class&gt;bsh.servlet.BshServlet&lt;/servlet.class&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/servlet&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;servlet.mapping&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;servlet.name&gt;bshservlet&lt;/servlet.name&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;url.pattern&gt;/eval&lt;/url.pattern&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/servlet.mapping&gt; </span><wbr /><br><span style="line-height:1.8em;">&lt;/web.app&gt; </span><wbr /><br><span style="line-height:1.8em;">The above example deploys an instance of BshServlet under the name &quot;/eval&quot;. </span><wbr /><br><span style="line-height:1.8em;">The full path to the servlet will then depend on the name given to the webapp WAR file. </span><wbr /><br><span style="line-height:1.8em;">For example if the above appears in a WAR file named &quot;myapp.war&quot; then the path would be: </span><wbr /><br><span style="line-height:1.8em;"><a href="http://localhost/myapp/eval" target="_blank">http://localhost/myapp/eval</a><wbr /> </span><wbr /><br><span style="line-height:1.8em;">上面的例子在名字&quot;/eval&quot;的下面发布了BshServlet的一个实例。</span><wbr /><br><span style="line-height:1.8em;">servlet的全路径在那时将依靠被发送给web应用WAR文件的名字。</span><wbr /><br><span style="line-height:1.8em;">例如，如果上面的例子显示在一个名字为&quot;myapp.war&quot;的WAR文件中，那么这个路径将是：</span><wbr /><br><span style="line-height:1.8em;"><a href="http://localhost/myapp/eval" target="_blank">http://localhost/myapp/eval</a><wbr /></span><wbr /><br> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1226474488#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Wed, 12 Nov 2008 07:21:28 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1226474488</guid>
</item>

<item>
<title><![CDATA[Beanshell翻译18]]></title>
<link>http://281696143.qzone.qq.com/blog/1226301207</link>
<description><![CDATA[1.Multiple Interpreters vs. Multi.threading 多线程Interpreters VS.多线程 threading<br>A common design question is whether to use a single BeanShell interpreter <br>or multiple interpreter instances in your application. <br>一个通常的设计问题是，是否去使用一个单独的Beanshell解释器或者<br>在你的应用程序中使用多个解释器实例。<br>The Interpreter class is, in general, thread safe and allows you to work with threads,<br>within the normal bounds of the Java language. <br>解释类，通常是，线程安全的并且允许你和线程一起工作，<br>通过Java语言的通常的边界。<br>BeanShell does not change the normal application level threading issues of multiple <br>threads from accessing the same variables: <br>Beanshell不能改变通常应用程序的多线程的线程事务的级别，当接受相同的变量时：<br>you still have to synchronize access using some mechanism if necessary. <br>However it is legal to perform multiple simultaneous evaluations. <br>You can also write multi.threaded scripts within the language, <br>as we discussed briefly in &quot;Scripting Interfaces&quot;. <br>当需要的时候，你仍然要去使用一些机制去同步接受。<br>但是处理多个相似的计算是合法的。<br>你也可以使用语言写多线程的脚本，<br>就像我们在&quot;脚本接口&quot;中短暂的讨论的一样。<br>Since working with multiple threads introduces issues of synchronization <br>and application structure, <br>you may wish to simply create multiple Interpreter instances. <br>BeanShell Interpreter instances were designed to be very light weight. <br>Construction time is usually negligible and in simple tests, <br>we have found that it is possible to maintain hundreds (or even thousands) of instances. <br>当在多线程的工作模式下提出同步的事件，和在应用程序的结构下，<br>你会希望简单的创建多线程的解释器实例。<br>Beanshell解释器实例是被设计为非常轻量级的。<br>构造时间在简单的测试中，通常是被忽略的，<br>我们已经发现，有可能去维持成百个（甚至上千个）实例。<br>There are other options in.between options as well. <br>It is possible to retrieve BeanShell scripted objects from the interpreter <br>and &quot;re.bind&quot; them again to the interpreter. <br>We'll talk about that in the next section. <br>You can also get and set the root level bsh.NameSpace object for the entire Interpreter. <br>The NameSpace is roughly equivalent to a BeanShell method context. <br>Each method context has an associated NameSpace object. <br>在所有的选择中有一些其他的选择。<br>有可能重新从解释器中重新得到Beanshell脚本对象并且将他们重新绑定到解释器中。<br>我们将在下一个章节中讨论到。<br>我们也能从整个的解释器中取得和设置根级别的bsh.NameSpace对象。<br>对于一个Beanshell函数环境来说名字空间是不可能相等的。<br>每一个函数环境有一个相联系的名字对象。<br>Tip: 提示：<br>You can clear all variables, methods, and imports from a scope using the clear() command. <br>你可以清除所有的变量，方法，并且从一个包含clear()命令的作用域中导入。<br>Note: at the time of this writing the synchronized language keyword is not implemented. <br>This will be corrected in an upcoming release. <br>注意：本次书面同步语言关键字是没有得到执行。<br>在即将来临的释放中，这些将都是正确的。<br>See also &quot;The BeanShell Parser&quot; for more about performance issues. <br>再看&quot;Beanshell解析&quot;获得更多的执行信息。<br>2.Serializing Interpreters and Scripted Objects 序列化解释器和脚本对象<br>The BeanShell Interpreter is serializable, <br>assuming of course that all objects referenced by variables in the global scope <br>are also serializable. <br>So you can save the entire static state of the interpreter by serializing it and storing it. <br>Note that serializing the Intepreter does not &quot;freeze&quot; execution of BeanShell scripts <br>in any sense other than saving the current state of the variables. <br>In general if you serialize an Interpreter while it is <br>executing code the results will be undetermined.<br>De.serializing an interpreter does not automatically restart method executions; <br>it simply restores state. <br>Beanshell是序列化的，假定所有在全局作用域的对象也是序列化的。<br>所以你能通过序列化来保存解释器的完整的静态状态。<br>注意，序列化解释器对象在一定程度上，比存储变量的当前状态，更加不会冰冻执行Beanshell脚本。<br>通常当它是执行代码时候，如果你序列化一个解释器，结果将变成不确定的。<br>完全的序列化一个解释器不能自动在重新启动函数执行;<br>它可以简单的存储状态。<br>Note: 注意：<br>There is serious Java bug that affects BeanShell serializability in Java versions prior to 1.3. <br>When using these versions of Java the primitive type class identifiers cannot be de.serialized. <br>See the FAQ for a workaround. <br>It is also possible to serialize individual BeanShell scripted objects <br>('this' type references and interfaces to scripts). <br>The same rules apply. <br>One thing to note is that by default serializing a scripted object context <br>will also serialize all of that object's parent contexts up to the global scope .<br>effectively serializing the whole interpreter. <br>有一个严重的Java缺陷，影响Beanshell在Java1.3之前的版本Beanshell的序列化。<br>当使用Java的这些版本，这个最初的类型标示不能被完全的序列化。<br>看工作台中的FAQ.<br>也可以序列化个人的Beanshell脚本对象(脚本的'this'类型引用和接口)。<br>相同的规则应用。<br>有一个要注意的事情是，默认的情况下，序列化一个脚本对象<br>也将序列化全局作用域的该对象的父对象。<br>有效的序列化整个解释器。<br>To detach a scripted object from its parent namespace<br>you can use the namespace prune() method: <br>从父亲的名字空间中，分离一个脚本对象，<br>你能使用名字空间prune()函数：<br>// From BeanShell 从Beanshell中执行。<br>object.namespace.prune(); <br>// From Java 从Java中执行<br>object.getNameSpace().prune(); <br>To bind a BeanShell scripted object back into a particular method scope <br>you can use the bind() command: <br>绑定一个Beanshell脚本对象到一个特定的函数作用域中，<br>你能使用bind()函数：<br>// From BeanShell 从Beanshell中实现<br>bind( object, this.namespace ); <br>// From Java 从Java中实现<br>bsh.This.bind( object, namespace, interpreter );<br>The bind() operation requires not only the namespace (method scope) into<br>which to bind the object, <br>but an interpreter reference as well. <br>The interpreter reference is the &quot;declaring interpreter&quot; of the object <br>and is used for cases where there is no active interpreter . <br>e.g. where an external method call from compiled Java enters the object. <br>bind()操作不仅需要名字空间(函数作用域)到绑定对象的哪一个，<br>而是一个解释器引用。<br>解释器引用是对象的定义解释器，并且用于没有现行的解释器的情况。<br>例如，一个第三方的函数调用编译好的Java的地方进入这个对象。<br>The BeanShell save() command which serializes objects recognize <br>when you are trying to save a BeanShell scripted object (a bsh.This reference) type <br>and automatically prune()s it from the parent namespace,<br>so that saving the object doesn't drag along the whole interpreter along for the ride. <br>Similarly, load() binds the object to the current scope. <br>当你尝试着存储一个Beanshell对象类型并且自动的从父亲名字空间中剪除的时候，<br>调用Beanshell的可以序列化对象的save命令，<br>于是存储对象不会向前拖累整个的解释器，而只是乘着它。<br>相似的是，load()绑定对象到当前的作用域中。 <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[281696143@qq.com(Ronger)]]></author>
<comments>http://281696143.qzone.qq.com/blog/1226301207#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Mon, 10 Nov 2008 07:13:27 GMT</pubDate>
<guid>http://281696143.qzone.qq.com/blog/1226301207</guid>
</item>

</channel>
</rss>

