summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-26 03:17:30 (EDT)
committerEike Stepper2008-05-26 03:17:30 (EDT)
commite8e2c12c764474eb19957204b4440218fbc93331 (patch)
treeefb8a86be548e0953bd30cd365abd6c6a51579a8
parent4dac74512359d1fa2e9dff585004eb6a58d9d915 (diff)
downloadcdo-e8e2c12c764474eb19957204b4440218fbc93331.zip
cdo-e8e2c12c764474eb19957204b4440218fbc93331.tar.gz
cdo-e8e2c12c764474eb19957204b4440218fbc93331.tar.bz2
[232648] Provide an HTTPConnector
https://bugs.eclipse.org/bugs/show_bug.cgi?id=232648
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java2
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java6
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java47
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java7
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java7
6 files changed, 67 insertions, 7 deletions
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java
index 4d223b1..ce1322e 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java
@@ -34,7 +34,7 @@ public interface INet4jTransportServlet extends Servlet
{
public IHTTPConnector[] handleList(String connectorID);
- public String handleConnect(String userID);
+ public IHTTPConnector handleConnect(String userID);
public void handleOpenChannel(String connectorID, short channelIndex, int channelID, String protocolType);
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java
index 63d4d01..3b411d6 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java
@@ -37,7 +37,7 @@ public class HTTPAcceptor extends Acceptor implements IHTTPAcceptor, INet4jTrans
{
public static final int DEFAULT_CONNECTOR_ID_LENGTH = 32;
- public static final int DEFAULT_MAX_IDLE_TIME = 10 * 60 * 1000; // 10 minutes
+ public static final int DEFAULT_MAX_IDLE_TIME = 60 * 1000; // 1 minute
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HTTPAcceptor.class);
@@ -133,7 +133,7 @@ public class HTTPAcceptor extends Acceptor implements IHTTPAcceptor, INet4jTrans
return new IHTTPConnector[] { httpConnectors.get(connectorID) };
}
- public String handleConnect(String userID)
+ public IHTTPConnector handleConnect(String userID)
{
String connectorID = createConnectorID(userID);
System.out.println("HELLO " + userID + " (" + connectorID + ")");
@@ -145,7 +145,7 @@ public class HTTPAcceptor extends Acceptor implements IHTTPAcceptor, INet4jTrans
addConnector(connector);
connector.activate();
- return connectorID;
+ return connector;
}
public void handleOpenChannel(String connectorID, short channelIndex, int channelID, String protocolType)
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java
new file mode 100644
index 0000000..0fe0d0e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.internal.http;
+
+import org.eclipse.internal.net4j.channel.Channel;
+
+/**
+ * @author Eike Stepper
+ */
+public class HTTPChannel extends Channel
+{
+ private long inputBufferCount;
+
+ private long outputBufferCount;
+
+ public HTTPChannel()
+ {
+ }
+
+ public long getInputBufferCount()
+ {
+ return inputBufferCount;
+ }
+
+ public void increaseInputBufferCount()
+ {
+ ++inputBufferCount;
+ }
+
+ public long getOutputBufferCount()
+ {
+ return outputBufferCount;
+ }
+
+ public void increaseOutputBufferCount()
+ {
+ ++outputBufferCount;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java
index 2441690..2924a0b 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java
@@ -18,6 +18,7 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.security.INegotiationContext;
import org.eclipse.internal.net4j.buffer.Buffer;
+import org.eclipse.internal.net4j.channel.Channel;
import org.eclipse.internal.net4j.channel.InternalChannel;
import org.eclipse.internal.net4j.connector.Connector;
@@ -71,4 +72,10 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
{
throw new UnsupportedOperationException();
}
+
+ @Override
+ protected Channel createChannelInstance()
+ {
+ return new HTTPChannel();
+ }
}
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java
index 038f798..b2801a0 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java
@@ -164,8 +164,9 @@ public class Net4jTransportServlet extends HttpServlet implements INet4jTranspor
try
{
String userID = in.readString();
- String connectorID = requestHandler.handleConnect(userID);
- out.writeString(connectorID);
+ IHTTPConnector connector = requestHandler.handleConnect(userID);
+ out.writeString(connector.getConnectorID());
+ out.writeInt(connector.getMaxIdleTime());
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java
index 7b211dc..161f5e3 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/connector/Connector.java
@@ -465,12 +465,17 @@ public abstract class Connector extends Container<IChannel> implements IConnecto
protected InternalChannel createChannel()
{
- Channel channel = new Channel();
+ Channel channel = createChannelInstance();
channel.setChannelMultiplexer(this);
channel.setReceiveExecutor(receiveExecutor);
return channel;
}
+ protected Channel createChannelInstance()
+ {
+ return new Channel();
+ }
+
public InternalChannel getChannel(final short channelIndex)
{
return channelsLock.read(new Callable<InternalChannel>()