/** {@inheritDoc} */
  @Override
  public void requestInitialized(final ServletRequestEvent event) {
    final Object oldContext = ThreadSingletonServiceImpl.enter(this.webBeansContext);
    if (event != null) {
      event.getServletRequest().setAttribute(contextKey, oldContext);
    }

    try {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Starting a new request : [{0}]",
            event == null ? "null" : event.getServletRequest().getRemoteAddr());
      }

      if (webBeansContext instanceof WebappWebBeansContext) { // start before child
        ((WebappWebBeansContext) webBeansContext)
            .getParent()
            .getContextsService()
            .startContext(RequestScoped.class, event);
      }
      this.webBeansContext.getContextsService().startContext(RequestScoped.class, event);

      // we don't initialise the Session here but do it lazily if it gets requested
      // the first time. See OWB-457

    } catch (final Exception e) {
      logger.error(OWBLogConst.ERROR_0019, event == null ? "null" : event.getServletRequest());
      WebBeansUtil.throwRuntimeExceptions(e);
    }
  }
 @Override
 public void requestInitialized(ServletRequestEvent _sre) {
   _sre.getServletContext();
   _sre.getSource();
   //	  throw new UnsupportedOperationException("Not supported yet."); //To change body of
   // generated methods, choose Tools | Templates.
 }
Esempio n. 3
0
  @Override
  public void requestInitialized(ServletRequestEvent sre) {
    if (corePlugin.isStagemonitorActive()) {
      final MeasurementSession measurementSession = corePlugin.getMeasurementSession();
      if (measurementSession.getApplicationName() != null) {
        MDC.put("application", measurementSession.getApplicationName());
      }
      if (measurementSession.getHostName() != null) {
        MDC.put("host", measurementSession.getHostName());
      }
      String instanceName = measurementSession.getInstanceName();
      if (instanceName == null) {
        instanceName = sre.getServletRequest().getServerName();
      }
      MDC.put("instance", instanceName);

      final String requestId = UUID.randomUUID().toString();
      sre.getServletRequest().setAttribute(STAGEMONITOR_REQUEST_ID_ATTR, requestId);

      if (Stagemonitor.isStarted()) {
        // don't store the requestId in MDC if stagemonitor is not active
        // so that thread pools that get created on startup don't inherit the requestId
        MDC.put("requestId", requestId);
      }
    }
  }
  @Override
  public void requestInitialized(final ServletRequestEvent servletRequestEvent) {
    final HttpServletRequest httpServletRequest =
        (HttpServletRequest) servletRequestEvent.getServletRequest();

    if (Requests.searchEngineBotRequest(httpServletRequest)) {
      LOGGER.log(
          Level.DEBUG,
          "Request made from a search engine[User-Agent={0}]",
          httpServletRequest.getHeader("User-Agent"));
      httpServletRequest.setAttribute(Keys.HttpRequest.IS_SEARCH_ENGINE_BOT, true);
    } else {
      httpServletRequest.setAttribute(Keys.HttpRequest.IS_SEARCH_ENGINE_BOT, false);

      if (StaticResources.isStatic(httpServletRequest)) {
        return;
      }

      // Gets the session of this request
      final HttpSession session = httpServletRequest.getSession();
      LOGGER.log(
          Level.TRACE,
          "Gets a session[id={0}, remoteAddr={1}, User-Agent={2}, isNew={3}]",
          new Object[] {
            session.getId(),
            httpServletRequest.getRemoteAddr(),
            httpServletRequest.getHeader("User-Agent"),
            session.isNew()
          });
      // Online visitor count
      OptionQueryService.onlineVisitorCount(httpServletRequest);
    }
  }
