com.azaptree.services.spring.application.SpringApplicationService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azaptree-spring-application-service Show documentation
Show all versions of azaptree-spring-application-service Show documentation
Used to launch a Spring Application Service.
The Spring Application Service is configured via Java based configuration.
The newest version!
package com.azaptree.services.spring.application;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import java.util.concurrent.CountDownLatch;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import com.azaptree.services.spring.application.config.SpringApplicationServiceConfig;
/*
* #%L
* AZAPTREE-SPRING-APPLICATION-SERVICE
* %%
* Copyright (C) 2012 - 2013 AZAPTREE.COM
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
/**
* Used to launch a Spring Application.
*
* Command Line Usage: java com.azaptree.services.spring.application.SpringApplicationService [config.xml]
*
* where [config.xml] = XML file location (loaded using Spring ResourceLoader) that must validate against spring-application-service.xsd
*
* Example [config.xml]:
*
*
* classpath:config.xml - loads config.xml from the classpath
* file:config.xml - loads config.xml from the file system
*
*
* The process may be killed via sending the process a SIGTERM signal, i.e., kill [pid]
*
* @author alfio
*
*/
public class SpringApplicationService {
private static final CountDownLatch shutdownLatch = new CountDownLatch(1);
private static ApplicationContext applicationContext;
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
private static Logger getLogger() {
return LoggerFactory.getLogger(SpringApplicationService.class);
}
private static void logConfig(final SpringApplicationServiceConfig config) {
final Logger log = getLogger();
log.info(config.toString());
logDebugSystemProperties(log);
logEnvironment(log);
}
private static void logDebugSystemProperties(final Logger log) {
Assert.notNull(log);
if (log.isDebugEnabled()) {
final TreeMap sysProps = new TreeMap<>();
for (final Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy