Search in sources :

Example 6 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project spring-security-oauth by spring-projects.

the class ResourceServerBeanDefinitionParserTests method testDefaults.

@Test
public void testDefaults() {
    GenericXmlApplicationContext context = new GenericXmlApplicationContext(getClass(), "resource-server-context.xml");
    assertTrue(context.containsBeanDefinition("oauth2ProviderFilter"));
    assertTrue(context.containsBeanDefinition("anotherProviderFilter"));
    assertTrue(context.containsBeanDefinition("thirdProviderFilter"));
    context.close();
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Example 7 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project webservices-axiom by apache.

the class ScenarioTestCase method setUp.

@Override
protected void setUp() throws Exception {
    server = new Server();
    // Set up a custom thread pool to improve thread names (for logging purposes)
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setName("jetty");
    server.setThreadPool(threadPool);
    Connector connector = new SelectChannelConnector();
    connector.setPort(0);
    server.setConnectors(new Connector[] { connector });
    ServletContextHandler handler = new ServletContextHandler(server, "/");
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setContextClass(GenericWebApplicationContext.class);
    servlet.setContextInitializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {

        public void initialize(ConfigurableApplicationContext applicationContext) {
            configureContext((GenericWebApplicationContext) applicationContext, config.getServerMessageFactoryConfigurator(), new ClassPathResource("server.xml", ScenarioTestCase.this.getClass()));
        }
    });
    ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.setName("spring-ws");
    servletHolder.setInitOrder(1);
    handler.addServlet(servletHolder, "/*");
    server.start();
    context = new GenericXmlApplicationContext();
    MockPropertySource propertySource = new MockPropertySource("client-properties");
    propertySource.setProperty("port", connector.getLocalPort());
    context.getEnvironment().getPropertySources().replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, propertySource);
    configureContext(context, config.getClientMessageFactoryConfigurator(), new ClassPathResource("client.xml", getClass()));
    context.refresh();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Connector(org.eclipse.jetty.server.Connector) SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) MessageDispatcherServlet(org.springframework.ws.transport.http.MessageDispatcherServlet) ClassPathResource(org.springframework.core.io.ClassPathResource) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) MockPropertySource(org.springframework.mock.env.MockPropertySource) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext)

Example 8 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project ignite by apache.

the class GridSpringTransactionManagerSelfTest method beforeTest.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTest() throws Exception {
    ApplicationContext applicationContext = new GenericXmlApplicationContext("config/spring-transactions.xml");
    service = (GridSpringTransactionService) applicationContext.getBean("gridSpringTransactionService");
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 9 with GenericXmlApplicationContext

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

the class StorageOsPlugin method onApplicationStart.

/**
 * Called at application start (and at each reloading) Time to start stateful things.
 */
@Override
public void onApplicationStart() {
    // NOSONAR
    instance = this;
    // ("Suppressing Sonar violation of Lazy initialization of static fields should be synchronized for field instance")
    if (!isEnabled()) {
        return;
    }
    try {
        Logger.info("Connecting to Coordinator Service");
        // To using Spring profile feature
        context = new GenericXmlApplicationContext();
        context.getEnvironment().setActiveProfiles(System.getProperty("buildType"));
        context.load(getContextFiles());
        context.refresh();
        Logger.info("Connected to Coordinator Service");
        zkConnection = getBean("zkconn", ZkConnection.class);
        coordinatorClient = getBean("coordinator", CoordinatorClient.class);
        encryptionProvider = getBean("encryptionProvider", EncryptionProvider.class);
        authSvcEndPointLocator = getBean("authSvcEndpointLocator", AuthSvcEndPointLocator.class);
        Validator.setAuthSvcEndPointLocator(authSvcEndPointLocator);
        Validator.setCoordinator(coordinatorClient);
        // need reference to local-security-conf.xml to load this
        Validator.setStorageOSUserRepository(null);
        coordinatorClient.start();
        encryptionProvider.start();
        Logger.info("Started ViPR connection, version: %s", version);
        KeyStoreExporter keystoreExporter = getBean("keystoreExporter", KeyStoreExporter.class);
        keystoreExporter.export();
        // register node listener for catalog acl change
        coordinatorClient.addNodeListener(new CatalogAclListener());
        Logger.info("added CatalogAclListener");
    } catch (Exception e) {
        Logger.error(e, "Error initializing ViPR Connection");
        shutdown();
    }
}
Also used : AuthSvcEndPointLocator(com.emc.storageos.security.authentication.AuthSvcEndPointLocator) KeyStoreExporter(com.emc.storageos.security.keystore.KeyStoreExporter) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) CatalogAclListener(controllers.util.CatalogAclListener) EncryptionProvider(com.emc.storageos.db.client.model.EncryptionProvider) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection)

Example 10 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project spring-integration-samples by spring-projects.

the class CafeDemoAppUtilities method loadProfileContext.

/**
 * @param path path to the file
 * @param targetClass the class who's classloader we will use to laod the context file
 * @param profile a profile name
 * @return the spring context
 */
public static AbstractApplicationContext loadProfileContext(String path, Class<?> targetClass, String profile) {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.getEnvironment().setActiveProfiles(profile);
    ctx.setClassLoader(targetClass.getClassLoader());
    ctx.load(path);
    ctx.refresh();
    return ctx;
}
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