X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fblueprint%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Fext%2FStaticServiceReferenceRecipe.java;h=368980565525c600bad52cd378302a3262400a25;hp=0466aab6c20fe0649d572c763b540e4e9cd32099;hb=67ff0fc78b2933b8b4f5a8544c7639499824e622;hpb=1ecaae69e61d9eca89b7521d542ca2ec4885c98d diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java index 0466aab6c2..3689805655 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/StaticServiceReferenceRecipe.java @@ -11,7 +11,6 @@ import com.google.common.base.Preconditions; import java.util.Collections; import java.util.function.Consumer; import org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe; -import org.apache.aries.blueprint.container.SatisfiableRecipe; import org.apache.aries.blueprint.services.ExtendedBlueprintContainer; import org.osgi.framework.ServiceReference; import org.osgi.service.blueprint.container.ComponentDefinitionException; @@ -28,11 +27,8 @@ import org.slf4j.LoggerFactory; class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { private static final Logger LOG = LoggerFactory.getLogger(StaticServiceReferenceRecipe.class); - private static final SatisfactionListener NOOP_LISTENER = new SatisfactionListener() { - @Override - public void notifySatisfaction(SatisfiableRecipe satisfiable) { + private static final SatisfactionListener NOOP_LISTENER = satisfiable -> { - } }; private volatile ServiceReference trackedServiceReference; @@ -45,8 +41,8 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { Collections.emptyList()); } - void startTracking(Consumer serviceSatisfiedCallback) { - this.serviceSatisfiedCallback = serviceSatisfiedCallback; + void startTracking(Consumer newServiceSatisfiedCallback) { + this.serviceSatisfiedCallback = newServiceSatisfiedCallback; super.start(NOOP_LISTENER); } @@ -61,7 +57,7 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { protected void untrack(ServiceReference reference) { LOG.debug("{}: In untrack {}", getName(), reference); - if(trackedServiceReference == reference) { + if (trackedServiceReference == reference) { LOG.debug("{}: Current reference has been untracked", getName(), trackedServiceReference); } } @@ -70,12 +66,12 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { protected void retrack() { LOG.debug("{}: In retrack", getName()); - if(trackedServiceReference == null) { + if (trackedServiceReference == null) { trackedServiceReference = getBestServiceReference(); LOG.debug("{}: getBestServiceReference: {}", getName(), trackedServiceReference); - if(trackedServiceReference != null && serviceSatisfiedCallback != null) { + if (trackedServiceReference != null && serviceSatisfiedCallback != null) { serviceSatisfiedCallback.accept(internalCreate()); } } @@ -85,10 +81,10 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { protected void doStop() { LOG.debug("{}: In doStop", getName()); - if(trackedServiceReference != null && trackedService != null) { + if (trackedServiceReference != null && trackedService != null) { try { getBundleContextForServiceLookup().ungetService(trackedServiceReference); - } catch(IllegalStateException e) { + } catch (IllegalStateException e) { // In case the service no longer exists, ignore. } @@ -104,7 +100,7 @@ class StaticServiceReferenceRecipe extends AbstractServiceReferenceRecipe { LOG.debug("{}: In internalCreate: trackedServiceReference: {}", getName(), localTrackedServiceReference); // being paranoid - internalCreate should only get called once - if(trackedService != null) { + if (trackedService != null) { return trackedService; }