will be called before executing method or constructor

@param pc
@return the old scope map
513310
public Variables beforeCall(PageContext pc) {
	Variables parent = pc.variablesScope();
	pc.setVariablesScope(scope);
	return parent;
    }
1063669
ProcScope createScope(Scope scope) {
        ProcScope created = scopes.get(scope);
        if (created == null) {
            created = new ProcScope(scope.getName());
            scopes.put(scope, created);
            created.setStrong(scope.isStrong());
            created.setIgnoreText(scope.isIgnoreText());
            if (scope.getParent() != null) {
                created.setParent(createScope(scope.getParent()));
            }
            Set<ProcCode> scopeCodes = new HashSet<ProcCode>();
            for (Code code : scope.getCodes()) {
                scopeCodes.add(createCode(code));
            }
            created.setScopeCodes(scopeCodes);
            created.setMin(scope.getMin());
            created.setMax(scope.getMax());
        }
        return created;
    }
750760
public static Map createInitParamMap(PageContext pContext)
    {
        final ServletContext context = pContext.getServletContext();

        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return context.getInitParameterNames();
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return context.getInitParameter((String) pKey);
                } else {
                    return null;
                }
            }

            public boolean isMutable()
            {
                return false;
            }
        };
    }
566377
protected static int getScopeAsInt(String scope) {

        int scopeValue;
        switch (SCOPES_LIST.indexOf(scope)) {
            case 3:
                // application
                scopeValue = PageContext.APPLICATION_SCOPE;
                break;
            case 2:
                // session
                scopeValue = PageContext.SESSION_SCOPE;
                break;
            case 1:
                // request
                scopeValue = PageContext.REQUEST_SCOPE;
                break;
            default:
                // page
                scopeValue = PageContext.PAGE_SCOPE;
                break;
        }
        return scopeValue;
    }
1052990
protected Map<ScopeImpl, PvmExecutionImpl> createActivityExecutionMapping(ScopeImpl currentScope,
                                                                            final Map<ScopeImpl, PvmExecutionImpl> mapping) {
    if (!isScope()) {
      throw new ProcessEngineException("Execution must be a scope execution");
    }
    if (!currentScope.isScope()) {
      throw new ProcessEngineException("Current scope must be a scope.");
    }

    // collect all ancestor scope executions unless one is encountered that is already in "mapping"
    ScopeExecutionCollector scopeExecutionCollector = new ScopeExecutionCollector();
    new ExecutionWalker(this)
      .addPreVisitor(scopeExecutionCollector)
      .walkWhile(new ReferenceWalker.WalkCondition<PvmExecutionImpl>() {
        public boolean isFulfilled(PvmExecutionImpl element) {
          return element == null || mapping.containsValue(element);
        }
      });
    final List<PvmExecutionImpl> scopeExecutions = scopeExecutionCollector.getScopeExecutions();

    // collect all ancestor scopes unless one is encountered that is already in "mapping"
    ScopeCollector scopeCollector = new ScopeCollector();
    new FlowScopeWalker(currentScope)
      .addPreVisitor(scopeCollector)
      .walkWhile(new ReferenceWalker.WalkCondition<ScopeImpl>() {
        public boolean isFulfilled(ScopeImpl element) {
          return element == null || mapping.containsKey(element);
        }
      });

    final List<ScopeImpl> scopes = scopeCollector.getScopes();

    // add all ancestor scopes and scopeExecutions that are already in "mapping"
    // and correspond to ancestors of the topmost previously collected scope
    ScopeImpl topMostScope = scopes.get(scopes.size() - 1);
    new FlowScopeWalker(topMostScope.getFlowScope())
      .addPreVisitor(new TreeVisitor<ScopeImpl>() {
        public void visit(ScopeImpl obj) {
          scopes.add(obj);
          PvmExecutionImpl priorMappingExecution = mapping.get(obj);

          if (priorMappingExecution != null && !scopeExecutions.contains(priorMappingExecution)) {
            scopeExecutions.add(priorMappingExecution);
          }
        }
      })
      .walkWhile();

    if (scopes.size() == scopeExecutions.size()) {
      // the trees are in sync
      Map<ScopeImpl, PvmExecutionImpl> result = new HashMap<>();
      for (int i = 0; i < scopes.size(); i++) {
        result.put(scopes.get(i), scopeExecutions.get(i));
      }
      return result;
    } else {
      // Wounderful! The trees are out of sync. This is due to legacy behavior
      return LegacyBehavior.createActivityExecutionMapping(scopeExecutions, scopes);
    }
  }
853171
public static Map createCookieMap(PageContext pContext)
    {
        // Read all the cookies and construct the entire map
        HttpServletRequest request = (HttpServletRequest) pContext.getRequest();
        Cookie[] cookies = request.getCookies();
        Map ret = new HashMap();

        for (int i = 0; cookies != null && i < cookies.length; i++) {
            Cookie cookie = cookies[i];
            if (cookie != null) {
                String name = cookie.getName();
                if (!ret.containsKey(name)) {
                    ret.put(name, cookie);
                }
            }
        }
        return ret;
    }
1043316
@Override
    public Map<String, Object> getApplicationMap()
    {
        if (_applicationMap == null)
        {
            _applicationMap = new ApplicationMap(_servletContext);
        }
        return _applicationMap;
    }
