Remove some of the field injections (Sonar recomendtion) (#2218)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -18,21 +18,18 @@ import org.springframework.cloud.bus.ServiceMatcher;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
||||
/**
|
||||
* A singleton bean which holds the event publisher and service origin Id in
|
||||
* order to publish remote application events. It can be used in beans not
|
||||
* instantiated by spring e.g. JPA entities which cannot be auto-wired.
|
||||
* A singleton bean which holds the event publisher and service origin id in order to publish remote application events.
|
||||
* It can be used in beans not instantiated by spring e.g. JPA entities which cannot be auto-wired.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
|
||||
public final class EventPublisherHolder {
|
||||
|
||||
private static final EventPublisherHolder SINGLETON = new EventPublisherHolder();
|
||||
|
||||
@Getter
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
@Autowired(required = false)
|
||||
private ServiceMatcher serviceMatcher;
|
||||
@Autowired
|
||||
private BusProperties bus;
|
||||
|
||||
/**
|
||||
@@ -42,9 +39,24 @@ public final class EventPublisherHolder {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
@Autowired // spring setter injection
|
||||
public void setApplicationEventPublisher(final ApplicationEventPublisher eventPublisher) {
|
||||
this.eventPublisher = eventPublisher;
|
||||
}
|
||||
|
||||
@Autowired(required = false) // spring setter injection
|
||||
public void setServiceMatcher(final ServiceMatcher serviceMatcher) {
|
||||
this.serviceMatcher = serviceMatcher;
|
||||
}
|
||||
|
||||
@Autowired // spring setter injection
|
||||
public void setBusProperties(final BusProperties bus) {
|
||||
this.bus = bus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the service origin Id coming either from {@link ServiceMatcher}
|
||||
* when available or {@link BusProperties} otherwise.
|
||||
* @return the service origin Id coming either from {@link ServiceMatcher} when available or {@link BusProperties}
|
||||
* otherwise.
|
||||
*/
|
||||
public String getApplicationId() {
|
||||
String id = null;
|
||||
|
||||
@@ -16,22 +16,27 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* A singleton bean which holds {@link SystemSecurityContext} service and makes
|
||||
* it accessible to beans which are not managed by spring, e.g. JPA entities.
|
||||
* A singleton bean which holds {@link SystemSecurityContext} 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 SystemSecurityContextHolder {
|
||||
|
||||
private static final SystemSecurityContextHolder INSTANCE = new SystemSecurityContextHolder();
|
||||
private static final SystemSecurityContextHolder SINGLETON = new SystemSecurityContextHolder();
|
||||
|
||||
@Getter
|
||||
@Autowired
|
||||
private SystemSecurityContext systemSecurityContext;
|
||||
|
||||
/**
|
||||
* @return the singleton {@link SystemSecurityContextHolder} instance
|
||||
*/
|
||||
public static SystemSecurityContextHolder getInstance() {
|
||||
return INSTANCE;
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
@Autowired // spring setter injection
|
||||
public void setSystemSecurityContext(final SystemSecurityContext systemSecurityContext) {
|
||||
this.systemSecurityContext = systemSecurityContext;
|
||||
}
|
||||
}
|
||||
@@ -16,23 +16,27 @@ import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* A singleton bean which holds {@link TenantConfigurationManagement} service
|
||||
* and makes it accessible to beans which are not managed by spring, e.g. JPA
|
||||
* entities.
|
||||
* A singleton bean which holds {@link TenantConfigurationManagement} 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 TenantConfigurationManagementHolder {
|
||||
|
||||
private static final TenantConfigurationManagementHolder INSTANCE = new TenantConfigurationManagementHolder();
|
||||
private static final TenantConfigurationManagementHolder SINGLETON = new TenantConfigurationManagementHolder();
|
||||
|
||||
@Getter
|
||||
@Autowired
|
||||
private TenantConfigurationManagement tenantConfigurationManagement;
|
||||
|
||||
/**
|
||||
* @return the singleton {@link TenantConfigurationManagementHolder} instance
|
||||
*/
|
||||
public static TenantConfigurationManagementHolder getInstance() {
|
||||
return INSTANCE;
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
@Autowired // spring setter injection
|
||||
public void setTenantConfigurationManagement(final TenantConfigurationManagement tenantConfigurationManagement) {
|
||||
this.tenantConfigurationManagement = tenantConfigurationManagement;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user