use of org.springframework.context.support.AbstractApplicationContext in project camel by apache.
the class DefaultStreamCachingTest method testStreamCaching.
public void testStreamCaching() throws Exception {
AbstractApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] { "org/apache/camel/spring/streamCaching.xml" });
CamelContext camelContext = appContext.getBean("camelContext", CamelContext.class);
assertFalse("StreamCaching should not be enabled", camelContext.isStreamCaching());
// we're done so let's properly close the application context
IOHelper.close(appContext);
}
use of org.springframework.context.support.AbstractApplicationContext in project centipede by paulhoule.
the class StaticCentipedeShellTest method lazyEvaluationIsLazy.
@Test
public void lazyEvaluationIsLazy() {
ApplicationContext c = newContext(objectCountingContext(), true);
assertEquals(0, ObjectThatCountsClassInstances.get());
Object that = c.getBean("l");
assertEquals(1, ObjectThatCountsClassInstances.get());
Object another = c.getBean("e");
assertEquals(2, ObjectThatCountsClassInstances.get());
((AbstractApplicationContext) c).close();
assertEquals(0, ObjectThatCountsClassInstances.get());
}
use of org.springframework.context.support.AbstractApplicationContext in project centipede by paulhoule.
the class StaticCentipedeShellTest method eagerEvaluationIsEager.
@Test
public void eagerEvaluationIsEager() {
ApplicationContext c = newContext(objectCountingContext(), false);
assertEquals(2, ObjectThatCountsClassInstances.get());
((AbstractApplicationContext) c).close();
assertEquals(0, ObjectThatCountsClassInstances.get());
}
use of org.springframework.context.support.AbstractApplicationContext in project camel by apache.
the class Main method createDefaultApplicationContext.
protected AbstractApplicationContext createDefaultApplicationContext() {
ApplicationContext parentContext = getParentApplicationContext();
AnnotationConfigApplicationContext acApplicationContext = new AnnotationConfigApplicationContext();
if (parentContext != null) {
acApplicationContext.setParent(parentContext);
}
if (getConfigClasses() != null) {
Class<?>[] configClasses = getConfigClasses(getConfigClasses());
for (Class<?> cls : configClasses) {
acApplicationContext.register(cls);
}
}
if (getConfigClass() != null) {
for (Class<?> cls : getConfigClass()) {
acApplicationContext.register(cls);
}
}
if (getBasedPackages() != null) {
String[] basePackages = getBasedPackages().split("(;|,)");
for (String basePackage : basePackages) {
basePackage = basePackage.trim();
acApplicationContext.scan(basePackage);
}
}
acApplicationContext.refresh();
return acApplicationContext;
}
use of org.springframework.context.support.AbstractApplicationContext in project OpenMEAP by OpenMEAP.
the class AdminServlet method service.
@SuppressWarnings("unchecked")
@Override
public void service(HttpServletRequest request, HttpServletResponse response) {
logger.trace("Entering service()");
try {
DocumentProcessor documentProcessor = null;
logger.debug("Request uri: {}", request.getRequestURI());
logger.debug("Request url: {}", request.getRequestURL());
logger.debug("Query string: {}", request.getQueryString());
if (logger.isDebugEnabled()) {
logger.debug("Parameter map: {}", ParameterMapUtils.toString(request.getParameterMap()));
}
if (request.getParameter("logout") != null) {
logger.trace("Executing logout");
request.getSession().invalidate();
response.sendRedirect(request.getContextPath() + "/interface/");
}
if (request.getParameter("refreshContext") != null && context instanceof AbstractApplicationContext) {
logger.trace("Refreshing context");
((AbstractApplicationContext) context).refresh();
}
// support for clearing the persistence context
if (request.getParameter("clearPersistenceContext") != null && context instanceof AbstractApplicationContext) {
logger.trace("Clearing the persistence context");
ModelServiceImpl ms = (ModelServiceImpl) ((AbstractApplicationContext) context).getBean("modelService");
ms.clearPersistenceContext();
}
// default to the mainOptionPage, unless otherwise specified
String pageBean = null;
if (request.getParameter(FormConstants.PAGE_BEAN) != null)
pageBean = request.getParameter(FormConstants.PAGE_BEAN);
else
pageBean = FormConstants.PAGE_BEAN_MAIN;
logger.debug("Using page bean: {}", pageBean);
documentProcessor = (DocumentProcessor) context.getBean(pageBean);
ModelManager mgr = getModelManager();
Map<Object, Object> map = new HashMap<Object, Object>();
// TODO: I'm not really happy with this hacky work-around for the login form not being in actual request scope
if (documentProcessor.getProcessesFormData()) {
GlobalSettings settings = mgr.getGlobalSettings();
map = ServletUtils.cloneParameterMap(settings.getMaxFileUploadSize(), settings.getTemporaryStoragePath(), request);
map.put("userPrincipalName", new String[] { request.getUserPrincipal().getName() });
AuthorizerImpl authorizer = (AuthorizerImpl) context.getBean("authorizer");
authorizer.setRequest(request);
}
response.setContentType(FormConstants.CONT_TYPE_HTML);
Map<Object, Object> defaultTemplateVars = new HashMap<Object, Object>();
defaultTemplateVars.put("request", new BeanModel(request, new DefaultObjectWrapper()));
documentProcessor.setTemplateVariables(defaultTemplateVars);
documentProcessor.handleProcessAndRender(map, response.getWriter());
response.getWriter().flush();
response.getWriter().close();
} catch (IOException te) {
throw new RuntimeException(te);
}
logger.trace("Leaving service()");
}
Aggregations