Search in sources :

Example 46 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project camunda-bpm-platform by camunda.

the class SpringConfigurationHelper method buildProcessEngine.

public static ProcessEngine buildProcessEngine(URL resource) {
    log.fine("==== BUILDING SPRING APPLICATION CONTEXT AND PROCESS ENGINE =========================================");
    ApplicationContext applicationContext = new GenericXmlApplicationContext(new UrlResource(resource));
    Map<String, ProcessEngine> beansOfType = applicationContext.getBeansOfType(ProcessEngine.class);
    if ((beansOfType == null) || (beansOfType.isEmpty())) {
        throw new ProcessEngineException("no " + ProcessEngine.class.getName() + " defined in the application context " + resource.toString());
    }
    ProcessEngine processEngine = beansOfType.values().iterator().next();
    log.fine("==== SPRING PROCESS ENGINE CREATED ==================================================================");
    return processEngine;
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) UrlResource(org.springframework.core.io.UrlResource) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 47 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project Activiti by Activiti.

the class SpringConfigurationHelper method buildProcessEngine.

public static ProcessEngine buildProcessEngine(URL resource) {
    log.debug("==== BUILDING SPRING APPLICATION CONTEXT AND PROCESS ENGINE =========================================");
    ApplicationContext applicationContext = new GenericXmlApplicationContext(new UrlResource(resource));
    Map<String, ProcessEngine> beansOfType = applicationContext.getBeansOfType(ProcessEngine.class);
    if ((beansOfType == null) || (beansOfType.isEmpty())) {
        throw new ActivitiException("no " + ProcessEngine.class.getName() + " defined in the application context " + resource.toString());
    }
    ProcessEngine processEngine = beansOfType.values().iterator().next();
    log.debug("==== SPRING PROCESS ENGINE CREATED ==================================================================");
    return processEngine;
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ActivitiException(org.activiti.engine.ActivitiException) UrlResource(org.springframework.core.io.UrlResource) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) ProcessEngine(org.activiti.engine.ProcessEngine)

Example 48 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project coprhd-controller by CoprHD.

the class Main method main.

public static void main(String[] args) {
    try {
        SLF4JBridgeHandler.install();
        // To using Spring profile feature
        GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
        ctx.getEnvironment().setActiveProfiles(System.getProperty("buildType"));
        ctx.load(args);
        ctx.refresh();
        ProvisioningService apiservice = (ProvisioningService) ctx.getBean(SERVICE_BEAN);
        apiservice.start();
    } catch (Exception e) {
        _log.error("failed to start {}:", SERVICE_BEAN, e);
        System.exit(1);
    }
}
Also used : ProvisioningService(com.emc.storageos.api.service.ProvisioningService) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 49 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project coprhd-controller by CoprHD.

the class Main method main.

public static void main(String[] args) {
    try {
        SLF4JBridgeHandler.install();
        // To using Spring profile feature
        GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
        ctx.getEnvironment().setActiveProfiles(System.getProperty("buildType"));
        ctx.load(args);
        ctx.refresh();
        DbService dbsvc = (DbService) ctx.getBean(SERVICE_BEAN);
        addShutdownHook(dbsvc);
        dbsvc.start();
    } catch (Exception e) {
        _log.error("Failed to start {}:", SERVICE_BEAN, e);
        System.exit(1);
    }
}
Also used : DbService(com.emc.storageos.db.server.DbService) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 50 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project coprhd-controller by CoprHD.

the class ApplicationContextUtil method initContext.

public static void initContext(String buildType, String... contextFiles) {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.getEnvironment().setActiveProfiles(buildType);
    ctx.load(contextFiles);
    ctx.refresh();
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Aggregations

GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)61 Test (org.junit.Test)21 Test (org.junit.jupiter.api.Test)13 MBeanServer (javax.management.MBeanServer)5 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)5 Scanner (java.util.Scanner)4 ObjectName (javax.management.ObjectName)4 Resource (org.springframework.core.io.Resource)4 QueueChannel (org.springframework.integration.channel.QueueChannel)4 MessageChannel (org.springframework.messaging.MessageChannel)4 ApplicationContext (org.springframework.context.ApplicationContext)3 ByteArrayResource (org.springframework.core.io.ByteArrayResource)3 Message (org.springframework.messaging.Message)3 MBeanOperationInfo (javax.management.MBeanOperationInfo)2 Server (org.eclipse.jetty.server.Server)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 BatchStatus (org.springframework.batch.core.BatchStatus)2 BeanDefinitionParsingException (org.springframework.beans.factory.parsing.BeanDefinitionParsingException)2 CacheInterceptor (org.springframework.cache.interceptor.CacheInterceptor)2