com.stormpath.spring.mvc.MessageContextRegistrar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stormpath-spring-webmvc Show documentation
Show all versions of stormpath-spring-webmvc Show documentation
Web MVC support for Stormpath-enabled Spring applications.
package com.stormpath.spring.mvc;
import com.stormpath.sdk.lang.Assert;
import com.stormpath.sdk.servlet.i18n.MessageContext;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import javax.servlet.ServletContext;
/**
* @since 1.0.0
*/
public class MessageContextRegistrar implements InitializingBean, DisposableBean {
private final MessageContext messageContext;
private final ServletContext servletContext;
public MessageContextRegistrar(MessageContext messageContext, ServletContext servletContext) {
Assert.notNull(messageContext, "MessageContext cannot be null.");
Assert.notNull(servletContext, "ServletContext cannot be null.");
this.messageContext = messageContext;
this.servletContext = servletContext;
}
@Override
public void afterPropertiesSet() throws Exception {
servletContext.setAttribute(MessageContext.class.getName(), messageContext);
}
@Override
public void destroy() throws Exception {
servletContext.removeAttribute(MessageContext.class.getName());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy