Java Code Examples for org.springframework.web.servlet.i18n.LocaleChangeInterceptor

The following are top voted examples for showing how to use org.springframework.web.servlet.i18n.LocaleChangeInterceptor. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: springboot-shiro-cas-mybatis   File: ClientActionTests.java   View source code 6 votes vote down vote up
@Test
public void verifyStartAuthentication() throws Exception {
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest();
    mockRequest.setParameter(ThemeChangeInterceptor.DEFAULT_PARAM_NAME, MY_THEME);
    mockRequest.setParameter(LocaleChangeInterceptor.DEFAULT_PARAM_NAME, MY_LOCALE);
    mockRequest.setParameter(CasProtocolConstants.PARAMETER_METHOD, MY_METHOD);

    final MockHttpSession mockSession = new MockHttpSession();
    mockRequest.setSession(mockSession);

    final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
    when(servletExternalContext.getNativeRequest()).thenReturn(mockRequest);

    final MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.setExternalContext(servletExternalContext);
    mockRequestContext.getFlowScope().put(CasProtocolConstants.PARAMETER_SERVICE,
            org.jasig.cas.services.TestUtils.getService(MY_SERVICE));

    final FacebookClient facebookClient = new FacebookClient(MY_KEY, MY_SECRET);
    final TwitterClient twitterClient = new TwitterClient(MY_KEY, MY_SECRET);
    final Clients clients = new Clients(MY_LOGIN_URL, facebookClient, twitterClient);
    final ClientAction action = new ClientAction();
    action.setCentralAuthenticationService(mock(CentralAuthenticationService.class));
    action.setClients(clients);

    final Event event = action.execute(mockRequestContext);
    assertEquals("error", event.getId());
    assertEquals(MY_THEME, mockSession.getAttribute(ThemeChangeInterceptor.DEFAULT_PARAM_NAME));
    assertEquals(MY_LOCALE, mockSession.getAttribute(LocaleChangeInterceptor.DEFAULT_PARAM_NAME));
    assertEquals(MY_METHOD, mockSession.getAttribute(CasProtocolConstants.PARAMETER_METHOD));
    final MutableAttributeMap flowScope = mockRequestContext.getFlowScope();
    final Map<String, String> urls = (Map<String, String>) flowScope.get(ClientAction.PAC4J_URLS);
    assertTrue((urls.get("Facebook"))
            .startsWith("https://www.facebook.com/v2.2/dialog/oauth?client_id=my_key&redirect_uri=http%3A%2F%2Fcasserver%2Flogin%3F"
                    + Clients.DEFAULT_CLIENT_NAME_PARAMETER + "%3DFacebookClient&state="));
    assertEquals(MY_LOGIN_URL + '?' + Clients.DEFAULT_CLIENT_NAME_PARAMETER
            + "=TwitterClient&needs_client_redirection=true", urls.get("Twitter"));
}
 
