mirror of https://github.com/apache/nifi.git
NIFI-1289 added support for refreshing properties - Added _getNewInstance()_ operation to NiFiProperties to ensure there is a way to refresh/reload NiFi properties - Fixed javadocs
Signed-off-by: Bryan Bende <bbende@apache.org> This closes #142
This commit is contained in:
parent
3189a13da1
commit
2845e93812
|
@ -241,10 +241,27 @@ public class NiFiProperties extends Properties {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the method through which the NiFiProperties object should be obtained.
|
* Factory method to create and return a new instance of
|
||||||
|
* {@link NiFiProperties}. Unlike its {@link #getInstance()} counterpart
|
||||||
|
* which may return you a cached instance of {@link NiFiProperties} this
|
||||||
|
* method creates new instance every time it's called. It is suitable for
|
||||||
|
* cases where properties may change at runtime.
|
||||||
*
|
*
|
||||||
* @return the NiFiProperties object to use
|
* @return new instance of {@link NiFiProperties}
|
||||||
* @throws RuntimeException if unable to load properties file
|
*/
|
||||||
|
public static synchronized NiFiProperties getNewInstance() {
|
||||||
|
instance = null;
|
||||||
|
return getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory method to create and return a new instance of
|
||||||
|
* {@link NiFiProperties}. Unlike its {@link #getNewInstance()} counterpart
|
||||||
|
* which always creates a new instance of {@link NiFiProperties}, this
|
||||||
|
* method employs a standard singleton pattern by caching the instance if it
|
||||||
|
* was already obtained
|
||||||
|
*
|
||||||
|
* @return instance of {@link NiFiProperties}
|
||||||
*/
|
*/
|
||||||
public static synchronized NiFiProperties getInstance() {
|
public static synchronized NiFiProperties getInstance() {
|
||||||
if (null == instance) {
|
if (null == instance) {
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.apache.nifi.reporting.InitializationException;
|
||||||
import org.apache.nifi.reporting.ReportingContext;
|
import org.apache.nifi.reporting.ReportingContext;
|
||||||
import org.apache.nifi.reporting.ReportingInitializationContext;
|
import org.apache.nifi.reporting.ReportingInitializationContext;
|
||||||
import org.apache.nifi.scheduling.SchedulingStrategy;
|
import org.apache.nifi.scheduling.SchedulingStrategy;
|
||||||
|
import org.apache.nifi.util.NiFiProperties;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
@ -60,6 +61,7 @@ public class TestStandardProcessScheduler {
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws InitializationException {
|
public void setup() throws InitializationException {
|
||||||
System.setProperty("nifi.properties.file.path", "src/test/resources/nifi.properties");
|
System.setProperty("nifi.properties.file.path", "src/test/resources/nifi.properties");
|
||||||
|
NiFiProperties.getNewInstance(); // ensures that properties have been reloaded
|
||||||
scheduler = new StandardProcessScheduler(Mockito.mock(Heartbeater.class), Mockito.mock(ControllerServiceProvider.class), null);
|
scheduler = new StandardProcessScheduler(Mockito.mock(Heartbeater.class), Mockito.mock(ControllerServiceProvider.class), null);
|
||||||
scheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, Mockito.mock(SchedulingAgent.class));
|
scheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, Mockito.mock(SchedulingAgent.class));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue