summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/extension-helper
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-08 23:10:31 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-08 23:10:31 +0000
commit2410d8844182e057fd59ea4139b9a7d61413bbea (patch)
treebf16f0379149936193778e805a2d88c3cad69959 /java/sca/modules/extension-helper
parent755737f1cef0f827f6c87c3d55560adebdb776f0 (diff)
Make the ServiceDiscovery pluggable and add support for OSGi-based service discoverer
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@675040 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/extension-helper')
-rw-r--r--java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java38
1 files changed, 19 insertions, 19 deletions
diff --git a/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java b/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java
index 9d772c8ae8..720d409a44 100644
--- a/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java
+++ b/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/impl/DiscoveryUtils.java
@@ -38,23 +38,24 @@ import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
*/
public class DiscoveryUtils {
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public static <T> List<T> discoverActivators(Class<T> activatorClass, ExtensionPointRegistry registry) {
List<T> activators;
- try {
- Set<ServiceDeclaration> activatorClasses = ServiceDiscovery.getInstance().getServiceDeclarations(activatorClass);
- activators = new ArrayList<T>();
- for (ServiceDeclaration declaration : activatorClasses) {
- try {
- Class<T> c = (Class<T>)declaration.loadClass();
- activators.add(c.cast(instantiateActivator(c, registry)));
- } catch (Throwable e) {
- e.printStackTrace(); // TODO: log
- }
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ try {
+ Set<ServiceDeclaration> activatorClasses =
+ ServiceDiscovery.getInstance().getServiceDeclarations(activatorClass);
+ activators = new ArrayList<T>();
+ for (ServiceDeclaration declaration : activatorClasses) {
+ try {
+ Class<T> c = (Class<T>)declaration.loadClass();
+ activators.add(c.cast(instantiateActivator(c, registry)));
+ } catch (Throwable e) {
+ e.printStackTrace(); // TODO: log
+ }
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
return activators;
}
@@ -63,18 +64,18 @@ public class DiscoveryUtils {
if (cs.length != 1) {
throw new RuntimeException("Activator must have only one constructors");
}
-
+
Class<?>[] paramTypes = cs[0].getParameterTypes();
Object[] extensions = new Object[paramTypes.length];
- for (int i=0; i< paramTypes.length; i++) {
+ for (int i = 0; i < paramTypes.length; i++) {
if ("org.apache.tuscany.sca.host.http.ServletHost".equals(paramTypes[i].getName())) {
extensions[i] = getServletHost(registry);
} else {
extensions[i] = registry.getExtensionPoint(paramTypes[i]);
}
}
-
+
try {
return cs[0].newInstance(extensions);
@@ -109,5 +110,4 @@ public class DiscoveryUtils {
}
}
-
}