Wrong applicationId fixed in case of context refresh (#811)
Signed-off-by: Dominic Schabel <dominic.schabel@bosch-si.com>
This commit is contained in:
committed by
Stefan Behl
parent
51be28147f
commit
56b938d22b
@@ -10,23 +10,23 @@ package org.eclipse.hawkbit.repository.model.helper;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.bus.BusProperties;
|
import org.springframework.cloud.bus.BusProperties;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A singleton bean which holds the event publisher to have to the cache manager
|
* A singleton bean which holds the event publisher to have to the cache manager
|
||||||
* in beans not instantiated by spring e.g. JPA entities or
|
* in beans not instantiated by spring e.g. JPA entities or
|
||||||
* CacheFieldEntityListener which cannot be autowired.
|
* CacheFieldEntityListener which cannot be autowired.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class EventPublisherHolder {
|
public final class EventPublisherHolder implements ApplicationContextAware {
|
||||||
|
|
||||||
private static final EventPublisherHolder SINGLETON = new EventPublisherHolder();
|
private static final EventPublisherHolder SINGLETON = new EventPublisherHolder();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEventPublisher eventPublisher;
|
private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
@Autowired
|
private String applicationId;
|
||||||
private BusProperties bus;
|
|
||||||
|
|
||||||
private EventPublisherHolder() {
|
private EventPublisherHolder() {
|
||||||
|
|
||||||
@@ -47,7 +47,11 @@ public final class EventPublisherHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getApplicationId() {
|
public String getApplicationId() {
|
||||||
return bus.getId();
|
return applicationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(final ApplicationContext applicationContext) {
|
||||||
|
applicationId = applicationContext.getBean(BusProperties.class).getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user