Refactored project into modules, splitting the Jetty binding and the HTTP layer.

This commit is contained in:
Simone Bordet 2012-02-10 15:38:22 +01:00
parent 48cc0d33bf
commit 773f3202f8
109 changed files with 226 additions and 94 deletions

65
pom.xml
View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-spdy-project</artifactId>
<artifactId>spdy-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SPDY :: Project</name>
@ -14,31 +14,35 @@
</properties>
<modules>
<module>jetty-spdy-core</module>
<module>spdy-core</module>
<module>spdy-jetty</module>
<module>spdy-jetty-http</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>require-jdk7</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.7,)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>require-jdk7</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.7,)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
@ -47,8 +51,27 @@
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -4,12 +4,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-spdy-project</artifactId>
<artifactId>spdy-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-spdy-core</artifactId>
<artifactId>spdy-core</artifactId>
<name>SPDY :: Core</name>
<properties>
@ -52,8 +52,6 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

27
spdy-jetty-http/pom.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>spdy-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-jetty-http</artifactId>
<name>SPDY :: Jetty HTTP Layer</name>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>spdy-jetty</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio.http;
package org.eclipse.jetty.spdy.http;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -22,6 +22,9 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.http.HttpException;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.spdy.EmptyAsyncEndPoint;
import org.eclipse.jetty.spdy.SPDYAsyncConnection;
import org.eclipse.jetty.spdy.ServerSPDYAsyncConnectionFactory;
import org.eclipse.jetty.spdy.api.DataInfo;
import org.eclipse.jetty.spdy.api.Headers;
import org.eclipse.jetty.spdy.api.HeadersInfo;
@ -29,9 +32,6 @@ import org.eclipse.jetty.spdy.api.ReplyInfo;
import org.eclipse.jetty.spdy.api.Stream;
import org.eclipse.jetty.spdy.api.SynInfo;
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
import org.eclipse.jetty.spdy.nio.EmptyAsyncEndPoint;
import org.eclipse.jetty.spdy.nio.SPDYAsyncConnection;
import org.eclipse.jetty.spdy.nio.ServerSPDYAsyncConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio.http;
package org.eclipse.jetty.spdy.http;
import java.io.EOFException;
import java.io.IOException;
@ -41,10 +41,10 @@ import org.eclipse.jetty.io.nio.NIOBuffer;
import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.spdy.SPDYAsyncConnection;
import org.eclipse.jetty.spdy.api.Headers;
import org.eclipse.jetty.spdy.api.ReplyInfo;
import org.eclipse.jetty.spdy.api.Stream;
import org.eclipse.jetty.spdy.nio.SPDYAsyncConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio.http;
package org.eclipse.jetty.spdy.http;
import org.eclipse.jetty.spdy.nio.SPDYServerConnector;
import org.eclipse.jetty.spdy.SPDYServerConnector;
public class HTTPSPDYServerConnector extends SPDYServerConnector
{

View File

@ -14,19 +14,23 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio.http;
package org.eclipse.jetty.spdy.http;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.spdy.AbstractTest;
import org.eclipse.jetty.spdy.SPDYClient;
import org.eclipse.jetty.spdy.SPDYServerConnector;
import org.eclipse.jetty.spdy.api.Headers;
import org.eclipse.jetty.spdy.api.ReplyInfo;
import org.eclipse.jetty.spdy.api.SPDY;
@ -34,20 +38,83 @@ import org.eclipse.jetty.spdy.api.Session;
import org.eclipse.jetty.spdy.api.Stream;
import org.eclipse.jetty.spdy.api.StringDataInfo;
import org.eclipse.jetty.spdy.api.SynInfo;
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
import org.eclipse.jetty.spdy.nio.SPDYServerConnector;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ThreadPool;
import org.junit.After;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatchman;
import org.junit.runners.model.FrameworkMethod;
public class HTTPOverSPDYTest extends AbstractTest
public class HTTPOverSPDYTest
{
@Override
protected SPDYServerConnector newSPDYServerConnector(ServerSessionFrameListener listener)
@Rule
public final TestWatchman testName = new TestWatchman()
{
@Override
public void starting(FrameworkMethod method)
{
super.starting(method);
System.err.printf("Running %s.%s()%n",
method.getMethod().getDeclaringClass().getName(),
method.getName());
}
};
protected Server server;
protected SPDYClient.Factory clientFactory;
protected SPDYServerConnector connector;
protected InetSocketAddress startHTTPServer(Handler handler) throws Exception
{
server = new Server();
connector = newHTTPSPDYServerConnector();
connector.setPort(0);
server.addConnector(connector);
server.setHandler(handler);
server.start();
return new InetSocketAddress("localhost", connector.getLocalPort());
}
protected SPDYServerConnector newHTTPSPDYServerConnector()
{
return new HTTPSPDYServerConnector();
}
protected Session startClient(InetSocketAddress socketAddress, Session.FrameListener frameListener) throws Exception
{
if (clientFactory == null)
{
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName(threadPool.getName() + "-client");
clientFactory = newSPDYClientFactory(threadPool);
clientFactory.start();
}
return clientFactory.newSPDYClient().connect(socketAddress, frameListener).get();
}
protected SPDYClient.Factory newSPDYClientFactory(ThreadPool threadPool)
{
return new SPDYClient.Factory(threadPool);
}
@After
public void destroy() throws Exception
{
if (clientFactory != null)
{
clientFactory.stop();
clientFactory.join();
}
if (server != null)
{
server.stop();
server.join();
}
}
@Ignore
@Test
public void test100Continue() throws Exception

27
spdy-jetty/pom.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.eclipse.jetty</groupId>
<artifactId>spdy-project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spdy-jetty</artifactId>
<name>SPDY :: Jetty Binding</name>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>spdy-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio;
package org.eclipse.jetty.spdy;
import java.nio.channels.SocketChannel;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio;
package org.eclipse.jetty.spdy;
import java.io.IOException;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio;
package org.eclipse.jetty.spdy;
import java.io.IOException;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio;
package org.eclipse.jetty.spdy;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -27,7 +27,6 @@ import org.eclipse.jetty.io.nio.AsyncConnection;
import org.eclipse.jetty.io.nio.DirectNIOBuffer;
import org.eclipse.jetty.io.nio.IndirectNIOBuffer;
import org.eclipse.jetty.io.nio.NIOBuffer;
import org.eclipse.jetty.spdy.ISession;
import org.eclipse.jetty.spdy.ISession.Controller;
import org.eclipse.jetty.spdy.api.SPDY;
import org.eclipse.jetty.spdy.api.SPDYException;

View File

@ -19,7 +19,7 @@
* and open the template in the editor.
*/
package org.eclipse.jetty.spdy.nio;
package org.eclipse.jetty.spdy;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -45,9 +45,6 @@ import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
import org.eclipse.jetty.io.nio.SelectorManager;
import org.eclipse.jetty.io.nio.SslConnection;
import org.eclipse.jetty.npn.NextProtoNego;
import org.eclipse.jetty.spdy.CompressionFactory;
import org.eclipse.jetty.spdy.StandardCompressionFactory;
import org.eclipse.jetty.spdy.StandardSession;
import org.eclipse.jetty.spdy.api.Session;
import org.eclipse.jetty.spdy.api.Session.FrameListener;
import org.eclipse.jetty.spdy.generator.Generator;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio;
package org.eclipse.jetty.spdy;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.eclipse.jetty.spdy.nio;
package org.eclipse.jetty.spdy;
import java.io.IOException;
import java.nio.channels.SocketChannel;
@ -22,9 +22,6 @@ import java.nio.channels.SocketChannel;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.nio.AsyncConnection;
import org.eclipse.jetty.spdy.CompressionFactory;
import org.eclipse.jetty.spdy.StandardCompressionFactory;
import org.eclipse.jetty.spdy.StandardSession;
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
import org.eclipse.jetty.spdy.generator.Generator;
import org.eclipse.jetty.spdy.parser.Parser;

View File

@ -18,12 +18,9 @@ package org.eclipse.jetty.spdy;
import java.net.InetSocketAddress;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.spdy.api.Session;
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
import org.eclipse.jetty.spdy.nio.SPDYClient;
import org.eclipse.jetty.spdy.nio.SPDYServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ThreadPool;
@ -46,11 +43,12 @@ public abstract class AbstractTest
method.getName());
}
};
protected Server server;
protected SPDYClient.Factory clientFactory;
protected SPDYServerConnector connector;
protected InetSocketAddress startSPDYServer(ServerSessionFrameListener listener) throws Exception
protected InetSocketAddress startServer(ServerSessionFrameListener listener) throws Exception
{
server = new Server();
connector = newSPDYServerConnector(listener);
@ -60,17 +58,6 @@ public abstract class AbstractTest
return new InetSocketAddress("localhost", connector.getLocalPort());
}
protected InetSocketAddress startHTTPServer(Handler handler) throws Exception
{
server = new Server();
connector = newSPDYServerConnector(null);
connector.setPort(0);
server.addConnector(connector);
server.setHandler(handler);
server.start();
return new InetSocketAddress("localhost", connector.getLocalPort());
}
protected SPDYServerConnector newSPDYServerConnector(ServerSessionFrameListener listener)
{
return new SPDYServerConnector(listener);

View File

@ -64,7 +64,7 @@ public class ConcurrentSynDataReplyDataTest extends AbstractTest
};
}
};
final Session session = startClient(startSPDYServer(serverSessionFrameListener), null);
final Session session = startClient(startServer(serverSessionFrameListener), null);
final int iterations = 50;
final int count = 50;

