felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r895641 - /felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
Date Mon, 04 Jan 2010 14:36:09 GMT
Author: marrs
Date: Mon Jan  4 14:36:08 2010
New Revision: 895641

URL: http://svn.apache.org/viewvc?rev=895641&view=rev
Log:
fixed a shutdown issue where sometimes services were unregistered twice

Modified:
    felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java

Modified: felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java?rev=895641&r1=895640&r2=895641&view=diff
==============================================================================
--- felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
(original)
+++ felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/ServiceImpl.java
Mon Jan  4 14:36:08 2010
@@ -322,25 +322,30 @@
     }
 
     public synchronized void start() {
-        m_serviceRegistration = m_context.registerService(ServiceComponent.class.getName(),
this, null);
-    	State oldState, newState;
-        synchronized (m_dependencies) {
-        	oldState = m_state;
-            newState = new State((List) m_dependencies.clone(), true, m_isInstantiated, m_isBound);
-            m_state = newState;
-        }
-        calculateStateChanges(oldState, newState);
+    	if (m_serviceRegistration == null) {
+	        m_serviceRegistration = m_context.registerService(ServiceComponent.class.getName(),
this, null);
+	    	State oldState, newState;
+	        synchronized (m_dependencies) {
+	        	oldState = m_state;
+	            newState = new State((List) m_dependencies.clone(), true, m_isInstantiated,
m_isBound);
+	            m_state = newState;
+	        }
+	        calculateStateChanges(oldState, newState);
+    	}
     }
 
     public synchronized void stop() {
-    	State oldState, newState;
-        synchronized (m_dependencies) {
-        	oldState = m_state;
-            newState = new State((List) m_dependencies.clone(), false, m_isInstantiated,
m_isBound);
-            m_state = newState;
-        }
-        calculateStateChanges(oldState, newState);
-        m_serviceRegistration.unregister();
+    	if (m_serviceRegistration != null) {
+	    	State oldState, newState;
+	        synchronized (m_dependencies) {
+	        	oldState = m_state;
+	            newState = new State((List) m_dependencies.clone(), false, m_isInstantiated,
m_isBound);
+	            m_state = newState;
+	        }
+	        calculateStateChanges(oldState, newState);
+	        m_serviceRegistration.unregister();
+	        m_serviceRegistration = null;
+    	}
     }
 
     public synchronized Service setInterface(String serviceName, Dictionary properties) {



Mime
View raw message