Example 2
Project: spring4-understanding   File: MvcNamespaceTests.java   View source code 6 votes vote down vote up
@Test
public void testBeanDecoration() throws Exception {
	loadBeanDefinitions("mvc-config-bean-decoration.xml", 16);

	RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
	assertNotNull(mapping);
	mapping.setDefaultHandler(handlerMethod);

	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");

	HandlerExecutionChain chain = mapping.getHandler(request);
	assertEquals(3, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
	assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
	assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
	LocaleChangeInterceptor interceptor = (LocaleChangeInterceptor) chain.getInterceptors()[1];
	assertEquals("lang", interceptor.getParamName());
	ThemeChangeInterceptor interceptor2 = (ThemeChangeInterceptor) chain.getInterceptors()[2];
	assertEquals("style", interceptor2.getParamName());
}
 
Example 3
Project: springfield   File: LocaleChangeFilter.java   View source code 6 votes vote down vote up
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {

		String newLocale = request.getParameter(LocaleChangeInterceptor.DEFAULT_PARAM_NAME);
		if(localeResolver != null && newLocale != null){
			Locale locale = StringUtils.parseLocaleString(newLocale);
	    	logger.warn("setLocale : "+locale.toString());
			localeResolver.setLocale(request, response, locale);
            LocaleContextHolder.setLocale(locale);
		}
		
        chain.doFilter(request, response);
        
        if (localeResolver != null) {
        	LocaleContextHolder.resetLocaleContext();
        }
    }
 
Example 4
Project: class-guard   File: MvcNamespaceTests.java   View source code 6 votes vote down vote up
@Test
public void testBeanDecoration() throws Exception {
	loadBeanDefinitions("mvc-config-bean-decoration.xml", 14);

	RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
	assertNotNull(mapping);
	mapping.setDefaultHandler(handlerMethod);

	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");

	HandlerExecutionChain chain = mapping.getHandler(request);
	assertEquals(3, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
	assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
	assertTrue(chain.getInterceptors()[2] instanceof ThemeChangeInterceptor);
	LocaleChangeInterceptor interceptor = (LocaleChangeInterceptor) chain.getInterceptors()[1];
	assertEquals("lang", interceptor.getParamName());
	ThemeChangeInterceptor interceptor2 = (ThemeChangeInterceptor) chain.getInterceptors()[2];
	assertEquals("style", interceptor2.getParamName());
}
 
Example 5
Project: springboot-shiro-cas-mybatis   File: ClientAction.java   View source code 5 votes vote down vote up
/**
 * Prepare the data for the login page.
 *
 * @param context The current webflow context
 */
protected void prepareForLoginPage(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    final HttpServletResponse response = WebUtils.getHttpServletResponse(context);
    final HttpSession session = request.getSession();

    // web context
    final WebContext webContext = new J2EContext(request, response);

    // save parameters in web session
    final WebApplicationService service = WebUtils.getService(context);
    logger.debug("save service: {}", service);
    session.setAttribute(CasProtocolConstants.PARAMETER_SERVICE, service);
    saveRequestParameter(request, session, ThemeChangeInterceptor.DEFAULT_PARAM_NAME);
    saveRequestParameter(request, session, LocaleChangeInterceptor.DEFAULT_PARAM_NAME);
    saveRequestParameter(request, session, CasProtocolConstants.PARAMETER_METHOD);

    final LinkedHashMap<String, String> urls = new LinkedHashMap<>();
    // for all clients, generate redirection urls
    for (final Client client : this.clients.findAllClients()) {
        final IndirectClient indirectClient = (IndirectClient) client;
        // clean Client suffix for default names
        final String name = client.getName().replace("Client", "");
        final String redirectionUrl = indirectClient.getRedirectionUrl(webContext);
        logger.debug("{} -> {}", name, redirectionUrl);
        urls.put(name, redirectionUrl);
    }
    context.getFlowScope().put(PAC4J_URLS, urls);
}
 
Example 6
Project: cas-5.1.0   File: CasManagementWebAppConfiguration.java   View source code 5 votes vote down vote up
@RefreshScope
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
    final LocaleChangeInterceptor bean = new LocaleChangeInterceptor();
    bean.setParamName(this.casProperties.getLocale().getParamName());
    return bean;
}
 
Example 7
Project: cas-5.1.0   File: CasWebflowContextConfiguration.java   View source code 5 votes vote down vote up
@RefreshScope
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
    final LocaleChangeInterceptor bean = new LocaleChangeInterceptor();
    bean.setParamName(this.casProperties.getLocale().getParamName());
    return bean;
}
 
Example 8
Project: cas-5.1.0   File: DelegatedClientAuthenticationActionTests.java   View source code 5 votes vote down vote up
@Test
public void verifyStartAuthentication() throws Exception {
    final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest();
    mockRequest.setParameter(ThemeChangeInterceptor.DEFAULT_PARAM_NAME, MY_THEME);
    mockRequest.setParameter(LocaleChangeInterceptor.DEFAULT_PARAM_NAME, MY_LOCALE);
    mockRequest.setParameter(CasProtocolConstants.PARAMETER_METHOD, MY_METHOD);

    final MockHttpSession mockSession = new MockHttpSession();
    mockRequest.setSession(mockSession);

    final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
    when(servletExternalContext.getNativeRequest()).thenReturn(mockRequest);
    when(servletExternalContext.getNativeResponse()).thenReturn(mockResponse);

    final MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.setExternalContext(servletExternalContext);
    mockRequestContext.getFlowScope().put(CasProtocolConstants.PARAMETER_SERVICE,
            RegisteredServiceTestUtils.getService(MY_SERVICE));

    final FacebookClient facebookClient = new FacebookClient(MY_KEY, MY_SECRET);
    final TwitterClient twitterClient = new TwitterClient("3nJPbVTVRZWAyUgoUKQ8UA", "h6LZyZJmcW46Vu8R47MYfeXTSYGI30EqnWaSwVhFkbA");
    final Clients clients = new Clients(MY_LOGIN_URL, facebookClient, twitterClient);
    final DelegatedClientAuthenticationAction action = new DelegatedClientAuthenticationAction(clients,
            null, mock(CentralAuthenticationService.class),
            "theme", "locale", false);

    final Event event = action.execute(mockRequestContext);
    assertEquals("error", event.getId());
    assertEquals(MY_THEME, mockSession.getAttribute(ThemeChangeInterceptor.DEFAULT_PARAM_NAME));
    assertEquals(MY_LOCALE, mockSession.getAttribute(LocaleChangeInterceptor.DEFAULT_PARAM_NAME));
    assertEquals(MY_METHOD, mockSession.getAttribute(CasProtocolConstants.PARAMETER_METHOD));
    final MutableAttributeMap flowScope = mockRequestContext.getFlowScope();
    final Set<DelegatedClientAuthenticationAction.ProviderLoginPageConfiguration> urls =
            (Set<DelegatedClientAuthenticationAction.ProviderLoginPageConfiguration>) flowScope.get(DelegatedClientAuthenticationAction.PAC4J_URLS);

    assertFalse(urls.isEmpty());
    assertSame(2, urls.size());
}
 
Example 9
Project: TARA-Server   File: CasWebflowContextConfiguration.java   View source code 5 votes vote down vote up
@RefreshScope
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
    LocaleChangeInterceptor bean = new LocaleChangeInterceptor();
    bean.setParamName(this.casProperties.getLocale().getParamName());
    return bean;
}
 
Example 10
Project: cas-server-4.2.1   File: ClientAction.java   View source code 5 votes vote down vote up
/**
 * Prepare the data for the login page.
 *
 * @param context The current webflow context
 */
protected void prepareForLoginPage(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    final HttpServletResponse response = WebUtils.getHttpServletResponse(context);
    final HttpSession session = request.getSession();

    // web context
    final WebContext webContext = new J2EContext(request, response);

    // save parameters in web session
    final WebApplicationService service = WebUtils.getService(context);
    logger.debug("save service: {}", service);
    session.setAttribute(CasProtocolConstants.PARAMETER_SERVICE, service);
    saveRequestParameter(request, session, ThemeChangeInterceptor.DEFAULT_PARAM_NAME);
    saveRequestParameter(request, session, LocaleChangeInterceptor.DEFAULT_PARAM_NAME);
    saveRequestParameter(request, session, CasProtocolConstants.PARAMETER_METHOD);

    final LinkedHashMap<String, String> urls = new LinkedHashMap<>();
    // for all clients, generate redirection urls
    for (final Client client : this.clients.findAllClients()) {
        final IndirectClient indirectClient = (IndirectClient) client;
        // clean Client suffix for default names
        final String name = client.getName().replace("Client", "");
        final String redirectionUrl = indirectClient.getRedirectionUrl(webContext);
        logger.debug("{} -> {}", name, redirectionUrl);
        urls.put(name, redirectionUrl);
    }
    context.getFlowScope().put(PAC4J_URLS, urls);
}
 
