public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) { if (javaObject instanceof Map && !(javaObject instanceof ScriptableHashMap)) { return new NativeMap(scope, (Map)javaObject); } return super.wrapAsJavaObject(cx, scope, javaObject, staticType); } }
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) { if (javaObject instanceof Map && !(javaObject instanceof ScriptableHashMap)) { return new NativeMap(scope, (Map)javaObject); } return super.wrapAsJavaObject(cx, scope, javaObject, staticType); } }
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) { if (javaObject instanceof Map) { return new NativeMap(scope, (Map)javaObject); } return super.wrapAsJavaObject(cx, scope, javaObject, staticType); } }
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) { if (javaObject instanceof Map) { return new NativeMap(scope, (Map)javaObject); } return super.wrapAsJavaObject(cx, scope, javaObject, staticType); } }
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) { if (javaObject instanceof Map) { return new NativeMap(scope, (Map)javaObject); } return super.wrapAsJavaObject(cx, scope, javaObject, staticType); } }
/** * Wrap an object newly created by a constructor call. * @param cx the current Context for this thread * @param scope the scope of the executing script * @param obj the object to be wrapped * @return the wrapped value. */ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
/** * Wrap an object newly created by a constructor call. * @param cx the current Context for this thread * @param scope the scope of the executing script * @param obj the object to be wrapped * @return the wrapped value. */ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
/** * Wrap an object newly created by a constructor call. * @param cx the current Context for this thread * @param scope the scope of the executing script * @param obj the object to be wrapped * @return the wrapped value. */ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
/** * Wrap an object newly created by a constructor call. * @param cx the current Context for this thread * @param scope the scope of the executing script * @param obj the object to be wrapped * @return the wrapped value. */ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
/** * Wrap an object newly created by a constructor call. * @param cx the current Context for this thread * @param scope the scope of the executing script * @param obj the object to be wrapped * @return the wrapped value. */ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
/** * Wrap an object newly created by a constructor call. * @param cx the current Context for this thread * @param scope the scope of the executing script * @param obj the object to be wrapped * @return the wrapped value. */ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
return NativeJavaArray.wrap(scope, obj); return wrapAsJavaObject(cx, scope, obj, staticType);
return NativeJavaArray.wrap(scope, obj); return wrapAsJavaObject(cx, scope, obj, staticType);
return NativeJavaArray.wrap(scope, obj); return wrapAsJavaObject(cx, scope, obj, staticType);
/** * @param cx the current Context for this thread * @param scope the scope of the executing script * @param javaObject the object to be wrapped * @param staticType type hint. If security restrictions prevent to wrap * object based on its class, staticType will be used instead. * @return the wrapped value which shall not be null */ @SuppressWarnings("unchecked") @Override public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) { Scriptable result = null; try { String hostObjectName = getHostObjectName(staticType); if (hostObjectName == null) { hostObjectName = getHostObjectName(javaObject.getClass()); } if (hostObjectName != null) { result = cx.newObject(scope, hostObjectName, new Object[] { javaObject }); } } catch (Exception e) { log.warn("Cannot Wrap " + javaObject, e); } if(result==null) { result = super.wrapAsJavaObject(cx, scope, javaObject, staticType); } return result; }
public Object create(Object[] params) { ServiceCycle cycle = CycleUtil.getServiceCycle(); Scriptable parent; Context cx = RhinoUtil.enter(); try { Scriptable standard = getStandardObjects(); parent = cx.getWrapFactory().wrapAsJavaObject( cx, standard, cycle, ServiceCycle.class); } finally { Context.exit(); } return parent; } });
Object obj = createInterfaceAdapter(classObject, ScriptableObject.ensureScriptableObject(args[0])); return cx.getWrapFactory().wrapAsJavaObject(cx, scope, obj, null);
Object obj = createInterfaceAdapter(classObject, ScriptableObject.ensureScriptableObject(args[0])); return cx.getWrapFactory().wrapAsJavaObject(cx, scope, obj, null);
Object obj = createInterfaceAdapter(classObject, ScriptableObject.ensureScriptableObject(args[0])); return cx.getWrapFactory().wrapAsJavaObject(cx, scope, obj, null);
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticClass) { if (javaObject instanceof Map) { return new NativeMap(scope, (Map) javaObject); } else if (javaObject instanceof List) { return new NativeList(scope, (List) javaObject); } else if (javaObject instanceof AttributeScope && javaObject instanceof Scriptable == false) { AttributeScope attrs = (AttributeScope) javaObject; return new NativeAttributeScope(scope, attrs); } else if (javaObject instanceof ServiceCycle) { ServiceCycle cycle = (ServiceCycle) javaObject; return new NativeServiceCycle(scope, cycle); } else if (javaObject instanceof DynaBean) { DynaBean dynaBean = (DynaBean) javaObject; return new NativeDynaBean(scope, dynaBean); } return super.wrapAsJavaObject(cx, scope, javaObject, staticClass); }