Stores the given controller in the given request (using a request attribute).<p>

@param req the request where to store the controller in
@param controller the controller to store
764910
public static void setController(ServletRequest req, CmsFlexController controller) {

        req.setAttribute(CmsFlexController.ATTRIBUTE_NAME, controller);
    }
251615
public void connect(String controller, String username, char[] password) {
        connect(controller, username, password, null);
    }
133211
protected void maybeBuildAndSetRetryManager(AbstractDraweeController controller) {
    if (!mTapToRetryEnabled) {
      return;
    }
    controller.getRetryManager().setTapToRetryEnabled(mTapToRetryEnabled);
    maybeBuildAndSetGestureDetector(controller);
  }
540205
public function initialize(Controller $controller) {
        if ($controller->request->is('ajax')) {
            Configure::write('debug', 0);

            // Must disable security component for AJAX
            if (isset($controller->Security)) {
                $controller->Security->validatePost = false;
                $controller->Security->csrfCheck = false;
            }

            // If not from this domain, destroy
            if (!$this->allowRemote && (strpos(env('HTTP_REFERER'), trim(env('HTTP_HOST'), '/')) === false)) {
                if (isset($controller->Security)) {
                    $controller->Security->blackHole($controller, 'Invalid referrer detected for this request.');
                } else {
                    $controller->redirect(null, 403, true);
                }
            }
        }

        $this->controller = $controller;
    }
313139
public T locateLayoutTemplate(String controller, final String layout, final boolean useCache) throws ViewException {
        // first see if we have already looked for the template
        final String controllerLayoutCombined = controller + '/' + layout;
        if (useCache && cachedTemplates.containsKey(controllerLayoutCombined)) 
            return engine.clone(cachedTemplates.get(controllerLayoutCombined)); // README: computeIfAbsent does not save the result if null - which it actually might need to do to minimise disk reads
        
        
        T template;
        if ((template = lookupLayoutWithNonDefaultName(controllerLayoutCombined)) != null) 
            return cacheTemplate(controllerLayoutCombined, template, useCache);
        
        // going for defaults
        if ((template = lookupDefaultLayoutInControllerPathChain(controller)) != null) 
            return cacheTemplate(controllerLayoutCombined, template, useCache);
        
        if ((template = lookupDefaultLayout()) != null) 
            return cacheTemplate(controllerLayoutCombined, template, useCache);
        
        throw new ViewException(TemplateEngine.LAYOUT_DEFAULT + engine.getSuffixOfTemplatingEngine() + " is not to be found anywhere");
    }
910072
public boolean usesSecureSite(HttpServletRequest req) {

        CmsSite site = matchRequest(req);
        if (site == null) {
            return false;
        }
        CmsSiteMatcher secureMatcher = site.getSecureServerMatcher();
        boolean result = false;
        if (secureMatcher != null) {
            result = secureMatcher.equals(getRequestMatcher(req));
        }
        return result;
    }
1298722
public void releaseRequest(HttpRequestMessageImpl request) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "releaseRequest: " + request);
        }
        this.reqPool.put(request);
    }
731535
protected void addRequestHandler(I_CmsRequestHandler handler) {

        if (handler == null) {
            return;
        }
        String[] names = handler.getHandlerNames();
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            if (m_requestHandlers.get(name) != null) {
                CmsLog.INIT.error(Messages.get().getBundle().key(Messages.LOG_DUPLICATE_REQUEST_HANDLER_1, name));
                continue;
            }
            m_requestHandlers.put(name, handler);
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(
                    Messages.get().getBundle().key(
                        Messages.INIT_ADDED_REQUEST_HANDLER_2,
                        name,
                        handler.getClass().getName()));
            }
        }
    }
1027194
public static void bind(HttpServletRequest request) {
        if (request != null && threadLocal.get() != null) {
            throw new IllegalStateException("HttpServletRequestHolder.bind() called for a "
                    + "thread that already has a request associated with it. It's likely that the request "
                    + "was not correctly removed from the thread before it is put back into the thread pool.");
        }
        threadLocal.set(request);
    }
549216
public Controller getController(JsonPath jsonPath, String method) {
		for (Controller controller : controllers) {
			if (controller.isAcceptable(jsonPath, method)) {
				LOGGER.debug("using controller {}", controller);
				return controller;
			}
		}
		throw new BadRequestException(jsonPath + " with method " + method);
	}
12075
@SuppressWarnings("unchecked")
  private void handleRequest(long requestId, Object request) {
    HandlerHolder holder = handlers.get(request.getClass());
    if (holder == null) {
      connection.handleResponseError(requestId, new ConnectException("no handler registered"));
      return;
    }

    Function<Object, CompletableFuture<Object>> handler = (Function<Object, CompletableFuture<Object>>) holder.handler;

    try {
      holder.context.executor().execute(() -> {
        if (open && connection.open) {
          CompletableFuture<Object> responseFuture = handler.apply(request);
          if (responseFuture != null) {
            responseFuture.whenComplete((response, error) -> {
              if (!open || !connection.open) {
                connection.handleResponseError(requestId, new ConnectException("connection closed"));
              } else if (error == null) {
                connection.handleResponseOk(requestId, response);
              } else {
                connection.handleResponseError(requestId, error);
              }
            });
          }
        } else {
          connection.handleResponseError(requestId, new ConnectException("connection closed"));
        }
      });
    } catch (RejectedExecutionException e) {
      connection.handleResponseError(requestId, new ConnectException("connection closed"));
    }
  }
617857
def _send_request_to_controller(self, request):
        
        tries = 2  # in case our cached self._controller_id is outdated
        while tries:
            tries -= 1
            response = self._send_request_to_node(self._controller_id, request)
            # In Java, the error fieldname is inconsistent:
            #  - CreateTopicsResponse / CreatePartitionsResponse uses topic_errors
            #  - DeleteTopicsResponse uses topic_error_codes
            # So this is a little brittle in that it assumes all responses have
            # one of these attributes and that they always unpack into
            # (topic, error_code) tuples.
            topic_error_tuples = (response.topic_errors if hasattr(response, 'topic_errors')
                else response.topic_error_codes)
            # Also small py2/py3 compatibility -- py3 can ignore extra values
            # during unpack via: for x, y, *rest in list_of_values. py2 cannot.
            # So for now we have to map across the list and explicitly drop any
            # extra values (usually the error_message)
            for topic, error_code in map(lambda e: e[:2], topic_error_tuples):
                error_type = Errors.for_code(error_code)
                if tries and error_type is NotControllerError:
                    # No need to inspect the rest of the errors for
                    # non-retriable errors because NotControllerError should
                    # either be thrown for all errors or no errors.
                    self._refresh_controller_id()
                    break
                elif error_type is not Errors.NoError:
                    raise error_type(
                        "Request '{}' failed with response '{}'."
                        .format(request, response))
            else:
                return response
        raise RuntimeError("This should never happen, please file a bug with full stacktrace if encountered")
287572
public function persistData(Request $request, $controller)
    {
        if (null === ($repository = $request->get('repository', null)) || $this->isRoutedFromHome($request)) {
            return;
        }
        $referer = $request->headers->get('referer');

        $this->client->incrementTotalAccess();
        $this->client->incrementRepositoryAccess($repository);
        $this->client->addRepositoryToLatestAccessed($repository);
        $this->client->incrementRepositoryAccessType($repository, $controller);
        if ($referer) {
            $this->client->addReferer($referer);
        }

        return true;
    }
1234203
public void setController(Object object, GraphicsController controller) {
		// set them all
		doSetController(getGroup(object), controller, Event.MOUSEEVENTS | Event.ONDBLCLICK | Event.ONMOUSEWHEEL);
	}
535339
public static function execute($controller, $request) {   
        switch($request->method()) { 
            case 'POST':
                $data = $controller->store($request->bodyRequest());
                KernelHttp::makeResponse('201', $data);
                break;
            case 'PUT':
                $data = $controller->update($request->bodyRequest());
                KernelHttp::makeResponse('200', $data);
                break;
            case 'DELETE':
                $controller->destroy($request->getInteractionsRequest());
                KernelHttp::makeResponse('200');
                break;
            default: 
                $request->getRequiredParameter() ? $data = $controller->show($request->getInteractionsRequest()) : $data = $controller->index($request->getInteractionsRequest()); 
                KernelHttp::makeResponse('200', $data);
                break;
        } 
    }
1089726
function(controller, qp) {
        var value = get(controller, qp.prop);
        qp.svalue = this.serializeQueryParam(value, qp.urlKey, qp.type);
      }
967327
public static void clearSession(HttpServletRequest req) {
		SecurityContextHolder.clearContext();
		if (req != null) {
			HttpSession session = req.getSession(false);
			if (session != null) {
				session.invalidate();
			}
		}
	}