felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r619132 - /felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
Date Wed, 06 Feb 2008 20:05:11 GMT
Author: marrs
Date: Wed Feb  6 12:05:09 2008
New Revision: 619132

URL: http://svn.apache.org/viewvc?rev=619132&view=rev
Log:
Changed the synchronization of two methods so they don't start and stop service trackers whilst
holding on to locks.

Modified:
    felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java

Modified: felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java?rev=619132&r1=619131&r2=619132&view=diff
==============================================================================
--- felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
(original)
+++ felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
Wed Feb  6 12:05:09 2008
@@ -99,40 +99,44 @@
         return m_trackedServiceName;
     }
 
-    public synchronized void start(Service service) {
-        if (m_isStarted) {
-            throw new IllegalStateException("Service dependency was already started." + m_trackedServiceName);
-        }
-        m_service = service;
-        if (m_trackedServiceName != null) {
-            if (m_trackedServiceFilter != null) {
-                try {
-                    m_tracker = new ServiceTracker(m_context, m_context.createFilter(m_trackedServiceFilter),
this);
+    public void start(Service service) {
+        synchronized (this) {
+            if (m_isStarted) {
+                throw new IllegalStateException("Service dependency was already started."
+ m_trackedServiceName);
+            }
+            m_service = service;
+            if (m_trackedServiceName != null) {
+                if (m_trackedServiceFilter != null) {
+                    try {
+                        m_tracker = new ServiceTracker(m_context, m_context.createFilter(m_trackedServiceFilter),
this);
+                    }
+                    catch (InvalidSyntaxException e) {
+                        throw new IllegalStateException("Invalid filter definition for dependency.");
+                    }
                 }
-                catch (InvalidSyntaxException e) {
-                    throw new IllegalStateException("Invalid filter definition for dependency.");
+                else if (m_trackedServiceReference != null) {
+                    m_tracker = new ServiceTracker(m_context, m_trackedServiceReference,
this);
+                }
+                else {
+                    m_tracker = new ServiceTracker(m_context, m_trackedServiceName.getName(),
this);
                 }
-            }
-            else if (m_trackedServiceReference != null) {
-                m_tracker = new ServiceTracker(m_context, m_trackedServiceReference, this);
             }
             else {
-                m_tracker = new ServiceTracker(m_context, m_trackedServiceName.getName(),
this);
+                throw new IllegalStateException("Could not create tracker for dependency,
no service name specified.");
             }
+            m_isStarted = true;
         }
-        else {
-            throw new IllegalStateException("Could not create tracker for dependency, no
service name specified.");
-        }
-        m_isStarted = true;
         m_tracker.open();
     }
 
-    public synchronized void stop(Service service) {
-        if (!m_isStarted) {
-            throw new IllegalStateException("Service dependency was not started.");
+    public void stop(Service service) {
+        synchronized (this) {
+            if (!m_isStarted) {
+                throw new IllegalStateException("Service dependency was not started.");
+            }
+            m_isStarted = false;
         }
         m_tracker.close();
-        m_isStarted = false;
         m_tracker = null;
     }
 



Mime
View raw message