20250828 cleanup (#2639)

* Cleanup

* Refactor artifact management
This commit is contained in:
Avgustin Marinov
2025-09-02 16:08:14 +03:00
committed by GitHub
parent 4f0a8893c7
commit 2a636328a0
305 changed files with 2253 additions and 4566 deletions

View File

@@ -9,9 +9,9 @@
*/
package org.eclipse.hawkbit.autoconfigure.artifact;
import org.eclipse.hawkbit.repository.artifact.urlhandler.ArtifactUrlHandler;
import org.eclipse.hawkbit.repository.artifact.urlhandler.ArtifactUrlHandlerProperties;
import org.eclipse.hawkbit.repository.artifact.urlhandler.PropertyBasedArtifactUrlHandler;
import org.eclipse.hawkbit.artifact.urlresolver.ArtifactUrlResolver;
import org.eclipse.hawkbit.artifact.urlresolver.PropertyBasedArtifactUrlResolver;
import org.eclipse.hawkbit.artifact.urlresolver.PropertyBasedArtifactUrlResolverProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -20,22 +20,18 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
/**
* Autoconfiguration for {@link ArtifactUrlHandler} based on a properties.
* Autoconfiguration for {@link ArtifactUrlResolver} based on a properties.
*/
@Configuration
@EnableConfigurationProperties({ ArtifactUrlHandlerProperties.class })
@EnableConfigurationProperties({ PropertyBasedArtifactUrlResolverProperties.class })
@PropertySource("classpath:/hawkbit-artifactdl-defaults.properties")
public class ArtifactUrlHandlerAutoConfiguration {
public class PropertyBasedArtifactUrlResolverAutoConfiguration {
/**
* @param urlHandlerProperties for bean configuration
* @return PropertyBasedArtifactUrlHandler bean
*/
@Bean
@ConditionalOnMissingBean(ArtifactUrlHandler.class)
PropertyBasedArtifactUrlHandler propertyBasedArtifactUrlHandler(
final ArtifactUrlHandlerProperties urlHandlerProperties,
@ConditionalOnMissingBean(ArtifactUrlResolver.class)
PropertyBasedArtifactUrlResolver propertyBasedArtifactUrlHandler(
final PropertyBasedArtifactUrlResolverProperties urlHandlerProperties,
@Value("${server.servlet.context-path:}") final String contextPath) {
return new PropertyBasedArtifactUrlHandler(urlHandlerProperties, contextPath);
return new PropertyBasedArtifactUrlResolver(urlHandlerProperties, contextPath);
}
}

View File

@@ -10,8 +10,8 @@
package org.eclipse.hawkbit.autoconfigure.cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.eclipse.hawkbit.cache.TenancyCacheManager;
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
import org.eclipse.hawkbit.tenancy.cache.TenantCacheManager;
import org.eclipse.hawkbit.tenancy.cache.TenantAwareCacheManager;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Primary;
* A configuration for configuring the spring {@link CacheManager} for specific multi-tenancy caching. The caches between
* tenants must not interfere each other.
* <p/>
* This is done by providing a special {@link TenancyCacheManager} which generates a cache name included the current tenant.
* This is done by providing a special {@link TenantCacheManager} which generates a cache name included the current tenant.
*/
@Configuration
@EnableCaching
@@ -39,9 +39,8 @@ public class CacheAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@Primary
TenancyCacheManager cacheManager(
@Qualifier("directCacheManager") final CacheManager directCacheManager,
final TenantAware tenantAware) {
TenantCacheManager cacheManager(
@Qualifier("directCacheManager") final CacheManager directCacheManager, final TenantAware tenantAware) {
return new TenantAwareCacheManager(directCacheManager, tenantAware);
}
@@ -63,9 +62,7 @@ public class CacheAutoConfiguration {
final CaffeineCacheManager cacheManager = new CaffeineCacheManager();
if (cacheProperties.getTtl() > 0) {
final Caffeine<Object, Object> cacheBuilder = Caffeine.newBuilder()
.expireAfterWrite(cacheProperties.getTtl(), cacheProperties.getTtlUnit());
cacheManager.setCaffeine(cacheBuilder);
cacheManager.setCaffeine(Caffeine.newBuilder().expireAfterWrite(cacheProperties.getTtl(), cacheProperties.getTtlUnit()));
}
return cacheManager;

View File

@@ -19,7 +19,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* After lifetime the data gets reloaded out of the database.
*/
@Data
@ConfigurationProperties("hawkbit.cache.global")
@ConfigurationProperties("hawkbit.cache")
public class CacheProperties {
/**

View File

@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
/**
* Autoconfiguration for the events..
* Autoconfiguration for the events.
*/
@Configuration
@Import(EventPublisherConfiguration.class)

View File

@@ -38,13 +38,13 @@ import org.springframework.security.concurrent.DelegatingSecurityContextSchedule
*/
@Slf4j
@Configuration
@EnableConfigurationProperties(AsyncConfigurerThreadPoolProperties.class)
@EnableConfigurationProperties(ExecutorProperties.class)
public class ExecutorAutoConfiguration {
private final AsyncConfigurerThreadPoolProperties asyncConfigurerProperties;
private final ExecutorProperties executorProperties;
public ExecutorAutoConfiguration(final AsyncConfigurerThreadPoolProperties asyncConfigurerProperties) {
this.asyncConfigurerProperties = asyncConfigurerProperties;
public ExecutorAutoConfiguration(final ExecutorProperties executorProperties) {
this.executorProperties = executorProperties;
}
/**
@@ -72,7 +72,7 @@ public class ExecutorAutoConfiguration {
@ConditionalOnMissingBean
public ScheduledExecutorService scheduledExecutorService() {
return new DelegatingSecurityContextScheduledExecutorService(Executors.newScheduledThreadPool(
asyncConfigurerProperties.getSchedulerThreads(), threadFactory("central-scheduled-executor-pool-%d")));
executorProperties.getSchedulerThreads(), threadFactory("central-scheduled-executor-pool-%d")));
}
/**
@@ -97,9 +97,9 @@ public class ExecutorAutoConfiguration {
* @return central ThreadPoolExecutor for general purpose multithreaded operations. Tries an orderly shutdown when destroyed.
*/
private ThreadPoolExecutor threadPoolExecutor() {
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(asyncConfigurerProperties.getQueueSize());
return new ThreadPoolExecutor(asyncConfigurerProperties.getCoreThreads(),
asyncConfigurerProperties.getMaxThreads(), asyncConfigurerProperties.getIdleTimeout(),
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(executorProperties.getQueueSize());
return new ThreadPoolExecutor(executorProperties.getCoreThreads(),
executorProperties.getMaxThreads(), executorProperties.getIdleTimeout(),
TimeUnit.MILLISECONDS, blockingQueue,
threadFactory("central-executor-pool-%d"),
new PoolSizeExceededPolicy());

View File

@@ -16,8 +16,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* Properties for the async configurer.
*/
@Data
@ConfigurationProperties("hawkbit.threadpool")
public class AsyncConfigurerThreadPoolProperties {
@ConfigurationProperties("hawkbit.executor")
public class ExecutorProperties {
/**
* Max queue size for central event executor.

View File

@@ -25,11 +25,12 @@ import org.springframework.security.config.annotation.authentication.configurati
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
@EnableConfigurationProperties({ TenantAwareUserProperties.class })
public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticationConfigurerAdapter {
public class StaticUserManagementAutoConfiguration extends GlobalAuthenticationConfigurerAdapter {
private final StaticAuthenticationProvider authenticationProvider;
InMemoryUserManagementAutoConfiguration(final SecurityProperties securityProperties,
StaticUserManagementAutoConfiguration(
final SecurityProperties securityProperties,
final TenantAwareUserProperties tenantAwareUserProperties) {
authenticationProvider = new StaticAuthenticationProvider(tenantAwareUserProperties, securityProperties);
}