ModuleConfiguration properties
- Add `prefix` based module configuration properties - Add default properties in `application.yml` - Move the properties into separate `ConfigurationProperties` bean rather than being inside `Configuration` bean
This commit is contained in:
committed by
Marius Bogoevici
parent
2aa33ca010
commit
e078e29db4
@@ -16,17 +16,14 @@
|
||||
|
||||
package org.springframework.cloud.stream.module.launcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.boot.loader.ModuleJarLauncher;
|
||||
import org.springframework.boot.loader.archive.JarFileArchive;
|
||||
import org.springframework.cloud.stream.module.resolver.AetherModuleResolver;
|
||||
import org.springframework.cloud.stream.module.resolver.ModuleResolver;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -51,12 +48,6 @@ public class ModuleLauncher {
|
||||
|
||||
private final ModuleResolver moduleResolver;
|
||||
|
||||
@Deprecated
|
||||
public ModuleLauncher() {
|
||||
this(new AetherModuleResolver(new File(ModuleLauncherConfiguration.DEFAULT_LOCAL_REPO),
|
||||
Collections.singletonMap("spring-cloud-stream-modules", ModuleLauncherConfiguration.DEFAULT_REMOTE_REPO)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a module launcher using the provided module resolver
|
||||
* @param moduleResolver the module resolver instance to use
|
||||
|
||||
@@ -16,40 +16,28 @@
|
||||
|
||||
package org.springframework.cloud.stream.module.launcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.stream.module.resolver.AetherModuleResolver;
|
||||
import org.springframework.cloud.stream.module.resolver.ModuleResolver;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Configuration class that has the beans required for module launcher.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties
|
||||
// TODO: use a prefix
|
||||
@EnableConfigurationProperties(ModuleLauncherProperties.class)
|
||||
public class ModuleLauncherConfiguration {
|
||||
|
||||
public static final String DEFAULT_LOCAL_REPO = System.getProperty("user.home")
|
||||
+ File.separator + ".m2" + File.separator + "repository";
|
||||
|
||||
public static final String DEFAULT_REMOTE_REPO = "https://repo.spring.io/libs-snapshot";
|
||||
|
||||
private File localRepository = new File(DEFAULT_LOCAL_REPO);
|
||||
|
||||
private String remoteRepository = DEFAULT_REMOTE_REPO;
|
||||
|
||||
public void setLocalRepository(File localRepository) {
|
||||
this.localRepository = localRepository;
|
||||
}
|
||||
|
||||
public void setRemoteRepository(String remoteRepository) {
|
||||
this.remoteRepository = remoteRepository;
|
||||
}
|
||||
@Autowired
|
||||
private ModuleLauncherProperties properties;
|
||||
|
||||
/**
|
||||
* Sets up the default Aether-based module resolver, unless overridden
|
||||
@@ -57,8 +45,8 @@ public class ModuleLauncherConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ModuleResolver.class)
|
||||
public ModuleResolver moduleResolver() {
|
||||
return new AetherModuleResolver(this.localRepository, Collections.singletonMap(
|
||||
"remoteRepository", this.remoteRepository));
|
||||
return new AetherModuleResolver(properties.getLocalRepository(), Collections.singletonMap(
|
||||
"remoteRepository", properties.getRemoteRepository()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
*
|
||||
* 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 org.springframework.cloud.stream.module.launcher;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
@ConfigurationProperties
|
||||
public class ModuleLauncherProperties {
|
||||
|
||||
private File localRepository;
|
||||
|
||||
private String remoteRepository;
|
||||
|
||||
public void setRemoteRepository(String remoteRepository) {
|
||||
this.remoteRepository = remoteRepository;
|
||||
}
|
||||
|
||||
protected String getRemoteRepository() {
|
||||
return remoteRepository;
|
||||
}
|
||||
|
||||
public void setLocalRepository(File localRepository) {
|
||||
this.localRepository = localRepository;
|
||||
}
|
||||
|
||||
protected File getLocalRepository() {
|
||||
return localRepository;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
localRepository: ${user.home}${file.separator}.m2${file.separator}repository
|
||||
remoteRepository: https://repo.spring.io/libs-snapshot
|
||||
Reference in New Issue
Block a user