tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r801851 - /tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
Date Fri, 07 Aug 2009 00:32:49 GMT
Author: rfeng
Date: Fri Aug  7 00:32:49 2009
New Revision: 801851

URL: http://svn.apache.org/viewvc?rev=801851&view=rev
Log:
Allow the creation of utility by class without registration

Modified:
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.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=801851&r1=801850&r2=801851&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 00:32:49 2009
@@ -177,9 +177,13 @@
             try {
                 ServiceDeclaration utilityDeclaration =
                     ServiceDiscovery.getInstance().getServiceDeclaration(utilityType.getName());
+                Class<?> utilityClass = null;
                 if (utilityDeclaration != null) {
-                    Class<?> utilityClass = utilityDeclaration.loadClass();
-
+                    utilityClass = utilityDeclaration.loadClass();
+                } else if (isConcreteClass(utilityType)) {
+                    utilityClass = utilityType;
+                }
+                if (utilityClass != null) {
                     // Construct the utility
                     Constructor<?>[] constructors = utilityClass.getConstructors();
                     Constructor<?> constructor = getConstructor(constructors, ExtensionPointRegistry.class,
Map.class);
@@ -218,7 +222,13 @@
             }
         }
         return utilityType.cast(utility);
-    }    
+    }
+
+    private boolean isConcreteClass(Class<?> utilityType) {
+        int modifiers = utilityType.getModifiers();
+        return !utilityType.isInterface() && Modifier.isPublic(modifiers) &&
!Modifier.isAbstract(modifiers);
+    }
+
     public void start() {
         // NOOP
     }



Mime
View raw message