Java Doc for BSFManager.java in  » Scripting » bsf-2.4.0 » org » apache » bsf » 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 » Scripting » bsf 2.4.0 » org.apache.bsf 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.bsf.BSFManager

BSFManager
public class BSFManager (Code)
This class is the entry point to the bean scripting framework. An application wishing to integrate scripting to a Java app would place an instance of a BSFManager in their code and use its services to register the beans they want to make available for scripting, load scripting engines, and run scripts.

BSFManager serves as the registry of available scripting engines as well. Loading and unloading of scripting engines is supported as well. Each BSFManager loads one engine per language. Several BSFManagers can be created per JVM.
author:
   Sanjiva Weerawarana
author:
   Matthew J. Duftler
author:
   Sam Ruby
author:
   Olivier Gruber (added original debugging support)
author:
   Don Schwarz (added support for registering languages dynamically)



Field Summary
protected  ClassLoaderclassLoader
    
protected  StringclassPath
    
protected  VectordeclaredBeans
    
protected static  Hashtableextn2Lang
    
protected  HashtableloadedEngines
    
protected  ObjectRegistryobjectRegistry
    
protected  PropertyChangeSupportpcs
    
protected static  HashtableregisteredEngines
    
protected  StringtempDir
    
protected static  Stringversion
    

Constructor Summary
public  BSFManager()
    

Method Summary
public  Objectapply(String lang, String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments)
     Apply the given anonymous function of the given language to the given parameters and return the resulting value.
public  voidcompileApply(String lang, String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments, CodeBuffer cb)
     Compile the application of the given anonymous function of the given language to the given parameters into the given CodeBuffer.
public  voidcompileExpr(String lang, String source, int lineNo, int columnNo, Object expr, CodeBuffer cb)
     Compile the given expression of the given language into the given CodeBuffer.
public  voidcompileScript(String lang, String source, int lineNo, int columnNo, Object script, CodeBuffer cb)
     Compile the given script of the given language into the given CodeBuffer.
public  voiddeclareBean(String beanName, Object bean, Class type)
     Declare a bean.
public  Objecteval(String lang, String source, int lineNo, int columnNo, Object expr)
     Evaluate the given expression of the given language and return the resulting value.
public  voidexec(String lang, String source, int lineNo, int columnNo, Object script)
     Execute the given script of the given language.
public  ClassLoadergetClassLoader()
    
public  StringgetClassPath()
    
public static  StringgetLangFromFilename(String fileName)
     Determine the language of a script file by looking at the file extension.
public  ObjectRegistrygetObjectRegistry()
     Return the current object registry of the manager.
public  StringgetTempDir()
    
public static  StringgetVersion()
     Returns the version string of BSF.
public  voidiexec(String lang, String source, int lineNo, int columnNo, Object script)
     Execute the given script of the given language, attempting to emulate an interactive session w/ the language.
public static  booleanisLanguageRegistered(String lang)
     Determine whether a language is registered.
public  BSFEngineloadScriptingEngine(String lang)
     Load a scripting engine based on the lang string identifying it.
Parameters:
  lang - string identifying language
exception:
  BSFException - if the language is unknown (i.e., if ithas not been registered) with a reason ofREASON_UNKNOWN_LANGUAGE.
public  ObjectlookupBean(String beanName)
     return a handle to a bean registered in the bean registry by the application or a scripting engine.
public  voidregisterBean(String beanName, Object bean)
     Registering a bean allows a scripting engine or the application to access that bean by name and to manipulate it.
public static  voidregisterScriptingEngine(String lang, String engineClassName, String[] extensions)
     Register a scripting engine in the static registry of the BSFManager.
Parameters:
  lang - string identifying language
Parameters:
  engineClassName - fully qualified name of the class interfacingthe language to BSF.
Parameters:
  extensions - array of file extensions that should be mapped tothis language type.
public  voidsetClassLoader(ClassLoader classLoader)
     Set the class loader for those that need to use it.
public  voidsetClassPath(String classPath)
     Set the classpath for those that need to use it.
public  voidsetObjectRegistry(ObjectRegistry objectRegistry)
     Set the object registry used by this manager.
public  voidsetTempDir(String tempDir)
     Temporary directory to put stuff into (for those who need to).
public  voidterminate()
    
public  voidundeclareBean(String beanName)
     Undeclare a previously declared bean.
public  voidunregisterBean(String beanName)
     Unregister a previously registered bean.

Field Detail
classLoader
protected ClassLoader classLoader(Code)



classPath
protected String classPath(Code)



declaredBeans
protected Vector declaredBeans(Code)



extn2Lang
protected static Hashtable extn2Lang(Code)



loadedEngines
protected Hashtable loadedEngines(Code)



objectRegistry
protected ObjectRegistry objectRegistry(Code)



pcs
protected PropertyChangeSupport pcs(Code)



