Search in sources :

Example 1 with CloudStackSpringContext

use of org.apache.cloudstack.spring.module.factory.CloudStackSpringContext in project cloudstack by apache.

the class Main method start.

public void start() throws Exception {
    CloudStackSpringContext context = new CloudStackSpringContext();
    context.registerShutdownHook();
    if (Boolean.getBoolean("force.exit")) {
        System.exit(0);
    }
}
Also used : CloudStackSpringContext(org.apache.cloudstack.spring.module.factory.CloudStackSpringContext)

Example 2 with CloudStackSpringContext

use of org.apache.cloudstack.spring.module.factory.CloudStackSpringContext in project cloudstack by apache.

the class ModuleBasedFilter method init.

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    String module = filterConfig.getInitParameter("module");
    CloudStackSpringContext context = (CloudStackSpringContext) filterConfig.getServletContext().getAttribute(CloudStackSpringContext.CLOUDSTACK_CONTEXT_SERVLET_KEY);
    if (context == null)
        return;
    ApplicationContext applicationContext = context.getApplicationContextForWeb(module);
    if (applicationContext != null) {
        AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
        if (factory != null) {
            factory.autowireBean(this);
            enabled = true;
        }
    }
}
Also used : CloudStackSpringContext(org.apache.cloudstack.spring.module.factory.CloudStackSpringContext) ApplicationContext(org.springframework.context.ApplicationContext) AutowireCapableBeanFactory(org.springframework.beans.factory.config.AutowireCapableBeanFactory)

Example 3 with CloudStackSpringContext

use of org.apache.cloudstack.spring.module.factory.CloudStackSpringContext in project cloudstack by apache.

the class CloudStackContextLoaderListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent event) {
    try {
        cloudStackContext = new CloudStackSpringContext();
        cloudStackContext.registerShutdownHook();
        event.getServletContext().setAttribute(CloudStackSpringContext.CLOUDSTACK_CONTEXT_SERVLET_KEY, cloudStackContext);
    } catch (IOException e) {
        log.error("Failed to start CloudStack", e);
        throw new RuntimeException("Failed to initialize CloudStack Spring modules", e);
    }
    configuredParentName = event.getServletContext().getInitParameter(WEB_PARENT_MODULE);
    if (configuredParentName == null) {
        configuredParentName = WEB_PARENT_MODULE_DEFAULT;
    }
    super.contextInitialized(event);
}
Also used : CloudStackSpringContext(org.apache.cloudstack.spring.module.factory.CloudStackSpringContext) IOException(java.io.IOException)

Aggregations

CloudStackSpringContext (org.apache.cloudstack.spring.module.factory.CloudStackSpringContext)3 IOException (java.io.IOException)1 AutowireCapableBeanFactory (org.springframework.beans.factory.config.AutowireCapableBeanFactory)1 ApplicationContext (org.springframework.context.ApplicationContext)1