Java tutorial
// <editor-fold defaultstate="collapsed"> /** * ***************************************************************************** * * KABILIRAVI LICENSE AGREEMENT FOR KAMAN SOLUTIONS * * IMPORTANT PLEASE READ THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT * CAREFULLY BEFORE CONTINUING USING KAMAN SOLUTIONS AS ANY KIND OF USER OR * DEVELOPER * * KABILIRAVI License Agreement is a legal agreement between you (either an * individual or a single entity) and Mr. Nasim Kabiliravi the creator and the * owner of Kaman Solutions known as "the owner of KAMAN" product known as KAMAN * in the rest of this licese agreement, for all the properties of Kaman * Solutions product which may include all pieces of software components, any * kind of source code, any knid of media, any kind of documentation and their * materials, all pieces of hardware components and their source codes and * schematics, documentations and media. * * * KAMAN is protected by copyright laws and international copyright treaties, as * well as other intellectual property laws and treaties. KAMAN is licensed, and * it is not sold. * DESCRIPTION RIGHTS AND LIMITATIONS 1. MAINTENANCE OF * COPYRIGHT NOTICES You must not remove or alter any copyright notices on any * parts of KAMAN. * * 2. DISTRIBUTION You may not distribute any parts of KAMAN to third parties. * Evaluation versions available for download from the owner of KAMAN's * websites. * * 3. PROHIBITION ON DECOMPILATION, DISASSEMBLY AND REVERSE ENGINEERING, You may * not decompile, disassemble or reverse engineer, any parts of KAMAN. * 4. * RENTAL You may not rent, lease, or lend any parts of KAMAN. * * 5. INSTALLATION AND USE You have the right to install and use copies of the * purchased parts of KAMAN on your computer running a validly licensed copy of * the operating system for which KAMAN was designed. * * 6. BACKUP COPIES You may also make copies of KAMAN as may be necessary for * backup and archival purposes. * * 7. SUPPORT SERVICES The owner of KAMAN may provide any support services * related to any parts of KAMAN. You may not provide any support services * without the terms, conditions and the contract between you and the owner of * KAMAN. * * 8. NO WARRANTIES The owner of KAMAN expressly disclaims any warranty for * KAMAN. KAMAN is provided 'As Is' without any express or implied warranty of * any kind, including but not limited to any warranties of merchantability, * noninfringement, or fitness of a particular purpose. KAMAN does not warrant * or assume responsibility for the accuracy or completeness of any information, * text, graphics, links or other items contained within KAMAN. The owner of * KAMAN makes no warranties respecting any harm that may be caused by the * transmission of a computer virus, worm, time bomb, logic bomb, or other such * computer program. The owner of KAMAN further expressly disclaims any warranty * or representation to Authorized Users or to any third party. * * 9. LIMITATION OF LIABILITY The owner of KAMAN shall have no liability with * respect to any parts of KAMAN, including but not limited to errors or * omissions contained therein, libel, infringements of rights of publicity, * privacy, trademark rights, business interruption, personal injury, loss of * privacy, moral rights or the disclosure of confidential information. In no * event will the owner of KAMAN be liable for loss of data or for indirect, * special, incidental, consequential (including lost profit), or other damages * based in contract, tort or otherwise. In no event shall the owner of KAMAN be * liable for any damages such as lost profits, business interruption, or lost * information even if the owener of KAMAN has been advised of the possibility * of such damages. * 10. TERMINATION The owner of KAMAN may terminate this * license agreement if you fail to comply with the terms and conditions of this * license agreement. In such event, you must destroy all parts of KAMAN in your * possession. * * 11. COPYRIGHT All title, including but not limited to copyrights, in and to * KAMAN and any parts of it are owned by Mr. Nasim Kabiliravi. All title and * intellectual property rights in and to the content which may be accessed * through use of KAMAN is the property of the respective content owner and may * be protected by applicable copyright or other intellectual property laws and * treaties. All rights not expressly granted are reserved by Mr. Nasim * Kabiliravi with following identification Begining of identification part * First Name: Nasim Last Name: Kabiliravi Sex: Male Birth Place: Abadan, IRAN, * Birth Date: January 14th, 1980 End of identification part * * 12. OWNER INFORMATION Please refer to the currenly official web site: * http://www.kabiliravi.com to have a contact for more information about Kaman * Solutions. * ****************************************************************************** */ // </editor-fold> package com.kabiliravi.kaman.web; import javax.servlet.FilterRegistration; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRegistration; import org.springframework.security.config.BeanIds; import org.springframework.web.WebApplicationInitializer; import org.springframework.web.context.ContextLoaderListener; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.request.RequestContextListener; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.filter.DelegatingFilterProxy; import org.springframework.web.servlet.DispatcherServlet; /** * * @author kabi */ public class KamanApplicationInitializer implements WebApplicationInitializer { @Override public void onStartup(final ServletContext servletContext) throws ServletException { registerDispatcherServlet(servletContext); registerSpringSecurityFilterChain(servletContext); } private void registerDispatcherServlet(final ServletContext servletContext) { WebApplicationContext dispatcherContext = createContext(WebMvcContextConfiguration.class); servletContext.addListener(new ContextLoaderListener(dispatcherContext)); servletContext.addListener(new RequestContextListener()); DispatcherServlet dispatcherServlet = new DispatcherServlet(dispatcherContext); ServletRegistration.Dynamic dispatcher; dispatcher = servletContext.addServlet("dispatcher", dispatcherServlet); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); } private WebApplicationContext createContext(final Class<?>... annotatedClasses) { AnnotationConfigWebApplicationContext context; context = new AnnotationConfigWebApplicationContext(); context.register(annotatedClasses); return context; } private void registerSpringSecurityFilterChain(ServletContext servletContext) { FilterRegistration.Dynamic springSecurityFilterChain = servletContext .addFilter(BeanIds.SPRING_SECURITY_FILTER_CHAIN, new DelegatingFilterProxy()); springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*"); } }