Author: dkulp
Date: Fri Oct 26 18:19:16 2012
New Revision: 1402606
URL: http://svn.apache.org/viewvc?rev=1402606&view=rev
Log:
Attempt to fix some hard to debug blueprint "grace period" hangs.
If a bundle has multiple processors, only stop and restart the services
references once.
Modified:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
Modified:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
URL:
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java?rev=1402606&r1=1402605&r2=1402606&view=diff
==============================================================================
---
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
(original)
+++
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
Fri Oct 26 18:19:16 2012
@@ -87,7 +87,7 @@ public abstract class AbstractServiceRef
private final AtomicBoolean satisfied = new AtomicBoolean();
private SatisfactionListener satisfactionListener;
- private final AccessControlContext accessControlContext;
+ private final AccessControlContext accessControlContext;
protected AbstractServiceReferenceRecipe(String name,
ExtendedBlueprintContainer
blueprintContainer,
@@ -111,7 +111,6 @@ public abstract class AbstractServiceRef
{
accessControlContext = null;
}
-
}
@@ -120,6 +119,7 @@ public abstract class AbstractServiceRef
return listenersRecipe;
}
+ static boolean waited = false;
public void start(SatisfactionListener listener) {
if (listener == null) throw new
NullPointerException("satisfactionListener is null");
if (started.compareAndSet(false, true)) {
@@ -158,6 +158,7 @@ public abstract class AbstractServiceRef
}
satisfied.set(false);
}
+ satisfactionListener = null;
}
}
@@ -301,10 +302,10 @@ public abstract class AbstractServiceRef
}
public void serviceChanged(final ServiceEvent event) {
+ final int eventType = event.getType();
+ final ServiceReference ref = event.getServiceReference();
blueprintContainer.getExecutors().submit(new Runnable() {
public void run() {
- int eventType = event.getType();
- ServiceReference ref = event.getServiceReference();
switch (eventType) {
case ServiceEvent.REGISTERED:
serviceAdded(ref);
@@ -322,33 +323,43 @@ public abstract class AbstractServiceRef
private void serviceAdded(ServiceReference ref) {
LOGGER.debug("Tracking reference {} for OSGi service {}", ref,
getOsgiFilter());
- synchronized (references) {
- if (references.contains(ref)) {
- return;
+ if (isStarted()) {
+ synchronized (references) {
+ if (references.contains(ref)) {
+ return;
+ }
+ references.add(ref);
}
- references.add(ref);
+ track(ref);
+ setSatisfied(true);
}
- track(ref);
- setSatisfied(true);
}
private void serviceModified(ServiceReference ref) {
// ref must be in references and must be satisfied
- track(ref);
+ if (isStarted()) {
+ synchronized (references) {
+ if (references.contains(ref)) {
+ track(ref);
+ }
+ }
+ }
}
private void serviceRemoved(ServiceReference ref) {
- LOGGER.debug("Untracking reference {} for OSGi service {}", ref,
getOsgiFilter());
- boolean removed;
- boolean satisfied;
- synchronized (references) {
- removed = references.remove(ref);
- satisfied = optional || !references.isEmpty();
- }
- if (removed) {
- untrack(ref);
+ if (isStarted()) {
+ LOGGER.debug("Untracking reference {} for OSGi service {}", ref,
getOsgiFilter());
+ boolean removed;
+ boolean satisfied;
+ synchronized (references) {
+ removed = references.remove(ref);
+ satisfied = optional || !references.isEmpty();
+ }
+ if (removed) {
+ untrack(ref);
+ }
+ setSatisfied(satisfied);
}
- setSatisfied(satisfied);
}
protected Class getInterfaceClass() {
Modified:
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
URL:
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java?rev=1402606&r1=1402605&r2=1402606&view=diff
==============================================================================
---
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
(original)
+++
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
Fri Oct 26 18:19:16 2012
@@ -475,6 +475,7 @@ public class BlueprintContainerImpl
}
private void processProcessors() throws Exception {
+ boolean changed = false;
// Instanciate ComponentDefinitionRegistryProcessor and BeanProcessor
for (BeanMetadata bean : getMetadata(BeanMetadata.class)) {
if (bean instanceof ExtendedBeanMetadata &&
!((ExtendedBeanMetadata) bean).isProcessor()) {
@@ -495,12 +496,16 @@ public class BlueprintContainerImpl
if
(ComponentDefinitionRegistryProcessor.class.isAssignableFrom(clazz)) {
Object obj = repository.create(bean.getId(),
ProxyUtils.asList(ComponentDefinitionRegistryProcessor.class));
((ComponentDefinitionRegistryProcessor)
obj).process(componentDefinitionRegistry);
+ changed = true;
} else if (Processor.class.isAssignableFrom(clazz)) {
Object obj = repository.create(bean.getId(),
ProxyUtils.asList(Processor.class));
this.processors.add((Processor) obj);
+ changed = true;
} else {
continue;
}
+ }
+ if (changed) {
// Update repository with recipes processed by the processors
untrackServiceReferences();
Repository tmpRepo = new RecipeBuilder(this,
tempRecipeIdSpace).createRepository();
@@ -527,7 +532,6 @@ public class BlueprintContainerImpl
LOGGER.debug("Recipe {} is already instantiated and cannot
be updated", new Object[] { name });
}
}
-
getSatisfiableDependenciesMap(true);
trackServiceReferences();
}