package com.ikasoa.core.nifty;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;

public class ConnectionContextHandler extends SimpleChannelUpstreamHandler {
	@Override
	public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
		super.channelConnected(ctx, e);

		NiftyConnectionContext context = new NiftyConnectionContext();
		context.setRemoteAddress(ctx.getChannel().getRemoteAddress());

		ctx.setAttachment(context);
	}
};

@@ -25,16 +25,174 @@
 nifty;%0A%0A
+import java.net.SocketAddress;%0Aimport java.util.Collections;%0Aimport java.util.Iterator;%0Aimport java.util.Map;%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0A
 import o
@@ -426,16 +426,17 @@
 ndler %7B%0A
+%0A
 %09@Overri
@@ -491,18 +491,22 @@
 ontext c
+ontex
 t
-x
 , Channe
@@ -569,24 +569,28 @@
 ed(c
+ontex
 t
-x
 , e);%0A
-%0A
 %09%09
-Nifty
+Ikasoa
 Conn
@@ -599,25 +599,41 @@
 tionContext 
-c
+ikasoaConnectionC
 ontext = new
@@ -637,13 +637,14 @@
 new 
-Nifty
+Ikasoa
 Conn
@@ -662,17 +662,33 @@
 xt();%0A%09%09
-c
+ikasoaConnectionC
 ontext.s
@@ -704,18 +704,22 @@
 ddress(c
+ontex
 t
-x
 .getChan
@@ -749,14 +749,17 @@
 ));%0A
-%0A
 %09%09c
+ontex
 t
-x
 .set
@@ -782,11 +782,1169 @@
 xt);%0A%09%7D%0A
+%0A%09private class IkasoaConnectionContext implements ConnectionContext %7B%0A%0A%09%09private SocketAddress remoteAddress;%0A%09%09private Map%3CString, Object%3E attributes = new ConcurrentHashMap%3C%3E();%0A%0A%09%09@Override%0A%09%09public SocketAddress getRemoteAddress() %7B%0A%09%09%09return remoteAddress;%0A%09%09%7D%0A%0A%09%09public void setRemoteAddress(SocketAddress remoteAddress) %7B%0A%09%09%09this.remoteAddress = remoteAddress;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public Object getAttribute(String attributeName) %7B%0A%09%09%09if (attributeName == null)%0A%09%09%09%09throw new NullPointerException();%0A%09%09%09return attributes.get(attributeName);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public Object setAttribute(String attributeName, Object value) %7B%0A%09%09%09if (attributeName == null)%0A%09%09%09%09throw new NullPointerException();%0A%09%09%09if (value == null)%0A%09%09%09%09throw new NullPointerException();%0A%09%09%09return attributes.put(attributeName, value);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public Object removeAttribute(String attributeName) %7B%0A%09%09%09if (attributeName == null)%0A%09%09%09%09throw new NullPointerException();%0A%09%09%09return attributes.remove(attributeName);%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public Iterator%3CMap.Entry%3CString, Object%3E%3E attributeIterator() %7B%0A%09%09%09return Collections.unmodifiableSet(attributes.entrySet()).iterator();%0A%09%09%7D%0A%09%7D%0A%0A
 %7D;%0A

Update ConnectionContextHandler.java