use of org.springframework.context.support.AbstractApplicationContext in project OpenMEAP by OpenMEAP.
the class ServiceManagementServlet method service.
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
Result result = null;
PrintWriter os = new PrintWriter(response.getOutputStream());
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()));
}
String action = request.getParameter(UrlParamConstants.ACTION);
if (action == null) {
action = "";
}
if (!authenticates(request)) {
logger.error("Request failed to authenticate ", request);
result = new Result(Result.Status.FAILURE, "Authentication failed");
sendResult(response, os, result);
return;
}
if (action.equals(ModelEntityEventAction.MODEL_REFRESH.getActionName())) {
logger.trace("Processing refresh");
result = refresh(request, response);
sendResult(response, os, result);
return;
} else if (action.equals(ClusterNodeRequest.HEALTH_CHECK)) {
logger.trace("Cluster node health check");
result = healthCheck(request, response);
sendResult(response, os, result);
return;
}
GlobalSettings settings = modelManager.getGlobalSettings();
ClusterNode clusterNode = modelManager.getClusterNode();
if (clusterNode == null) {
throw new RuntimeException("openmeap-services-web needs to be configured as a cluster node in the settings of the admin interface.");
}
Map<Method, String> validationErrors = clusterNode.validate();
if (validationErrors != null) {
throw new RuntimeException(new InvalidPropertiesException(clusterNode, validationErrors));
}
if (request.getParameter("clearPersistenceContext") != null && context instanceof AbstractApplicationContext) {
logger.trace("Clearing persistence context");
clearPersistenceContext();
} else if (action.equals(ModelEntityEventAction.ARCHIVE_UPLOAD.getActionName())) {
logger.trace("Processing archive upload - max file size: {}, storage path prefix: {}", settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix());
archiveUploadHandler.setFileSystemStoragePathPrefix(clusterNode.getFileSystemStoragePathPrefix());
Map<Object, Object> paramMap = ServletUtils.cloneParameterMap(settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix(), request);
result = handleArchiveEvent(archiveUploadHandler, new MapPayloadEvent(paramMap), paramMap);
} else if (action.equals(ModelEntityEventAction.ARCHIVE_DELETE.getActionName())) {
logger.trace("Processing archive delete - max file size: {}, storage path prefix: {}", settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix());
archiveDeleteHandler.setFileSystemStoragePathPrefix(clusterNode.getFileSystemStoragePathPrefix());
Map<Object, Object> paramMap = ServletUtils.cloneParameterMap(settings.getMaxFileUploadSize(), clusterNode.getFileSystemStoragePathPrefix(), request);
result = handleArchiveEvent(archiveDeleteHandler, new MapPayloadEvent(paramMap), paramMap);
}
sendResult(response, os, result);
}
use of org.springframework.context.support.AbstractApplicationContext in project centipede by paulhoule.
the class StaticCentipedeShellTest method defaultEvaluationIsDefinedInFiles.
@Test
public void defaultEvaluationIsDefinedInFiles() {
ApplicationContext c = newContext(objectCountingContext());
assertEquals(1, ObjectThatCountsClassInstances.get());
Object that = c.getBean("l");
assertEquals(2, ObjectThatCountsClassInstances.get());
((AbstractApplicationContext) c).close();
assertEquals(0, ObjectThatCountsClassInstances.get());
}
use of org.springframework.context.support.AbstractApplicationContext in project spring-framework by spring-projects.
the class QuartzSchedulerLifecycleTests method destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang.
// SPR-6354
@Test
public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", this.getClass());
assertNotNull(context.getBean("lazyInitSchedulerWithDefaultShutdownOrder"));
StopWatch sw = new StopWatch();
sw.start("lazyScheduler");
context.destroy();
sw.stop();
assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500);
}
use of org.springframework.context.support.AbstractApplicationContext in project camel by apache.
the class AnotherCamelProxyTest method testAnotherCamelProxy.
public void testAnotherCamelProxy() throws Exception {
// START SNIPPET: e1
AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/AnotherCamelProxyTest.xml");
MyProxySender sender = ac.getBean("myProxySender", MyProxySender.class);
String reply = sender.hello("Camel");
assertEquals("Bye Camel", reply);
// we're done so let's properly close the application context
IOHelper.close(ac);
// END SNIPPET: e1
}
use of org.springframework.context.support.AbstractApplicationContext in project camel by apache.
the class CamelProxyTest method testCamelProxy.
public void testCamelProxy() throws Exception {
AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyTest.xml");
MyProxySender sender = ac.getBean("myProxySender", MyProxySender.class);
String reply = sender.hello("World");
assertEquals("Hello World", reply);
// test sending inOnly message
MyProxySender anotherSender = ac.getBean("myAnotherProxySender", MyProxySender.class);
SpringCamelContext context = ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
MockEndpoint result = resolveMandatoryEndpoint(context, "mock:result", MockEndpoint.class);
result.expectedBodiesReceived("Hello my friends!");
anotherSender.greeting("Hello my friends!");
result.assertIsSatisfied();
result.reset();
// test sending inOnly message with other sender
MyProxySender myProxySenderWithCamelContextId = ac.getBean("myProxySenderWithCamelContextId", MyProxySender.class);
result.expectedBodiesReceived("Hello my friends again!");
myProxySenderWithCamelContextId.greeting("Hello my friends again!");
result.assertIsSatisfied();
// we're done so let's properly close the application context
IOHelper.close(ac);
}
Aggregations