Skip to content

Commit

Permalink
Merge pull request #274 from ScorpioBroker/ldlibchange
Browse files Browse the repository at this point in the history
Ldlibchange
  • Loading branch information
ScorpioBroker committed Feb 2, 2022
2 parents 22bd666 + 4f872d9 commit f13827b
Show file tree
Hide file tree
Showing 492 changed files with 31,281 additions and 28,979 deletions.
772 changes: 772 additions & 0 deletions AllInOneRunner/hs_err_pid19180.log

Large diffs are not rendered by default.

140 changes: 105 additions & 35 deletions AllInOneRunner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,100 @@
<relativePath>../BrokerParent</relativePath>
</parent>
<artifactId>AllInOneRunner</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<profiles>

<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.springframework.experimental</groupId>
<artifactId>spring-aot-maven-plugin</artifactId>
<version>0.11.0</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>

<configuration>
<profiles>
<profile>docker</profile>
</profiles>
<requiresUnpack>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>InfoServer</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>AtContextServer</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>EntityManager</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>HistoryManager</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>QueryManager</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>RegistryManager</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<!-- <dependency> <groupId>eu.neclab.ngsildbroker</groupId> <artifactId>StorageManager</artifactId>
<version>1.1.0-SNAPSHOT</version> </dependency> -->
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>SubscriptionManager</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
</requiresUnpack>
<image>
<builder>paketobuildpacks/builder:tiny</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
</env>
<name>scorpiobroker/aaio</name>
</image>
</configuration>
</plugin>
<!-- <plugin> <groupId>org.graalvm.buildtools</groupId> <artifactId>native-maven-plugin</artifactId>
<version>0.9.8</version> <extensions>true</extensions> <executions> <execution>
<id>build-native</id> <goals> <goal>build</goal> </goals> <phase>package</phase>
</execution> <execution> <id>test-native</id> <goals> <goal>test</goal> </goals>
<phase>test</phase> </execution> </executions> <configuration> ... </configuration>
</plugin> Avoid a clash between Spring Boot repackaging and native-maven-plugin
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration> <classifier>exec</classifier> </configuration> </plugin> -->
</plugins>
</build>
</profile>

<profile>
<id>aaio</id>
<build>
Expand Down Expand Up @@ -90,19 +180,11 @@
<artifactId>Commons</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.5.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
</dependency>
<!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId>
</dependency> <dependency> <groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId> <version>2.5.1.RELEASE</version>
</dependency> <dependency> <groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId> </dependency> -->
</dependencies>
</profile>
<profile>
Expand All @@ -122,21 +204,12 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.5.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
</dependency>
</dependencies>
<!-- <dependencies> <dependency> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId> </dependency> <dependency>
<groupId>org.springframework.security.oauth</groupId> <artifactId>spring-security-oauth2</artifactId>
<version>2.5.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId> </dependency>
</dependencies> -->
</profile>
</profiles>
<dependencies>
Expand Down Expand Up @@ -172,18 +245,15 @@
</dependency>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>StorageManager</artifactId>
<artifactId>RegistrySubscriptionManager</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<!-- <dependency> <groupId>eu.neclab.ngsildbroker</groupId> <artifactId>StorageManager</artifactId>
<version>1.1.0-SNAPSHOT</version> </dependency> -->
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>SubscriptionManager</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
122 changes: 8 additions & 114 deletions AllInOneRunner/src/main/java/eu/neclab/ngsildbroker/runner/Runner.java
Original file line number Diff line number Diff line change
@@ -1,127 +1,21 @@
package eu.neclab.ngsildbroker.runner;

import org.apache.catalina.connector.Connector;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.http.HttpMethod;
import org.springframework.security.web.firewall.DefaultHttpFirewall;
import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Profile;
import eu.neclab.ngsildbroker.entityhandler.EntityHandler;
import eu.neclab.ngsildbroker.historymanager.HistoryHandler;
import eu.neclab.ngsildbroker.queryhandler.QueryHandler;
import eu.neclab.ngsildbroker.registry.subscriptionmanager.RegistrySubscriptionHandler;
import eu.neclab.ngsildbroker.registryhandler.RegistryHandler;
import eu.neclab.ngsildbroker.subscriptionmanager.SubscriptionHandler;

