FINERACT-730: Fixed dependencies, SSL config and main class etc to get bootRun to work. Migrated from Gradle Tomcat plugin to Cargo plugin to fix integration test
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
cb690f6d5b
commit
b05162f60b
+1
-1
@@ -161,4 +161,4 @@ public class SchedulerJobHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,15 @@
|
||||
*/
|
||||
package org.apache.fineract;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.fineract.infrastructure.core.boot.AbstractApplicationConfiguration;
|
||||
import org.apache.fineract.infrastructure.core.boot.ApplicationExitUtil;
|
||||
import org.apache.fineract.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration;
|
||||
import org.apache.fineract.infrastructure.core.boot.db.DataSourceConfiguration;
|
||||
import org.apache.fineract.infrastructure.core.boot.db.DataSourceProperties;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
/**
|
||||
* Fineract main() application which launches Fineract in an embedded Tomcat HTTP
|
||||
@@ -40,17 +41,26 @@ import org.springframework.context.annotation.Import;
|
||||
*
|
||||
* It's the old/classic Mifos (non-X) Workspace 2.0 reborn for Fineract! ;-)
|
||||
*
|
||||
* @see DataSourceProperties about how to configure the DataSource used
|
||||
* @see ServerWithMariaDB4jApplication for an alternative with an embedded DB
|
||||
*/
|
||||
public class ServerApplication {
|
||||
|
||||
@Import({ DataSourceConfiguration.class, EmbeddedTomcatWithSSLConfiguration.class })
|
||||
public class ServerApplication extends SpringBootServletInitializer {
|
||||
|
||||
@Import({ EmbeddedTomcatWithSSLConfiguration.class })
|
||||
@ImportResource({ "classpath*:META-INF/spring/hikariDataSource.xml" })
|
||||
private static class Configuration extends AbstractApplicationConfiguration { }
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args);
|
||||
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||||
return builder.sources(Configuration.class);
|
||||
}
|
||||
|
||||
}
|
||||
private static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
|
||||
return builder.sources(Configuration.class);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
ConfigurableApplicationContext ctx = configureApplication(new SpringApplicationBuilder(ServerApplication.class)).run(args);
|
||||
//ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
|
||||
}
|
||||
}
|
||||
+3
-7
@@ -21,11 +21,11 @@ package org.apache.fineract.infrastructure.core.boot;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.coyote.http11.Http11NioProtocol;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -34,10 +34,10 @@ import org.springframework.core.io.Resource;
|
||||
@Configuration
|
||||
public class EmbeddedTomcatWithSSLConfiguration {
|
||||
|
||||
// http://docs.spring.io/spring-boot/docs/1.1.5.RELEASE/reference/htmlsingle/#howto-enable-multiple-connectors-in-tomcat
|
||||
// https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/html/howto.html#howto-enable-multiple-connectors-in-tomcat
|
||||
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory servletContainer() {
|
||||
public ServletWebServerFactory servletContainer() {
|
||||
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
|
||||
tomcat.setContextPath(getContextPath());
|
||||
tomcat.addAdditionalTomcatConnectors(createSslConnector());
|
||||
@@ -53,16 +53,12 @@ public class EmbeddedTomcatWithSSLConfiguration {
|
||||
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
|
||||
try {
|
||||
File keystore = getFile(getKeystore());
|
||||
File truststore = keystore;
|
||||
connector.setScheme("https");
|
||||
connector.setSecure(true);
|
||||
connector.setPort(getHTTPSPort());
|
||||
protocol.setSSLEnabled(true);
|
||||
protocol.setKeystoreFile(keystore.getAbsolutePath());
|
||||
protocol.setKeystorePass(getKeystorePass());
|
||||
protocol.setTruststoreFile(truststore.getAbsolutePath());
|
||||
protocol.setTruststorePass(getKeystorePass());
|
||||
// ? protocol.setKeyAlias("apitester");
|
||||
return connector;
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException("can't access keystore: [" + "keystore" + "] or truststore: [" + "keystore" + "]", ex);
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.core.boot;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
/**
|
||||
* Required to still have a working legacy "classic" WAR.
|
||||
*
|
||||
* Configuration just adds the JNDI-based DataSource lookup to its
|
||||
* AbstractApplicationConfiguration.
|
||||
*
|
||||
* This (intentionally) only configures the original (pre-Spring Boot &
|
||||
* MariaDB4j) fineract Spring Beans, and does NOT include the embedded Tomcat
|
||||
* (incl. TomcatSSLConfiguration) nor the MariaDB4jSetupService or
|
||||
* MariaDB4jDataSourceConfiguration, and not even the DataSourceConfiguration
|
||||
* (as it uses "classic" JNDI) - we want the WAR to "work like before".
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-convert-an-existing-application-to-spring-boot">#howto-convert-an-existing-application-to-spring-boot</a>
|
||||
*/
|
||||
public class WarWebApplicationInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@ImportResource({ "classpath*:META-INF/spring/hikariDataSource.xml" })
|
||||
private static class Configuration extends AbstractApplicationConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(
|
||||
SpringApplicationBuilder application) {
|
||||
// let's share Spring Boot Love, so no showBanner(false)
|
||||
return application.sources(Configuration.class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user