// check sling object
Object slingObject = slingBindings.get(SLING);
if (slingObject == null) {
if ( request != null ) {
slingObject = new ScriptHelper(this.bundleContext, this, request, slingBindings.getResponse());
} else {
slingObject = new ScriptHelper(this.bundleContext, this);
}
} else if (!(slingObject instanceof SlingScriptHelper) ) {
throw fail(scriptName, SLING, "Wrong type");
}
final SlingScriptHelper sling = (SlingScriptHelper)slingObject;