View File

@ -33,11 +33,10 @@ import org.eclipse.jetty.spdy.api.Stream;
import org.eclipse.jetty.spdy.api.StringDataInfo;
import org.eclipse.jetty.spdy.api.SynInfo;
import org.eclipse.jetty.spdy.api.server.ServerSessionFrameListener;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
public class GoAwayTest extends AbstractTest
{
@Test
@ -61,7 +60,7 @@ public class GoAwayTest extends AbstractTest
latch.countDown();
}
};
Session session = startClient(startSPDYServer(serverSessionFrameListener), null);
Session session = startClient(startServer(serverSessionFrameListener), null);
session.syn(SPDY.V2, new SynInfo(true), null);
@ -94,7 +93,7 @@ public class GoAwayTest extends AbstractTest
latch.countDown();
}
};
Session session = startClient(startSPDYServer(serverSessionFrameListener), clientSessionFrameListener);
Session session = startClient(startServer(serverSessionFrameListener), clientSessionFrameListener);
Stream stream1 = session.syn(SPDY.V2, new SynInfo(true), null);
@ -138,7 +137,7 @@ public class GoAwayTest extends AbstractTest
ref.get().syn(SPDY.V2, new SynInfo(true), null);
}
};
Session session = startClient(startSPDYServer(serverSessionFrameListener), clientSessionFrameListener);
Session session = startClient(startServer(serverSessionFrameListener), clientSessionFrameListener);
ref.set(session);
session.syn(SPDY.V2, new SynInfo(true), null);
@ -190,7 +189,7 @@ public class GoAwayTest extends AbstractTest
goAwayLatch.countDown();
}
};
Session session = startClient(startSPDYServer(serverSessionFrameListener), clientSessionFrameListener);
Session session = startClient(startServer(serverSessionFrameListener), clientSessionFrameListener);
// First stream is processed ok
final CountDownLatch reply1Latch = new CountDownLatch(1);
@ -218,7 +217,7 @@ public class GoAwayTest extends AbstractTest
}
catch (SPDYException x)
{
Assert.assertThat(x.getCause(), instanceOf(ClosedChannelException.class));
Assert.assertThat(x.getCause(), CoreMatchers.instanceOf(ClosedChannelException.class));
}
// Be sure the last good stream is the first

Some files were not shown because too many files have changed in this diff Show More