String scriptStr = sb.toString();
Context cx = Context.enter();
boolean providerFound = false;
try {
Scriptable scriptScope = cx.initStandardObjects(null, true);
Object[] ids = compileScript(cx, scriptStr, scriptScope, f);
if (ids.length > 0) {
Service.Mode mode = Service.Mode.PAYLOAD;
for (Object idObj : ids) {
if (!(idObj instanceof String)) {
continue;
}
String id = (String)idObj;
if (!id.startsWith("WebServiceProvider")) {
continue;
}
Object obj = scriptScope.get(id, scriptScope);
if (!(obj instanceof Scriptable)) {
continue;
}
Scriptable wspVar = (Scriptable)obj;
providerFound = true;
obj = wspVar.get("ServiceMode", wspVar);
if (obj != Scriptable.NOT_FOUND) {
if (obj instanceof String) {
String value = (String)obj;
if ("PAYLOAD".equalsIgnoreCase(value)) {
mode = Service.Mode.PAYLOAD;