Author: david.lloyd(a)jboss.com
Date: 2008-07-03 10:16:42 -0400 (Thu, 03 Jul 2008)
New Revision: 4347
Removed:
remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/SunHttpServerChannel.java
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/AbstractHttpUrlChannel.java
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpUrlChannel.java
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpsUrlChannel.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpChannel.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpMessageWriter.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/Http.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpMessageWriter.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpChannelContext.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpServerContext.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/impl/
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractOutputStreamByteMessageOutput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageOutput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageOutput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/InputStreamByteMessageInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageOutput.java
Modified:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java
Log:
More cleanup
Modified:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java
===================================================================
---
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,11 +1,6 @@
package org.jboss.cx.remoting.core.stream;
import java.io.IOException;
-import java.util.LinkedList;
-import java.util.NoSuchElementException;
-import java.util.Queue;
-import org.jboss.cx.remoting.util.ObjectMessageInput;
-import org.jboss.cx.remoting.util.ObjectMessageOutput;
import org.jboss.cx.remoting.spi.stream.StreamSerializerFactory;
import org.jboss.cx.remoting.spi.marshal.MarshallerFactory;
import org.jboss.cx.remoting.stream.ObjectSource;
Deleted:
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpChannel.java
===================================================================
---
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpChannel.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpChannel.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,93 +0,0 @@
-package org.jboss.cx.remoting.http;
-
-import org.jboss.cx.remoting.http.RemotingHttpChannelContext;
-
-/**
- *
- */
-public abstract class AbstractHttpChannel {
-
- protected AbstractHttpChannel() {
- }
-
- // Configuration
-
- private int localParkTime = -1;
- private int remoteParkTime = -1;
-
- /**
- * Get the amount of time that a given channel member may be locally parked. A value
of {@code -1} means "park
- * indefinitely". A value of {@code 0} means "do not park".
Otherwise the value is interpreted as milliseconds.
- *
- * In the case of an HTTP server, the minimum of this time and the client-requested
timeout should be used.
- *
- * @return the local park time
- */
- public int getLocalParkTime() {
- return localParkTime;
- }
-
- /**
- * Set the amount of time that a given channel member may be locally parked. A value
of {@code -1} means "park
- * indefinitely". A value of {@code 0} means "do not park".
Otherwise the value is interpreted as milliseconds.
- *
- * In the case of an HTTP server, the minimum of this time and the client-requested
timeout should be used.
- *
- * @param localParkTime the local park time
- */
- public void setLocalParkTime(final int localParkTime) {
- this.localParkTime = localParkTime;
- }
-
- /**
- * Get the amount of time that a given channel member may be remotely parked. A
value of {@code -1} means "park
- * indefinitely". A value of {@code 0} means "do not park".
Otherwise the value is interpreted as milliseconds.
- *
- * @return the remote park time
- */
- public int getRemoteParkTime() {
- return remoteParkTime;
- }
-
- /**
- * Set the amount of time that a given channel member may be remotely parked. A
value of {@code -1} means "park
- * indefinitely". A value of {@code 0} means "do not park".
Otherwise the value is interpreted as milliseconds.
- *
- * @param remoteParkTime the remote park time
- */
- public void setRemoteParkTime(final int remoteParkTime) {
- this.remoteParkTime = remoteParkTime;
- }
-
- // Dependencies
-
- private RemotingHttpChannelContext channelContext;
-
- public RemotingHttpChannelContext getChannelContext() {
- return channelContext;
- }
-
- public void setChannelContext(final RemotingHttpChannelContext channelContext) {
- this.channelContext = channelContext;
- }
-
- // Lifecycle
-
- public void create() {
- if (channelContext == null) {
- throw new NullPointerException("channelContext is null");
- }
- }
-
- public void start() {
-
- }
-
- public void stop() {
-
- }
-
- public void destroy() {
-
- }
-}
Deleted:
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpMessageWriter.java
===================================================================
---
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpMessageWriter.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/AbstractHttpMessageWriter.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,8 +0,0 @@
-package org.jboss.cx.remoting.http;
-
-/**
- *
- */
-public abstract class AbstractHttpMessageWriter implements HttpMessageWriter {
-
-}
Deleted: remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/Http.java
===================================================================
--- remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/Http.java 2008-07-03
05:00:21 UTC (rev 4346)
+++ remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/Http.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,34 +0,0 @@
-package org.jboss.cx.remoting.http;
-
-/**
- *
- */
-public final class Http {
- private Http() {}
-
- enum MessageType {
- SESSION_OPEN,
- SESSION_JOIN,
- SESSION_CLOSE,
-
- STREAM_OPEN,
- STREAM_CLOSE,
- STREAM_DATA,
-
- SERVICE_CLOSING,
-
- SERVICE_CLOSE,
- SERVICE_CONTEXT_OPEN,
-
- CONTEXT_CLOSE,
-
- CONTEXT_CLOSING,
-
- REQUEST,
- REQUEST_CANCEL,
-
- REQUEST_REPLY,
- REQUEST_EXCEPTION,
- REQUEST_CANCELLED,
- }
-}
Deleted:
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpMessageWriter.java
===================================================================
---
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpMessageWriter.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpMessageWriter.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,11 +0,0 @@
-package org.jboss.cx.remoting.http;
-
-import java.io.IOException;
-import org.jboss.cx.remoting.util.ByteMessageOutput;
-
-/**
- *
- */
-public interface HttpMessageWriter {
- void writeMessageData(ByteMessageOutput byteOutput) throws IOException;
-}
Deleted:
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpChannelContext.java
===================================================================
---
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpChannelContext.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpChannelContext.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,25 +0,0 @@
-package org.jboss.cx.remoting.http;
-
-import org.jboss.cx.remoting.util.ByteMessageInput;
-
-/**
- *
- */
-public interface RemotingHttpChannelContext {
- /**
- * Process an HTTP message that has arrived.
- *
- * @param input the source of the message data
- */
- void processInboundMessage(ByteMessageInput input);
-
- /**
- * Wait for an outgoing HTTP message to become available, up to a certain time limit.
If no message is available
- * within the specified time limit, or if the thread is interrupted before a message
could become available, return
- * an empty message.
- *
- * @param millis the amount of time to wait in millseconds, {@code 0} to not wait, or
{@code -1} to wait indefinitely.
- * @return an outgoing HTTP message
- */
- HttpMessageWriter waitForOutgoingHttpMessage(int millis);
-}
Deleted:
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpServerContext.java
===================================================================
---
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpServerContext.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpServerContext.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,10 +0,0 @@
-package org.jboss.cx.remoting.http;
-
-import org.jboss.cx.remoting.util.ByteMessageInput;
-
-/**
- *
- */
-public interface RemotingHttpServerContext {
- RemotingHttpChannelContext processUnsolicitedInboundMessage(ByteMessageInput
messageInput);
-}
Deleted:
remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/SunHttpServerChannel.java
===================================================================
---
remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/SunHttpServerChannel.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/SunHttpServerChannel.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,179 +0,0 @@
-package org.jboss.cx.remoting.http.se6;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.ConcurrentMap;
-import java.security.SecureRandom;
-import org.jboss.cx.remoting.http.AbstractHttpChannel;
-import org.jboss.cx.remoting.http.HttpMessageWriter;
-import org.jboss.cx.remoting.http.RemotingHttpChannelContext;
-import org.jboss.cx.remoting.http.RemotingHttpServerContext;
-import org.jboss.cx.remoting.util.AbstractOutputStreamByteMessageOutput;
-import org.jboss.cx.remoting.util.CollectionUtil;
-import org.jboss.cx.remoting.util.InputStreamByteMessageInput;
-import org.jboss.xnio.IoUtils;
-
-import com.sun.net.httpserver.Headers;
-import com.sun.net.httpserver.HttpContext;
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-
-/**
- *
- */
-public final class SunHttpServerChannel extends AbstractHttpChannel implements
HttpHandler {
-
- public SunHttpServerChannel() {
- }
-
- // Configuration
-
- private CookieParser cookieParser;
-
- public CookieParser getCookieParser() {
- return cookieParser;
- }
-
- public void setCookieParser(final CookieParser cookieParser) {
- this.cookieParser = cookieParser;
- }
-
- // Dependencies
-
- private RemotingHttpServerContext serverContext;
- private HttpContext httpContext;
- private Random random;
-
- public RemotingHttpServerContext getServerContext() {
- return serverContext;
- }
-
- public void setServerContext(final RemotingHttpServerContext serverContext) {
- this.serverContext = serverContext;
- }
-
- public HttpContext getHttpContext() {
- return httpContext;
- }
-
- public void setHttpContext(final HttpContext httpContext) {
- this.httpContext = httpContext;
- }
-
- public Random getRandom() {
- return random;
- }
-
- public void setRandom(final Random random) {
- this.random = random;
- }
-
- // Lifecycle
-
- public void create() {
- if (serverContext == null) {
- throw new NullPointerException("serverContext is null");
- }
- if (random == null) {
- random = new SecureRandom();
- }
- }
-
- public void start() {
- httpContext.setHandler(this);
- }
-
- public void stop() {
- httpContext.setHandler(new HttpHandler() {
- public void handle(final HttpExchange exchange) throws IOException {
- throw new IOException("Context is not available");
- }
- });
- }
-
- public void destroy() {
- serverContext = null;
- httpContext = null;
- random = null;
- }
-
- // Implementation
-
- private final ConcurrentMap<String, RemotingHttpChannelContext> sessions =
CollectionUtil.concurrentMap();
-
- public void handle(final HttpExchange exchange) throws IOException {
- // it could be a non-https exchange (in the case of a separate SSL frontend)
- final boolean secure = "https".equals(exchange.getProtocol());
- final Headers requestHeader = exchange.getRequestHeaders();
- final List<String> cookieHeaders = requestHeader.get("Cookie");
- int parkTimeout = -1;
- String sessionId = null;
- for (String cookieString : cookieHeaders) {
- final List<Cookie> cookies = cookieParser.parseCookie(cookieString);
- for (Cookie cookie : cookies) {
- if ("Park-Timeout".equals(cookie.getName())) {
- try {
- parkTimeout = Integer.parseInt(cookie.getValue());
- } catch (NumberFormatException e) {
- // oh well
- }
- } else if ("JSESSIONID".equals(cookie.getName())) {
- sessionId = cookie.getValue();
- }
- }
- }
- final boolean needToSetSession;
- RemotingHttpChannelContext context = sessions.get(sessionId);
- final InputStream inputStream = exchange.getRequestBody();
- try {
- if (context == null) {
- needToSetSession = true;
- context = serverContext.processUnsolicitedInboundMessage(new
InputStreamByteMessageInput(inputStream, -1));
- } else {
- needToSetSession = false;
- context.processInboundMessage(new
InputStreamByteMessageInput(inputStream, -1));
- }
- } finally {
- IoUtils.safeClose(inputStream);
- }
- if (needToSetSession) {
- final StringBuilder setCookieBuilder = new StringBuilder(60);
- setCookieBuilder.append("JSESSIONID=");
- for (;;) {
- String jsessionid = generateSessionId();
- if (sessions.putIfAbsent(jsessionid, context) == null) {
- setCookieBuilder.append(jsessionid);
- break;
- }
- }
- if (secure) {
- setCookieBuilder.append("; secure");
- }
- exchange.getResponseHeaders().set("Set-Cookie",
setCookieBuilder.toString());
- }
- final HttpMessageWriter messageWriter =
context.waitForOutgoingHttpMessage(parkTimeout);
- final OutputStream outputStream = exchange.getResponseBody();
- try {
- messageWriter.writeMessageData(new
AbstractOutputStreamByteMessageOutput(outputStream) {
- public void commit() throws IOException {
- }
- });
- } finally {
- IoUtils.safeClose(outputStream);
- }
- }
-
- private String generateSessionId() {
- final byte[] bytes = new byte[16];
- StringBuilder builder = new StringBuilder(bytes.length * 2);
- random.nextBytes(bytes);
- for (byte b : bytes) {
- builder.append(Character.forDigit(b >>> 4 & 15, 16));
- builder.append(Character.forDigit(b & 15, 16));
- }
- return builder.toString();
- }
-}
Deleted:
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/AbstractHttpUrlChannel.java
===================================================================
---
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/AbstractHttpUrlChannel.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/AbstractHttpUrlChannel.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,236 +0,0 @@
-package org.jboss.cx.remoting.http.urlconnection;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.List;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.Future;
-import org.jboss.cx.remoting.http.AbstractHttpChannel;
-import org.jboss.cx.remoting.http.HttpMessageWriter;
-import org.jboss.cx.remoting.http.RemotingHttpChannelContext;
-import org.jboss.xnio.log.Logger;
-import org.jboss.cx.remoting.util.AbstractOutputStreamByteMessageOutput;
-import org.jboss.cx.remoting.util.NamingThreadFactory;
-import org.jboss.cx.remoting.util.InputStreamByteMessageInput;
-import org.jboss.xnio.IoUtils;
-
-/**
- *
- */
-public abstract class AbstractHttpUrlChannel extends AbstractHttpChannel {
-
- private static final Logger log = Logger.getLogger(AbstractHttpUrlChannel.class);
-
- private final CookieClientSession cookieClientSession = new CookieClientSession();
-
- protected AbstractHttpUrlChannel() {
- }
-
- // Configuration
-
- private int concurrentRequests = 2;
- private int connectTimeout = 5000;
- private int readTimeout = 0; // Default to unlimited to support "parking"
the connection at the other end
- private int errorBackoffTime = 5000;
- private URL connectUrl;
-
- public int getConcurrentRequests() {
- return concurrentRequests;
- }
-
- public void setConcurrentRequests(final int concurrentRequests) {
- this.concurrentRequests = concurrentRequests;
- }
-
- public int getConnectTimeout() {
- return connectTimeout;
- }
-
- public void setConnectTimeout(final int connectTimeout) {
- this.connectTimeout = connectTimeout;
- }
-
- public int getReadTimeout() {
- return readTimeout;
- }
-
- public void setReadTimeout(final int readTimeout) {
- this.readTimeout = readTimeout;
- }
-
- public int getErrorBackoffTime() {
- return errorBackoffTime;
- }
-
- public void setErrorBackoffTime(final int errorBackoffTime) {
- this.errorBackoffTime = errorBackoffTime;
- }
-
- public URL getConnectUrl() {
- return connectUrl;
- }
-
- public void setConnectUrl(final URL connectUrl) {
- this.connectUrl = connectUrl;
- }
-
- // Dependencies
-
- private Executor executor;
-
- public Executor getExecutor() {
- return executor;
- }
-
- public void setExecutor(final Executor executor) {
- this.executor = executor;
- }
-
- // Lifecycle
-
- private ExecutorService executorService;
- private Future[] futures;
-
- public void create() {
- super.create();
- if (executor == null) {
- executor = executorService = Executors.newFixedThreadPool(concurrentRequests,
new NamingThreadFactory(Executors.defaultThreadFactory(), "Remoting HTTP client
%s"));
- }
- if (connectUrl == null) {
- throw new NullPointerException("connectUrl is null");
- }
- }
-
- public void start() {
- final Future[] futures = new Future[concurrentRequests];
- for (int i = 0; i < futures.length; i++) {
- final FutureTask task = new FutureTask<Void>(null) {
- public void run() {
- while (! isCancelled()) try {
- handleRequest();
- } catch (Throwable t) {
- log.trace(t, "Request hander failed");
- }
- }
- };
- executor.execute(task);
- futures[i] = task;
- }
- this.futures = futures;
- }
-
- public void stop() {
- if (futures != null) {
- final Future[] futures = this.futures;
- this.futures = null;
- for (Future future : futures) try {
- future.cancel(true);
- } catch (Throwable t) {
- log.trace(t, "Error cancelling task");
- }
- }
- }
-
- public void destroy() {
- try {
- super.destroy();
- } finally {
- if (executorService != null) {
- executorService.shutdown();
- }
- }
- executor = executorService = null;
- }
-
- // Interface
-
- protected void handleRequest() {
- final URL connectUrl = getConnectUrl();
- final RemotingHttpChannelContext channelContext = getChannelContext();
- final int localParkTime = getLocalParkTime();
- final int remoteParkTime = getRemoteParkTime();
- final HttpMessageWriter messageWriter =
channelContext.waitForOutgoingHttpMessage(localParkTime);
- try {
- final HttpURLConnection httpConnection = intializeConnection(connectUrl);
- try {
- if (remoteParkTime >= 0) {
- httpConnection.addRequestProperty("Park-Timeout",
Integer.toString(remoteParkTime));
- }
- httpConnection.connect();
- final OutputStream outputStream = httpConnection.getOutputStream();
- try {
- messageWriter.writeMessageData(new
AbstractOutputStreamByteMessageOutput(outputStream) {
- public void commit() throws IOException {
- }
- });
- // now read the reply
- final String responseMessage = httpConnection.getResponseMessage();
- log.trace("HTTP server sent back a response message: %s",
responseMessage);
- final List<String> setCookies =
httpConnection.getHeaderFields().get("Set-Cookie");
- for (String s : setCookies) {
- cookieClientSession.handleSetCookieHeader(s,
connectUrl.getHost(), connectUrl.getPath());
- }
- final InputStream inputStream = httpConnection.getInputStream();
- try {
- channelContext.processInboundMessage(new
InputStreamByteMessageInput(inputStream, -1));
- } finally {
- IoUtils.safeClose(inputStream);
- }
- } finally {
- IoUtils.safeClose(outputStream);
- }
- } catch (IOException e) {
- // probably a HTTP error occurred, so let's consume it
- try {
- final InputStream errorStream = httpConnection.getErrorStream();
- if (errorStream != null) try {
- // consume & discard the error stream
- while (errorStream.read() > -1);
- errorStream.close();
- } finally {
- IoUtils.safeClose(errorStream);
- } else {
- log.trace(e, "Connection failed but there is no error
stream");
- }
- } catch (IOException e2) {
- log.trace(e2, "Error consuming the error stream from remote URL
'%s'", connectUrl);
- }
- final int time = errorBackoffTime;
- if (time > 0) {
- try {
- log.debug("HTTP error occurred; backing off for %d
milliseconds", Integer.valueOf(time));
- Thread.sleep(time);
- } catch (InterruptedException e1) {
- log.trace("Thread interrupted while waiting for error
backoff time to expire");
- Thread.currentThread().interrupt();
- }
- }
- }
- } catch (IOException e) {
- log.trace(e, "Error establishing connection");
- }
- }
-
- protected HttpURLConnection intializeConnection(final URL connectUrl) throws
IOException {
- final HttpURLConnection httpConnection = (HttpURLConnection)
connectUrl.openConnection();
- httpConnection.setDoInput(true);
- httpConnection.setDoOutput(true);
- httpConnection.setDefaultUseCaches(false);
- httpConnection.setUseCaches(false);
- httpConnection.setInstanceFollowRedirects(false);
- httpConnection.setConnectTimeout(getConnectTimeout());
- httpConnection.setReadTimeout(getReadTimeout());
- httpConnection.setRequestMethod("POST"); // All remoting requests are
POST
- final String cookieHeader =
cookieClientSession.getCookieHeader(connectUrl.getHost(), connectUrl.getPath(), false);
- if (cookieHeader != null) {
- httpConnection.setRequestProperty("Cookie", cookieHeader);
- }
- return httpConnection;
- }
-}
Deleted:
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpUrlChannel.java
===================================================================
---
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpUrlChannel.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpUrlChannel.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,16 +0,0 @@
-package org.jboss.cx.remoting.http.urlconnection;
-
-/**
- *
- */
-public final class HttpUrlChannel extends AbstractHttpUrlChannel {
-
- // lifecycle
-
- public void create() {
- final String protocol = getConnectUrl().getProtocol();
- if (! "http".equals(protocol)) {
- throw new IllegalArgumentException("Cannot use " +
HttpUrlChannel.class.getName() + " for protocol \"" + protocol +
"\"");
- }
- }
-}
Deleted:
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpsUrlChannel.java
===================================================================
---
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpsUrlChannel.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/http-urlconnection/src/main/java/org/jboss/cx/remoting/http/urlconnection/HttpsUrlChannel.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,81 +0,0 @@
-package org.jboss.cx.remoting.http.urlconnection;
-
-import java.io.IOException;
-import java.net.URL;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- *
- */
-public final class HttpsUrlChannel extends AbstractHttpUrlChannel {
-
- // Configuration
-
- private HostnameVerifier hostnameVerifier;
- private SSLSocketFactory sslSocketFactory;
-
- public HostnameVerifier getHostnameVerifier() {
- return hostnameVerifier;
- }
-
- public void setHostnameVerifier(final HostnameVerifier hostnameVerifier) {
- this.hostnameVerifier = hostnameVerifier;
- }
-
- public SSLSocketFactory getSslSocketFactory() {
- return sslSocketFactory;
- }
-
- public void setSslSocketFactory(final SSLSocketFactory sslSocketFactory) {
- this.sslSocketFactory = sslSocketFactory;
- }
-
- // Dependencies
-
-
-
- // Lifecycle
-
- public void create() {
- super.create();
- if (hostnameVerifier == null) {
- hostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
- }
- if (sslSocketFactory == null) {
- sslSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
- }
- final String protocol = getConnectUrl().getProtocol();
- if (! "https".equals(protocol)) {
- throw new IllegalArgumentException("Cannot use " +
HttpsUrlChannel.class.getName() + " for protocol \"" + protocol +
"\"");
- }
- }
-
- public void start() {
- super.start();
- }
-
- public void stop() {
- super.stop();
- }
-
- public void destroy() {
- try {
- super.destroy();
- } finally {
- hostnameVerifier = null;
- sslSocketFactory = null;
- }
- }
-
- // Interface
-
- protected HttpsURLConnection intializeConnection(final URL connectUrl) throws
IOException {
- final HttpsURLConnection httpsURLConnection = (HttpsURLConnection)
super.intializeConnection(connectUrl);
- httpsURLConnection.setHostnameVerifier(hostnameVerifier);
- httpsURLConnection.setSSLSocketFactory(sslSocketFactory);
- return httpsURLConnection;
- }
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractOutputStreamByteMessageOutput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractOutputStreamByteMessageOutput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractOutputStreamByteMessageOutput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,46 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- *
- */
-public abstract class AbstractOutputStreamByteMessageOutput implements ByteMessageOutput
{
- private final OutputStream outputStream;
- private int count;
-
- protected AbstractOutputStreamByteMessageOutput(final OutputStream outputStream) {
- if (outputStream == null) {
- throw new NullPointerException("outputStream is null");
- }
- this.outputStream = outputStream;
- }
-
- public void write(final int b) throws IOException {
- outputStream.write(b);
- count ++;
- }
-
- public void write(final byte[] b) throws IOException {
- outputStream.write(b);
- count += b.length;
- }
-
- public void write(final byte[] b, final int offs, final int len) throws IOException
{
- outputStream.write(b, offs, len);
- count += len;
- }
-
- public int getBytesWritten() throws IOException {
- return count;
- }
-
- public void close() throws IOException {
- outputStream.close();
- }
-
- public void flush() throws IOException {
- outputStream.flush();
- }
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageInput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageInput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageInput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,44 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.Closeable;
-import java.io.IOException;
-
-/**
- * A readable source of byte data.
- */
-public interface ByteMessageInput extends Closeable {
- /**
- * Read one byte.
- *
- * @return the byte, or -1 if the end of the stream has been reached.
- * @throws IOException if an I/O error occurs
- */
- int read() throws IOException;
-
- /**
- * Read a series of bytes into an array.
- *
- * @param data the array into which data is to be read
- * @return the total number of bytes read, or -1 if there are no bytes remaining to
read
- * @throws IOException if an I/O error occurs
- */
- int read(byte[] data) throws IOException;
-
- /**
- * Read a series of bytes into an array.
- *
- * @param data the array into which data is to be read
- * @param offs the start offset in the {@code data} array at which the data is
written
- * @param len the maximum number of bytes to read
- * @return the total number of bytes read, or -1 if there are no bytes remaining to
read
- * @throws IOException if an I/O error occurs
- */
- int read(byte[] data, int offs, int len) throws IOException;
-
- /**
- * Return the number of bytes remaining.
- *
- * @return the number of bytes, or -1 if the byte count cannot be determined
- */
- int remaining();
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageOutput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageOutput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteMessageOutput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,52 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.Closeable;
-import java.io.Flushable;
-import java.io.IOException;
-
-/**
- * A writable destination for byte data.
- */
-public interface ByteMessageOutput extends Closeable, Flushable {
- /**
- * Write a single byte of data. The input argument is truncated to 8 bits.
- *
- * @param b the byte to write
- * @throws IOException if an I/O error occurs
- */
- void write(int b) throws IOException;
-
- /**
- * Write many bytes of data.
- *
- * @param b the bytes to write
- * @throws IOException if an I/O error occurs
- */
- void write(byte[] b) throws IOException;
-
- /**
- * Write many bytes of data.
- *
- * @param b the bytes to write
- * @param offs the offset in {@code b} to start reading bytes from
- * @param len the number of bytes to write
- * @throws IOException if an I/O error occurs
- */
- void write(byte[] b, int offs, int len) throws IOException;
-
- /**
- * Commit the written data. This causes the accumulated data to be sent as a message
on the underlying
- * channel.
- *
- * @throws IOException if an I/O error occurs
- */
- void commit() throws IOException;
-
- /**
- * Get a count of the number of bytes written to this message.
- *
- * @return the count
- * @throws IOException if an I/O error occurs
- */
- int getBytesWritten() throws IOException;
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageInput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageInput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageInput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,9 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.DataInput;
-
-/**
- *
- */
-public interface DataMessageInput extends ByteMessageInput, DataInput {
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageOutput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageOutput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DataMessageOutput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,9 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.DataOutput;
-
-/**
- *
- */
-public interface DataMessageOutput extends ByteMessageOutput, DataOutput {
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/InputStreamByteMessageInput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/InputStreamByteMessageInput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/InputStreamByteMessageInput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,51 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- *
- */
-public class InputStreamByteMessageInput implements ByteMessageInput {
- private final InputStream inputStream;
- private int remaining;
-
- public InputStreamByteMessageInput(final InputStream inputStream, final int size) {
- this.inputStream = inputStream;
- remaining = size;
- }
-
- public int read() throws IOException {
- final int data = inputStream.read();
- if (data != -1 && remaining >= 0) {
- remaining--;
- }
- return data;
- }
-
- public int read(final byte[] data) throws IOException {
- final int cnt = inputStream.read(data);
- if (cnt != -1 && remaining >= 0) {
- remaining -= cnt;
- }
- return cnt;
- }
-
- public int read(final byte[] data, final int offs, final int len) throws IOException
{
- final int cnt = inputStream.read(data, offs, len);
- if (cnt != -1 && remaining >= 0) {
- remaining -= cnt;
- }
- return cnt;
- }
-
- public int remaining() {
- final int remaining = this.remaining;
- return remaining < 0 ? -1 : remaining;
- }
-
- public void close() throws IOException {
- remaining = -1;
- inputStream.close();
- }
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageInput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageInput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageInput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,19 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-
-/**
- * A readable message.
- */
-public interface ObjectMessageInput extends DataMessageInput, ObjectInput {
- /**
- * Read an object using the current context classloader, or, if there is no such
classloader, the classloader
- * which loaded this interface.
- *
- * @return the object from the message
- * @throws ClassNotFoundException if the class of the object could not be resolved by
the classloader
- * @throws IOException if an I/O error occurs
- */
- Object readObject() throws ClassNotFoundException, IOException;
-}
Deleted:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageOutput.java
===================================================================
---
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageOutput.java 2008-07-03
05:00:21 UTC (rev 4346)
+++
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ObjectMessageOutput.java 2008-07-03
14:16:42 UTC (rev 4347)
@@ -1,9 +0,0 @@
-package org.jboss.cx.remoting.util;
-
-import java.io.ObjectOutput;
-
-/**
- * A writable message.
- */
-public interface ObjectMessageOutput extends DataMessageOutput, ObjectOutput {
-}