You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ad...@apache.org on 2009/12/15 04:15:04 UTC
svn commit: r890623 [1/2] - in /mina/sandbox/adc/ahc: ./
src/main/java/org/apache/ahc/api/ src/main/java/org/apache/ahc/client/
src/main/java/org/apache/ahc/client/api/ src/test/java/com/acme/ahc/
src/test/java/com/acme/ahc/listeners/ src/test/java/org...
Author: adc
Date: Tue Dec 15 03:15:02 2009
New Revision: 890623
URL: http://svn.apache.org/viewvc?rev=890623&view=rev
Log:
More sketches using Mina 2.0
Added:
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java (contents, props changed)
- copied, changed from r883577, mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslSessionConfigListener.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/api/
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/api/IoSessionCache.java (with props)
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/api/SessionConfigListener.java (with props)
mina/sandbox/adc/ahc/src/test/java/org/apache/ahc/client/
mina/sandbox/adc/ahc/src/test/java/org/apache/ahc/client/EquipmentStackTest.java (with props)
Modified:
mina/sandbox/adc/ahc/pom.xml
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpBatch.java
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClient.java
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpConnection.java
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpFactory.java
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpRequest.java
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClient.java
mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConfig.java
mina/sandbox/adc/ahc/src/test/java/com/acme/ahc/AcmeHttpClient.java
mina/sandbox/adc/ahc/src/test/java/com/acme/ahc/listeners/BenchmarkListener.java
Modified: mina/sandbox/adc/ahc/pom.xml
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/pom.xml?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/pom.xml (original)
+++ mina/sandbox/adc/ahc/pom.xml Tue Dec 15 03:15:02 2009
@@ -53,6 +53,10 @@
</plugins>
</build>
+ <properties>
+ <minaVersion>2.0.0-RC1</minaVersion>
+ </properties>
+
<dependencies>
<dependency>
@@ -65,7 +69,7 @@
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
- <version>2.0.0-RC1</version>
+ <version>${minaVersion}</version>
</dependency>
</dependencies>
Modified: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpBatch.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpBatch.java?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpBatch.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpBatch.java Tue Dec 15 03:15:02 2009
@@ -18,6 +18,7 @@
*/
package org.apache.ahc.api;
+import java.net.MalformedURLException;
import java.util.Map;
@@ -28,12 +29,14 @@
{
HttpBatch send(HttpRequest request);
- HttpBatch get(String url);
+ HttpBatch get(String url) throws MalformedURLException;
HttpBatch post(String url, Map<String, String> map, MimeContent... content);
HttpBatchFuture submit();
+ HttpBatch equipWith(HttpConfig config);
+
HttpBatch equipWith(HttpListener listener);
HttpBatch equipWith(String key, Object value);
Modified: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClient.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClient.java?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClient.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClient.java Tue Dec 15 03:15:02 2009
@@ -28,8 +28,6 @@
*/
public interface HttpClient extends Provisionable
{
- void addConfig(HttpConfig config);
-
HttpClientFuture<HttpResponse> send(HttpRequest request);
HttpClientFuture<HttpResponse> get(String url);
@@ -48,6 +46,8 @@
HttpClient equipWith(String key, Object value);
+ HttpClient equipWith(HttpConfig config);
+
HttpClient equipWith(HttpListener listener);
HttpClient push();
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.api;
+
+import java.util.concurrent.Future;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface HttpClientFuture<V> extends Future<V>
+{
+ public HttpClientFuture<V> register(FutureListener<V> listener);
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java (from r883577, mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java)
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java?p2=mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java&p1=mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java&r1=883577&r2=890623&rev=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFuture.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java Tue Dec 15 03:15:02 2009
@@ -22,7 +22,6 @@
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
@@ -31,17 +30,17 @@
/**
* @version $Revision$ $Date: $
*/
-public class HttpClientFuture<V> implements Future<V>
+public class HttpClientFutureImpl<V> implements HttpClientFuture<V>
{
private final CountDownLatch latch = new CountDownLatch(1);
private final List<FutureListener<V>> listeners = new ArrayList<FutureListener<V>>();
private final AtomicReference<Object> result = new AtomicReference<Object>();
- private final AtomicReference<FutureResultOwner<V>> owner = new AtomicReference<FutureResultOwner<V>>();
+ private final FutureResultOwner<V> owner;
private volatile boolean canceled;
- public HttpClientFuture(FutureResultOwner<V> owner)
+ public HttpClientFutureImpl(FutureResultOwner<V> owner)
{
- this.owner.set(owner);
+ this.owner = owner;
owner.set(new ChangeListener<V>()
{
@@ -61,7 +60,7 @@
}
listeners.clear();
- HttpClientFuture.this.owner.set(null);
+ HttpClientFutureImpl.this.owner.set(null);
}
public void set(V value)
@@ -80,13 +79,13 @@
}
listeners.clear();
- HttpClientFuture.this.owner.set(null);
+ HttpClientFutureImpl.this.owner.set(null);
}
});
}
@SuppressWarnings({"unchecked"})
- public HttpClientFuture<V> register(FutureListener<V> listener)
+ public HttpClientFutureImpl<V> register(FutureListener<V> listener)
{
synchronized (latch)
{
@@ -113,11 +112,16 @@
return this;
}
+ protected FutureResultOwner<V> getOwner()
+ {
+ return owner;
+ }
+
public boolean cancel(boolean mayInterruptIfRunning)
{
synchronized (latch)
{
- boolean c = !canceled && !isDone() && owner.get().cancel(mayInterruptIfRunning);
+ boolean c = !canceled && !isDone() && owner.cancel(mayInterruptIfRunning);
if (c) canceled = true;
@@ -180,4 +184,32 @@
void set(V value);
}
+
+ public static class ChangeListenerCoordinator<V> implements FutureResultOwner<V>
+ {
+ private ChangeListener<V> listener;
+ private FutureResultOwner<V> owner;
+
+ public void set(ChangeListener<V> listener)
+ {
+ if (this.listener != null) throw new IllegalStateException("Listener already set");
+ this.listener = listener;
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning)
+ {
+ return owner != null && owner.cancel(mayInterruptIfRunning);
+ }
+
+ public ChangeListener<V> getListener()
+ {
+ return listener;
+ }
+
+ public void setOwner(FutureResultOwner<V> owner)
+ {
+ if (this.owner != null) throw new IllegalStateException("Owner already set");
+ this.owner = owner;
+ }
+ }
}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java
------------------------------------------------------------------------------
svn:keywords = "Date Revision Id Author"
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpClientFutureImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpConnection.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpConnection.java?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpConnection.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpConnection.java Tue Dec 15 03:15:02 2009
@@ -25,6 +25,8 @@
{
HttpClient getClient();
+ HttpConnection equipWith(HttpConfig config);
+
HttpConnection equipWith(HttpListener listener);
HttpConnection equipWith(String key, Object value);
@@ -33,5 +35,5 @@
HttpConnection pop();
- HttpClientFuture<HttpResponse> send(HttpRequest request);
+ HttpClientFutureImpl<HttpResponse> send(HttpRequest request);
}
Modified: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpFactory.java?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpFactory.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpFactory.java Tue Dec 15 03:15:02 2009
@@ -23,10 +23,10 @@
*/
public interface HttpFactory extends Provisionable
{
- void addConfig(HttpConfig config);
-
HttpClient generateClient();
+ HttpFactory equipWith(HttpConfig config);
+
HttpFactory equipWith(String key, Object value);
HttpFactory equipWith(HttpListener listener);
Modified: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpRequest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpRequest.java?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpRequest.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/api/HttpRequest.java Tue Dec 15 03:15:02 2009
@@ -23,17 +23,20 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.ahc.HttpHeaders;
import org.apache.ahc.api.listeners.MimeContentListener;
+import org.apache.ahc.client.EquipmentStack;
/**
* @version $Revision$ $Date: $
*/
-public class HttpRequest
+public class HttpRequest implements Provisionable
{
+ private EquipmentStack stack;
private URL url;
private HttpVerb verb;
private HttpHeaders headers;
@@ -73,6 +76,15 @@
this.url = url;
}
+ @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"})
+ public void setStack(EquipmentStack stack)
+ {
+ synchronized (stack)
+ {
+ this.stack = new EquipmentStack(stack);
+ }
+ }
+
public URL getUrl()
{
return url;
@@ -157,4 +169,54 @@
return this;
}
+
+ public <T extends HttpConfig> T getConfig(Class<T> clazz)
+ {
+ return stack.getConfig(clazz);
+ }
+
+ public HttpRequest equipWith(HttpConfig config)
+ {
+ stack.equipWith(config);
+
+ return this;
+ }
+
+ public <T extends HttpListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return stack.getListeners(clazz);
+ }
+
+ public HttpRequest equipWith(HttpListener listener)
+ {
+ stack.equipWith(listener);
+
+ return this;
+ }
+
+ public Object getEquip(String key)
+ {
+ return stack.get(key);
+ }
+
+ public HttpRequest equipWith(String key, Object value)
+ {
+ stack.equipWith(key, value);
+
+ return this;
+ }
+
+ public HttpRequest push()
+ {
+ stack.push();
+
+ return this;
+ }
+
+ public HttpRequest pop()
+ {
+ stack.pop();
+
+ return this;
+ }
}
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.ahc.api.HttpBatch;
+import org.apache.ahc.api.HttpBatchFuture;
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpListener;
+import org.apache.ahc.api.HttpRequest;
+import org.apache.ahc.api.HttpVerb;
+import org.apache.ahc.api.MimeContent;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpBatch implements HttpBatch
+{
+ private final EquipmentStack stack;
+ private final int duration;
+ private final TimeUnit timeUnit;
+ private final List<HttpRequest> batch = new ArrayList<HttpRequest>();
+
+ public AsyncHttpBatch(EquipmentStack stack, int duration, TimeUnit timeUnit)
+ {
+ this.stack = stack;
+ this.duration = duration;
+ this.timeUnit = timeUnit;
+ }
+
+ public HttpBatch send(HttpRequest request)
+ {
+ batch.add(request);
+
+ return this;
+ }
+
+ public HttpBatch get(String url) throws MalformedURLException
+ {
+ HttpRequest request = new HttpRequest();
+
+ request.setUrl(new URL(url));
+ request.setVerb(HttpVerb.GET);
+
+ batch.add(request);
+
+ return this;
+ }
+
+ public HttpBatch post(String url, Map<String, String> map, MimeContent... content)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public HttpBatchFuture submit()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Object getEquip(String key)
+ {
+ return stack.get(key);
+ }
+
+ public HttpBatch equipWith(HttpConfig config)
+ {
+ stack.equipWith(config);
+
+ return this;
+ }
+
+ public HttpBatch equipWith(HttpListener listener)
+ {
+ stack.equipWith(listener);
+
+ return this;
+ }
+
+ public HttpBatch equipWith(String key, Object value)
+ {
+ stack.equipWith(key, value);
+
+ return this;
+ }
+
+ public HttpBatch push()
+ {
+ stack.push();
+
+ return this;
+ }
+
+ public HttpBatch pop()
+ {
+ stack.pop();
+
+ return this;
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatch.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.ahc.api.FutureListener;
+import org.apache.ahc.api.HttpBatchFuture;
+import org.apache.ahc.api.HttpResponse;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+class AsyncHttpBatchFuture implements HttpBatchFuture
+{
+ public HttpBatchFuture register(FutureListener<List<HttpResponse>> listener)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning)
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isCancelled()
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isDone()
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<HttpResponse> get() throws InterruptedException, ExecutionException, TimeoutException
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpBatchFuture.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClient.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClient.java?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClient.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClient.java Tue Dec 15 03:15:02 2009
@@ -19,14 +19,17 @@
package org.apache.ahc.client;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.Queue;
import java.util.concurrent.TimeUnit;
+import org.apache.mina.core.session.IoSession;
+
import org.apache.ahc.api.HttpBatch;
import org.apache.ahc.api.HttpClient;
-import org.apache.ahc.api.HttpClientFuture;
+import org.apache.ahc.api.HttpClientFutureImpl;
import org.apache.ahc.api.HttpConfig;
import org.apache.ahc.api.HttpConnection;
import org.apache.ahc.api.HttpListener;
@@ -40,54 +43,63 @@
*/
public class AsyncHttpClient implements HttpClient
{
- public AsyncHttpClient(Executor executor, ScheduledThreadPoolExecutor scheduledThreadPoolExecutor)
- {
- //Todo change body of created methods use File | Settings | File Templates.
- }
+ private final Map<InetSocketAddress, Queue<IoSession>> connections = new HashMap<InetSocketAddress, Queue<IoSession>>();
+ private final EquipmentStack stack;
- public Object getEquip(String key)
+ public AsyncHttpClient()
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ this(new EquipmentStack());
+
+ stack.equipWith(new DefaultIoSessionCache());
+ stack.equipWith(new DefaultSslConfig());
+ stack.equipWith(new SslSessionConfigListener());
}
- public void addConfig(HttpConfig config)
+ public AsyncHttpClient(EquipmentStack stack)
{
- //Todo change body of implemented methods use File | Settings | File Templates.
+ if (stack == null) stack = new EquipmentStack();
+ this.stack = stack;
}
- public HttpClientFuture<HttpResponse> send(HttpRequest request)
+ public HttpClientFutureImpl<HttpResponse> send(HttpRequest request)
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+
+ synchronized (stack)
+ {
+ AsyncHttpConnection connection = new AsyncHttpConnection(this, new EquipmentStack(stack));
+
+ return connection.send(request);
+ }
}
- public HttpClientFuture<HttpResponse> get(String url)
+ public HttpClientFutureImpl<HttpResponse> get(String url)
{
return null; //Todo change body of implemented methods use File | Settings | File Templates.
}
- public HttpClientFuture<HttpResponse> post(String url, Map<String, String> map, MimeContent... content)
+ public HttpClientFutureImpl<HttpResponse> post(String url, Map<String, String> map, MimeContent... content)
{
return null; //Todo change body of implemented methods use File | Settings | File Templates.
}
- public HttpClientFuture<HttpResponse> put(String url, Map<String, String> map, MimeContent... content)
+ public HttpClientFutureImpl<HttpResponse> put(String url, Map<String, String> map, MimeContent... content)
{
return null; //Todo change body of implemented methods use File | Settings | File Templates.
}
- public HttpClientFuture<HttpResponse> delete(String url)
+ public HttpClientFutureImpl<HttpResponse> delete(String url)
{
return null; //Todo change body of implemented methods use File | Settings | File Templates.
}
public HttpBatch batch()
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ return batch(0, TimeUnit.SECONDS);
}
public HttpBatch batch(int duration, TimeUnit timeUnit)
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ return new AsyncHttpBatch(new EquipmentStack(stack), duration, timeUnit);
}
public HttpConnection open(InetAddress address, int port)
@@ -95,23 +107,43 @@
return null; //Todo change body of implemented methods use File | Settings | File Templates.
}
+ public Object getEquip(String key)
+ {
+ return stack.get(key);
+ }
+
public HttpClient equipWith(String key, Object value)
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ stack.equipWith(key, value);
+
+ return this;
+ }
+
+ public HttpClient equipWith(HttpConfig config)
+ {
+ stack.equipWith(config);
+
+ return this;
}
public HttpClient equipWith(HttpListener listener)
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ stack.equipWith(listener);
+
+ return this;
}
public HttpClient push()
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ stack.push();
+
+ return this;
}
public HttpClient pop()
{
- return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ stack.pop();
+
+ return this;
}
}
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.ahc.api.HttpClientFutureImpl;
+import org.apache.ahc.api.HttpResponse;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpClientFutureException extends HttpClientFutureImpl<HttpResponse>
+{
+ public AsyncHttpClientFutureException(Throwable t)
+ {
+ super(new HttpClientFutureImpl.ChangeListenerCoordinator<HttpResponse>());
+ ((HttpClientFutureImpl.ChangeListenerCoordinator<HttpResponse>)getOwner()).getListener().exception(t);
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpClientFutureException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConfig.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConfig.java?rev=890623&r1=890622&r2=890623&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConfig.java (original)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConfig.java Tue Dec 15 03:15:02 2009
@@ -26,15 +26,26 @@
*/
public class AsyncHttpConfig implements HttpConfig
{
- private boolean TcpNoDelay;
+ private boolean tcpNoDelay;
+ private boolean keepAlive;
public boolean isTcpNoDelay()
{
- return TcpNoDelay;
+ return tcpNoDelay;
}
public void setTcpNoDelay(boolean tcpNoDelay)
{
- TcpNoDelay = tcpNoDelay;
+ this.tcpNoDelay = tcpNoDelay;
+ }
+
+ public boolean isKeepAlive()
+ {
+ return keepAlive;
+ }
+
+ public void setKeepAlive(boolean keepAlive)
+ {
+ this.keepAlive = keepAlive;
}
}
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,204 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import java.net.InetSocketAddress;
+import java.net.URL;
+
+import org.apache.mina.core.future.ConnectFuture;
+import org.apache.mina.core.future.DefaultConnectFuture;
+import org.apache.mina.core.future.IoFuture;
+import org.apache.mina.core.future.IoFutureListener;
+import org.apache.mina.core.service.IoConnector;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.transport.socket.nio.NioSocketConnector;
+
+import org.apache.ahc.api.HttpClient;
+import org.apache.ahc.api.HttpClientFutureImpl;
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpConnection;
+import org.apache.ahc.api.HttpListener;
+import org.apache.ahc.api.HttpRequest;
+import org.apache.ahc.api.HttpResponse;
+import org.apache.ahc.client.api.IoSessionCache;
+import org.apache.ahc.client.api.SessionConfigListener;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpConnection implements HttpConnection
+{
+ private final AsyncHttpClient httpClient;
+ private final EquipmentStack stack;
+
+ public AsyncHttpConnection(AsyncHttpClient httpClient, EquipmentStack stack)
+ {
+ this.httpClient = httpClient;
+ this.stack = stack;
+ }
+
+ public HttpClient getClient()
+ {
+ return httpClient;
+ }
+
+ public Object getEquip(String key)
+ {
+ return stack.get(key);
+ }
+
+ public HttpConnection equipWith(HttpConfig config)
+ {
+ stack.equipWith(config);
+
+ return this;
+ }
+
+ public HttpConnection equipWith(HttpListener listener)
+ {
+ stack.equipWith(listener);
+
+ return this;
+ }
+
+ public HttpConnection equipWith(String key, Object value)
+ {
+ stack.equipWith(key, value);
+
+ return this;
+ }
+
+ public HttpConnection push()
+ {
+ stack.push();
+
+ return this;
+ }
+
+ public HttpConnection pop()
+ {
+ stack.pop();
+
+ return this;
+ }
+
+ public HttpClientFutureImpl<HttpResponse> send(final HttpRequest request)
+ {
+ try
+ {
+ synchronized (stack)
+ {
+ URL url = request.getUrl();
+ InetSocketAddress address = InetSocketAddress.createUnresolved(url.getHost(), url.getPort());
+ IoSessionCache cache = request.getConfig(IoSessionCache.class);
+ final IoConnector connector = new NioSocketConnector();
+
+ final IoSession session = cache.getIoSession(connector, address);
+ ConnectFuture future = new DefaultConnectFuture();
+ future.setSession(session);
+
+ return new HttpClientFutureImpl<HttpResponse>(new HttpClientFutureImpl.FutureResultOwner<HttpResponse>()
+ {
+ EquipmentStack e = new EquipmentStack(stack);
+ HttpClientFutureImpl.ChangeListener<HttpResponse> changeListener;
+
+ {
+ ConnectFuture future = connector.connect();
+ future.addListener(new IoFutureListener()
+ {
+ public void operationComplete(IoFuture future)
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
+ ConnectFuture connFuture = (ConnectFuture)future;
+
+ try
+ {
+ if (connFuture.isConnected())
+ {
+ IoSession sess = future.getSession();
+
+ for (SessionConfigListener listener : e.getListeners(SessionConfigListener.class))
+ listener.configure(session, request);
+
+ // add the protocol filter (if it's not there already like
+ // in a reused session)
+ // addProtocolCodecFilter(sess);
+ // (optional) add the executor filter for the event thread
+ // pool (if it's not there already like in a reused session)
+ // addEventThreadPoolFilter(sess);
+ // now that we're connection, configure the session appropriately.
+ // configureSession(sess);
+
+ // and finally start the request process rolling.
+ session.write(request);
+
+ // notifyMonitoringListeners(MonitoringEvent.CONNECTION_SUCCESSFUL, request);
+ }
+ else
+ {
+// if (retries-- > 0)
+// {
+// // go retry this connection
+// retryConnection(request, response, this);
+// }
+// else
+// {
+// future.getSession();
+// throw new AsyncHttpClientException("Connection failed.");
+// }
+ }
+ }
+ catch (RuntimeException re)
+ {
+ // set the future exception to ensure the exception propagate
+// response.setException(re);
+// notifyMonitoringListeners(MonitoringEvent.CONNECTION_FAILED, request);
+ throw re;
+ }
+ catch (Error e)
+ {
+ // set the future exception to ensure the exception propagate
+// response.setException(e);
+// notifyMonitoringListeners(MonitoringEvent.CONNECTION_FAILED, request);
+ throw e;
+ }
+ }
+ });
+ }
+
+ public void set(HttpClientFutureImpl.ChangeListener<HttpResponse> changeListener)
+ {
+ this.changeListener = changeListener;
+ }
+
+ public boolean cancel(boolean mayInterruptIfRunning)
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+ });
+
+ }
+ }
+ catch (Throwable throwable)
+ {
+ return new AsyncHttpClientFutureException(throwable);
+ }
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpConnection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.ahc.api.HttpClient;
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpFactory;
+import org.apache.ahc.api.HttpListener;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpFactory implements HttpFactory
+{
+ private final EquipmentStack stack = new EquipmentStack();
+
+ public AsyncHttpFactory()
+ {
+ stack.equipWith(new DefaultIoSessionCache());
+ stack.equipWith(new DefaultSslConfig());
+ stack.equipWith(new SslSessionConfigListener());
+ }
+
+ public Object getEquip(String key)
+ {
+ return stack.get(key);
+ }
+
+ public HttpClient generateClient()
+ {
+ return new AsyncHttpClient(new EquipmentStack(stack));
+ }
+
+ public HttpFactory equipWith(String key, Object value)
+ {
+ stack.equipWith(key, value);
+
+ return this;
+ }
+
+ public HttpFactory equipWith(HttpConfig config)
+ {
+ stack.equipWith(config);
+
+ return this;
+ }
+
+ public HttpFactory equipWith(HttpListener listener)
+ {
+ stack.equipWith(listener);
+
+ return this;
+ }
+
+ public HttpFactory push()
+ {
+ stack.push();
+
+ return this;
+ }
+
+ public HttpFactory pop()
+ {
+ stack.pop();
+
+ return this;
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.mina.core.future.IoFuture;
+import org.apache.mina.core.future.IoFutureListener;
+import org.apache.mina.core.session.IoSession;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpIoFuture implements IoFuture
+{
+ public IoSession getSession()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoFuture await() throws InterruptedException
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean await(long timeout, TimeUnit unit) throws InterruptedException
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean await(long timeoutMillis) throws InterruptedException
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoFuture awaitUninterruptibly()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean awaitUninterruptibly(long timeout, TimeUnit unit)
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean awaitUninterruptibly(long timeoutMillis)
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void join()
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean join(long timeoutMillis)
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isDone()
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoFuture addListener(IoFutureListener<?> ioFutureListener)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoFuture removeListener(IoFutureListener<?> ioFutureListener)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoFuture.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.mina.core.future.IoFuture;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.core.session.IoSessionInitializer;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpIoSessionInitializer implements IoSessionInitializer
+{
+ public void initializeSession(IoSession ioSession, IoFuture ioFuture)
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpIoSessionInitializer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpProtocolCodecFactory implements ProtocolCodecFactory
+{
+ public ProtocolEncoder getEncoder(IoSession session) throws Exception
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public ProtocolDecoder getDecoder(IoSession session) throws Exception
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AsyncHttpProtocolDecoder extends CumulativeProtocolDecoder
+{
+ @Override
+ protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception
+ {
+ return false; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/AsyncHttpProtocolDecoder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import java.net.InetSocketAddress;
+
+import org.apache.mina.core.future.ConnectFuture;
+import org.apache.mina.core.service.IoConnector;
+import org.apache.mina.core.session.IoSession;
+
+import org.apache.ahc.client.api.IoSessionCache;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DefaultIoSessionCache implements IoSessionCache
+{
+ public IoSession getIoSession(IoConnector connector, InetSocketAddress address) throws Throwable
+ {
+ ConnectFuture future = connector.connect(address).awaitUninterruptibly();
+
+ if (future.getException() != null) throw future.getException();
+
+ return future.getSession();
+ }
+
+ public void returnIoSession(IoSession session)
+ {
+ session.close(false);
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultIoSessionCache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DefaultSslConfig extends SslConfig
+{
+ public DefaultSslConfig()
+ {
+ setTrustManagers(new TrustManager[]{
+ new X509TrustManager()
+ {
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException
+ {
+ }
+
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException
+ {
+ }
+
+ public X509Certificate[] getAcceptedIssuers()
+ {
+ return new X509Certificate[0];
+ }
+ }
+ });
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/DefaultSslConfig.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,207 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import java.util.ArrayList;
+import java.util.EmptyStackException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpListener;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class EquipmentStack implements Cloneable
+{
+ private final Stack<EquipmentEntries> stack = new Stack<EquipmentEntries>();
+
+ public EquipmentStack()
+ {
+ stack.push(new EquipmentEntries());
+ }
+
+ @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"})
+ public EquipmentStack(EquipmentStack equipmentStack)
+ {
+ synchronized (equipmentStack)
+ {
+ for (EquipmentEntries entries : equipmentStack.stack)
+ stack.push(new EquipmentEntries(entries));
+ }
+ }
+
+
+ public synchronized Object get(String key)
+ {
+ return get(key, null);
+ }
+
+ public synchronized Object get(String key, Object defaultValue)
+ {
+ Object value = stack.peek().get(key);
+ if (value == null) value = defaultValue;
+ return value;
+ }
+
+ public synchronized void equipWith(String key, Object value)
+ {
+ stack.peek().equipWith(key, value);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public synchronized <T extends HttpConfig> T getConfig(Class<T> clazz)
+ {
+ return stack.peek().getConfig(clazz);
+ }
+
+ public synchronized void equipWith(HttpConfig config)
+ {
+ stack.peek().equipWith(config);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public synchronized <T extends HttpListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return stack.peek().getListeners(clazz);
+ }
+
+ public synchronized void equipWith(HttpListener listener)
+ {
+ stack.peek().equipWith(listener);
+ }
+
+ public synchronized void push()
+ {
+ stack.push(new EquipmentEntries(stack.peek()));
+ }
+
+ public synchronized void pop()
+ {
+ if (stack.size() > 1) stack.pop();
+ else throw new EmptyStackException();
+ }
+
+ @Override
+ @SuppressWarnings({"CloneDoesntCallSuperClone"})
+ protected synchronized Object clone() throws CloneNotSupportedException
+ {
+ return new EquipmentStack(this);
+ }
+
+ private static List<Class> collectConfigurations(Class aClass)
+ {
+ List<Class> result = new ArrayList<Class>();
+
+ if (HttpConfig.class.isAssignableFrom(aClass)) result.add(aClass);
+
+ Class superclass = aClass.getSuperclass();
+
+ if ((HttpConfig.class.isAssignableFrom(superclass))) result.addAll(collectConfigurations(superclass));
+
+ return result;
+ }
+
+ private static List<Class> collectInterfaces(Class aClass)
+ {
+ List<Class> result = new ArrayList<Class>();
+
+ for (Class iface : aClass.getInterfaces())
+ {
+ if (HttpListener.class != iface && HttpListener.class.isAssignableFrom(iface)) result.add(iface);
+ }
+
+ Class superclass = aClass.getSuperclass();
+
+ if ((HttpListener.class.isAssignableFrom(superclass))) result.addAll(collectInterfaces(superclass));
+
+ return result;
+ }
+
+ private static class EquipmentEntries
+ {
+ private final Map<String, Object> map;
+ private final Map<Class, Object> configMap;
+ private final Map<Class, Set<HttpListener>> listeners = new HashMap<Class, Set<HttpListener>>();
+
+ public EquipmentEntries()
+ {
+ map = new HashMap<String, Object>();
+ configMap = new HashMap<Class, Object>();
+ }
+
+ private EquipmentEntries(EquipmentEntries equipmentEntries)
+ {
+ assert equipmentEntries != null;
+
+ map = new HashMap<String, Object>(equipmentEntries.map);
+ configMap = new HashMap<Class, Object>(equipmentEntries.configMap);
+ for (Map.Entry<Class, Set<HttpListener>> entry : equipmentEntries.listeners.entrySet())
+ {
+ listeners.put(entry.getKey(), new HashSet<HttpListener>(entry.getValue()));
+ }
+ }
+
+ public Object get(String key)
+ {
+ return map.get(key);
+ }
+
+ public void equipWith(String key, Object value)
+ {
+ map.put(key, value);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T extends HttpConfig> T getConfig(Class<T> clazz)
+ {
+ return (T)configMap.get(clazz);
+ }
+
+ public void equipWith(HttpConfig config)
+ {
+ for (Class clazz : collectConfigurations(config.getClass()))
+ {
+ configMap.put(clazz, config);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T extends HttpListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return (Set<T>)listeners.get(clazz);
+ }
+
+ public void equipWith(HttpListener listener)
+ {
+ for (Class clazz : collectInterfaces(listener.getClass()))
+ {
+ Set<HttpListener> list = listeners.get(clazz);
+ if (list == null) listeners.put(clazz, list = new HashSet<HttpListener>());
+ list.add(listener);
+ }
+ }
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/EquipmentStack.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class HttpProtocolCodecFactory implements ProtocolCodecFactory
+{
+ private final ProtocolEncoder encoder;
+ private final ProtocolDecoder decoder;
+
+ public HttpProtocolCodecFactory()
+ {
+ encoder = new HttpRequestEncoder();
+ decoder = new HttpResponseDecoder();
+ }
+
+ public ProtocolEncoder getEncoder(IoSession session) throws Exception
+ {
+ return encoder;
+ }
+
+ public ProtocolDecoder getDecoder(IoSession session) throws Exception
+ {
+ return decoder;
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpProtocolCodecFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+import org.apache.ahc.api.HttpRequest;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class HttpRequestEncoder extends ProtocolEncoderAdapter
+{
+ public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out) throws Exception
+ {
+ HttpRequest msg = (HttpRequest)message;
+
+ out.write(null);
+ out.flush();
+ }
+}
+
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpRequestEncoder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class HttpResponseDecoder extends ProtocolDecoderAdapter
+{
+ public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/HttpResponseDecoder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+
+import org.apache.ahc.api.HttpRequest;
+import org.apache.ahc.client.api.SessionConfigListener;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class ProtocolCodecFilterSessionConfigListener implements SessionConfigListener
+{
+ public final static String PROTOCOL_FILTER = ProtocolCodecFilterSessionConfigListener.class.getName() + ".filter";
+
+ public void configure(IoSession session, HttpRequest request)
+ {
+ if (!session.getFilterChain().contains(PROTOCOL_FILTER))
+ {
+ session.getFilterChain().addLast(PROTOCOL_FILTER, new ProtocolCodecFilter(new HttpProtocolCodecFactory()));
+ }
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/ProtocolCodecFilterSessionConfigListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java?rev=890623&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java (added)
+++ mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java Tue Dec 15 03:15:02 2009
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.ahc.client;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import java.security.SecureRandom;
+
+import org.apache.ahc.api.HttpConfig;
+
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class SslConfig implements HttpConfig
+{
+ private SSLContext sslContext;
+ private String sslProtocol;
+ private KeyManager[] keyManagers;
+ private TrustManager[] trustManagers;
+ private SecureRandom secureRandom;
+
+ public SSLContext getSslContext()
+ {
+ return sslContext;
+ }
+
+ public void setSslContext(SSLContext sslContext)
+ {
+ this.sslContext = sslContext;
+ }
+
+ public String getSslProtocol()
+ {
+ return sslProtocol;
+ }
+
+ public void setSslProtocol(String sslProtocol)
+ {
+ this.sslProtocol = sslProtocol;
+ }
+
+ public KeyManager[] getKeyManagers()
+ {
+ return keyManagers;
+ }
+
+ public void setKeyManagers(KeyManager[] keyManagers)
+ {
+ this.keyManagers = new KeyManager[keyManagers.length];
+ System.arraycopy(keyManagers, 0, this.keyManagers, 0, keyManagers.length);
+ }
+
+ public TrustManager[] getTrustManagers()
+ {
+ return trustManagers;
+ }
+
+ public void setTrustManagers(TrustManager[] trustManagers)
+ {
+ this.trustManagers = new TrustManager[trustManagers.length];
+ System.arraycopy(trustManagers, 0, this.trustManagers, 0, trustManagers.length);
+ }
+
+ public SecureRandom getSecureRandom()
+ {
+ return secureRandom;
+ }
+
+ public void setSecureRandom(SecureRandom secureRandom)
+ {
+ this.secureRandom = secureRandom;
+ }
+}
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Id Author
Propchange: mina/sandbox/adc/ahc/src/main/java/org/apache/ahc/client/SslConfig.java
------------------------------------------------------------------------------
svn:mime-type = text/plain