cleanup
This commit is contained in:
parent
bd258bfbd7
commit
d4f11acbae
|
@ -1,56 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
||||||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CascadingPropertyLoader loads a number of property files and mergers them together, so that the last properties
|
|
||||||
* override the previous. It also supports property expansion like:
|
|
||||||
*
|
|
||||||
* <code>
|
|
||||||
* something = 1
|
|
||||||
* somethingelse = 2
|
|
||||||
* test = ${something}/${somethingelse}
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* And if you override something to XX, then test will become XX/2
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author marko
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CascadingPropertyLoader extends PropertyPlaceholderConfigurer implements InitializingBean {
|
|
||||||
|
|
||||||
private Properties properties;
|
|
||||||
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
|
||||||
this.properties = mergeProperties();
|
|
||||||
|
|
||||||
// Convert the merged properties, if necessary.
|
|
||||||
convertProperties(this.properties);
|
|
||||||
|
|
||||||
logger.debug("Properties: " + properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void processProperties(final ConfigurableListableBeanFactory beanFactoryToProcess, final Properties props) throws BeansException {
|
|
||||||
super.processProperties(beanFactoryToProcess, props);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Properties getProperties() {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProperties(final Properties properties) {
|
|
||||||
super.setProperties(properties);
|
|
||||||
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.config;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
||||||
import org.springframework.web.context.ContextLoaderListener;
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
|
||||||
import org.springframework.web.context.support.XmlWebApplicationContext;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class RepoManagerContextLoaderListener extends ContextLoaderListener {
|
|
||||||
private static Logger logger = Logger.getLogger(RepoManagerContextLoaderListener.class);
|
|
||||||
|
|
||||||
|
|
||||||
public RepoManagerContextLoaderListener() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public RepoManagerContextLoaderListener(WebApplicationContext context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected WebApplicationContext createWebApplicationContext(
|
|
||||||
ServletContext servletContext)
|
|
||||||
throws BeansException {
|
|
||||||
logger.debug("Creating web application context");
|
|
||||||
Properties props = this.loadProperties();
|
|
||||||
String repoMode = props.getProperty("services.validator.mode.repo");
|
|
||||||
String userMode = props.getProperty("services.validator.mode.user");
|
|
||||||
Boolean standaloneMode = Boolean.parseBoolean(props.getProperty("services.validator.mode.standalone"));
|
|
||||||
|
|
||||||
logger.info("User mode: " + userMode);
|
|
||||||
logger.info("Repo mode: " + repoMode);
|
|
||||||
logger.info("Standalone mode: " + standaloneMode);
|
|
||||||
// logger.info("Dnet workflow enabled: " + repoMode);
|
|
||||||
XmlWebApplicationContext ctx = new XmlWebApplicationContext();
|
|
||||||
|
|
||||||
ctx.setServletContext(servletContext);
|
|
||||||
|
|
||||||
String userApiContext = null;
|
|
||||||
if (userMode.equalsIgnoreCase("local"))
|
|
||||||
userApiContext = "eu/dnetlib/validator/web/api/impls/users/springContext-validator-user-local.xml";
|
|
||||||
else if (userMode.equalsIgnoreCase("ldap"))
|
|
||||||
userApiContext = "eu/dnetlib/users/springContext-users-ldap.xml";
|
|
||||||
|
|
||||||
String[] springContextCore = new String[] {
|
|
||||||
"classpath:META-INF/cxf/cxf.xml",
|
|
||||||
"classpath:META-INF/cxf/cxf-extension-soap.xml",
|
|
||||||
"classpath:META-INF/cxf/cxf-extension-jaxws.xml",
|
|
||||||
"classpath:META-INF/cxf/cxf-servlet.xml",
|
|
||||||
"classpath*:/cxf.xml",
|
|
||||||
"classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml",
|
|
||||||
"classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml",
|
|
||||||
"classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml",
|
|
||||||
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-struts.xml",
|
|
||||||
// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-emailer.xml",
|
|
||||||
// "classpath*:/eu/dnetlib/validator/web/config/springContext-validator.xml",
|
|
||||||
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml",
|
|
||||||
// "classpath*:/eu/dnetlib/validator/commons/dao/springContext-*.xml",
|
|
||||||
"classpath*:/eu/dnetlib/repos/springContext-repos-" + repoMode + ".xml",
|
|
||||||
"classpath*:/" + userApiContext
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
String[] springContextForStandalone = new String[] {
|
|
||||||
};
|
|
||||||
|
|
||||||
String[] springContextForIS = new String[] {
|
|
||||||
"classpath*:/gr/uoa/di/driver/util/springContext-locators.xml",
|
|
||||||
"classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml",
|
|
||||||
"classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml",
|
|
||||||
"classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml",
|
|
||||||
"classpath*:/gr/uoa/di/driver/app/springContext-commons.xml",
|
|
||||||
"classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (standaloneMode) {
|
|
||||||
logger.debug("Loading contexts for standalone mode");
|
|
||||||
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForStandalone));
|
|
||||||
} else {
|
|
||||||
logger.debug("Loading contexts for dnet");
|
|
||||||
ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForIS));
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.refresh();
|
|
||||||
|
|
||||||
logger.debug("done");
|
|
||||||
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Properties loadProperties() {
|
|
||||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {
|
|
||||||
"classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml"
|
|
||||||
});
|
|
||||||
|
|
||||||
CascadingPropertyLoader pLoader = (CascadingPropertyLoader) ctx.getBean("propertyLoader");
|
|
||||||
Properties props = pLoader.getProperties();
|
|
||||||
|
|
||||||
ctx.destroy();
|
|
||||||
ctx.close();
|
|
||||||
return props;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue