summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/host-http/src/main
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-04-05 20:11:08 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-04-05 20:11:08 +0000
commite89fc85c2a209d6dd4eb2a409ec3ad4cf8141925 (patch)
treef7625ab838e6509bc2b79fb119769c2b214fbf2f /sca-java-2.x/trunk/modules/host-http/src/main
parent331477b79355c30312e87f6c5a88bc5a7c7b8c61 (diff)
All the ServletHost impl class to receive attributes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@930948 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/host-http/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java26
1 files changed, 5 insertions, 21 deletions
diff --git a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
index 4c868f73e4..3145e90164 100644
--- a/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
+++ b/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
@@ -20,7 +20,6 @@
package org.apache.tuscany.sca.host.http;
import java.io.IOException;
-import java.lang.reflect.Constructor;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@@ -32,6 +31,7 @@ import javax.servlet.Servlet;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceHelper;
/**
* Default implementation of a Servlet host extension point.
@@ -110,18 +110,8 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi
public synchronized ServletHost getServletHost() {
if (host == null) {
try {
- Class<?> cls = sd.loadClass();
- Constructor<?> ctor = null;
- try {
- ctor = cls.getConstructor(ExtensionPointRegistry.class);
- host = (ServletHost)ctor.newInstance(registry);
- } catch (NoSuchMethodException e) {
- ctor = cls.getConstructor();
- host = (ServletHost)ctor.newInstance();
- }
- if(host instanceof LifeCycleListener) {
- ((LifeCycleListener) host).start();
- }
+ host = ServiceHelper.newInstance(registry, sd);
+ ServiceHelper.start(host);
} catch (Throwable e) {
throw new IllegalStateException(e);
}
@@ -181,9 +171,7 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi
}
public void stop() {
- if (host instanceof LifeCycleListener) {
- ((LifeCycleListener)host).stop();
- }
+ ServiceHelper.stop(host);
}
}
@@ -191,11 +179,7 @@ public class DefaultServletHostExtensionPoint implements ServletHostExtensionPoi
}
public void stop() {
- for (ServletHost host : servletHosts) {
- if (host instanceof LifeCycleListener) {
- ((LifeCycleListener)host).stop();
- }
- }
+ ServiceHelper.stop(servletHosts);
servletHosts.clear();
registry = null;
}