Example 11
Project: cas-server-4.2.1   File: ClientActionTests.java   View source code 5 votes vote down vote up
@Test
public void verifyStartAuthentication() throws Exception {
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest();
    mockRequest.setParameter(ThemeChangeInterceptor.DEFAULT_PARAM_NAME, MY_THEME);
    mockRequest.setParameter(LocaleChangeInterceptor.DEFAULT_PARAM_NAME, MY_LOCALE);
    mockRequest.setParameter(CasProtocolConstants.PARAMETER_METHOD, MY_METHOD);

    final MockHttpSession mockSession = new MockHttpSession();
    mockRequest.setSession(mockSession);

    final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
    when(servletExternalContext.getNativeRequest()).thenReturn(mockRequest);

    final MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.setExternalContext(servletExternalContext);
    mockRequestContext.getFlowScope().put(CasProtocolConstants.PARAMETER_SERVICE,
            org.jasig.cas.services.TestUtils.getService(MY_SERVICE));

    final FacebookClient facebookClient = new FacebookClient(MY_KEY, MY_SECRET);
    final TwitterClient twitterClient = new TwitterClient(MY_KEY, MY_SECRET);
    final Clients clients = new Clients(MY_LOGIN_URL, facebookClient, twitterClient);
    final ClientAction action = new ClientAction();
    action.setCentralAuthenticationService(mock(CentralAuthenticationService.class));
    action.setClients(clients);

    final Event event = action.execute(mockRequestContext);
    assertEquals("error", event.getId());
    assertEquals(MY_THEME, mockSession.getAttribute(ThemeChangeInterceptor.DEFAULT_PARAM_NAME));
    assertEquals(MY_LOCALE, mockSession.getAttribute(LocaleChangeInterceptor.DEFAULT_PARAM_NAME));
    assertEquals(MY_METHOD, mockSession.getAttribute(CasProtocolConstants.PARAMETER_METHOD));
    final MutableAttributeMap flowScope = mockRequestContext.getFlowScope();
    final Map<String, String> urls = (Map<String, String>) flowScope.get(ClientAction.PAC4J_URLS);
    assertTrue((urls.get("Facebook"))
            .startsWith("https://www.facebook.com/v2.2/dialog/oauth?client_id=my_key&redirect_uri=http%3A%2F%2Fcasserver%2Flogin%3F"
                    + Clients.DEFAULT_CLIENT_NAME_PARAMETER + "%3DFacebookClient&state="));
    assertEquals(MY_LOGIN_URL + '?' + Clients.DEFAULT_CLIENT_NAME_PARAMETER
            + "=TwitterClient&needs_client_redirection=true", urls.get("Twitter"));
}
 
Example 12
Project: spring-boot-slingshot   File: WebMvcConfig.java   View source code 5 votes vote down vote up
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
   LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
   lci.setParamName("lang");

   return lci;
}
 
Example 13
Project: simple-hostel-management   File: SpringConfiguration.java   View source code 5 votes vote down vote up
/**
 * Set up locale configuration by url parameter
 *
 * @return
 */
@Bean
public LocaleChangeInterceptor localeInterceptor() {
    LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
    interceptor.setParamName(LANG_PARAMETER_NAME);
    return interceptor;
}
 
Example 14
Project: simple-hostel-management   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
/**
 * Set up locale configuration by url parameter
 *
 * @return
 */
@Bean
public LocaleChangeInterceptor localeInterceptor() {
    LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
    interceptor.setParamName("lang");
    return interceptor;
}
 
Example 15
Project: wolf   File: LocaleConfig.java   View source code 5 votes vote down vote up
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
    LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
    // 参数名
    lci.setParamName("lang");
    return lci;
}
 
Example 16
Project: judge   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("lang");
    localeChangeInterceptor.setIgnoreInvalidLocale(true);
    localeChangeInterceptor.setLanguageTagCompliant(true);
    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 17
