import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
-import javax.annotation.Nullable;
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.services.BlueprintExtenderService;
import org.apache.aries.quiesce.participant.QuiesceParticipant;
import org.apache.aries.util.AriesFrameworkUtil;
+import org.eclipse.jdt.annotation.Nullable;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
import org.opendaylight.controller.blueprint.ext.OpendaylightNamespaceHandler;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
import org.osgi.framework.Bundle;
public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCustomizer<Bundle>, BlueprintListener,
SynchronousBundleListener {
private static final Logger LOG = LoggerFactory.getLogger(BlueprintBundleTracker.class);
- private static final String BLUEPRINT_FILE_PATH = "org/opendaylight/blueprint/";
+ private static final String ODL_CUSTOM_BLUEPRINT_FILE_PATH = "org/opendaylight/blueprint/";
+ private static final String STANDARD_BLUEPRINT_FILE_PATH = "OSGI-INF/blueprint/";
private static final String BLUEPRINT_FLE_PATTERN = "*.xml";
private static final long SYSTEM_BUNDLE_ID = 0;
restartService.setBlueprintExtenderService(blueprintExtenderService);
blueprintContainerRestartReg = bundleContext.registerService(
- BlueprintContainerRestartService.class.getName(), restartService, new Hashtable<>());
+ BlueprintContainerRestartService.class.getName(), restartService, emptyDict());
return blueprintExtenderService;
}
private void registerNamespaceHandler(final BundleContext context) {
- Dictionary<String, Object> props = new Hashtable<>();
+ Dictionary<String, Object> props = emptyDict();
props.put("osgi.service.blueprint.namespace", OpendaylightNamespaceHandler.NAMESPACE_1_0_0);
namespaceReg = context.registerService(NamespaceHandler.class.getName(),
new OpendaylightNamespaceHandler(), props);
}
private void registerBlueprintEventHandler(final BundleContext context) {
- eventHandlerReg = context.registerService(BlueprintListener.class.getName(), this, new Hashtable<>());
+ eventHandlerReg = context.registerService(BlueprintListener.class.getName(), this, emptyDict());
+ }
+
+ @SuppressModernizer
+ private static Dictionary<String, Object> emptyDict() {
+ return new Hashtable<>();
}
/**
}
if (bundle.getState() == Bundle.ACTIVE) {
- List<Object> paths = findBlueprintPaths(bundle);
+ List<Object> paths = findBlueprintPaths(bundle, ODL_CUSTOM_BLUEPRINT_FILE_PATH);
if (!paths.isEmpty()) {
LOG.info("Creating blueprint container for bundle {} with paths {}", bundle, paths);
}
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
static List<Object> findBlueprintPaths(final Bundle bundle) {
- Enumeration<?> rntries = bundle.findEntries(BLUEPRINT_FILE_PATH, BLUEPRINT_FLE_PATTERN, false);
+ List<Object> paths = findBlueprintPaths(bundle, STANDARD_BLUEPRINT_FILE_PATH);
+ return !paths.isEmpty() ? paths : findBlueprintPaths(bundle, ODL_CUSTOM_BLUEPRINT_FILE_PATH);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private static List<Object> findBlueprintPaths(final Bundle bundle, final String path) {
+ Enumeration<?> rntries = bundle.findEntries(path, BLUEPRINT_FLE_PATTERN, false);
if (rntries == null) {
return Collections.emptyList();
} else {
return bundlesToDestroy;
}
- @Nullable
- private Bundle findBundleWithHighestUsedServiceId(final Collection<Bundle> containerBundles) {
+ private @Nullable Bundle findBundleWithHighestUsedServiceId(final Collection<Bundle> containerBundles) {
ServiceReference<?> highestServiceRef = null;
for (Bundle bundle : containerBundles) {
ServiceReference<?>[] references = bundle.getRegisteredServices();