registeredEngines
protected static Hashtable registeredEngines(Code)



tempDir
protected String tempDir(Code)



version
protected static String version(Code)




Constructor Detail
BSFManager
public BSFManager()(Code)




Method Detail
apply
public Object apply(String lang, String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments) throws BSFException(Code)
Apply the given anonymous function of the given language to the given parameters and return the resulting value.
Parameters:
  lang - language identifier
Parameters:
  source - (context info) the source of this expression(e.g., filename)
Parameters:
  lineNo - (context info) the line number in source for expr
Parameters:
  columnNo - (context info) the column number in source for expr
Parameters:
  funcBody - the multi-line, value returning script to evaluate
Parameters:
  paramNames - the names of the parameters above assumes
Parameters:
  arguments - values of the above parameters
exception:
  BSFException - if anything goes wrong while running the script



compileApply
public void compileApply(String lang, String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments, CodeBuffer cb) throws BSFException(Code)
Compile the application of the given anonymous function of the given language to the given parameters into the given CodeBuffer.
Parameters:
  lang - language identifier
Parameters:
  source - (context info) the source of this expression(e.g., filename)
Parameters:
  lineNo - (context info) the line number in source for expr
Parameters:
  columnNo - (context info) the column number in source for expr
Parameters:
  funcBody - the multi-line, value returning script to evaluate
Parameters:
  paramNames - the names of the parameters above assumes
Parameters:
  arguments - values of the above parameters
Parameters:
  cb - code buffer to compile into
exception:
  BSFException - if anything goes wrong while running the script



compileExpr
public void compileExpr(String lang, String source, int lineNo, int columnNo, Object expr, CodeBuffer cb) throws BSFException(Code)
Compile the given expression of the given language into the given CodeBuffer.
Parameters:
  lang - language identifier
Parameters:
  source - (context info) the source of this expression(e.g., filename)
Parameters:
  lineNo - (context info) the line number in source for expr
Parameters:
  columnNo - (context info) the column number in source for expr
Parameters:
  expr - the expression to compile
Parameters:
  cb - code buffer to compile into
exception:
  BSFException - if any error while compiling the expression



compileScript
public void compileScript(String lang, String source, int lineNo, int columnNo, Object script, CodeBuffer cb) throws BSFException(Code)
Compile the given script of the given language into the given CodeBuffer.
Parameters:
  lang - language identifier
Parameters:
  source - (context info) the source of this script(e.g., filename)
Parameters:
  lineNo - (context info) the line number in source for script
Parameters:
  columnNo - (context info) the column number in source for script
Parameters:
  script - the script to compile
Parameters:
  cb - code buffer to compile into
exception:
  BSFException - if any error while compiling the script



declareBean
public void declareBean(String beanName, Object bean, Class type) throws BSFException(Code)
Declare a bean. The difference between declaring and registering is that engines are spsed to make declared beans "pre-available" in the scripts as far as possible. That is, if a script author needs a registered bean, he needs to look it up in some way. However if he needs a declared bean, the language has the responsibility to make those beans avaialable "automatically."

When a bean is declared it is automatically registered as well so that any declared bean can be gotton to by looking it up as well.

If any of the languages that are already running in this manager says they don't like this (by throwing an exception) then this method will simply quit with that exception. That is, any engines that come after than in the engine enumeration will not even be told about this new bean.

So, in general its best to declare beans before the manager has been asked to load any engines because then the user can be informed when an engine rejects it. Also, its much more likely that an engine can declare a bean at start time than it can at any time.
Parameters:
  beanName - name to declare bean as
Parameters:
  bean - the bean that's being declared
Parameters:
  type - the type to represent the bean as
exception:
  BSFException - if any of the languages that are alreadyrunning decides to throw an exception when asked todeclare this bean.




eval
public Object eval(String lang, String source, int lineNo, int columnNo, Object expr) throws BSFException(Code)
Evaluate the given expression of the given language and return the resulting value.
Parameters:
  lang - language identifier
Parameters:
  source - (context info) the source of this expression(e.g., filename)
Parameters:
  lineNo - (context info) the line number in source for expr
Parameters:
  columnNo - (context info) the column number in source for expr
Parameters:
  expr - the expression to evaluate
exception:
  BSFException - if anything goes wrong while running the script



exec
public void exec(String lang, String source, int lineNo, int columnNo, Object script) throws BSFException(Code)
Execute the given script of the given language.
Parameters:
  lang - language identifier
Parameters:
  source - (context info) the source of this expression(e.g., filename)
Parameters:
  lineNo - (context info) the line number in source for expr
Parameters:
  columnNo - (context info) the column number in source for expr
Parameters:
  script - the script to execute
exception:
  BSFException - if anything goes wrong while running the script



getClassLoader
public ClassLoader getClassLoader()(Code)
Get classLoader



