Interface RhinoHostObjectProvider
RhinoHostObjectProvider defines the service interface to
inject additional ECMAScript host objects as well as to make classes and
packages known.-
Method Summary
Modifier and TypeMethodDescriptionClass<? extends org.mozilla.javascript.Scriptable>[]Returns an array of classes implementing the RhinoScriptableinterface.Class<?>[]Returns an array of classes, which are transparently converted into ECMAScript host objects in the global scope.String[]Returns an array of Java package names to define name spaces in the global scope.
-
Method Details
-
getHostObjectClasses
Class<? extends org.mozilla.javascript.Scriptable>[] getHostObjectClasses()Returns an array of classes implementing the RhinoScriptableinterface. These classes will be registered with the global scope as host objects and may then be used in any server-side ECMAScript scripts.- Returns:
- the host object classes; may return
nullinstead of an empty array for implementations that do not provide any host objects
-
getImportedClasses
Class<?>[] getImportedClasses()Returns an array of classes, which are transparently converted into ECMAScript host objects in the global scope.Normally any Java class may be used within ECMAScript but it must be prefixed with
Packagesand the fully qualified package name of the class. For example to use the classorg.slf4j.Login an ECMAScript it must be noted asPackages.org.slf4j.Log. By registering theorg.slf4j.Logas an imported class, it may simply be referred to asLog(provided there is no other object of that name, of course).- Returns:
- the imported classes; may return
nullinstead of an empty array for implementations that do not import any classes
-
getImportedPackages
String[] getImportedPackages()Returns an array of Java package names to define name spaces in the global scope.Normally any Java class may be used within ECMAScript but it must be prefixed with
Packagesand the fully qualified package name of the class. For example to use the classorg.slf4j.Login an ECMAScript it must be noted asPackages.org.slf4j.Log. By registering theorg.slf4jpackage as an imported package, it may simply be referred to asLog(provided there is no other object of that name, of course).The difference between importing packages and importing classes is that for a package import to work, the package must be visible to the ECMAScript bundle.
Implementations may return
nullinstead of an empty array if they do not provide any package names.- Returns:
- the imported packages; may return
nullinstead of an empty array for implementations that do import any packages
-