Java Doc for Script.java in  » EJB-Server-resin-3.1.5 » ecmascript » com » caucho » es » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server resin 3.1.5 » ecmascript » com.caucho.es 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.caucho.es.Script

Script
abstract public class Script (Code)
The Script object represents a compiled JavaScript. Executing it is thread safe. To create a Script, use the Parser class to parse a file.

Java programs set JavaScript Global properties by adding objects to a HashMap. Typically you will at least assign the 'File' and the 'out' objects. The running script will see these objects as properties of the Global object. If you set the 'out' object, the script can use the bare bones 'writeln("foo")' to write to 'out'.


 HashMap map = new HashMap();
 map.put("File", Vfs.lookup());
 map.put("out", System.out);
 map.put("myObject", myObject);
 script.execute(map, null);
 

You can also make any Java object be the global prototype. Essentially, the effect is similar to the HashMap technique, but it's a little simpler.

Scripts are thread-safe. Multiple script instances can safely execute in separate threads. Script.execute creates the entire JavaScript global object hierarchy fresh for each execution. So one Script execution cannot interfere with another, even by doing evil things like modifying the Object prototype.

Of course, wrapped Java objects shared by script invocations must still be synchronized.



Field Summary
protected  PathclassDir
    
protected  PathscriptPath
    


Method Summary
public  Stringexecute(HashMap properties, Object proto)
     Execute the script; the main useful entry.

Calling programs can make Java objects available as properties of the global object by creating a property hash map or assigning a global prototype.


 HashMap map = new HashMap();
 map.put("File", Vfs.lookup());
 map.put("out", System.out);
 map.put("myObject", myObject);
 script.execute(map, null);
 
Then the JavaScript can use the defined objects:

 out.println(myObject.myMethod("foo"));
 

Parameters:
  properties - A hash map of global properties.
Parameters:
  proto - Global prototype.
public  ScriptClosureexecuteClosure(HashMap properties, Object proto)
     Execute the program, returning a closure of the global state. executeClosure will execute the global script.

Later routines can then call into the closure.

public  voidexport(ESObject dest, ESObject src)
     Internal method to export objects.
public  LineMapgetLineMap()
     Returns the map from source file line numbers to the generated java line numbers.
public  ESGlobalinitClass(Global resin, ESObject global)
     Internal method to initialize the script after loading it.
abstract public  ESGlobalinitClass(Global resin)
     Internal method implemented by the generated script for initialization.
public  booleanisModified()
     Internal method to check if the source files have changed.
public  voidsetClassDir(Path classDir)
     Internal method to set the work directory for generated *.java and *.class.
public  voidsetScriptPath(Path scriptPath)
     Internal method to set the script search path for imported scripts.

Field Detail
classDir
protected Path classDir(Code)



scriptPath
protected Path scriptPath(Code)





Method Detail
execute
public String execute(HashMap properties, Object proto) throws Throwable(Code)
Execute the script; the main useful entry.

Calling programs can make Java objects available as properties of the global object by creating a property hash map or assigning a global prototype.


 HashMap map = new HashMap();
 map.put("File", Vfs.lookup());
 map.put("out", System.out);
 map.put("myObject", myObject);
 script.execute(map, null);
 
Then the JavaScript can use the defined objects:

 out.println(myObject.myMethod("foo"));
 

Parameters:
  properties - A hash map of global properties.
Parameters:
  proto - Global prototype. Gives the script direct access tothe java methods of the object. String value of the last expression, like the JavaScript eval.This is useful only for testing.



executeClosure
public ScriptClosure executeClosure(HashMap properties, Object proto) throws Throwable(Code)
Execute the program, returning a closure of the global state. executeClosure will execute the global script.

Later routines can then call into the closure. The closure is not thread-safe. So only a single thread may execute the closure.
Parameters:
  properties - A hash map of global properties.
Parameters:
  proto - Global prototype. Gives the script direct access tothe java methods of the object. the closure




export
public void export(ESObject dest, ESObject src) throws Throwable(Code)
Internal method to export objects.



getLineMap
public LineMap getLineMap()(Code)
Returns the map from source file line numbers to the generated java line numbers.



initClass
public ESGlobal initClass(Global resin, ESObject global) throws Throwable(Code)
Internal method to initialize the script after loading it.



initClass
abstract public ESGlobal initClass(Global resin) throws Throwable(Code)
Internal method implemented by the generated script for initialization.



isModified
public boolean isModified()(Code)
Internal method to check if the source files have changed.



setClassDir
public void setClassDir(Path classDir)(Code)
Internal method to set the work directory for generated *.java and *.class.



setScriptPath
public void setScriptPath(Path scriptPath)(Code)
Internal method to set the script search path for imported scripts.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.