use of javax.servlet.ServletContext in project atmosphere by Atmosphere.
the class AtmosphereFilter method init.
/**
* Initialize the {@link Filter}.
*
* @param filterConfig The {@link javax.servlet.FilterConfig}
* @throws ServletException
*/
public void init(final FilterConfig filterConfig) throws ServletException {
logger.info("AtmosphereServlet running as a Filter");
as.init(new ServletConfig() {
@Override
public String getServletName() {
return filterConfig.getFilterName();
}
@Override
public ServletContext getServletContext() {
return filterConfig.getServletContext();
}
@Override
public String getInitParameter(String name) {
return filterConfig.getInitParameter(name);
}
@Override
public Enumeration<String> getInitParameterNames() {
return filterConfig.getInitParameterNames();
}
});
String s = filterConfig.getInitParameter(ApplicationConfig.ATMOSPHERE_EXCLUDED_FILE);
if (s != null) {
excluded = s;
}
}
use of javax.servlet.ServletContext in project atmosphere by Atmosphere.
the class DefaultAnnotationProcessor method configure.
@Override
public void configure(final AtmosphereConfig config) {
ServletContext sc = config.framework().getServletContext();
Map<Class<? extends Annotation>, Set<Class<?>>> annotations = (Map<Class<? extends Annotation>, Set<Class<?>>>) sc.getAttribute(ANNOTATION_ATTRIBUTE);
sc.removeAttribute(ANNOTATION_ATTRIBUTE);
boolean useByteCodeProcessor = config.getInitParameter(ApplicationConfig.BYTECODE_PROCESSOR, false);
boolean scanForAtmosphereAnnotation = false;
if (useByteCodeProcessor || annotations == null || annotations.isEmpty()) {
delegate = new BytecodeBasedAnnotationProcessor(handler);
scanForAtmosphereAnnotation = true;
} else {
Map<Class<? extends Annotation>, Set<Class<?>>> clone = new HashMap<Class<? extends Annotation>, Set<Class<?>>>();
clone.putAll(annotations);
delegate = new ServletContainerInitializerAnnotationProcessor(handler, clone, config.framework());
}
logger.info("AnnotationProcessor {} being used", delegate.getClass());
if (scanForAtmosphereAnnotation) {
scanForAnnotation(config.framework());
}
delegate.configure(config.framework().getAtmosphereConfig());
}
use of javax.servlet.ServletContext in project OpenAM by OpenRock.
the class AMModuleProperties method getModuleProperties.
/**
* Return the list of authentication module property
* @param fileName that has module properties
* @return <code>List</code> of module property
* @exception AuthLoginException if fails to get properties from the file.
*/
public static List getModuleProperties(String fileName) throws AuthLoginException {
List list = (List) moduleProps.get(fileName);
List pageAttr;
if (list != null) {
return list;
}
ServletContext servletContext = AuthD.getAuth().getServletContext();
InputStream resStream = null;
try {
if (servletContext != null) {
resStream = servletContext.getResourceAsStream(fileName);
}
;
if (resStream == null) {
resStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName.substring(1));
// remove leading '/' from fileName
}
// file might be empty for modules like Cert,Anonymous etc.
if (resStream != null && resStream.read() == -1) {
if (debug.messageEnabled()) {
debug.message(fileName + " is empty");
}
list = new ArrayList();
synchronized (moduleProps) {
moduleProps.put(fileName, list);
}
return list;
}
} catch (Exception e) {
debug.message("getModuleProperties: Error: ", e);
} finally {
try {
resStream.close();
} catch (Exception ee) {
debug.message("Error closing input stream");
}
}
AMModuleProperties prop = new AMModuleProperties(fileName, servletContext);
list = prop.getCallbacks();
if (list != null && !list.isEmpty()) {
synchronized (moduleProps) {
moduleProps.put(fileName, list);
}
}
return list;
}
use of javax.servlet.ServletContext in project Activiti by Activiti.
the class WebConfigurer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext servletContext = sce.getServletContext();
log.debug("Configuring Spring root application context");
AnnotationConfigWebApplicationContext rootContext = null;
if (context == null) {
rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationConfiguration.class);
rootContext.refresh();
} else {
rootContext = context;
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);
initSpring(servletContext, rootContext);
log.debug("Web application fully configured");
}
use of javax.servlet.ServletContext in project Activiti by Activiti.
the class WebConfigurer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext servletContext = sce.getServletContext();
log.debug("Configuring Spring root application context");
AnnotationConfigWebApplicationContext rootContext = null;
if (context == null) {
rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationConfiguration.class);
rootContext.refresh();
} else {
rootContext = context;
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);
EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
initSpring(servletContext, rootContext);
initSpringSecurity(servletContext, disps);
log.debug("Web application fully configured");
}
Aggregations