Browse files

Remove all Jetty based code

Fixes #66
  • Loading branch information...
1 parent be17d1b commit 7a5f84fb82644e09cedef6b3f313ca4b72d4eeef Rob Fletcher committed Oct 28, 2013
View
14 betamax-jetty/betamax-jetty.gradle
@@ -1,14 +0,0 @@
-apply from: "$rootDir/gradle/groovyModule.gradle"
-apply from: "$rootDir/gradle/publishedModule.gradle"
-
-dependencies {
- compile project(":betamax-core")
- compile commonDependencies.jetty
-}
-
-modifyPom {
- project {
- name "Betamax Jetty"
- description "The base Jetty support classes for Betamax."
- }
-}
View
114 betamax-jetty/src/main/groovy/co/freeside/betamax/proxy/jetty/SimpleServer.groovy
@@ -1,114 +0,0 @@
-/*
- * Copyright 2011 the original author or authors.
- *
- * Licensed 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 co.freeside.betamax.proxy.jetty
-
-import java.util.concurrent.CountDownLatch
-import java.util.logging.Logger
-import org.eclipse.jetty.server.*
-import org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
-import org.eclipse.jetty.util.component.LifeCycle
-
-class SimpleServer extends AbstractLifeCycleListener {
-
- static final int DEFAULT_PORT = 5000
-
- final String host
- protected int port
- private Server server
- private CountDownLatch startedLatch
- private CountDownLatch stoppedLatch
-
- private static final log = Logger.getLogger(getClass().name)
-
- SimpleServer() {
- this(DEFAULT_PORT)
- }
-
- SimpleServer(int port) {
- // if there is no network connection we need to connect to the server via hostname rather than IP. At least this
- // is true on a Mac. Suspect it may be OS dependent. I should really make an effort to understand this but this
- // workaround means the proxy seems to operate correctly with or without a network connection. The weird thing
- // is that the hostName _doesn't_ work when there _is_ a network connection.
- def localAddress = InetAddress.localHost
- if (localAddress.loopbackAddress) {
- log.info "local address is loopback, using hostname $localAddress.hostName"
- host = localAddress.hostName
- } else {
- host = localAddress.hostAddress
- }
- this.port = port
- }
-
- String getUrl() {
- "http://$host:$port/"
- }
-
- void start(Class<? extends Handler> handlerClass) {
- start handlerClass.newInstance()
- }
-
- void start(Handler handler) {
- startedLatch = new CountDownLatch(1)
- stoppedLatch = new CountDownLatch(1)
-
- server = createServer(port)
- server.handler = handler
- server.addLifeCycleListener(this)
- server.start()
-
- startedLatch.await()
- }
-
- void stop() {
- if (server) {
- server.stop()
- stoppedLatch.await()
- }
- }
-
- void setPort(int port) {
- if (running) {
- throw new IllegalStateException('Cannot set port once the server is already started')
- }
- this.port = port
- }
-
- int getPort() {
- port
- }
-
- boolean isRunning() {
- startedLatch?.count == 0 && stoppedLatch?.count > 0
- }
-
- @Override
- void lifeCycleStarted(LifeCycle event) {
- log.fine 'started...'
- startedLatch.countDown()
- }
-
- @Override
- void lifeCycleStopped(LifeCycle event) {
- log.fine 'stopped...'
- stoppedLatch.countDown()
- }
-
- protected Server createServer(int port) {
- new Server(port)
- }
-
-}
View
1 betamax.gradle
@@ -27,7 +27,6 @@ allprojects {
exclude module: "httpclient"
}),
httpClient: dependencies.create("org.apache.httpcomponents:httpclient:4.2.2"),
- jetty: dependencies.create("org.eclipse.jetty:jetty-server:7.3.1.v20110307"),
junit: dependencies.create("junit:junit:4.10"),
netty: dependencies.create("io.netty:netty-all:4.0.7.Final"),
spock: dependencies.create("org.spockframework:spock-core:0.7-groovy-2.0", {
View
1 settings.gradle
@@ -1,6 +1,5 @@
include "betamax-core",
"betamax-httpclient",
- "betamax-jetty",
"betamax-proxy",
"betamax-manual",
"betamax-test-support"

0 comments on commit 7a5f84f

Please sign in to comment.