org.mozilla.javascript.WrapFactory Java Examples

The following examples show how to use org.mozilla.javascript.WrapFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavascriptEngine.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void initWrapFactory( )
{
	WrapFactory wrapFactory = new WrapFactory( ) {

		protected IJavascriptWrapper coreWrapper = new CoreJavaScriptWrapper( );

		/**
		 * wrapper an java object to javascript object.
		 */
		public Object wrap( Context cx, Scriptable scope, Object obj,
				Class staticType )
		{
			Object object = coreWrapper.wrap( cx, scope, obj, staticType );
			if ( object != obj )
			{
				return object;
			}
			return super.wrap( cx, scope, obj, staticType );
		}
	};
	context.setWrapFactory( wrapFactory );
	new CoreJavaScriptInitializer( ).initialize( context, global );
}