tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r801875 - in /tuscany/java/sca/modules/extensibility/src: main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
Date Fri, 07 Aug 2009 04:03:22 GMT
Author: rfeng
Date: Fri Aug  7 04:03:21 2009
New Revision: 801875

URL: http://svn.apache.org/viewvc?rev=801875&view=rev
Log:
Allow the utility to be a concrete class

Modified:
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
    tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java?rev=801875&r1=801874&r2=801875&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
(original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
Fri Aug  7 04:03:21 2009
@@ -71,10 +71,14 @@
         }
 
         if (key == null) {
-            Set<Class<?>> interfaces = getAllInterfaces(utility.getClass());
+            Class<?> cls = utility.getClass();
+            Set<Class<?>> interfaces = getAllInterfaces(cls);
             for (Class<?> i : interfaces) {
                 utilities.put(i, utility);
             }
+            if (interfaces.isEmpty() || isConcreteClass(cls)) {
+                utilities.put(cls, utility);
+            }
         } else {
             utilities.put(key, utility);
         }
@@ -182,6 +186,7 @@
                     utilityClass = utilityDeclaration.loadClass();
                 } else if (isConcreteClass(utilityType)) {
                     utilityClass = utilityType;
+                    key = utilityType;
                 }
                 if (utilityClass != null) {
                     // Construct the utility

Modified: tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java?rev=801875&r1=801874&r2=801875&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
(original)
+++ tuscany/java/sca/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
Fri Aug  7 04:03:21 2009
@@ -67,6 +67,12 @@
         ep.removeUtility(my);
         u1= ep.getUtility(Utility1.class, "1");
         Assert.assertNull(u1);
+        
+        u1 = ep.getUtility(MyUtilityImpl.class);
+        Assert.assertNotNull(u1);
+        u2 = ep.getUtility(Utility2.class);
+        Assert.assertSame(u1, u2);
+        ep.removeUtility(u1);
     }
 
     /**



Mime
View raw message