Esempio n. 5
0
  @Override
  public void requestInitialized(ServletRequestEvent sre) {
    if (!(sre.getServletRequest() instanceof HttpServletRequest)) return;
    HttpServletRequest req = (HttpServletRequest) sre.getServletRequest();
    if (req.getSession(false) == null) {
      return;
    }

    // Only put attribute once.
    HttpSession session = req.getSession();
    if (session.getAttribute(ATT_NAME) != null) {
      return;
    }

    String ip = req.getRemoteAddr();
    // recheck if the attribute is still not there, and if so, put a temporarly attribute to prevent
    // duplicate session counting.
    synchronized (session) {
      if (session.getAttribute(ATT_NAME) != null) {
        return;
      }
      session.setAttribute(ATT_NAME, ip);
    }

    String hostName;

    try {
      hostName = InetAddress.getByName(ip).getHostName();
      int indexOfTld = hostName.lastIndexOf('.');
      if (indexOfTld != -1) {
        hostName = hostName.substring(indexOfTld + 1);
      }
      if (hostName.length() > SourceTldFilter.TLD_LENGTH_LIMIT) {
        hostName = hostName.substring(0, SourceTldFilter.TLD_LENGTH_LIMIT);
      }

      if (Character.isDigit(hostName.charAt(hostName.length() - 1))) {
        hostName = "-unresolved-";
      }
    } catch (Exception e) {
      hostName = "ERROR";
    }
    session.setAttribute(ATT_NAME, hostName);
    countCreatedSession(hostName);
  }
 @Override
 public void requestInitialized(ServletRequestEvent requestEvent) {
   // TODO Auto-generated method stub
   HttpServletRequest request = ((HttpServletRequest) requestEvent.getServletRequest());
   HttpSession session = request.getSession();
   String ipaddr = new APControl().getRequestIP(request);
   if (session.getAttribute("IPInSession") == null) {
     session.setAttribute("IPInSession", ipaddr);
   }
   // System.out.println("request created from " + ipaddr);
 }
Esempio n. 7
0
  @Override
  public void requestInitialized(final ServletRequestEvent evt) {
    final BoundRequestContext ctx = CDI.current().select(BoundRequestContext.class).get();
    final Map<String, Object> instanceMap = new HashMap<>();

    final ServletRequest req = evt.getServletRequest();
    req.setAttribute(CDI_CONTEXT, ctx);
    req.setAttribute(CDI_INSTANCE_MAP, instanceMap);

    ctx.associate(instanceMap);
    ctx.activate();
  }
Esempio n. 8
0
  @Override
  public void requestDestroyed(final ServletRequestEvent evt) {
    final ServletRequest req = evt.getServletRequest();

    @SuppressWarnings("unchecked")
    final Map<String, Object> instanceMap =
        (Map<String, Object>) req.getAttribute(CDI_INSTANCE_MAP);
    final BoundRequestContext ctx = (BoundRequestContext) req.getAttribute(CDI_CONTEXT);

    ctx.invalidate();
    ctx.deactivate();
    ctx.dissociate(instanceMap);

    req.removeAttribute(CDI_CONTEXT);
    req.removeAttribute(CDI_INSTANCE_MAP);
  }
 @Override
 public void requestInitialized(ServletRequestEvent arg0) {
   requestHolder.set((HttpServletRequest) arg0.getServletRequest());
 }
Esempio n. 10
0
 private String getConversationId(ServletRequestEvent event) {
   return event.getServletRequest().getParameter("cid");
 }
 /** @see ServletRequestListener#requestInitialized(ServletRequestEvent) */
 public void requestInitialized(ServletRequestEvent event) {
   ServletContext context = event.getServletContext();
   Integer num = (Integer) context.getAttribute("clickNum");
   context.setAttribute("clickNum", num + 1);
 }
Esempio n. 12
0
 /**
  * Request initialized.
  *
  * @param sre the sre
  */
 @Override
 public void requestInitialized(ServletRequestEvent sre) {
   ServletRequest request = sre.getServletRequest();
   Locale locale = LocaleManager.INSTANCE.resolveLocale(request);
   request.setAttribute("locale", locale);
 }
Esempio n. 13
0
 @Override
 public void requestInitialized(ServletRequestEvent sre) {
   sre.getServletContext().log("#####Request created#####");
 }
Esempio n. 14
0
 @Override
 public void requestDestroyed(ServletRequestEvent sre) {
   sre.getServletContext().log("#####Request destroyed#####");
 }
Esempio n. 15
0
 @Override
 public void requestInitialized(ServletRequestEvent servletRequestEvent) {
   reqProvider.setServletRequest(servletRequestEvent.getServletRequest());
 }