Search in sources :

Example 26 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();
        AuthenticationServerImpl service = (AuthenticationServerImpl) ctx.getBean(SERVICE_BEAN);
        service.start();
    } catch (Exception e) {
        _log.error("failed to start {}:", SERVICE_BEAN, e);
        System.exit(1);
    }
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 27 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();
        GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
        ctx.getEnvironment().setActiveProfiles(System.getProperty(BUILD_TYPE));
        ctx.load(args);
        // start ipsec monitor
        IPSecMonitor ipsecMonitor = new IPSecMonitor();
        ipsecMonitor.setApplicationContext(ctx);
        ipsecMonitor.start();
        ctx.refresh();
        // start syssvc
        SysSvcImpl sysservice = (SysSvcImpl) ctx.getBean(SERVICE_BEAN);
        sysservice.start();
        // start initial ipsec key rotation
        SecretsInit initialRotate = (SecretsInit) ctx.getBean(IPSEC_ROTATE_BEAN);
        new Thread(initialRotate).start();
    } catch (Exception e) {
        _log.error("failed to start {}:", SERVICE_BEAN, e);
        // Add a delay here before terminating the service, so that DR ZK health
        // monitor has a chance to run before restart
        _log.error("service is going to restart after {} seconds", WAIT_BEFORE_EXIT_IN_SECONDS);
        try {
            Thread.sleep(WAIT_BEFORE_EXIT_IN_SECONDS * 1000);
        } catch (Exception ex) {
        }
        System.exit(1);
    }
}
Also used : SecretsInit(com.emc.storageos.systemservices.impl.security.SecretsInit) IPSecMonitor(com.emc.storageos.systemservices.impl.security.IPSecMonitor) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 28 with GenericXmlApplicationContext

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

the class DefaultServiceAuthenticationDetailsTests method loadServiceAuthenticationDetails.

private ServiceAuthenticationDetails loadServiceAuthenticationDetails(String resourceName) {
    this.context = new GenericXmlApplicationContext(getClass(), resourceName);
    ServiceAuthenticationDetailsSource source = this.context.getBean(ServiceAuthenticationDetailsSource.class);
    return source.buildDetails(this.request);
}
Also used : GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 29 with GenericXmlApplicationContext

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

the class Main method executeSample1.

private static void executeSample1() {
    final Scanner scanner = new Scanner(System.in);
    final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
    context.load("classpath:META-INF/spring/integration/spring-integration-sample1-context.xml");
    context.registerShutdownHook();
    context.refresh();
    final StringConversionService service = context.getBean(StringConversionService.class);
    final String message = "\n=========================================================" + "\n                                                         " + "\n    Please press 'q + Enter' to quit the application.    " + "\n                                                         " + "\n=========================================================" + "\n\n Please enter a string and press <enter>: ";
    System.out.print(message);
    while (!scanner.hasNext("q")) {
        String input = scanner.nextLine();
        System.out.println("Converting String to Uppcase using Stored Procedure...");
        String inputUpperCase = service.convertToUpperCase(input);
        System.out.println("Retrieving Numeric value via Sql Function...");
        Integer number = service.getNumber();
        System.out.println(String.format("Converted '%s' - End Result: '%s_%s'.", input, inputUpperCase, number));
        System.out.print("To try again, please enter a string and press <enter>:");
    }
    scanner.close();
    context.close();
    System.out.println("Back to main menu.");
}
Also used : Scanner(java.util.Scanner) StringConversionService(org.springframework.integration.service.StringConversionService) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 30 with GenericXmlApplicationContext

use of org.springframework.context.support.GenericXmlApplicationContext in project java-examples by urvanov-ru.

the class App method main.

public static void main(String[] args) {
    try (GenericXmlApplicationContext context = new GenericXmlApplicationContext()) {
        context.load("classpath:applicationContext.xml");
        context.refresh();
        JavaMailSender mailSender = context.getBean("mailSender", JavaMailSender.class);
        SimpleMailMessage templateMessage = context.getBean("templateMessage", SimpleMailMessage.class);
        // Создаём потокобезопасную копию шаблона.
        SimpleMailMessage mailMessage = new SimpleMailMessage(templateMessage);
        // TODO: Сюда напишите свой e-mail получателя.
        mailMessage.setTo("ouhb93u4hng9hndf9@mail.ru");
        mailMessage.setText("Привет, товарищи. Присылаю вам письмо...");
        try {
            mailSender.send(mailMessage);
            System.out.println("Mail sended");
        } catch (MailException mailException) {
            System.out.println("Mail send failed.");
            mailException.printStackTrace();
        }
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException) JavaMailSender(org.springframework.mail.javamail.JavaMailSender) 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