From 0f3f9b59b310833f31ba234ee4aefa808649833c Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:50 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835120 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/http/tomcat/ServletWrapper.java | 56 ----- .../sca/http/tomcat/TomcatDefaultServlet.java | 70 ------ .../tuscany/sca/http/tomcat/TomcatServer.java | 249 -------------------- .../module/TomcatRuntimeModuleActivator.java | 54 ----- .../org.apache.tuscany.sca.core.ModuleActivator | 18 -- .../sca/http/tomcat/TomcatServerTestCase.java | 254 --------------------- .../src/test/resources/content/test.html | 21 -- 7 files changed, 722 deletions(-) delete mode 100644 branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java delete mode 100644 branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java delete mode 100644 branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java delete mode 100644 branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/module/TomcatRuntimeModuleActivator.java delete mode 100644 branches/sca-java-0.91/modules/http-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator delete mode 100644 branches/sca-java-0.91/modules/http-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java delete mode 100644 branches/sca-java-0.91/modules/http-tomcat/src/test/resources/content/test.html (limited to 'branches/sca-java-0.91/modules/http-tomcat/src') diff --git a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java b/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java deleted file mode 100644 index e5dbbc5694..0000000000 --- a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/ServletWrapper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.http.tomcat; - -import javax.servlet.Servlet; -import javax.servlet.ServletException; - -import org.apache.catalina.core.StandardWrapper; - -/** - * A servlet wrapper. - * - * @version $Rev$ $Date$ - */ -public class ServletWrapper extends StandardWrapper { - private static final long serialVersionUID = 1L; - - private final Servlet servlet; - - public ServletWrapper(Servlet servlet) { - this.servlet = servlet; - } - - public synchronized Servlet loadServlet() { - return servlet; - } - - public Servlet getServlet() { - return servlet; - } - - public void initServlet() throws ServletException { - servlet.init(facade); - } - - public void destroyServlet() { - servlet.destroy(); - } - -} diff --git a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java b/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java deleted file mode 100644 index e38f9a0dc9..0000000000 --- a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatDefaultServlet.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.http.tomcat; - -import java.net.URI; -import java.util.Hashtable; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - -import org.apache.catalina.servlets.DefaultServlet; -import org.apache.naming.resources.FileDirContext; -import org.apache.naming.resources.ProxyDirContext; - -public class TomcatDefaultServlet extends DefaultServlet { - private static final long serialVersionUID = -7503581551326796573L; - - private String documentRoot; - private ProxyDirContext proxyDirContext; - - public TomcatDefaultServlet(String servletPath, String documentRoot) { - this.documentRoot = documentRoot; - - FileDirContext dirContext = new FileDirContext(); - URI uri = URI.create(this.documentRoot); - dirContext.setDocBase(uri.getPath()); - - proxyDirContext = new ProxyDirContext(new Hashtable(), dirContext); - resources = proxyDirContext; - } - - @Override - public void init() throws ServletException { - super.init(); - resources = proxyDirContext; - } - - @Override - public void init(ServletConfig servletConfig) throws ServletException { - super.init(servletConfig); - resources = proxyDirContext; - } - - @Override - protected String getRelativePath(HttpServletRequest request) { - String path = request.getPathInfo(); - if (path == null || path.length() == 0) { - path = "/"; - } - return path; - } -} diff --git a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java b/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java deleted file mode 100644 index bf794486f2..0000000000 --- a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.http.tomcat; - -import java.net.URI; -import java.util.concurrent.Executor; - -import javax.servlet.Servlet; -import javax.servlet.ServletException; - -import org.apache.catalina.Context; -import org.apache.catalina.Lifecycle; -import org.apache.catalina.connector.Connector; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardEngine; -import org.apache.catalina.core.StandardHost; -import org.apache.catalina.startup.ContextConfig; -import org.apache.coyote.http11.Http11Protocol; -import org.apache.tomcat.util.buf.MessageBytes; -import org.apache.tomcat.util.http.mapper.MappingData; -import org.apache.tomcat.util.net.JIoEndpoint; -import org.apache.tuscany.sca.http.DefaultResourceServlet; -import org.apache.tuscany.sca.http.ServletHost; -import org.apache.tuscany.sca.http.ServletMappingException; -import org.apache.tuscany.sca.work.WorkScheduler; - -/** - * A Tomcat based implementation of ServletHost. - * - * @version $Rev$ $Date$ - */ -@SuppressWarnings("deprecation") -public class TomcatServer implements ServletHost { - - private static final int DEFAULT_PORT = 8080; - private StandardEngine engine; - private StandardHost host; - private Connector connector; - private WorkScheduler workScheduler; - - /** - * A custom connector that uses our WorkScheduler to schedule - * worker threads. - */ - private class CustomConnector extends Connector { - - private class CustomHttpProtocolHandler extends Http11Protocol { - - /** - * An Executor wrappering our WorkScheduler - */ - private class WorkSchedulerExecutor implements Executor { - public void execute(Runnable command) { - workScheduler.scheduleWork(command); - } - } - - /** - * A custom Endpoint that waits for its acceptor thread to - * terminate before stopping. - */ - private class CustomEndpoint extends JIoEndpoint { - private Thread acceptorThread; - - private class CustomAcceptor extends Acceptor { - CustomAcceptor() { - super(); - } - } - - public void start() throws Exception { - if (!initialized) - init(); - if (!running) { - running = true; - paused = false; - acceptorThread = new Thread(new CustomAcceptor(), getName() + "-Acceptor-" + 0); - acceptorThread.setPriority(threadPriority); - acceptorThread.setDaemon(daemon); - acceptorThread.start(); - } - } - - public void stop() { - super.stop(); - try { - acceptorThread.join(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - public int getCurrentThreadsBusy() { - return 0; - } - } - - CustomHttpProtocolHandler() { - endpoint = new CustomEndpoint(); - endpoint.setExecutor(new WorkSchedulerExecutor()); - } - } - - CustomConnector() throws Exception { - protocolHandler = new CustomHttpProtocolHandler(); - } - } - - /** - * Constructs a new embedded Tomcat server. - * - * @param workScheduler the WorkScheduler to use to process requests. - */ - public TomcatServer(WorkScheduler workScheduler) { - this.workScheduler = workScheduler; - } - - public void init() throws ServletMappingException { - - // Create an engine - engine = new StandardEngine(); - engine.setBaseDir(""); - engine.setDefaultHost("localhost"); - - // Create a host - host = new StandardHost(); - host.setAppBase(""); - host.setName("localhost"); - engine.addChild(host); - - // Create the root context - StandardContext context = new StandardContext(); - context.setDocBase(""); - context.setPath(""); - ContextConfig config = new ContextConfig(); - ((Lifecycle)context).addLifecycleListener(config); - host.addChild(context); - } - - public void destroy() throws ServletMappingException { - - // Stop the server - try { - if (connector !=null) { - connector.stop(); - engine.stop(); - } - } catch (Exception e) { - throw new ServletMappingException(e); - } - } - - public void addServletMapping(String strURI, Servlet servlet) { - URI uri = URI.create(strURI); - - int port = uri.getPort(); - if (port == -1) { - port = DEFAULT_PORT; - } - // Install a default HTTP connector - if (connector == null) { - //TODO support multiple connectors on different ports - try { - engine.start(); - connector = new CustomConnector(); - connector.setPort(port); - connector.setContainer(engine); - connector.initialize(); - connector.start(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - // Register the servlet mapping - ServletWrapper wrapper; - if (servlet instanceof DefaultResourceServlet) { - - // Optimize the handling of resource requests, use the Tomcat default servlet - // instead of our default resource servlet - String servletPath = uri.getPath(); - if (servletPath.endsWith("*")) { - servletPath = servletPath.substring(0, servletPath.length()-1); - } - if (servletPath.endsWith("/")) { - servletPath = servletPath.substring(0, servletPath.length()-1); - } - DefaultResourceServlet resourceServlet = (DefaultResourceServlet)servlet; - TomcatDefaultServlet defaultServlet = new TomcatDefaultServlet(servletPath, resourceServlet.getDocumentRoot()); - wrapper = new ServletWrapper(defaultServlet); - - } else { - wrapper = new ServletWrapper(servlet); - } - String mapping = uri.getPath(); - Context context = host.map(mapping); - wrapper.setName(mapping); - wrapper.addMapping(mapping); - context.addChild(wrapper); - context.addServletMapping(mapping, mapping); - connector.getMapper().addWrapper("localhost", "", mapping, wrapper); - - // Initialize the servlet - try { - wrapper.initServlet(); - } catch (ServletException e) { - throw new ServletMappingException(e); - } - } - - public Servlet removeServletMapping(String uri) { - String mapping = URI.create(uri).getPath(); - Context context = host.map(mapping); - MappingData md = new MappingData(); - MessageBytes mb = MessageBytes.newInstance(); - mb.setString(mapping); - try { - context.getMapper().map(mb, md); - } catch (Exception e) { - return null; - } - if (md.wrapper instanceof ServletWrapper) { - ServletWrapper servletWrapper = (ServletWrapper)md.wrapper; - context.removeServletMapping(mapping); - context.removeChild(servletWrapper); - servletWrapper.destroyServlet(); - return servletWrapper.getServlet(); - } else { - return null; - } - } - -} diff --git a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/module/TomcatRuntimeModuleActivator.java b/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/module/TomcatRuntimeModuleActivator.java deleted file mode 100644 index 3d59813608..0000000000 --- a/branches/sca-java-0.91/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/module/TomcatRuntimeModuleActivator.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.http.tomcat.module; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.http.ServletHostExtensionPoint; -import org.apache.tuscany.sca.http.tomcat.TomcatServer; -import org.apache.tuscany.sca.work.WorkScheduler; - -/** - * @version $Rev$ $Date$ - */ -public class TomcatRuntimeModuleActivator implements ModuleActivator { - - private TomcatServer server; - - public Object[] getExtensionPoints() { - return null; - } - - public void start(ExtensionPointRegistry extensionPointRegistry) { - - // Register a Tomcat servlet host - ServletHostExtensionPoint servletHosts = - extensionPointRegistry.getExtensionPoint(ServletHostExtensionPoint.class); - WorkScheduler workScheduler = extensionPointRegistry.getExtensionPoint(WorkScheduler.class); - server = new TomcatServer(workScheduler); - server.init(); - servletHosts.addServletHost(server); - } - - public void stop(ExtensionPointRegistry registry) { - server.destroy(); - } - -} diff --git a/branches/sca-java-0.91/modules/http-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/branches/sca-java-0.91/modules/http-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator deleted file mode 100644 index f0f4e17507..0000000000 --- a/branches/sca-java-0.91/modules/http-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# Implementation class for the ModuleActivator -org.apache.tuscany.sca.http.tomcat.module.TomcatRuntimeModuleActivator diff --git a/branches/sca-java-0.91/modules/http-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java b/branches/sca-java-0.91/modules/http-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java deleted file mode 100644 index 0431ea320b..0000000000 --- a/branches/sca-java-0.91/modules/http-tomcat/src/test/java/org/apache/tuscany/sca/http/tomcat/TomcatServerTestCase.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.http.tomcat; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.Socket; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.http.DefaultResourceServlet; -import org.apache.tuscany.sca.work.NotificationListener; -import org.apache.tuscany.sca.work.WorkScheduler; - -/** - * @version $Rev$ $Date$ - */ -public class TomcatServerTestCase extends TestCase { - - private static final String REQUEST1_HEADER = - "GET /foo HTTP/1.0\n" + "Host: localhost\n" - + "Content-Type: text/xml\n" - + "Connection: close\n" - + "Content-Length: "; - private static final String REQUEST1_CONTENT = ""; - private static final String REQUEST1 = - REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT; - - private static final String REQUEST2_HEADER = - "GET /webcontent/test.html HTTP/1.0\n" + "Host: localhost\n" - + "Content-Type: text/xml\n" - + "Connection: close\n" - + "Content-Length: "; - private static final String REQUEST2_CONTENT = ""; - private static final String REQUEST2 = - REQUEST2_HEADER + REQUEST2_CONTENT.getBytes().length + "\n\n" + REQUEST2_CONTENT; - - private static final int HTTP_PORT = 8085; - - private WorkScheduler workScheduler = new WorkScheduler() { - - public void scheduleWork(T work) { - Thread thread = new Thread(work); - thread.start(); - } - - public void scheduleWork(T work, NotificationListener listener) { - scheduleWork(work); - } - }; - - /** - * Verifies requests are properly routed according to the servlet mapping - */ - public void testRegisterServletMapping() throws Exception { - TomcatServer service = new TomcatServer(workScheduler); - service.init(); - TestServlet servlet = new TestServlet(); - service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet); - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - os.write(REQUEST1.getBytes()); - os.flush(); - read(client); - service.destroy(); - assertTrue(servlet.invoked); - } - - public void testUnregisterMapping() throws Exception { - TomcatServer service = new TomcatServer(workScheduler); - service.init(); - TestServlet servlet = new TestServlet(); - service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet); - service.removeServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo"); - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - os.write(REQUEST1.getBytes()); - os.flush(); - read(client); - service.destroy(); - assertFalse(servlet.invoked); - } - - public void testRequestSession() throws Exception { - TomcatServer service = new TomcatServer(workScheduler); - service.init(); - TestServlet servlet = new TestServlet(); - service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/foo", servlet); - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - os.write(REQUEST1.getBytes()); - os.flush(); - read(client); - service.destroy(); - assertTrue(servlet.invoked); - assertNotNull(servlet.sessionId); - } - - public void testRestart() throws Exception { - TomcatServer service = new TomcatServer(workScheduler); - service.init(); - service.destroy(); - service.init(); - service.destroy(); - } - - public void testNoMappings() throws Exception { - TomcatServer service = new TomcatServer(workScheduler); - service.init(); - Exception ex = null; - try { - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - os.write(REQUEST1.getBytes()); - os.flush(); - } catch (Exception e) { - ex = e; - } - assertNotNull(ex); - service.destroy(); - } - - public void testResourceServlet() throws Exception { - TomcatServer service = new TomcatServer(workScheduler); - service.init(); - - String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString(); - documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/')); - DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot); - TestResourceServlet servlet = new TestResourceServlet(resourceServlet); - service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", servlet); - - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - os.write(REQUEST2.getBytes()); - os.flush(); - - String document = read(client); - assertTrue(document.indexOf("

hello") != -1); - - service.destroy(); - } - - public void testDefaultServlet() throws Exception { - TomcatServer service = new TomcatServer(workScheduler); - service.init(); - - String documentRoot = getClass().getClassLoader().getResource("content/test.html").toString(); - documentRoot = documentRoot.substring(0, documentRoot.lastIndexOf('/')); - DefaultResourceServlet resourceServlet = new DefaultResourceServlet(documentRoot); - service.addServletMapping("http://127.0.0.1:" + HTTP_PORT + "/webcontent/*", resourceServlet); - - Socket client = new Socket("127.0.0.1", HTTP_PORT); - OutputStream os = client.getOutputStream(); - os.write(REQUEST2.getBytes()); - os.flush(); - - String document = read(client); - assertTrue(document.indexOf("

hello") != -1); - - service.destroy(); - } - - private static String read(Socket socket) throws IOException { - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); - StringBuffer sb = new StringBuffer(); - String str; - while ((str = reader.readLine()) != null) { - sb.append(str); - } - return sb.toString(); - } finally { - if (reader != null) { - reader.close(); - } - } - } - - private class TestServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - boolean invoked; - String sessionId; - - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - invoked = true; - sessionId = req.getSession().getId(); - OutputStream writer = resp.getOutputStream(); - try { - writer.write("result".getBytes()); - } finally { - writer.close(); - } - } - - } - - private class TestResourceServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - private HttpServlet delegate; - - public TestResourceServlet(HttpServlet delegate) { - this.delegate = delegate; - } - - @Override - public void init() throws ServletException { - super.init(); - delegate.init(); - } - - @Override - public void init(ServletConfig config) throws ServletException { - super.init(); - delegate.init(config); - } - - @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - delegate.service(req, resp); - } - - @Override - public void destroy() { - super.destroy(); - delegate.destroy(); - } - } -} diff --git a/branches/sca-java-0.91/modules/http-tomcat/src/test/resources/content/test.html b/branches/sca-java-0.91/modules/http-tomcat/src/test/resources/content/test.html deleted file mode 100644 index f4b79d7f01..0000000000 --- a/branches/sca-java-0.91/modules/http-tomcat/src/test/resources/content/test.html +++ /dev/null @@ -1,21 +0,0 @@ - - -

hello - \ No newline at end of file -- cgit v1.2.3