Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse McConnell2013-06-03 13:21:18 -0400
committerJesse McConnell2013-06-03 13:21:27 -0400
commitfc87693ba99cde3b30a57ecafbd6c4794a6b6cb0 (patch)
treedd89078ab7661bfb85f7092615ea5165eff8dabc /examples
parent1bbab6d6f25b2085d9a767e7d08a0b4488e66257 (diff)
downloadorg.eclipse.jetty.project-fc87693ba99cde3b30a57ecafbd6c4794a6b6cb0.tar.gz
org.eclipse.jetty.project-fc87693ba99cde3b30a57ecafbd6c4794a6b6cb0.tar.xz
org.eclipse.jetty.project-fc87693ba99cde3b30a57ecafbd6c4794a6b6cb0.zip
add proxy server example from proxy tests into the embedded examples
Diffstat (limited to 'examples')
-rw-r--r--examples/embedded/pom.xml5
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java53
2 files changed, 58 insertions, 0 deletions
diff --git a/examples/embedded/pom.xml b/examples/embedded/pom.xml
index 8ee3c4a090..7b70eb0461 100644
--- a/examples/embedded/pom.xml
+++ b/examples/embedded/pom.xml
@@ -56,6 +56,11 @@
<artifactId>jetty-plus</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-proxy</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java
new file mode 100644
index 0000000000..15cc12ab7d
--- /dev/null
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ProxyServer.java
@@ -0,0 +1,53 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.embedded;
+
+import org.eclipse.jetty.proxy.ConnectHandler;
+import org.eclipse.jetty.proxy.ProxyServlet;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class ProxyServer
+{
+ public static void main(String[] args) throws Exception
+ {
+ Server server = new Server();
+ ServerConnector connector = new ServerConnector(server);
+ connector.setPort(8888);
+ server.addConnector(connector);
+
+ // Setup proxy handler to handle CONNECT methods
+ ConnectHandler proxy = new ConnectHandler();
+// proxy.setWhite(new String[]{"mail.google.com"});
+// proxy.addWhitelistHost("www.google.com");
+ server.setHandler(proxy);
+
+ // Setup proxy servlet
+ ServletContextHandler context = new ServletContextHandler(proxy, "/", ServletContextHandler.SESSIONS);
+ ServletHolder proxyServlet = new ServletHolder(ProxyServlet.class);
+// proxyServlet.setInitParameter("whiteList", "google.com, www.eclipse.org, localhost");
+// proxyServlet.setInitParameter("blackList", "google.com/calendar/*, www.eclipse.org/committers/");
+ context.addServlet(proxyServlet, "/*");
+
+ server.start();
+ }
+
+}

Back to the top