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/19 18:21:02 UTC
svn commit: r892489 - in /mina/sandbox/adc/ahc: ./
api/src/test/java/com/acme/ahc/ api/src/test/java/org/apache/ahc/client/
mina2/src/test/java/com/acme/ahc/ mina3/
mina3/src/main/java/org/apache/ahc/mina3/
mina3/src/main/java/org/apache/mina/core/ min...
Author: adc
Date: Sat Dec 19 17:21:01 2009
New Revision: 892489
URL: http://svn.apache.org/viewvc?rev=892489&view=rev
Log:
cleanup and more sketch
Added:
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/AbstractIoChannel.java
- copied, changed from r892157, mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConfig.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoDown.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoListener.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoUp.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/StateMachineChannel.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/impl/
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/impl/EquipmentStack.java
Removed:
mina/sandbox/adc/ahc/api/src/test/java/org/apache/ahc/client/
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/AsyncHttpIoFuture.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/AsyncHttpIoSessionInitializer.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/AsyncHttpProtocolCodecFactory.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/AsyncHttpProtocolDecoder.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/HttpProtocolCodecFactory.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/HttpRequestEncoder.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/HttpResponseDecoder.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/ProtocolCodecFilterSessionConfigListener.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannels.java
Modified:
mina/sandbox/adc/ahc/api/src/test/java/com/acme/ahc/AcmeHttpRequest.java
mina/sandbox/adc/ahc/mina2/src/test/java/com/acme/ahc/AcmeHttpRequest.java
mina/sandbox/adc/ahc/mina3/pom.xml
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/SslSessionConfigListener.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConnector.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoFilter.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoSession.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/SslChannel.java
mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/nio/NioSocketConnector.java
mina/sandbox/adc/ahc/mina3/src/test/java/com/acme/ahc/AcmeHttpRequest.java
mina/sandbox/adc/ahc/pom.xml
Modified: mina/sandbox/adc/ahc/api/src/test/java/com/acme/ahc/AcmeHttpRequest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/api/src/test/java/com/acme/ahc/AcmeHttpRequest.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/api/src/test/java/com/acme/ahc/AcmeHttpRequest.java (original)
+++ mina/sandbox/adc/ahc/api/src/test/java/com/acme/ahc/AcmeHttpRequest.java Sat Dec 19 17:21:01 2009
@@ -1,15 +1,80 @@
+/**
+ * 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 com.acme.ahc;
+import java.util.Set;
+
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpListener;
import org.apache.ahc.api.HttpRequest;
/**
- * Created by IntelliJ IDEA.
- * User: acabrera
- * Date: Nov 22, 2009
- * Time: 9:21:24 AM
- * To change this template use File | Settings | File Templates.
+ * @version $Revision$ $Date$
*/
public class AcmeHttpRequest extends HttpRequest
{
+ @Override
+ public <T extends HttpConfig> T getConfig(Class<T> clazz)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(HttpConfig config)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public <T extends HttpListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(HttpListener listener)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Object getEquip(String key)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(String key, Object value)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest push()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest pop()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
}
Modified: mina/sandbox/adc/ahc/mina2/src/test/java/com/acme/ahc/AcmeHttpRequest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina2/src/test/java/com/acme/ahc/AcmeHttpRequest.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina2/src/test/java/com/acme/ahc/AcmeHttpRequest.java (original)
+++ mina/sandbox/adc/ahc/mina2/src/test/java/com/acme/ahc/AcmeHttpRequest.java Sat Dec 19 17:21:01 2009
@@ -1,15 +1,80 @@
+/**
+ * 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 com.acme.ahc;
+import java.util.Set;
+
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpListener;
import org.apache.ahc.api.HttpRequest;
/**
- * Created by IntelliJ IDEA.
- * User: acabrera
- * Date: Nov 22, 2009
- * Time: 9:21:24 AM
- * To change this template use File | Settings | File Templates.
+ * @version $Revision$ $Date$
*/
public class AcmeHttpRequest extends HttpRequest
{
+ @Override
+ public <T extends HttpConfig> T getConfig(Class<T> clazz)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(HttpConfig config)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public <T extends HttpListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(HttpListener listener)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Object getEquip(String key)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(String key, Object value)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest push()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest pop()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
}
Modified: mina/sandbox/adc/ahc/mina3/pom.xml
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/pom.xml?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/pom.xml (original)
+++ mina/sandbox/adc/ahc/mina3/pom.xml Sat Dec 19 17:21:01 2009
@@ -41,6 +41,11 @@
<artifactId>api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
</dependencies>
</project>
Modified: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/SslSessionConfigListener.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/SslSessionConfigListener.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/SslSessionConfigListener.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/ahc/mina3/SslSessionConfigListener.java Sat Dec 19 17:21:01 2009
@@ -26,8 +26,9 @@
import org.apache.ahc.api.HttpRequest;
import org.apache.ahc.mina3.api.SessionConfigListener;
import org.apache.mina.core.IoChannel;
-import org.apache.mina.core.IoChannels;
+import org.apache.mina.core.IoDown;
import org.apache.mina.core.IoSession;
+import org.apache.mina.core.IoUp;
import org.apache.mina.core.SslChannel;
@@ -44,25 +45,27 @@
if ("https".equalsIgnoreCase(scheme))
{
- IoChannels channels = session.getChannels();
-
// add the SSL filter if it's not there already, i.e. in a reused session
- if (channels.get(SSL_FILTER) != null)
+ if (session.getChannel(SSL_FILTER) != null)
{
try
{
SslChannel sslChannel = createSslFilter(request);
- channels.mark(sslChannel, SSL_FILTER);
+ session.mark(sslChannel, SSL_FILTER);
- IoChannel tail = channels.get(AsyncHttpConnection.TAIL);
- Set<IoChannel> children = new HashSet<IoChannel>(tail.getChildren());
+ IoChannel tail = session.getChannel(AsyncHttpConnection.TAIL);
+ if (IoUp.class.isInstance(tail))
+ {
+ IoUp newParent = (IoUp)tail;
+ Set<IoDown> children = new HashSet<IoDown>(newParent.getChildren());
- tail.getChildren().clear();
- tail.getChildren().add(sslChannel);
+ newParent.getChildren().clear();
+ newParent.getChildren().add(sslChannel);
- sslChannel.getChildren().addAll(children);
+ sslChannel.getChildren().addAll(children);
+ }
- channels.mark(sslChannel, AsyncHttpConnection.TAIL);
+ session.mark(sslChannel, AsyncHttpConnection.TAIL);
}
catch (GeneralSecurityException gse)
{
Copied: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/AbstractIoChannel.java (from r892157, mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java)
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/AbstractIoChannel.java?p2=mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/AbstractIoChannel.java&p1=mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java&r1=892157&r2=892489&rev=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/AbstractIoChannel.java Sat Dec 19 17:21:01 2009
@@ -18,17 +18,166 @@
*/
package org.apache.mina.core;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
+import org.apache.mina.impl.EquipmentStack;
+
/**
* @version $Revision: $ $Date: $
*/
-public interface IoChannel
+public abstract class AbstractIoChannel implements IoChannel
{
- Set<IoChannel> getParents();
+ private final Set<IoUp> parents = new HashSet<IoUp>();
+ private final Set<IoDown> children = new HashSet<IoDown>();
+ private final EquipmentStack stack = new EquipmentStack();
+
+ public Set<IoUp> getParents()
+ {
+ return new Set<IoUp>()
+ {
+ final Set<IoUp> p = parents;
+
+ public int size() { return p.size(); }
+
+ public boolean isEmpty() { return p.isEmpty(); }
+
+ public boolean contains(Object o) { return p.contains(o); }
+
+ public Iterator<IoUp> iterator() { return p.iterator(); }
+
+ public Object[] toArray() { return p.toArray(); }
+
+ public <T> T[] toArray(T[] a) { return p.toArray(a); }
+
+ public boolean add(IoUp o)
+ {
+ if (IoDown.class.isInstance(AbstractIoChannel.this)) o.getChildren().add((IoDown)AbstractIoChannel.this);
+ return p.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ if (IoDown.class.isInstance(AbstractIoChannel.this)) ((AbstractIoChannel)o).getChildren().add((IoDown)AbstractIoChannel.this);
+ return p.remove(o);
+ }
+
+ public boolean containsAll(Collection<?> c) { return p.containsAll(c); }
+
+ public boolean addAll(Collection<? extends IoUp> c)
+ {
+ if (IoDown.class.isInstance(AbstractIoChannel.this)) for (IoUp parent : c) parent.getChildren().add((IoDown)AbstractIoChannel.this);
+ return p.addAll(c);
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ Set<IoUp> toBeRemoved = new HashSet<IoUp>(p);
+
+ toBeRemoved.removeAll(c);
+ for (IoUp parent : toBeRemoved) parent.getChildren().remove(AbstractIoChannel.this);
+
+ return p.retainAll(c);
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ for (AbstractIoChannel parent : (Collection<AbstractIoChannel>)c) parent.getChildren().remove(AbstractIoChannel.this);
+ return p.removeAll(c);
+ }
+
+ public void clear()
+ {
+ for (IoUp parent : p) parent.getChildren().remove(AbstractIoChannel.this);
+ p.clear();
+ }
+
+ public boolean equals(Object o) { return p.equals(o); }
+
+ public int hashCode() { return p.hashCode(); }
+ };
+ }
+
+ public Set<IoDown> getChildren()
+ {
+ return new Set<IoDown>()
+ {
+ final Set<IoDown> c = children;
+
+ public int size() { return c.size(); }
+
+ public boolean isEmpty() { return c.isEmpty(); }
+
+ public boolean contains(Object o) { return c.contains(o); }
+
+ public Iterator<IoDown> iterator() { return c.iterator(); }
+
+ public Object[] toArray() { return c.toArray(); }
+
+ public <T> T[] toArray(T[] a) { return c.toArray(a); }
+
+ public boolean add(IoDown o)
+ {
+ if (IoUp.class.isInstance(AbstractIoChannel.this)) o.getParents().add((IoUp)AbstractIoChannel.this);
+ return c.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ if (IoUp.class.isInstance(AbstractIoChannel.this)) ((AbstractIoChannel)o).getParents().add((IoUp)AbstractIoChannel.this);
+ return c.remove(o);
+ }
+
+ public boolean containsAll(Collection<?> c) { return this.c.containsAll(c); }
+
+ public boolean addAll(Collection<? extends IoDown> c)
+ {
+ if (IoUp.class.isInstance(AbstractIoChannel.this)) for (IoDown parent : c) parent.getParents().add((IoUp)AbstractIoChannel.this);
+ return this.c.addAll(c);
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ Set<IoDown> toBeRemoved = new HashSet<IoDown>(this.c);
+
+ toBeRemoved.removeAll(c);
+ for (IoDown parent : toBeRemoved) parent.getParents().remove(AbstractIoChannel.this);
+
+ return this.c.retainAll(c);
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ for (IoDown parent : (Collection<IoDown>)c) parent.getParents().remove(AbstractIoChannel.this);
+ return this.c.removeAll(c);
+ }
+
+ public void clear()
+ {
+ for (IoDown parent : c) parent.getParents().remove(AbstractIoChannel.this);
+ c.clear();
+ }
+
+ public boolean equals(Object o) { return c.equals(o); }
+
+ public int hashCode() { return c.hashCode(); }
+ };
+ }
+
+ public IoChannel equipWith(String key, Object value)
+ {
+ stack.equipWith(key, value);
+
+ return this;
+ }
- Set<IoChannel> getChildren();
+ public IoChannel equipWith(IoListener listener)
+ {
+ stack.equipWith(listener);
- void messageReceived(IoSession session, Object message) throws Exception;
+ return this;
+ }
}
Added: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java?rev=892489&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoChannel.java Sat Dec 19 17:21:01 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.mina.core;
+
+import java.util.Set;
+
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public interface IoChannel
+{
+ void init() throws Exception;
+
+ void destroy() throws Exception;
+
+ IoChannel equipWith(String key, Object value);
+
+ IoChannel equipWith(IoListener listener);
+}
Added: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConfig.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConfig.java?rev=892489&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConfig.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConfig.java Sat Dec 19 17:21:01 2009
@@ -0,0 +1,26 @@
+/**
+ * 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.mina.core;
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public interface IoConfig
+{
+}
Modified: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConnector.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConnector.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConnector.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoConnector.java Sat Dec 19 17:21:01 2009
@@ -21,6 +21,9 @@
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpListener;
+
/**
* @version $Revision: $ $Date: $
@@ -28,4 +31,14 @@
public interface IoConnector
{
Future<IoSession> connect(InetSocketAddress address);
+
+ IoConnector equipWith(String key, Object value);
+
+ IoConnector equipWith(IoConfig config);
+
+ IoConnector equipWith(IoListener listener);
+
+ IoConnector push();
+
+ IoConnector pop();
}
Added: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoDown.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoDown.java?rev=892489&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoDown.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoDown.java Sat Dec 19 17:21:01 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.mina.core;
+
+import java.util.Set;
+
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public interface IoDown
+{
+ Set<IoUp> getParents();
+
+ void send(IoSession session, Object message) throws Exception;
+}
Modified: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoFilter.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoFilter.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoFilter.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoFilter.java Sat Dec 19 17:21:01 2009
@@ -27,7 +27,7 @@
void destroy();
- void messageReceived(IoSession session, Object message) throws Exception;
+ Object send(IoSession session, Object message) throws Exception;
- void messageSent(IoSession session, Object message) throws Exception;
+ Object receive(IoSession session, Object message) throws Exception;
}
Added: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoListener.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoListener.java?rev=892489&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoListener.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoListener.java Sat Dec 19 17:21:01 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.mina.core;
+
+import java.util.EventListener;
+
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public interface IoListener extends EventListener
+{
+}
Modified: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoSession.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoSession.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoSession.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoSession.java Sat Dec 19 17:21:01 2009
@@ -19,6 +19,7 @@
package org.apache.mina.core;
import java.security.GeneralSecurityException;
+import java.util.Set;
/**
@@ -30,5 +31,15 @@
void exceptionCaught(GeneralSecurityException gse);
- IoChannels getChannels();
+ AbstractIoChannel getRoot();
+
+ Set<AbstractIoChannel> getChannels();
+
+ AbstractIoChannel getChannel(String filterName);
+
+ void mark(AbstractIoChannel channel, String filterName);
+
+ IoSession equipWith(String key, Object value);
+
+ IoSession equipWith(IoListener listener);
}
Added: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoUp.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoUp.java?rev=892489&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoUp.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoUp.java Sat Dec 19 17:21:01 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.mina.core;
+
+import java.util.Set;
+
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public interface IoUp
+{
+ Set<IoDown> getChildren();
+
+ void receive(IoSession session, Object message) throws Exception;
+}
Modified: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/SslChannel.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/SslChannel.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/SslChannel.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/SslChannel.java Sat Dec 19 17:21:01 2009
@@ -24,10 +24,33 @@
/**
* @version $Revision: $ $Date: $
*/
-public class SslChannel implements IoChannel
+public class SslChannel extends AbstractIoChannel implements IoDown, IoUp
{
+ private final SSLContext context;
+
public SslChannel(SSLContext context)
{
- //Todo change body of created methods use File | Settings | File Templates.
+ if (context == null) throw new IllegalArgumentException("SSL context cannot be null");
+ this.context = context;
+ }
+
+ public void init() throws Exception
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void destroy() throws Exception
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void send(IoSession session, Object message) throws Exception
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void receive(IoSession session, Object message) throws Exception
+ {
+ //Todo change body of implemented methods use File | Settings | File Templates.
}
}
Added: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/StateMachineChannel.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/StateMachineChannel.java?rev=892489&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/StateMachineChannel.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/StateMachineChannel.java Sat Dec 19 17:21:01 2009
@@ -0,0 +1,87 @@
+/**
+ * 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.mina.core;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public class StateMachineChannel extends AbstractIoChannel implements IoDown, IoUp
+{
+ private final static Logger LOGGER = LoggerFactory.getLogger(StateMachineChannel.class);
+ private final Object lock = new Object();
+ private String state;
+ private Map<String, List<IoFilter>> states = new HashMap<String, List<IoFilter>>();
+
+ public String getState()
+ {
+ return state;
+ }
+
+ public void setState(String state)
+ {
+ this.state = state;
+ }
+
+ public Map<String, List<IoFilter>> getStates()
+ {
+ return states;
+ }
+
+ public void init() throws Exception
+ {
+ }
+
+ public void destroy() throws Exception
+ {
+ }
+
+ public void send(IoSession session, Object message) throws Exception
+ {
+ Object ball = message;
+
+ synchronized (lock)
+ {
+ List<IoFilter> chain = states.get(getState());
+ for (IoFilter filter : chain) ball = filter.send(session, ball);
+ }
+
+ for (IoDown child : getChildren()) child.send(session, ball);
+ }
+
+ public void receive(IoSession session, Object message) throws Exception
+ {
+ Object ball = message;
+
+ synchronized (lock)
+ {
+ List<IoFilter> chain = states.get(getState());
+ for (IoFilter filter : chain) ball = filter.receive(session, ball);
+ }
+
+ for (IoUp parent : getParents()) parent.receive(session, ball);
+ }
+}
Added: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/impl/EquipmentStack.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/impl/EquipmentStack.java?rev=892489&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/impl/EquipmentStack.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/impl/EquipmentStack.java Sat Dec 19 17:21:01 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.mina.impl;
+
+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.mina.core.IoConfig;
+import org.apache.mina.core.IoListener;
+
+
+/**
+ * @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 IoConfig> T getConfig(Class<T> clazz)
+ {
+ return stack.peek().getConfig(clazz);
+ }
+
+ public synchronized void equipWith(IoConfig config)
+ {
+ stack.peek().equipWith(config);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public synchronized <T extends IoListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return stack.peek().getListeners(clazz);
+ }
+
+ public synchronized void equipWith(IoListener 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 (IoConfig.class.isAssignableFrom(aClass)) result.add(aClass);
+
+ Class superclass = aClass.getSuperclass();
+
+ if ((IoConfig.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 (IoListener.class != iface && IoListener.class.isAssignableFrom(iface)) result.add(iface);
+ }
+
+ Class superclass = aClass.getSuperclass();
+
+ if ((IoListener.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<IoListener>> listeners = new HashMap<Class, Set<IoListener>>();
+
+ 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<IoListener>> entry : equipmentEntries.listeners.entrySet())
+ {
+ listeners.put(entry.getKey(), new HashSet<IoListener>(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 IoConfig> T getConfig(Class<T> clazz)
+ {
+ return (T)configMap.get(clazz);
+ }
+
+ public void equipWith(IoConfig config)
+ {
+ for (Class clazz : collectConfigurations(config.getClass()))
+ {
+ configMap.put(clazz, config);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T extends IoListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return (Set<T>)listeners.get(clazz);
+ }
+
+ public void equipWith(IoListener listener)
+ {
+ for (Class clazz : collectInterfaces(listener.getClass()))
+ {
+ Set<IoListener> list = listeners.get(clazz);
+ if (list == null) listeners.put(clazz, list = new HashSet<IoListener>());
+ list.add(listener);
+ }
+ }
+ }
+}
Modified: mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/nio/NioSocketConnector.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/nio/NioSocketConnector.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/nio/NioSocketConnector.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/nio/NioSocketConnector.java Sat Dec 19 17:21:01 2009
@@ -21,7 +21,9 @@
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
+import org.apache.mina.core.IoConfig;
import org.apache.mina.core.IoConnector;
+import org.apache.mina.core.IoListener;
import org.apache.mina.core.IoSession;
@@ -34,4 +36,29 @@
{
return null; //Todo change body of implemented methods use File | Settings | File Templates.
}
+
+ public IoConnector equipWith(String key, Object value)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoConnector equipWith(IoConfig config)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoConnector equipWith(IoListener listener)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoConnector push()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public IoConnector pop()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
}
Modified: mina/sandbox/adc/ahc/mina3/src/test/java/com/acme/ahc/AcmeHttpRequest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/test/java/com/acme/ahc/AcmeHttpRequest.java?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/test/java/com/acme/ahc/AcmeHttpRequest.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/test/java/com/acme/ahc/AcmeHttpRequest.java Sat Dec 19 17:21:01 2009
@@ -1,15 +1,80 @@
+/**
+ * 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 com.acme.ahc;
+import java.util.Set;
+
+import org.apache.ahc.api.HttpConfig;
+import org.apache.ahc.api.HttpListener;
import org.apache.ahc.api.HttpRequest;
/**
- * Created by IntelliJ IDEA.
- * User: acabrera
- * Date: Nov 22, 2009
- * Time: 9:21:24 AM
- * To change this template use File | Settings | File Templates.
+ * @version $Revision$ $Date$
*/
public class AcmeHttpRequest extends HttpRequest
{
+ @Override
+ public <T extends HttpConfig> T getConfig(Class<T> clazz)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(HttpConfig config)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public <T extends HttpListener> Set<T> getListeners(Class<T> clazz)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(HttpListener listener)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Object getEquip(String key)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest equipWith(String key, Object value)
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest push()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public HttpRequest pop()
+ {
+ return null; //Todo change body of implemented methods use File | Settings | File Templates.
+ }
}
Modified: mina/sandbox/adc/ahc/pom.xml
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/pom.xml?rev=892489&r1=892488&r2=892489&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/pom.xml (original)
+++ mina/sandbox/adc/ahc/pom.xml Sat Dec 19 17:21:01 2009
@@ -59,20 +59,30 @@
</plugins>
</build>
+ <dependencies>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <scope>test</scope>
+ <groupId>org.apache.ahc</groupId>
+ <artifactId>api</artifactId>
+ <version>${pom.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.ahc</groupId>
- <artifactId>api</artifactId>
- <version>${pom.version}</version>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.8</version>
</dependency>
</dependencies>