harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r536754 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/beancontext/BeanContextServicesSupport.java test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
Date Thu, 10 May 2007 06:35:52 GMT
Author: pyang
Date: Wed May  9 23:35:51 2007
New Revision: 536754

URL: http://svn.apache.org/viewvc?view=rev&rev=536754
Log:
Apply patch for HARMONY-3830([classlib][beans]java.beans.beancontext.BeanContextServicesSupport.addService(Class
serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent) should return true even
if fireEvent = false)

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java?view=diff&rev=536754&r1=536753&r2=536754
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextServicesSupport.java
Wed May  9 23:35:51 2007
@@ -194,6 +194,8 @@
         if (bcsp == null) {
             throw new NullPointerException(Messages.getString("beans.16")); //$NON-NLS-1$
         }
+        
+        boolean added = false;
 
         synchronized (BeanContext.globalHierarchyLock) {
             synchronized (this.services) {
@@ -204,26 +206,22 @@
                     if (getChildSerializable(bcsp) != null) {
                         this.serializable++;
                     }
-                } else {
-                    fireEvent = false;
-                }
+                    added = true;
+                } 
             }
 
             BeanContextServiceAvailableEvent ev = getEvent(serviceClass);
 
-            if (fireEvent) {
+            if (added && fireEvent) {
                 fireServiceAdded(ev);
-            }
-
-            for (Iterator it = iterator(); it.hasNext();) {
-                Object child = it.next();
-
-                if (child instanceof BeanContextServices) {
-                    ((BeanContextServices) child).serviceAvailable(ev);
+                for (Iterator it = iterator(); it.hasNext();) {
+                    Object child = it.next();
+                    if (child instanceof BeanContextServices) {
+                        ((BeanContextServices) child).serviceAvailable(ev);
+                    }
                 }
             }
-
-            return fireEvent;
+            return added;
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java?view=diff&rev=536754&r1=536753&r2=536754
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
Wed May  9 23:35:51 2007
@@ -1370,4 +1370,43 @@
         }
         assertEquals(count, serServices.size());
     }
+    
+    //Regression for HARMONY-3830
+    public void testAddService_with_fireEvent_false() {
+        MyBeanContextServicesSupport myBeanContextServicesSupport = new MyBeanContextServicesSupport();
+        boolean result = myBeanContextServicesSupport.addService(
+                MyService.class, new MyBeanContextServiceProvider(), false);
+        assertTrue(result);
+    }
+
+    public static class MyBeanContextServicesSupport extends
+            BeanContextServicesSupport {
+        private static final long serialVersionUID = 1L;
+
+        public boolean addService(Class serviceClass,
+                BeanContextServiceProvider bcsp, boolean fireEvent) {
+            return super.addService(serviceClass, bcsp, fireEvent);
+        }
+    }
+
+    public static class MyService implements Serializable {
+        private static final long serialVersionUID = 1L;
+    }
+    
+    public static class MyBeanContextServiceProvider implements
+            BeanContextServiceProvider {
+        public Iterator getCurrentServiceSelectors(BeanContextServices arg0,
+                Class arg1) {
+            return null;
+        }
+
+        public Object getService(BeanContextServices arg0, Object arg1,
+                Class arg2, Object arg3) {
+            return null;
+        }
+        
+        public void releaseService(BeanContextServices arg0, Object arg1,
+                Object arg2) {
+        }
+    }
 }



Mime
View raw message