Пример #1
0
  @Override
  public void init(ServletConfig config) throws ServletException {
    super.init(config);

    SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(
        this, config.getServletContext());
  }
Пример #2
0
  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    if (backupService == null) {
      SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
    }

    String url = ((HttpServletRequest) request).getRequestURI();
    if (isBackupFinishJsonUrl(url)) {
      ((HttpServletResponse) response).setHeader("Cache-Control", "private, max-age=0, no-cache");
      ((HttpServletResponse) response).setDateHeader("Expires", 0);
      generateResponseForIsBackupFinishedAPI(response);
      return;
    }
    if (backupService.isBackingUp()) {
      ((HttpServletResponse) response).setHeader("Cache-Control", "private, max-age=0, no-cache");
      ((HttpServletResponse) response).setDateHeader("Expires", 0);
      if (isAPIUrl(url) && !isMessagesJson(url)) {
        generateAPIResponse(request, response);
      } else {
        generateHTMLResponse(response);
      }
    } else {
      chain.doFilter(request, response);
    }
  }
Пример #3
0
 public void execute(JobExecutionContext jobContext) throws JobExecutionException {
   SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
   JobKey jobKey = jobContext.getJobDetail().getKey();
   Long id = Long.parseLong(jobKey.getName());
   Event event = eventDAO.findById(id);
   MailService.sendMail(event, getRecipients(event));
   CronScheduler.removeJob(jobKey);
 }
Пример #4
0
  @Override
  public void init(ServletConfig config) throws ServletException {
    SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(
        this, config.getServletContext());

    ServletContext servletCtx = config.getServletContext();
    // 初始化路径
    // 保存文件的目录
    WORKPATH = servletCtx.getRealPath("/");
  }
  @Override
  public void execute(JobExecutionContext context) throws JobExecutionException {

    try {
      SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
      announcementManager.sendNotificationsJob(programId);
    } catch (Exception ex) {
      try {
        throw new Exception(
            "Error occurred send announcement notifications job from schedule task", ex);
      } catch (Exception ex1) {
        Logger.getLogger(sendAnnouncementEmailNotifications.class.getName())
            .log(Level.SEVERE, null, ex1);
      }
    }
  }
  @Override
  protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

    if (logger.isInfoEnabled()) {
      logger.info("PrepareVaccinationSMSRemindersForAllJob starting....");
    }
    int totalAlertsCreated = this.alertDAO.createVaccinationScheduleAlert();

    if (logger.isDebugEnabled()) {
      logger.debug("totalAlertsCreated : {}", totalAlertsCreated);
    }

    if (logger.isInfoEnabled()) {
      logger.info("PrepareVaccinationSMSRemindersForAllJob ended ....");
    }
  }
  @Override
  public void init(ServletConfig config) throws ServletException {
    try {
      SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(
          this, config.getServletContext());

      ConfigurationHelper.preConfigureConfigPathFromServletContext(config.getServletContext());
      // check if API is enabled
      String value = csDao.getConfigValue(ENABLE_S3_API);
      if (value != null) {
        isS3APIEnabled = Boolean.valueOf(value);
      }
      logger.info("S3Engine :: Configuration value is : " + value);

    } catch (Exception e) {
      throw new ServletException("Error initializing awsapi: " + e.getMessage());
    }
  }
  public void init(FilterConfig filterConfig) throws ServletException {
    boolean springHosted = Boolean.parseBoolean(filterConfig.getInitParameter("springHosted"));
    if (springHosted) {
      logger.info("using spring-hosted mode");
      SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
      logger.info("SessionFactory: " + sessionFactory);
      return;
    }

    // non-spring-hosted
    String sessionFactoryVal = filterConfig.getInitParameter("sessionFactory");
    if (sessionFactoryVal == null) {
      logger.info("sessionFactory param is not set, and default session factory is used");
      sessionFactory = new DefaultSessionFactory();
      return;
    }
    try {
      Class<?> sessionFactoryClz = Class.forName(sessionFactoryVal);
      // sessionFactory类需要包含一个带FilterConfig参数的构造函数或一个无参的构造函数
      try {
        Constructor<?> constructor = sessionFactoryClz.getConstructor(FilterConfig.class);
        sessionFactory = (SessionFactory) constructor.newInstance(filterConfig);
      } catch (NoSuchMethodException constructorNotFound) {
        try {
          Constructor<?> constructor = sessionFactoryClz.getConstructor();
          sessionFactory = (SessionFactory) constructor.newInstance();
        } catch (NoSuchMethodException e) {
          throw new ServletException(
              String.format(
                  "constructor %s() or %s(FilterConfig) is required",
                  sessionFactoryVal, sessionFactoryVal));
        }
      }

      logger.info("custom session using provider: " + sessionFactoryVal);
    } catch (ServletException e) {
      throw e;
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
Пример #9
0
  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
      throws Exception {
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
    //                request.getSession(true).setAttribute("newsList",
    // newsService.getNewsSorted());

    User user = new User();
    UserInformation userInfo = new UserInformation();
    user.setUserInformation(userInfo);
    request.setAttribute("user", user);
    try {
      List<News> newsList = newsService.getNewsSorted();

      request.setAttribute("newsList", newsList);
    } catch (NullPointerException e) {
      System.out.println("It is not working dafuq");
      System.out.println(e.fillInStackTrace());
    }
    //        request.setAttribute("newsList", newsService.getNewsSorted());

    //        System.out.println("Pre-handle");
    return true;
  }
Пример #10
0
 @PostConstruct
 public void init() {
   log.info("initializing Autowired Service.");
   SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
 }
 @PostConstruct
 public void postConstruct() {
   System.out.println("postconstruct has run.");
   SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
 }
 public void init(ServletConfig config) throws ServletException {
   super.init(config);
   SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
 }
Пример #13
0
 @Override
 public void init() throws ServletException {
   SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
 }
 @Override
 public void initialize(UniqueUserName constraintAnnotation) {
   SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
 }