Project: spring4-understanding   File: MvcNamespaceTests.java   View source code 5 votes vote down vote up
@Test
public void testInterceptors() throws Exception {
	loadBeanDefinitions("mvc-config-interceptors.xml", 21);

	RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
	assertNotNull(mapping);
	mapping.setDefaultHandler(handlerMethod);

	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
	request.setRequestURI("/accounts/12345");
	request.addParameter("locale", "en");
	request.addParameter("theme", "green");

	HandlerExecutionChain chain = mapping.getHandler(request);
	assertEquals(5, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
	assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
	assertTrue(chain.getInterceptors()[2] instanceof WebRequestHandlerInterceptorAdapter);
	assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);
	assertTrue(chain.getInterceptors()[4] instanceof UserRoleAuthorizationInterceptor);

	request.setRequestURI("/admin/users");
	chain = mapping.getHandler(request);
	assertEquals(3, chain.getInterceptors().length);

	request.setRequestURI("/logged/accounts/12345");
	chain = mapping.getHandler(request);
	assertEquals(5, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter);

	request.setRequestURI("/foo/logged");
	chain = mapping.getHandler(request);
	assertEquals(5, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter);
}
 
Example 18
Project: spring4-understanding   File: CookieAssertionTests.java   View source code 5 votes vote down vote up
@Before
public void setup() {
	CookieLocaleResolver localeResolver = new CookieLocaleResolver();
	localeResolver.setCookieDomain("domain");

	this.mockMvc = standaloneSetup(new SimpleController())
			.addInterceptors(new LocaleChangeInterceptor())
			.setLocaleResolver(localeResolver)
			.defaultRequest(get("/").param("locale", "en_US"))
			.alwaysExpect(status().isOk())
			.build();
}
 
Example 19
Project: generator-spring-spa   File: WebMvcConfig.java   View source code 5 votes vote down vote up
/**
 * Change Language from Url
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
    LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
    interceptor.setParamName("language"); // Url to change url be ?language=en
    registry.addInterceptor(interceptor);
}
 
Example 20
Project: castlemock   File: MvcConfig.java   View source code 5 votes vote down vote up
/**
 * The method handlerMapping is responsbile for creating and configuring the locale change interceptor
 * @return A new request mapping handler mapping
 */
@Bean
public HandlerMapping handlerMapping() {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");
    final RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setInterceptors(new Object[] { localeChangeInterceptor });
    return requestMappingHandlerMapping;
}
 
Example 21
Project: psi-probe   File: ProbeConfig.java   View source code 5 votes vote down vote up
/**
 * Gets the bean name url handler mapping.
 *
 * @param interceptor the interceptor
 * @return the bean name url handler mapping
 */
@Bean(name = "handlerMapping")
public HandlerMapping getHandlerMapping(@Autowired LocaleChangeInterceptor interceptor) {
  logger.debug("Instantiated beanNameUrlHandlerMapping");
  BeanNameUrlHandlerMapping mapping = new BeanNameUrlHandlerMapping();
  mapping.setAlwaysUseFullPath(true);
  mapping.setInterceptors(interceptor);
  return mapping;
}
 
Example 22
Project: psi-probe   File: ProbeConfig.java   View source code 5 votes vote down vote up
/**
 * Gets the locale change interceptor.
 *
 * @return the locale change interceptor
 */
@Bean(name = "localeChangeInterceptor")
public LocaleChangeInterceptor getLocaleChangeInterceptor() {
  logger.debug("Instantiated localeChangeInterceptor");
  LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
  interceptor.setParamName("lang");
  return interceptor;
}
 
Example 23
Project: jittrackGTS   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 24
Project: droidlinguist   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry)
{
	LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
	localeChangeInterceptor.setParamName("language");
	registry.addInterceptor(localeChangeInterceptor);
}
 
Example 25
Project: EasyEE   File: InterceptorConfiguration.java   View source code 5 votes vote down vote up
/**
 * Interceptors
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
	
	// Log HandlerInterceptor
	LogInterceptor logInterceptor=new LogInterceptor();
	logInterceptor.setSysLogService(sysLogService); // 手动注入
	registry.addInterceptor(logInterceptor).addPathPatterns("/**");

	// I18N HandlerInterceptor
	LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
	localeChangeInterceptor.setParamName("lang");
	registry.addInterceptor(localeChangeInterceptor).addPathPatterns("/**");
	super.addInterceptors(registry);
}
 
Example 26
Project: EasyEE   File: InterceptorConfiguration.java   View source code 5 votes vote down vote up
/**
 * Interceptors
 */
