Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
refactoring of the integration with Spring
* split autoconfiguration module onto core and autoconfiguration * fixed application bootstrap for the cases where there is no web environment * improve configurations and components bootstrap * update to proteus 0.8.10 * fixed examples
- Loading branch information
1 parent
2a4f417
commit 90d3593
Showing
32 changed files
with
506 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
...t-autoconfigure/src/main/java/com/netifi/proteus/springboot/ProteusAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* Copyright 2018 Netifi Inc. | ||
* | ||
* Licensed 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 com.netifi.proteus.springboot; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import com.netifi.proteus.spring.core.config.ProteusConfiguration; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.netifi.proteus.Proteus; | ||
import io.opentracing.Tracer; | ||
|
||
import org.springframework.boot.SpringBootConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Conditional; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.util.StringUtils; | ||
|
||
@SpringBootConfiguration | ||
@EnableConfigurationProperties(ProteusProperties.class) | ||
@Import(ProteusConfiguration.class) | ||
public class ProteusAutoConfiguration { | ||
|
||
@Bean | ||
@Conditional(MeterRegistrySupplierCondition.class) | ||
public MeterRegistry meterRegistry(Supplier<MeterRegistry> supplier) { | ||
return supplier.get(); | ||
} | ||
|
||
@Bean | ||
@Conditional(TracerSupplierCondition.class) | ||
public Tracer tracer(Supplier<Tracer> supplier) { | ||
return supplier.get(); | ||
} | ||
|
||
@SpringBootConfiguration | ||
@ConditionalOnNotWebApplication | ||
@ConditionalOnMissingBean(Proteus.class) | ||
public static class NonWebProteusConfiguration { | ||
|
||
@Bean | ||
public Proteus proteus(ProteusProperties proteusProperties) { | ||
Proteus proteus = configureProteus(proteusProperties); | ||
|
||
startDaemonAwaitThread(proteus); | ||
|
||
return proteus; | ||
} | ||
|
||
private void startDaemonAwaitThread(Proteus proteus) { | ||
Thread awaitThread = new Thread("proteus") { | ||
|
||
@Override | ||
public void run() { | ||
proteus.onClose().block(); | ||
} | ||
|
||
}; | ||
awaitThread.setContextClassLoader(getClass().getClassLoader()); | ||
awaitThread.setDaemon(false); | ||
awaitThread.start(); | ||
} | ||
} | ||
|
||
@SpringBootConfiguration | ||
@ConditionalOnWebApplication | ||
@ConditionalOnMissingBean(Proteus.class) | ||
public static class WebProteusConfiguration { | ||
|
||
@Bean | ||
public Proteus proteus(ProteusProperties proteusProperties) { | ||
return configureProteus(proteusProperties); | ||
} | ||
} | ||
|
||
|
||
static Proteus configureProteus(ProteusProperties proteusProperties) { | ||
ProteusProperties.AccessProperties access = proteusProperties.getAccess(); | ||
ProteusProperties.BrokerProperties broker = proteusProperties.getBroker(); | ||
|
||
Proteus.Builder builder = Proteus.builder(); | ||
|
||
if (!StringUtils.isEmpty(proteusProperties.getDestination())) { | ||
builder.destination(proteusProperties.getDestination()); | ||
} | ||
|
||
return builder | ||
.accessKey(access.getKey()) | ||
.accessToken(access.getToken()) | ||
.group(proteusProperties.getGroup()) | ||
.poolSize(proteusProperties.getPoolSize()) | ||
.host(broker.getHostname()) | ||
.port(broker.getPort()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.