View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.controllers.apps;
12  
13  import org.apache.catalina.Context;
14  import org.slf4j.Logger;
15  import org.slf4j.LoggerFactory;
16  import org.springframework.security.core.Authentication;
17  import org.springframework.security.core.context.SecurityContextHolder;
18  
19  /**
20   * Reloads application context.
21   */
22  public class BaseReloadContextController extends AbstractNoSelfContextHandlerController {
23  
24    /** The Constant logger. */
25    private static final Logger logger = LoggerFactory.getLogger(BaseReloadContextController.class);
26  
27    @Override
28    protected void executeAction(String contextName) throws Exception {
29      Context context = getContainerWrapper().getTomcatContainer().findContext(contextName);
30      if (context != null) {
31        context.reload();
32  
33        // Logging action
34        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
35        // get username logger
36        String name = auth.getName();
37        logger.info(getMessageSourceAccessor().getMessage("probe.src.log.reload"), name, contextName);
38      }
39    }
40  
41  }