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);
}
}
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);
}
}
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);
}
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.");
}
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();
}
}
}
Aggregations