public Scriptable wrapAsJavaObject()

in src/main/java/org/apache/sling/scripting/javascript/helper/SlingWrapFactory.java [50:74]


    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;
    }