getClassPath
public String getClassPath()(Code)
Get classPath



getLangFromFilename
public static String getLangFromFilename(String fileName) throws BSFException(Code)
Determine the language of a script file by looking at the file extension.
Parameters:
  fileName - the name of the file the scripting language the file is in if the file extensionis known to me (must have been registered viaregisterScriptingEngine).
exception:
  BSFException - if file's extension is unknown.



getObjectRegistry
public ObjectRegistry getObjectRegistry()(Code)
Return the current object registry of the manager. the current registry.



getTempDir
public String getTempDir()(Code)
Get tempDir



getVersion
public static String getVersion()(Code)
Returns the version string of BSF. version string in the form "abc.yyyymmdd" where"abc" represents a dewey decimal number (three levels, each between 0 and 9), and"yyyy" a four digit year, "mm" a two digit month,"dd" a two digit day.
Example: "240.20061006"stands for: BSF version 2.4.0 as of 2006-10-06.
since:
   2006-01-17



iexec
public void iexec(String lang, String source, int lineNo, int columnNo, Object script) throws BSFException(Code)
Execute the given script of the given language, attempting to emulate an interactive session w/ the language.
Parameters:
  lang - language identifier
Parameters:
  source - (context info) the source of this expression(e.g., filename)
Parameters:
  lineNo - (context info) the line number in source for expr
Parameters:
  columnNo - (context info) the column number in source for expr
Parameters:
  script - the script to execute
exception:
  BSFException - if anything goes wrong while running the script



isLanguageRegistered
public static boolean isLanguageRegistered(String lang)(Code)
Determine whether a language is registered.
Parameters:
  lang - string identifying a language true iff it is



loadScriptingEngine
public BSFEngine loadScriptingEngine(String lang) throws BSFException(Code)
Load a scripting engine based on the lang string identifying it.
Parameters:
  lang - string identifying language
exception:
  BSFException - if the language is unknown (i.e., if ithas not been registered) with a reason ofREASON_UNKNOWN_LANGUAGE. If the language is known butif the interface can't be created for some reason, thenthe reason is set to REASON_OTHER_ERROR and the actualexception is passed on as well.



lookupBean
public Object lookupBean(String beanName)(Code)
return a handle to a bean registered in the bean registry by the application or a scripting engine. Returns null if bean is not found.
Parameters:
  beanName - name of bean to look up the bean if its found or null



registerBean
public void registerBean(String beanName, Object bean)(Code)
Registering a bean allows a scripting engine or the application to access that bean by name and to manipulate it.
Parameters:
  beanName - name to register under
Parameters:
  bean - the bean to register



registerScriptingEngine
public static void registerScriptingEngine(String lang, String engineClassName, String[] extensions)(Code)
Register a scripting engine in the static registry of the BSFManager.
Parameters:
  lang - string identifying language
Parameters:
  engineClassName - fully qualified name of the class interfacingthe language to BSF.
Parameters:
  extensions - array of file extensions that should be mapped tothis language type. may be null.



setClassLoader
public void setClassLoader(ClassLoader classLoader)(Code)
Set the class loader for those that need to use it. Default is he who loaded me or null (i.e., its Class.forName).
Parameters:
  classLoader - the class loader to use.



setClassPath
public void setClassPath(String classPath)(Code)
Set the classpath for those that need to use it. Default is the value of the java.class.path property.
Parameters:
  classPath - the classpath to use



setObjectRegistry
public void setObjectRegistry(ObjectRegistry objectRegistry)(Code)
Set the object registry used by this manager. By default a new one is created when the manager is new'ed and this overwrites that one.
Parameters:
  objectRegistry - the registry to use



setTempDir
public void setTempDir(String tempDir)(Code)
Temporary directory to put stuff into (for those who need to). Note that unless this directory is in the classpath or unless the classloader knows to look in here, any classes here will not be found! BSFManager provides a service method to load a class which uses either the classLoader provided by the class loader property or, if that fails, a class loader which knows to load from the tempdir to try to load the class. Default value of tempDir is "." (current working dir).
Parameters:
  tempDir - the temporary directory



terminate
public void terminate()(Code)
Gracefully terminate all engines



undeclareBean
public void undeclareBean(String beanName) throws BSFException(Code)
Undeclare a previously declared bean. This removes the bean from the list of declared beans in the manager as well as asks every running engine to undeclared the bean. As with above, if any of the engines except when asked to undeclare, this method does not catch that exception. Quietly returns if the bean is unknown.
Parameters:
  beanName - name of bean to undeclare
exception:
  BSFException - if any of the languages that are alreadyrunning decides to throw an exception when asked toundeclare this bean.



unregisterBean
public void unregisterBean(String beanName)(Code)
Unregister a previously registered bean. Silent if name is not found.
Parameters:
  beanName - name of bean to unregister



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.