Guest User

Untitled

a guest
Jan 12th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. import java.net.URL;
  2.  
  3. import javax.sql.DataSource;
  4.  
  5. import org.apache.catalina.Context;
  6. import org.apache.catalina.startup.Tomcat;
  7. import org.apache.tomcat.util.descriptor.web.ContextResource;
  8. import org.springframework.boot.SpringApplication;
  9. import org.springframework.boot.autoconfigure.SpringBootApplication;
  10. import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  11. import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
  12. import org.springframework.boot.builder.SpringApplicationBuilder;
  13. import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
  14. import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
  15. import org.springframework.boot.web.support.SpringBootServletInitializer;
  16. import org.springframework.context.annotation.Bean;
  17. import org.springframework.context.annotation.ImportResource;
  18. import org.springframework.context.annotation.Profile;
  19.  
  20. @SpringBootApplication(exclude = { JmxAutoConfiguration.class,DataSourceAutoConfiguration.class })
  21. @ImportResource(locations = { "classpath:common-services.xml" })
  22. public class MyApplication extends SpringBootServletInitializer {
  23.  
  24. @Override
  25. protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  26. return application.sources(MyApplication.class);
  27. }
  28.  
  29. public static void main(String[] args) {
  30. SpringApplication.run(MyApplication.class, args);
  31. }
  32.  
  33. @Bean
  34. @Profile("dev")
  35. public TomcatEmbeddedServletContainerFactory tomcatFactory() {
  36.  
  37. return new TomcatEmbeddedServletContainerFactory() {
  38.  
  39. @Override
  40. protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {
  41.  
  42. tomcat.enableNaming();
  43. return super.getTomcatEmbeddedServletContainer(tomcat);
  44. }
  45.  
  46. @Override
  47. protected void postProcessContext(Context context) {
  48. ContextResource resource = new ContextResource();
  49. resource.setName("jdbc/myDataSource");
  50. resource.setType(DataSource.class.getName());
  51. resource.setProperty("driverClassName", "oracle.jdbc.OracleDriver");
  52. resource.setProperty("url", "jdbc:oracle:thin:@sadasd");
  53. resource.setProperty("username", "admin");
  54. resource.setProperty("password", "admin");
  55. resource.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");
  56. context.getNamingResources().addResource(resource);
  57.  
  58. ContextResource queryOnlyDataSourceResource = new ContextResource();
  59. queryOnlyDataSourceResource.setName("jdbc/queryOnlyDataSource");
  60. queryOnlyDataSourceResource.setType(DataSource.class.getName());
  61. queryOnlyDataSourceResource.setProperty("driverClassName", "oracle.jdbc.OracleDriver");
  62. queryOnlyDataSourceResource.setProperty("url", "jdbc:oracle:thin:@osajodoajo");
  63. queryOnlyDataSourceResource.setProperty("username", "admin");
  64. queryOnlyDataSourceResource.setProperty("password", "admin");
  65. queryOnlyDataSourceResource.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");
  66. context.getNamingResources().addResource(queryOnlyDataSourceResource);
  67.  
  68. ContextResource dataSourceOrbisExport = new ContextResource();
  69. dataSourceOrbisExport.setName("jdbc/exportDataSource");
  70. dataSourceOrbisExport.setType(DataSource.class.getName());
  71. dataSourceOrbisExport.setProperty("driverClassName", "oracle.jdbc.OracleDriver");
  72. dataSourceOrbisExport.setProperty("url", "jdbc:oracle:thin:@saddalsdkla");
  73. dataSourceOrbisExport.setProperty("username", "admin");
  74. dataSourceOrbisExport.setProperty("password", "admin");
  75. dataSourceOrbisExport.setProperty("factory", "org.apache.tomcat.jdbc.pool.DataSourceFactory");
  76. context.getNamingResources().addResource(dataSourceOrbisExport);
  77.  
  78. // File Configuration
  79. ContextResource engineConfigResource = new ContextResource();
  80. evolutionEngineConfigResource.setName("url/engineConfig");
  81. evolutionEngineConfigResource.setType(URL.class.getName()); resource.setProperty("protocol","file");
  82. evolutionEngineConfigResource.setProperty("file", "C:/configuration_DIT/EngineConfig.config");
  83.  
  84. context.getNamingResources().addResource(engineConfigResource);
  85.  
  86. ContextResource evolutionPresentationConfigResource = new ContextResource();
  87. presentationConfigResource.setName("url/presentationConfig");
  88. presentationConfigResource.setType(URL.class.getName()); resource.setProperty("protocol","file");
  89. evolutionPresentationConfigResource.setProperty("file", "C:/configuration_DIT/presentation.config");
  90.  
  91. context.getNamingResources().addResource(presentationConfigResource);
  92.  
  93.  
  94.  
  95. }
  96. };
  97. }
  98.  
  99. }
Add Comment
Please, Sign In to add comment