Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.URL;
- import javax.sql.DataSource;
- import org.apache.catalina.Context;
- import org.apache.catalina.startup.Tomcat;
- import org.apache.tomcat.util.descriptor.web.ContextResource;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
- import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
- import org.springframework.boot.builder.SpringApplicationBuilder;
- import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
- import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
- import org.springframework.boot.web.support.SpringBootServletInitializer;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.ImportResource;
- import org.springframework.context.annotation.Profile;
- @SpringBootApplication(exclude = { JmxAutoConfiguration.class,DataSourceAutoConfiguration.class })
- @ImportResource(locations = { "classpath:common-services.xml" })
- public class MyApplication extends SpringBootServletInitializer {
- @Override
- protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
- return application.sources(MyApplication.class);
- }
- public static void main(String[] args) {
- SpringApplication.run(MyApplication.class, args);
- }
- @Bean
- @Profile("dev")
- public TomcatEmbeddedServletContainerFactory tomcatFactory() {
- return new TomcatEmbeddedServletContainerFactory() {
- @Override
- protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {
- tomcat.enableNaming();
- return super.getTomcatEmbeddedServletContainer(tomcat);
- }
- @Override
- protected void postProcessContext(Context context) {
- ContextResource resource = new ContextResource();
- resource.setName("jdbc/myDataSource");
- resource.setType(DataSource.class.getName());
- resource.setProperty("driverClassName", "oracle.jdbc.OracleDriver");
- resource.setProperty("url", "jdbc:oracle:thin:@sadasd");
- resource.setProperty("username", "admin");
- resource.setProperty("password", "admin");
- resource.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");
- context.getNamingResources().addResource(resource);
- ContextResource queryOnlyDataSourceResource = new ContextResource();
- queryOnlyDataSourceResource.setName("jdbc/queryOnlyDataSource");
- queryOnlyDataSourceResource.setType(DataSource.class.getName());
- queryOnlyDataSourceResource.setProperty("driverClassName", "oracle.jdbc.OracleDriver");
- queryOnlyDataSourceResource.setProperty("url", "jdbc:oracle:thin:@osajodoajo");
- queryOnlyDataSourceResource.setProperty("username", "admin");
- queryOnlyDataSourceResource.setProperty("password", "admin");
- queryOnlyDataSourceResource.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");
- context.getNamingResources().addResource(queryOnlyDataSourceResource);
- ContextResource dataSourceOrbisExport = new ContextResource();
- dataSourceOrbisExport.setName("jdbc/exportDataSource");
- dataSourceOrbisExport.setType(DataSource.class.getName());
- dataSourceOrbisExport.setProperty("driverClassName", "oracle.jdbc.OracleDriver");
- dataSourceOrbisExport.setProperty("url", "jdbc:oracle:thin:@saddalsdkla");
- dataSourceOrbisExport.setProperty("username", "admin");
- dataSourceOrbisExport.setProperty("password", "admin");
- dataSourceOrbisExport.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");
- context.getNamingResources().addResource(dataSourceOrbisExport);
- // File Configuration
- ContextResource engineConfigResource = new ContextResource();
- evolutionEngineConfigResource.setName("url/engineConfig");
- evolutionEngineConfigResource.setType(URL.class.getName()); resource.setProperty("protocol","file");
- evolutionEngineConfigResource.setProperty("file", "C:/configuration_DIT/EngineConfig.config");
- context.getNamingResources().addResource(engineConfigResource);
- ContextResource evolutionPresentationConfigResource = new ContextResource();
- presentationConfigResource.setName("url/presentationConfig");
- presentationConfigResource.setType(URL.class.getName()); resource.setProperty("protocol","file");
- evolutionPresentationConfigResource.setProperty("file", "C:/configuration_DIT/presentation.config");
- context.getNamingResources().addResource(presentationConfigResource);
- }
- };
- }
- }
Add Comment
Please, Sign In to add comment