From 2410d8844182e057fd59ea4139b9a7d61413bbea Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 8 Jul 2008 23:10:31 +0000 Subject: 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 --- .../sca/extension/helper/impl/DiscoveryUtils.java | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'java/sca/modules/extension-helper') 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 List discoverActivators(Class activatorClass, ExtensionPointRegistry registry) { List activators; - try { - Set activatorClasses = ServiceDiscovery.getInstance().getServiceDeclarations(activatorClass); - activators = new ArrayList(); - for (ServiceDeclaration declaration : activatorClasses) { - try { - Class c = (Class)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 activatorClasses = + ServiceDiscovery.getInstance().getServiceDeclarations(activatorClass); + activators = new ArrayList(); + for (ServiceDeclaration declaration : activatorClasses) { + try { + Class c = (Class)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 { } } - } -- cgit v1.2.3