summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-26 05:53:10 (EDT)
committerEike Stepper2008-05-26 05:53:10 (EDT)
commit7ea2a2e2a0e23cda36196e69be6928b559fd982b (patch)
tree81a32663db8393758dcd801f95f999ad88172528
parentc83c69b216397ccf75fe4f2b1d7831657b805d00 (diff)
downloadcdo-7ea2a2e2a0e23cda36196e69be6928b559fd982b.zip
cdo-7ea2a2e2a0e23cda36196e69be6928b559fd982b.tar.gz
cdo-7ea2a2e2a0e23cda36196e69be6928b559fd982b.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/internal/http/HTTPAcceptor.java2
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java6
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java10
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPServerConnector.java20
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/tests/HTTPTest.java9
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java7
6 files changed, 36 insertions, 18 deletions
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 5bc5ec9..c8467f0 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
@@ -139,8 +139,6 @@ public class HTTPAcceptor extends Acceptor implements IHTTPAcceptor, INet4jTrans
public IHTTPConnector handleConnect(String userID)
{
String connectorID = createConnectorID(userID);
- System.out.println("HELLO " + userID + " (" + connectorID + ")");
-
HTTPServerConnector connector = createServerConnector();
prepareConnector(connector);
connector.setConnectorID(connectorID);
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java
index 39ef49d..e3a220d 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java
@@ -14,9 +14,7 @@ import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.connector.ConnectorLocation;
import org.eclipse.net4j.http.INet4jTransportServlet;
-import org.eclipse.net4j.internal.http.bundle.OM;
import org.eclipse.net4j.internal.util.lifecycle.Worker;
-import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.protocol.IProtocol;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -38,8 +36,6 @@ import java.text.MessageFormat;
*/
public class HTTPClientConnector extends HTTPConnector
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, HTTPClientConnector.class);
-
private String url;
private HttpClient httpClient;
@@ -249,6 +245,8 @@ public class HTTPClientConnector extends HTTPConnector
{
public void handleOut(ExtendedDataOutputStream out) throws IOException
{
+ out.writeByte(INet4jTransportServlet.OPCODE_BUFFERS);
+ out.writeString(getConnectorID());
moreBuffers[0] = writeOutputBuffers(out);
}
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 7d208b9..e2ae5ca 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
@@ -104,6 +104,11 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
do
{
QueuedBuffer queuedBuffer = outputQueue.poll();
+ if (queuedBuffer == null && pollAgain())
+ {
+ queuedBuffer = outputQueue.poll();
+ }
+
if (queuedBuffer == null)
{
break;
@@ -216,6 +221,11 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
return new HTTPChannel();
}
+ protected boolean pollAgain()
+ {
+ return false;
+ }
+
protected boolean writeMoreBuffers()
{
return true;
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPServerConnector.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPServerConnector.java
index 57f451c..2f11c3d 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPServerConnector.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPServerConnector.java
@@ -60,6 +60,13 @@ public class HTTPServerConnector extends HTTPConnector
}
@Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ leaveConnecting();
+ }
+
+ @Override
protected void registerChannelWithPeer(int channelID, short channelIndex, IProtocol protocol)
throws ConnectorException
{
@@ -67,9 +74,16 @@ public class HTTPServerConnector extends HTTPConnector
}
@Override
- protected void doActivate() throws Exception
+ protected boolean pollAgain()
{
- super.doActivate();
- leaveConnecting();
+ try
+ {
+ Thread.sleep(100);
+ return true;
+ }
+ catch (InterruptedException ex)
+ {
+ return false;
+ }
}
}
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/tests/HTTPTest.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/tests/HTTPTest.java
index d60526b..aee0282 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/tests/HTTPTest.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/tests/HTTPTest.java
@@ -12,7 +12,7 @@ package org.eclipse.net4j.internal.http.tests;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.http.HTTPUtil;
-import org.eclipse.net4j.http.IHTTPConnector;
+import org.eclipse.net4j.internal.http.HTTPClientConnector;
import org.eclipse.net4j.tests.AbstractTransportTest;
import org.eclipse.net4j.tests.signal.IntRequest;
import org.eclipse.net4j.tests.signal.TestSignalClientProtocolFactory;
@@ -114,18 +114,19 @@ public class HTTPTest extends AbstractTransportTest
public void test1() throws Exception
{
- IHTTPConnector connector = getHTTPConnector();
+ HTTPClientConnector connector = getHTTPConnector();
IChannel channel = connector.openChannel(TestSignalProtocol.PROTOCOL_NAME, null);
IntRequest request = new IntRequest(channel, 305419896);
int result = request.send();
assertEquals(305419896, result);
channel.close();
+ connector.deactivate();
}
- private IHTTPConnector getHTTPConnector()
+ private HTTPClientConnector getHTTPConnector()
{
- return (IHTTPConnector)container.getElement("org.eclipse.net4j.connectors", "http",
+ return (HTTPClientConnector)container.getElement("org.eclipse.net4j.connectors", "http",
"http://eike@localhost:8080/net4j");
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java
index 561f535..6bc5184 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ConcurrencyUtil.java
@@ -10,7 +10,6 @@
**************************************************************************/
package org.eclipse.net4j.util.concurrent;
-import org.eclipse.net4j.util.WrappedException;
/**
* @author Eike Stepper
@@ -27,9 +26,8 @@ public final class ConcurrencyUtil
{
Thread.sleep(millis);
}
- catch (InterruptedException ex)
+ catch (InterruptedException ignore)
{
- throw WrappedException.wrap(ex);
}
}
@@ -39,9 +37,8 @@ public final class ConcurrencyUtil
{
Thread.sleep(millis, nanos);
}
- catch (InterruptedException ex)
+ catch (InterruptedException ignore)
{
- throw WrappedException.wrap(ex);
}
}
}