- protected void retrieveService(String name, String interfaceName, Consumer<Object> onServiceRetrieved) {
- StaticServiceReferenceRecipe recipe = new StaticServiceReferenceRecipe(getId() + "-" + name,
- container, interfaceName);
- setDependendencyDesc(recipe.getOsgiFilter());
- serviceRecipes.add(recipe);
+ protected void retrieveService(final String name, final String interfaceName,
+ final Consumer<Object> onServiceRetrieved) {
+ synchronized (serviceRecipes) {
+ if (stoppedServiceRecipes) {
+ return;
+ }
+
+ StaticServiceReferenceRecipe recipe = new StaticServiceReferenceRecipe(getId() + "-" + name,
+ container, interfaceName);
+ setDependencyDesc(recipe.getOsgiFilter());
+ serviceRecipes.add(recipe);