@Override
public void addInterceptors(InterceptorRegistry registry) {
	
	// Log HandlerInterceptor
	LogInterceptor logInterceptor=new LogInterceptor();
	logInterceptor.setSysLogService(sysLogService); // 手动注入
	registry.addInterceptor(logInterceptor).addPathPatterns("/**");

	// I18N HandlerInterceptor
	LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
	localeChangeInterceptor.setParamName("lang");
	registry.addInterceptor(localeChangeInterceptor).addPathPatterns("/**");
	super.addInterceptors(registry);
}
 
Example 27
Project: ithings-demo   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 28
Project: agate   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
  LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
  localeChangeInterceptor.setParamName("language");

  registry.addInterceptor(localeChangeInterceptor);
}
 
Example 29
Project: JQuaternion   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 30
Project: lightadmin-jhipster   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 31
Project: class-guard   File: CookieAssertionTests.java   View source code 5 votes vote down vote up
@Before
public void setup() {
	CookieLocaleResolver localeResolver = new CookieLocaleResolver();
	localeResolver.setCookieDomain("domain");

	this.mockMvc = standaloneSetup(new SimpleController())
			.addInterceptors(new LocaleChangeInterceptor())
			.setLocaleResolver(localeResolver)
			.defaultRequest(get("/").param("locale", "en_US"))
			.alwaysExpect(status().isOk())
			.build();
}
 
Example 32
Project: class-guard   File: MvcNamespaceTests.java   View source code 5 votes vote down vote up
@Test
public void testInterceptors() throws Exception {
	loadBeanDefinitions("mvc-config-interceptors.xml", 17);

	RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
	assertNotNull(mapping);
	mapping.setDefaultHandler(handlerMethod);

	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
	request.setRequestURI("/accounts/12345");
	request.addParameter("locale", "en");
	request.addParameter("theme", "green");

	HandlerExecutionChain chain = mapping.getHandler(request);
	assertEquals(4, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor);
	assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor);
	assertTrue(chain.getInterceptors()[2] instanceof WebRequestHandlerInterceptorAdapter);
	assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor);

	request.setRequestURI("/admin/users");
	chain = mapping.getHandler(request);
	assertEquals(3, chain.getInterceptors().length);

	request.setRequestURI("/logged/accounts/12345");
	chain = mapping.getHandler(request);
	assertEquals(5, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter);

	request.setRequestURI("/foo/logged");
	chain = mapping.getHandler(request);
	assertEquals(5, chain.getInterceptors().length);
	assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter);
}
 
Example 33
Project: iobrew   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 34
Project: mvc-spring-hibernate   File: WebConfig.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {

	LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
	localeChangeInterceptor.setParamName("lang");
	registry.addInterceptor(localeChangeInterceptor);
}
 
Example 35
Project: alv-ch-sysinfos.api   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 36
Project: MLDS   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 37
Project: mica2   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
  LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
  localeChangeInterceptor.setParamName("language");

  registry.addInterceptor(localeChangeInterceptor);
}
 
Example 38
Project: spring4probe   File: WebConfig.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry)
{

    LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("lang");
    registry.addInterceptor(localeChangeInterceptor);
}
 
Example 39
Project: InSpider   File: AdminWebMvcConfig.java   View source code 5 votes vote down vote up
public @Bean LocaleChangeInterceptor localeChangeInterceptor () {
	if (this.localeChangeInterceptor == null) {
		this.localeChangeInterceptor = new LocaleChangeInterceptor ();
		
		localeChangeInterceptor.setParamName ("lang");
	}
	
	return this.localeChangeInterceptor;
}
 
Example 40
Project: jittrackGTS   File: LocaleConfiguration.java   View source code 5 votes vote down vote up
@Override
public void addInterceptors(InterceptorRegistry registry) {
    final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
    localeChangeInterceptor.setParamName("language");

    registry.addInterceptor(localeChangeInterceptor);
}