@SpringBootApplication
@ComponentScan(basePackages = {
"eu.neclab.ngsildbroker.*" }, excludeFilters = @Filter(type = FilterType.REGEX, pattern = {
"eu.neclab.ngsildbroker.commons.*" }))
//@Import(KafkaConfig.class)
public class Runner {

public static void main(String[] args) throws Exception {
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
SpringApplication.run(Runner.class, args);
SpringApplication.run(new Class[] { RegistryHandler.class, HistoryHandler.class, QueryHandler.class,
RegistrySubscriptionHandler.class, EntityHandler.class, SubscriptionHandler.class }, args);
}

@Value("${gateway.enablecors:false}")
boolean enableCors;
@Value("${gateway.enablecors.allowall:false}")
boolean allowAllCors;

@Value("${gateway.enablecors.allowedorigin:null}")
String allowedOrigin;

@Value("${gateway.enablecors.allowedheader:null}")
String allowedHeader;

@Value("${gateway.enablecors.allowallmethods:false}")
boolean allowAllCorsMethods;

@Value("${gateway.enablecors.allowedmethods:null}")
String allowedMethods;

@Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
if (!enableCors) {
return new CorsFilter(source);
}
final CorsConfiguration config = new CorsConfiguration();
if (allowAllCors) {
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod(HttpMethod.DELETE);
config.addAllowedMethod(HttpMethod.POST);
config.addAllowedMethod(HttpMethod.GET);
config.addAllowedMethod(HttpMethod.OPTIONS);
config.addAllowedMethod(HttpMethod.PATCH);
config.addAllowedMethod(HttpMethod.PUT);
config.addAllowedMethod(HttpMethod.HEAD);
config.addAllowedMethod(HttpMethod.TRACE);
source.registerCorsConfiguration("/**", config);
} else {
if (allowedOrigin != null) {
for (String origin : allowedOrigin.split(",")) {
config.addAllowedOrigin(origin);
}

}
if (allowedHeader != null) {
for (String header : allowedHeader.split(",")) {
config.addAllowedHeader(header);
}
}
if (allowAllCorsMethods) {
config.addAllowedMethod(HttpMethod.DELETE);
config.addAllowedMethod(HttpMethod.POST);
config.addAllowedMethod(HttpMethod.GET);
config.addAllowedMethod(HttpMethod.OPTIONS);
config.addAllowedMethod(HttpMethod.PATCH);
config.addAllowedMethod(HttpMethod.PUT);
config.addAllowedMethod(HttpMethod.HEAD);
config.addAllowedMethod(HttpMethod.TRACE);
} else {
if (allowedMethods != null) {
for (String method : allowedMethods.split(",")) {
config.addAllowedMethod(method);
}
}
}
}

return new CorsFilter(source);
}

@Profile({ "!docker", "!eureka" })
@Bean
public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
DefaultHttpFirewall firewall = new DefaultHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
return firewall;
}

@Profile({ "!docker", "!eureka" })
@Bean
public ConfigurableServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setProperty("relaxedQueryChars", "|{}[]");
// connector.setProperty("encodedSolidusHandling", "passthrough");
// Doesn't do anything
}
});
return factory;
}
}

This file was deleted.

8 changes: 5 additions & 3 deletions AllInOneRunner/src/main/resources/application-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ mysettings:
bootstrap:
host: ${bushost:kafka}
eureka:
protocol: ${eureka.protocol:http}
host: ${eureka.host:localhost}
port: ${eureka.port:8761}
protocol: ${eurekaprotocol:http}
host: ${eurekahost:localhost}
port: ${eurekaport:8761}
postgres:
host: ${dbhost:postgres}
gateway:
Expand All @@ -19,3 +19,5 @@ eureka:
fetchRegistry: true
serviceUrl:
defaultZone: ${eurekaurl}/eureka/
instance:
preferIpAddress: true
8 changes: 5 additions & 3 deletions AllInOneRunner/src/main/resources/application-eureka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ server:
port: 27015
mysettings:
eureka:
protocol: ${eureka.protocol:http}
host: ${eureka.host:localhost}
port: ${eureka.port:8761}
protocol: ${eurekaprotocol:http}
host: ${eurekahost:localhost}
port: ${eurekaport:8761}
eurekaurl: ${mysettings.eureka.protocol}://${mysettings.eureka.host}:${mysettings.eureka.port}
eureka:
client:
register-with-eureka: true
fetchRegistry: true
serviceUrl:
defaultZone: ${eurekaurl}/eureka/
instance:
preferIpAddress: true

0 comments on commit f13827b

Please sign in to comment.