tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r930948 - /tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
Date Mon, 05 Apr 2010 20:11:08 GMT
Author: rfeng
Date: Mon Apr  5 20:11:08 2010
New Revision: 930948

URL: http://svn.apache.org/viewvc?rev=930948&view=rev
Log:
All the ServletHost impl class to receive attributes

Modified:
    tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java

Modified: tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java?rev=930948&r1=930947&r2=930948&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
Mon Apr  5 20:11:08 2010
@@ -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 DefaultServletHostExtension
         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 DefaultServletHostExtension
         }
 
         public void stop() {
-            if (host instanceof LifeCycleListener) {
-                ((LifeCycleListener)host).stop();
-            }
+            ServiceHelper.stop(host);
         }
     }
 
@@ -191,11 +179,7 @@ public class DefaultServletHostExtension
     }
 
     public void stop() {
-        for (ServletHost host : servletHosts) {
-            if (host instanceof LifeCycleListener) {
-                ((LifeCycleListener)host).stop();
-            }
-        }
+        ServiceHelper.stop(servletHosts);
         servletHosts.clear();
         registry = null;
     }



Mime
View raw message