diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-07 00:32:49 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-07 00:32:49 +0000 |
commit | 0ca889163f6e6dabedff9dde76a8aca6bf18c84d (patch) | |
tree | a12e4c4263a348facdd45d3c640f6b61c70764c3 /java/sca | |
parent | fa3d18a5890b62ff0d5154d40537288154dd41e6 (diff) |
Allow the creation of utility by class without registration
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@801851 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r-- | java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java index 2ab50cf414..a395352e4f 100644 --- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java +++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java @@ -177,9 +177,13 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint { 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 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint { } } 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 } |