Remove some of the field injections (Sonar recomendtion) (#2218)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.model.helper;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -19,11 +20,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* entities which cannot be autowired.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
|
||||
public final class AfterTransactionCommitExecutorHolder {
|
||||
|
||||
private static final AfterTransactionCommitExecutorHolder SINGLETON = new AfterTransactionCommitExecutorHolder();
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
private AfterTransactionCommitExecutor afterCommit;
|
||||
|
||||
/**
|
||||
@@ -33,17 +35,8 @@ public final class AfterTransactionCommitExecutorHolder {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the afterCommit
|
||||
*/
|
||||
public AfterTransactionCommitExecutor getAfterCommit() {
|
||||
return afterCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param afterCommit the afterCommit to set
|
||||
*/
|
||||
public void setAfterCommit(final AfterTransactionCommitExecutor afterCommit) {
|
||||
@Autowired // spring setter injection
|
||||
public void setAfterTransactionCommitExecutor(final AfterTransactionCommitExecutor afterCommit) {
|
||||
this.afterCommit = afterCommit;
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,16 @@ package org.eclipse.hawkbit.repository.jpa.model.helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.eclipse.hawkbit.repository.jpa.EntityInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* A singleton bean which holds the {@link EntityInterceptor} to have all
|
||||
* interceptors in spring beans.
|
||||
* A singleton bean which holds the {@link EntityInterceptor} to have all interceptors in spring beans.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
|
||||
public final class EntityInterceptorHolder {
|
||||
|
||||
private static final EntityInterceptorHolder SINGLETON = new EntityInterceptorHolder();
|
||||
@@ -26,10 +29,6 @@ public final class EntityInterceptorHolder {
|
||||
@Autowired(required = false)
|
||||
private final List<EntityInterceptor> entityInterceptors = new ArrayList<>();
|
||||
|
||||
private EntityInterceptorHolder() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entity intreceptor holder singleton instance
|
||||
*/
|
||||
@@ -40,4 +39,4 @@ public final class EntityInterceptorHolder {
|
||||
public List<EntityInterceptor> getEntityInterceptors() {
|
||||
return entityInterceptors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model.helper;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -16,25 +18,24 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* A singleton bean which holds the {@link SecurityTokenGenerator} and make it
|
||||
* accessible to beans which are not managed by spring, e.g. JPA entities.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
|
||||
public final class SecurityTokenGeneratorHolder {
|
||||
|
||||
private static final SecurityTokenGeneratorHolder INSTANCE = new SecurityTokenGeneratorHolder();
|
||||
private static final SecurityTokenGeneratorHolder SINGLETON = new SecurityTokenGeneratorHolder();
|
||||
|
||||
@Autowired
|
||||
private SecurityTokenGenerator securityTokenGenerator;
|
||||
|
||||
/**
|
||||
* private constructor.
|
||||
*/
|
||||
private SecurityTokenGeneratorHolder() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a singleton instance of the security token generator holder.
|
||||
*/
|
||||
public static SecurityTokenGeneratorHolder getInstance() {
|
||||
return INSTANCE;
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
@Autowired // spring setter injection
|
||||
public void setSecurityTokenGenerator(final SecurityTokenGenerator securityTokenGenerator) {
|
||||
this.securityTokenGenerator = securityTokenGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,5 +46,4 @@ public final class SecurityTokenGeneratorHolder {
|
||||
public String generateToken() {
|
||||
return securityTokenGenerator.generateToken();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model.helper;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -16,21 +20,24 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* A singleton bean which holds {@link TenantAware} service and makes it
|
||||
* accessible to beans which are not managed by spring, e.g. JPA entities.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
|
||||
public final class TenantAwareHolder {
|
||||
|
||||
private static final TenantAwareHolder INSTANCE = new TenantAwareHolder();
|
||||
private static final TenantAwareHolder SINGLETON = new TenantAwareHolder();
|
||||
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
|
||||
private TenantAwareHolder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the singleton {@link TenantAwareHolder} instance
|
||||
*/
|
||||
public static TenantAwareHolder getInstance() {
|
||||
return INSTANCE;
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
@Autowired // spring setter injection
|
||||
public void setTenantAware(final TenantAware tenantAware) {
|
||||
this.tenantAware = tenantAware;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,4 +46,4 @@ public final class TenantAwareHolder {
|
||||
public TenantAware getTenantAware() {
|
||||
return tenantAware;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user