50275
public static Session getInstance(String name, PageContext pc, Log log) {

	Resource res = _loadResource(pc.getConfig(), SCOPE_SESSION, name, pc.getCFID());
	Struct data = _loadData(pc, res, log);
	return new SessionFile(pc, res, data);
    }
165725
public Object getMCWFromMctoMCWMap(Object mc) {
        Object mcw = null;
        mcToMCWMapRead.lock();
        try {
            mcw = mcToMCWMap.get(mc);
        } finally {
            mcToMCWMapRead.unlock();
        }
        return mcw;
    }
496056
private ScopeBlock findSynchronizedScopeBlock(ScopeBlock sb, int monitorEnterPC) {

        ScopeBlock monitorBlock = sb;

        if (sb.hasChildren()) {
            for (ScopeBlock child : sb.getChildren()) {
                if (child.isSync() && (child.getStart() > monitorBlock.getStart())) {
                    monitorBlock = child;
                    monitorBlock = findSynchronizedScopeBlock(monitorBlock, monitorEnterPC);
                }
            }
        }

        return monitorBlock;
    }
156130
@Nullable
    private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) {

        if ((pc <= sb.getStart()) || (pc >= sb.getFinish())) {
            return null;
        }

        List<ScopeBlock> children = sb.getChildren();
        if (children != null) {
            for (ScopeBlock child : children) {
                ScopeBlock foundSb = findScopeBlock(child, pc);
                if (foundSb != null) {
                    return foundSb;
                }
            }
        }
        return sb;
    }
840141
public static Object call(PageContext pc) throws PageException {
	Component ac = pc.getActiveComponent();
	if (ac != null) {
	    return call(pc, ac);
	}

	return new StructImpl();
    }
973696
function (scope, key) {
                    if (!key) {
                        key = scope;
                        scope = this;
                    }

                    if (!key) {
                        return null;
                    }

                    var path;

                    // if we have a path object
                    if (_.isArray(key)) {
                        path = key;
                        // path element
                    } else if (_.isObject(key)) {
                        path = [key];
                    } else {
                        path = Parser.parse(key, RULE_PATH);
                    }

                    var pathElement, val,
                        parameters, fnc,
                        newParameters;
                    for (var j = 0; j < path.length; j++) {
                        if (scope == null) {
                            return undefined;
                        } else {
                            pathElement = path[j];
                            if (pathElement.type == "fnc") {
                                fnc = scope[pathElement.name];
                                parameters = pathElement.parameter;
                                newParameters = [];
                                for (var i = 0; i < parameters.length; i++) {
                                    var param = parameters[i];

                                    if (_.isArray(param)) {
                                        param = this.get(param);
                                    } else if (_.isObject(param) && param.type && param.path) {
                                        param = this.get(param.path);
                                    }
                                    newParameters.push(param);
                                }
                                scope = fnc.apply(scope, newParameters);
                            } else if (pathElement.type == "var") {
                                if (scope instanceof Bindable) {
                                    if (path.length - 1 === j) {
                                        val = scope.$[pathElement.name];
                                        if (_.isUndefined(val)) {
                                            val = scope[pathElement.name];
                                        }
                                        scope = val;
                                    } else {
                                        scope = scope.get(pathElement.name);
                                    }

                                } else {
                                    scope = scope[pathElement.name];
                                }
                            }

                            if (scope && pathElement.index != null) {
                                // if it's an array
                                if (_.isArray(scope)) {
                                    scope = scope[pathElement.index];
                                    // if it's a list
                                } else if (scope.at) {
                                    scope = scope.at(pathElement.index);
                                }
                            }
                        }
                    }
                    return scope;
                }
250728
@Override
    public CompletableFuture<Map<String, StreamConfiguration>> listStreamsInScope(final String scopeName) {
        return getScope(scopeName).listStreamsInScope().thenCompose(streams -> {
            HashMap<String, CompletableFuture<Optional<StreamConfiguration>>> result = new HashMap<>();
            for (String s : streams) {
                Stream stream = getStream(scopeName, s, null);
                result.put(stream.getName(), 
                        Futures.exceptionallyExpecting(stream.getConfiguration(), 
                                e -> e instanceof StoreException.DataNotFoundException, 
                                null)
                        .thenApply(Optional::ofNullable));
            }
            return Futures.allOfWithResults(result)
                    .thenApply(x -> {
                        return x.entrySet().stream().filter(y -> y.getValue().isPresent())
                         .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get()));
                    });
        });
    }
7465
private ZooPC checkObjectForRefresh(Object pc) {
        if (!(pc instanceof ZooPC)) {
        	throw DBLogger.newUser("The object is not persistent capable: " + pc.getClass());
        }
        
        ZooPC pci = (ZooPC) pc;
        if (!pci.jdoZooIsPersistent()) {
        	return pci;
        }

        if (pci.jdoZooGetContext().getSession() != this) {
        	throw DBLogger.newUser("The object belongs to a different PersistenceManager.");
        }
        return pci;
	}
677580
public static boolean call(PageContext pc, double scope, String[] varNames) {
	return call(pc, scope, KeyImpl.toKeyArray(varNames));
    }
61126
private void sawLoad(int seen, int pc) {
        int reg = RegisterUtils.getLoadReg(this, seen);
        if (!ignoreRegs.get(reg)) {
            ScopeBlock sb = findScopeBlock(rootScopeBlock, pc);
            if (sb != null) {
                sb.addLoad(reg, pc);
            } else {
                ignoreRegs.set(reg);
            }
        }
    }