Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ public void stop( )
this.deactivate();
}

public void activate(final ExtPersistenceManager pm)
public synchronized void activate(final ExtPersistenceManager pm)
{
try
{
configurationManager = new ConfigurationManager(pm, bundleContext);
final ConfigurationManager cm = new ConfigurationManager(pm, bundleContext);
this.configurationManager = cm;
// start coordinator tracker
this.startCoordinatorTracker();

final ServiceReference<ConfigurationAdmin> ref = configurationManager.start();
configurationManager.updateRegisteredConfigurationPlugins(this.registeredConfigurationPlugins);
final ServiceReference<ConfigurationAdmin> ref = cm.start();
cm.updateRegisteredConfigurationPlugins(this.registeredConfigurationPlugins);
// update log
Log.logger.set(ref);

Expand All @@ -87,7 +88,7 @@ public void activate(final ExtPersistenceManager pm)
}
}

public void deactivate()
public synchronized void deactivate()
{
this.stopCoordinatorTracker();
if ( this.configurationManager != null )
Expand Down Expand Up @@ -115,7 +116,11 @@ public Object addingService(final ServiceReference<Object> reference)
synchronized ( this.sortedServices )
{
sortedServices.put(reference, srv);
configurationManager.setCoordinator(sortedServices.get(sortedServices.lastKey()));
final ConfigurationManager localCM = configurationManager;
if ( localCM != null )
{
localCM.setCoordinator(sortedServices.get(sortedServices.lastKey()));
}
}
}
return srv;
Expand All @@ -128,7 +133,11 @@ public void modifiedService(final ServiceReference<Object> reference, final Obje
// update the map, service ranking might have changed
sortedServices.remove(reference);
sortedServices.put(reference, srv);
configurationManager.setCoordinator(sortedServices.get(sortedServices.lastKey()));
final ConfigurationManager localCM = configurationManager;
if ( localCM != null )
{
localCM.setCoordinator(sortedServices.get(sortedServices.lastKey()));
}
}
}

Expand All @@ -137,13 +146,17 @@ public void removedService(final ServiceReference<Object> reference, final Objec
synchronized ( this.sortedServices )
{
sortedServices.remove(reference);
if ( sortedServices.isEmpty() )
{
configurationManager.setCoordinator(null);
}
else
final ConfigurationManager localCM = configurationManager;
if ( localCM != null )
{
configurationManager.setCoordinator(sortedServices.get(sortedServices.lastKey()));
if ( sortedServices.isEmpty() )
{
localCM.setCoordinator(null);
}
else
{
localCM.setCoordinator(sortedServices.get(sortedServices.lastKey()));
}
}
}
bundleContext.ungetService(reference);
Expand All @@ -161,17 +174,17 @@ private void stopCoordinatorTracker()
}
}

public void unsetPersistenceManager() {
public synchronized void unsetPersistenceManager() {
this.persistenceManager = null;
this.deactivate();
}

public void setPersistenceManager(final ExtPersistenceManager persistenceManager) {
public synchronized void setPersistenceManager(final ExtPersistenceManager persistenceManager) {
this.persistenceManager = persistenceManager;
this.checkStart();
}

public void updatePluginsSet(final boolean value) {
public synchronized void updatePluginsSet(final boolean value) {
if (this.pluginsAvailable.compareAndSet(!value, value)) {
if (!value) {
this.deactivate();
Expand All @@ -181,13 +194,13 @@ public void updatePluginsSet(final boolean value) {
}
}

public void checkStart() {
public synchronized void checkStart() {
if (this.pluginsAvailable.get() && this.persistenceManager != null) {
this.activate(this.persistenceManager);
}
}

public void updateRegisteredConfigurationPlugins(final String propValue) {
public synchronized void updateRegisteredConfigurationPlugins(final String propValue) {
this.registeredConfigurationPlugins = propValue;
final ConfigurationManager localCM = this.configurationManager;
if (localCM != null) {
Expand Down