View Javadoc

1   /*
2    * Copyright 2010 James Pether Sörling
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   *	$Id$
17   *  $HeadURL$
18  */
19  package com.hack23.cia.web.impl.ui.common;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  import org.springframework.context.ApplicationEvent;
27  import org.springframework.context.ApplicationListener;
28  import org.springframework.context.annotation.Configuration;
29  import org.springframework.jmx.export.annotation.ManagedAttribute;
30  import org.springframework.jmx.export.annotation.ManagedOperation;
31  import org.springframework.jmx.export.annotation.ManagedResource;
32  import org.springframework.web.servlet.ModelAndView;
33  import org.springframework.web.servlet.mvc.AbstractController;
34  
35  /**
36   * The Class SecurityControllerImpl.
37   */
38  @ManagedResource(objectName = "Configuration:name=securityController")
39  @Configuration(value="securityController")
40  public class SecurityControllerImpl extends AbstractController implements SecurityController,ApplicationListener<ApplicationEvent>  {
41  
42  	/** The Constant LOGGER. */
43  	private final static Logger LOGGER = LoggerFactory
44  	.getLogger(SecurityControllerImpl.class);
45  
46      /** The opened. */
47      private boolean opened = true;
48  
49      /**
50  	 * Close.
51  	 */
52      @ManagedOperation
53      public void close() {
54          opened = false;
55      }
56  
57      /**
58  	 * Checks if is opened.
59  	 *
60  	 * @return true, if is opened
61  	 */
62      @ManagedAttribute
63      public boolean isOpened() {
64          return opened;
65      }
66  
67      /**
68  	 * Open.
69  	 */
70      @ManagedOperation
71      public void open() {
72          opened = true;
73      }
74  
75  	/* (non-Javadoc)
76  	 * @see com.hack23.cia.web.impl.ui.common.SecurityController#verifyRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
77  	 */
78  	@Override
79  	public void verifyRequest(final HttpServletRequest request,
80  			final HttpServletResponse response) throws Exception {
81  	}
82  
83  	/* (non-Javadoc)
84  	 * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
85  	 */
86  	@Override
87  	protected ModelAndView handleRequestInternal(final HttpServletRequest request,
88  			final HttpServletResponse response) throws Exception {
89  		LOGGER.info(request.toString());
90          return null;
91  	}
92  
93  	/* (non-Javadoc)
94  	 * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
95  	 */
96  	@Override
97  	public void onApplicationEvent(final ApplicationEvent event) {
98  		LOGGER.info(event.toString());
99  	}
100 
101 }