You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ma...@apache.org on 2010/10/14 16:43:03 UTC
svn commit: r1022551 -
/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
Author: marrs
Date: Thu Oct 14 14:43:03 2010
New Revision: 1022551
URL: http://svn.apache.org/viewvc?rev=1022551&view=rev
Log:
Various fixes for problems with when to invoke instance bound dependency callbacks.
Modified:
felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java?rev=1022551&r1=1022550&r2=1022551&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java (original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ComponentImpl.java Thu Oct 14 14:43:03 2010
@@ -269,6 +269,7 @@ public class ComponentImpl implements Co
}
synchronized (m_dependencies) {
+ oldState = m_state;
// starting the dependency above might have triggered another state change, so
// we have to fetch the current state again
newState = new State((List) m_dependencies.clone(), !oldState.isInactive(), m_isInstantiated, m_isBound);
@@ -323,7 +324,7 @@ public class ComponentImpl implements Co
oldState = m_state;
m_dependencies.remove(dependency);
}
- if (oldState.isAllRequiredAvailable() || (oldState.isWaitingForRequired() && dependency.isRequired())) {
+ if (oldState.isAllRequiredAvailable() || ((oldState.isWaitingForRequired() || oldState.isWaitingForRequiredInstantiated()) && dependency.isRequired())) {
((DependencyActivation) dependency).stop(this);
}
synchronized (m_dependencies) {
@@ -599,30 +600,17 @@ public class ComponentImpl implements Co
// then we invoke the init callback so the service can further initialize
// itself
invoke(init);
-// // start extra/required dependencies which might have been added from the init() method.
-// startExtraRequiredDependencies();
// see if any of this caused further state changes
calculateStateChanges();
}
- private void startExtraRequiredDependencies() {
- Iterator i = m_dependencies.iterator();
- while (i.hasNext()) {
- Dependency dependency = (Dependency) i.next();
- if (dependency.isInstanceBound() && dependency.isRequired()) {
- // Optional extra dependencies will be started later, once our service is started.
- ((DependencyActivation) dependency).start(this);
- }
- }
- }
-
private void bindService(State state) {
String start;
synchronized (this) {
start = m_callbackStart;
}
-// // configure service with extra-dependencies which might have been added from init() method.
+ // configure service with extra-dependencies which might have been added from init() method.
configureServiceWithExtraDependencies(state);
// inform the state listeners we're starting
stateListenersStarting();
@@ -636,17 +624,13 @@ public class ComponentImpl implements Co
stateListenersStarted();
}
- private void configureServiceWithExtraDependencies(State state)
- {
+ private void configureServiceWithExtraDependencies(State state) {
Iterator i = state.getDependencies().iterator();
while (i.hasNext()) {
Dependency dependency = (Dependency) i.next();
if (dependency.isAutoConfig() && dependency.isInstanceBound()) {
configureImplementation(dependency.getAutoConfigType(), dependency.getAutoConfigInstance(), dependency.getAutoConfigName());
}
- if (dependency.isRequired() && dependency.isInstanceBound()) {
- dependency.invokeAdded(this);
- }
}
}
@@ -1056,6 +1040,14 @@ public class ComponentImpl implements Co
return (state.isAllRequiredAvailable());
}
+ public boolean isInstantiated() {
+ State state;
+ synchronized (m_dependencies) {
+ state = m_state;
+ }
+ return (state.isTrackingOptional() || state.isBound() || state.isWaitingForRequiredInstantiated());
+ }
+
// ServiceComponent interface
static class SCDImpl implements ComponentDependencyDeclaration {