You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by mw...@apache.org on 2008/03/11 04:41:44 UTC

svn commit: r635791 - in /mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example: ./ xml/ xml/codec/ xml/message/ xml/parser/

Author: mwebb
Date: Mon Mar 10 20:41:40 2008
New Revision: 635791

URL: http://svn.apache.org/viewvc?rev=635791&view=rev
Log:
This is the code contributed by Martin Helmhout for issue #DIRMINA-258.  I will be reviewing it for correctness with the 2.0 M1 release and hope to have it in the 2.0 final version.  Just want to get it into the sandbox for now and captured by subversion, this way nothing gets lost.

Added:
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Client.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ClientSessionHandler.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Server.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ServerSessionHandler.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageDecoder.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageEncoder.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageDecoder.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageEncoder.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/Constants.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageDecoder.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageEncoder.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/XMLProtocolCodecFactory.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/AbstractMessage.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ClientMessage.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ServerMessage.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ClientParser.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParser.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParserHandler.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParser.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParserHandler.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ServerParser.java   (with props)
    mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/SocketAddressParser.java   (with props)

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Client.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Client.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Client.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Client.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,102 @@
+/*
+ *   @(#) $Id: Client.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml;
+
+import java.net.InetSocketAddress;
+
+import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.IoConnector;
+import org.apache.mina.transport.socket.nio.NioSocketConnector;
+
+/**
+ * (<strong>Entry Point</strong>) Starts XML client.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * 
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ * 
+ */
+public class Client {
+	private static final String HOSTNAME = "localhost";
+
+	private static final int PORT = 8080;
+
+	private static final int CONNECT_TIMEOUT = 30; // seconds
+
+	private ClientSessionHandler handler;
+
+	/**
+	 * Starts the client and sends an XML Message to Server
+	 * 
+	 * @param args
+	 * @throws Throwable
+	 */
+	public static void main(String[] args) throws Throwable {
+		Client client = new Client();
+		System.out.println("made it");
+		String xmlMessage = "<test name=\"greeting\">HelloMina</test>";
+		client.send(xmlMessage);
+	}
+
+	/**
+	 * Starts the threads and creates the connection
+	 * 
+	 * @throws Throwable
+	 */
+	public Client() throws Throwable {
+		// Create I/O and Protocol thread pool filter.
+		// I/O thread pool performs encoding and decoding of messages.
+		// Protocol thread pool performs actual protocol flow.
+
+		// Set connect timeout.
+		IoConnector connector = new NioSocketConnector();
+		connector.setHandler( new ClientSessionHandler(this, false) );
+		connector.setConnectTimeoutMillis( CONNECT_TIMEOUT * 1000L );
+		for (;;) {
+			ConnectFuture future = connector.connect(new InetSocketAddress(HOSTNAME, PORT));
+			future.awaitUninterruptibly();
+			break;
+		}
+	}
+
+	/**
+	 * Set the reference to ClientSessionHandler that allows Client to send
+	 * messages.
+	 * 
+	 * @param handler
+	 */
+	public void setClientSessionHandler(ClientSessionHandler handler) {
+		this.handler = handler;
+	}
+
+	/**
+	 * Send message to server
+	 * 
+	 * @param message
+	 */
+	public void send(String message) {
+		handler.send(message);
+	}
+
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Client.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ClientSessionHandler.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ClientSessionHandler.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ClientSessionHandler.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ClientSessionHandler.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,134 @@
+/*
+ *   @(#) $Id: ClientSessionHandler.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml;
+
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.codec.XMLProtocolCodecFactory;
+import org.apache.mina.example.xml.message.ClientMessage;
+import org.apache.mina.example.xml.message.ServerMessage;
+import org.apache.mina.example.xml.parser.ClientParser;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
+import org.apache.mina.filter.logging.LoggingFilter;
+
+import com.sun.corba.se.pept.protocol.ProtocolHandler;
+
+/**
+ * {@link ProtocolHandler} for XML client.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * 
+ * @author The Apache Directory Project
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ * 
+ */
+public class ClientSessionHandler extends IoHandlerAdapter {
+	private StringBuffer messageBuffer = new StringBuffer();
+
+	boolean useCustomCodec;
+
+	private ClientParser clientParser;
+
+	private IoSession session;
+
+	/**
+	 * Constructor + create instance of ClientParser for parsing XML
+	 * @param client 
+	 * @param useCustomCodec 
+	 */
+	public ClientSessionHandler(Client client, boolean useCustomCodec) {
+		//BasicConfigurator.configure();
+		this.useCustomCodec = useCustomCodec;
+		this.clientParser = new ClientParser();
+		client.setClientSessionHandler(this);
+	}
+
+	/**
+	 * @see org.apache.mina.common.IoHandlerAdapter#sessionCreated(org.apache.mina.common.IoSession)
+	 */
+	public void sessionCreated(IoSession session) throws Exception {
+		this.session = session;
+		ProtocolCodecFactory codec;
+		if (useCustomCodec) {
+			codec = new XMLProtocolCodecFactory(false);
+		} else {
+			codec = new ObjectSerializationCodecFactory();
+		}
+
+		session.getFilterChain().addLast("protocolFilter",
+				new ProtocolCodecFilter(codec));
+		session.getFilterChain().addLast("logger", new LoggingFilter());
+	}
+
+	/**
+	 * @see org.apache.mina.common.IoHandlerAdapter#sessionOpened(org.apache.mina.common.IoSession)
+	 */
+	public void sessionOpened(IoSession session) {
+
+	}
+
+	
+	/** (non-Javadoc)
+	 * @see org.apache.mina.common.IoHandlerAdapter#messageReceived(org.apache.mina.common.IoSession, java.lang.Object)
+	 */
+	public void messageReceived(IoSession session, Object message) {
+		ServerMessage sm = (ServerMessage) message;
+		clientParser.parse(this, session, sm.toString());
+	}
+
+	/**
+	 * @see org.apache.mina.common.IoHandlerAdapter#exceptionCaught(org.apache.mina.common.IoSession, java.lang.Throwable)
+	 */
+	public void exceptionCaught(IoSession session, Throwable cause) {
+		session.close();
+	}
+
+	/**
+	 * Send a message to the server
+	 * 
+	 * @param message
+	 */
+	public synchronized void send(String message) {
+		messageBuffer.delete(0, messageBuffer.length());
+		messageBuffer.append(message);
+		messageBuffer.trimToSize();
+
+		ClientMessage cm = new ClientMessage();
+		cm.setMessageLength(messageBuffer.length());
+		cm.setStringBuffer(messageBuffer);
+		session.write(cm);
+		// garbage collection
+		cm = null;
+	}
+
+	/**
+	 * Close the session
+	 */
+	public void closeSession() {
+		session.close();
+	}
+
+}
\ No newline at end of file

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ClientSessionHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Server.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Server.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Server.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Server.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,54 @@
+/*
+ *   @(#) $Id: Server.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml;
+
+import java.net.InetSocketAddress;
+
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
+
+/**
+ * (<strong>Entry Point</strong>) Starts XML server. <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class Server {
+	private static final int SERVER_PORT = 8080;
+	
+    /**
+     * Starts the XMLserver
+     * @param args
+     * @throws Throwable
+     */
+    public static void main( String[] args ) throws Throwable
+    {
+        // Create ServiceRegistry.
+        IoAcceptor acceptor = new NioSocketAcceptor();
+        acceptor.setHandler( new ServerSessionHandler(false) );
+        acceptor.bind(new InetSocketAddress( SERVER_PORT ) );
+
+        System.out.println( "Listening on port " + SERVER_PORT );
+    }
+
+	
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/Server.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ServerSessionHandler.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ServerSessionHandler.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ServerSessionHandler.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ServerSessionHandler.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,257 @@
+/*
+ *   @(#) $Id: ServerSessionHandler.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.codec.XMLProtocolCodecFactory;
+import org.apache.mina.example.xml.message.ClientMessage;
+import org.apache.mina.example.xml.message.ServerMessage;
+import org.apache.mina.example.xml.parser.ServerParser;
+import org.apache.mina.example.xml.parser.SocketAddressParser;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
+import org.apache.mina.filter.logging.LoggingFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.corba.se.pept.protocol.ProtocolHandler;
+
+/**
+ * {@link ProtocolHandler} for XML server. <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class ServerSessionHandler implements IoHandler {
+
+    private final Logger logger = LoggerFactory.getLogger(ServerSessionHandler.class);
+    
+	private String receivedMessage;
+
+	private StringBuffer messageBuffer = new StringBuffer();
+
+	private Map<IoSession, SocketAddress> sessions = new HashMap<IoSession, SocketAddress>();
+
+	private ServerParser serverParser;
+
+	private boolean useCustomCodec;
+
+	private IoSession session;
+
+	/**
+	 * Constructor + create ServerParser for handling XML
+	 * @param useCustomCodec 
+	 */
+	public ServerSessionHandler(boolean useCustomCodec) {
+		//BasicConfigurator.configure();
+		serverParser = new ServerParser();
+		this.useCustomCodec = useCustomCodec;
+	}
+
+	
+	/**
+	 * @see org.apache.mina.common.IoHandler#sessionCreated(org.apache.mina.common.IoSession)
+	 */
+	public void sessionCreated(IoSession session) throws Exception {
+		ProtocolCodecFactory codec;
+		if (useCustomCodec) {
+			codec = new XMLProtocolCodecFactory(true);
+		} else {
+			codec = new ObjectSerializationCodecFactory();
+		}
+
+		session.getFilterChain().addFirst("protocolFilter",
+				new ProtocolCodecFilter(codec));
+		session.getFilterChain().addLast("logger", new LoggingFilter());
+	}
+
+	/**
+	 * After session is opened: put session in list of open sessions
+	 * 
+	 * @see org.apache.mina.common.IoHandler#sessionOpened(org.apache.mina.common.IoSession)
+	 */
+	public void sessionOpened(IoSession session) {
+		// set idle time to 60 seconds
+		session.getConfig().setIdleTime(IdleStatus.BOTH_IDLE, 60);
+		this.session = session;
+		sessions.put(session, session.getRemoteAddress());
+
+		System.out.println("SESSION OPENED!");
+	}
+
+	/**
+	 * After session closed, remove sesion from list
+	 * 
+	 * 
+	 * @see org.apache.mina.common.IoHandler#sessionClosed(org.apache.mina.common.IoSession)
+	 */
+	public void sessionClosed(IoSession session) {
+		sessions.remove(session);
+	}
+
+	
+	
+	
+	
+	
+	/**
+	 * Ater messageReceived: Give message to the serverParser
+	 *
+	 * @see org.apache.mina.common.IoHandler#messageReceived(org.apache.mina.common.IoSession, java.lang.Object)
+	 */
+	public void messageReceived(IoSession session, Object message) {
+		ClientMessage cm = (ClientMessage) message;
+		// receivedMessage
+		receivedMessage = cm.toString();
+		serverParser.parse(this, session, receivedMessage);
+	}
+
+	/**
+	 * Send a message to a specific client session
+	 * 
+	 * @param session
+	 * @param message
+	 */
+	public synchronized void send(IoSession session, String message) {
+		messageBuffer.delete(0, messageBuffer.length());
+		messageBuffer.append(message);
+		messageBuffer.trimToSize();
+		int messageBufferLength = messageBuffer.length();
+		ServerMessage sm = new ServerMessage();
+		sm.setMessageLength(messageBufferLength);
+		sm.setStringBuffer(messageBuffer);
+		session.write(sm);
+		// garbage collection
+		sm = null;
+	}
+
+	/**
+	 * Send Message to Client of current session
+	 * 
+	 * @param message
+	 */
+	public synchronized void send(String message) {
+		send(session, message);
+	}
+
+	/**
+	 * Send a message to a specific client SocketAddress
+	 * 
+	 * @param client_address
+	 * @param message
+	 */
+	public void send(SocketAddress client_address, String message) {
+		message.trim();
+
+		boolean found = false;
+		// Iterator<Session> itr = sessions.iterator();
+		while (!found) {
+			Iterator<Map.Entry<IoSession,SocketAddress>> keyValuePairs = sessions.entrySet().iterator();
+			for (int i = 0; i < sessions.size(); i++) {
+			    Map.Entry<IoSession,SocketAddress> entry = keyValuePairs.next();
+				IoSession key = (IoSession) entry.getKey();
+				SocketAddress value = (SocketAddress) entry.getValue();
+				if (SocketAddressParser.getIP(client_address).equals(
+						SocketAddressParser.getIP(value))) {
+					if (SocketAddressParser.getPort(client_address).equals(
+							SocketAddressParser.getIP(value))) {
+						session = key;
+						found = true;
+						break;
+					}
+				}
+			}
+		}
+		send(session, message);
+	}
+
+	/**
+	 * Send a message to a specific client InetSocketAddress
+	 * 
+	 * @param client_address
+	 * @param message
+	 */
+	public void send(InetSocketAddress client_address, String message) {
+		message.trim();
+		SocketAddress sa = (SocketAddress) client_address;
+		this.send(sa, message);
+	}
+
+	/**
+	 * Send a message to all Clients
+	 * 
+	 * @param message
+	 */
+	public void sendAll(String message) {
+		for (IoSession session : sessions.keySet()) {
+			send(session, message);
+		}
+	}
+
+	/**
+	 * Send a message to all session except for this session
+	 * 
+	 * @param session
+	 * @param message
+	 */
+	public void sendExcept(IoSession session, String message) {
+		for (IoSession key_session : sessions.keySet()) {
+			if (!key_session.equals(session)) {
+				send(key_session, message);
+			}
+		}
+	}
+	
+	/**
+	 * @see org.apache.mina.common.IoHandler#messageSent(org.apache.mina.common.IoSession, java.lang.Object)
+	 */
+	public void messageSent(IoSession session, Object message) {
+	}
+
+	/**
+	 * @see org.apache.mina.common.IoHandler#sessionIdle(org.apache.mina.common.IoSession, org.apache.mina.common.IdleStatus)
+	 */
+	public void sessionIdle(IoSession session, IdleStatus status) {
+		logger.warn("Disconnecting the idle.");
+		// disconnect an idle client
+		// session.close();
+	}
+
+	 /** 
+	 * @see org.apache.mina.common.IoHandler#exceptionCaught(org.apache.mina.common.IoSession,
+	 *      java.lang.Throwable)
+	 */
+	public void exceptionCaught(IoSession session, Throwable cause) {
+		// close the connection on exceptional situation
+		session.close();
+	}
+
+}
\ No newline at end of file

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/ServerSessionHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageDecoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageDecoder.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageDecoder.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageDecoder.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,100 @@
+/*
+ *   @(#) $Id: AbstractMessageDecoder.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.message.AbstractMessage;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.mina.filter.codec.demux.MessageDecoder;
+import org.apache.mina.filter.codec.demux.MessageDecoderResult;
+
+/**
+ * A {@link MessageDecoder} that decodes message header and forwards the <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public abstract class AbstractMessageDecoder implements MessageDecoder {
+	@SuppressWarnings("unused")
+	private final int type;
+
+	private boolean readHeader;
+
+	protected int messageLength;
+
+	protected AbstractMessageDecoder(int type) {
+		this.type = type;
+	}
+
+	/**
+	 * Try to decode any message
+	 * 
+	 * @param session
+	 * @param in
+	 * @return decodable yes or no
+	 */
+	public MessageDecoderResult decodable(IoSession session, IoBuffer in) {
+
+		// Return NOT_OK if not matches.
+		return MessageDecoderResult.OK;
+	}
+
+	/**
+	 * @return <tt>null</tt> if the whole body is not read yet
+	 */
+	protected abstract AbstractMessage decodeBody(IoSession session,
+	    IoBuffer in);
+
+	/**
+	 * Decode: readHeader (length of message) + read body
+	 * 
+	 * @param session
+	 * @param in
+	 * @param out
+	 * @return MessageDecoderResult (OK, NOT_OK, NEED_DATA)
+	 * @throws Exception 
+	 * 
+	 */
+	public MessageDecoderResult decode(IoSession session, IoBuffer in,
+			ProtocolDecoderOutput out) throws Exception {
+		// read a header if not read yet.
+		if (!readHeader) {
+			messageLength = in.getInt(); // Get messageLength
+			readHeader = true;
+		}
+
+		// Try to decode body
+
+		AbstractMessage am = decodeBody(session, in);
+		// Header is read, now try to read body
+		if (am == null) {
+			return MessageDecoderResult.NEED_DATA;
+		} else {
+			// finished reading single complete message
+			readHeader = false; // reset state
+		}
+		out.write(am);
+		return MessageDecoderResult.OK;
+	}
+
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageDecoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageEncoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageEncoder.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageEncoder.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageEncoder.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,73 @@
+/*
+ *   @(#) $Id: AbstractMessageEncoder.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.message.AbstractMessage;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+import org.apache.mina.filter.codec.demux.MessageEncoder;
+
+/**
+ * A {@link MessageEncoder} that encodes message header and forwards the
+ * encoding of body to a subclass. <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public abstract class AbstractMessageEncoder implements MessageEncoder<AbstractMessage> {
+	@SuppressWarnings("unused")
+	private final int type;
+
+	protected AbstractMessageEncoder(int type) {
+		this.type = type;
+	}
+
+	/**
+	 * Create / encode message putting header== length of message plus encoding
+	 * body
+	 * @param session 
+	 * @param message 
+	 * @param out 
+	 * @throws Exception 
+	 */ 
+	
+	public void encode(IoSession session, AbstractMessage message,
+			ProtocolEncoderOutput out) throws Exception {
+
+		IoBuffer buf = IoBuffer.allocate(16);
+		buf.setAutoExpand(true); // Enable auto-expand for easier encoding
+
+		// Encode a header
+		buf.putInt(message.getMessageLength());
+
+		// Encode a body
+		encodeBody(session, message, buf);
+		buf.flip();
+		out.write(buf);
+
+	}
+
+	protected abstract void encodeBody(IoSession session,
+			AbstractMessage message, IoBuffer out);
+
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/AbstractMessageEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageDecoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageDecoder.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageDecoder.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageDecoder.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,76 @@
+/*
+ *   @(#) $Id: AddMessageDecoder.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.message.AbstractMessage;
+import org.apache.mina.example.xml.message.ClientMessage;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.mina.filter.codec.demux.MessageDecoder;
+
+/**
+ * A {@link MessageDecoder} that decodes {@link ClientMessage}.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class ClientMessageDecoder extends AbstractMessageDecoder {
+
+	/**
+	 * Constructor
+	 */
+	public ClientMessageDecoder() {
+		super(Constants.CLIENT);
+	}
+
+	protected AbstractMessage decodeBody(IoSession session, IoBuffer in) {
+
+		if (in.remaining() < messageLength) {
+			return null;
+		}
+		int numberOfBytesToRetrieve = messageLength * 2;
+
+		ClientMessage m = new ClientMessage();
+		while (numberOfBytesToRetrieve > 0) {
+			char retrieved = in.getChar();
+			m.getStringBuffer().append(retrieved);
+			numberOfBytesToRetrieve -= 2;
+		}
+		return m;
+	}
+
+
+
+	/**
+	 * @see org.apache.mina.filter.codec.demux.MessageDecoder#finishDecode(org.apache.mina.common.IoSession, org.apache.mina.filter.codec.ProtocolDecoderOutput)
+	 */
+	public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception {
+		
+		
+	}
+
+
+
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageDecoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageEncoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageEncoder.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageEncoder.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageEncoder.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,73 @@
+/*
+ *   @(#) $Id: AddMessageEncoder.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.message.AbstractMessage;
+import org.apache.mina.example.xml.message.ClientMessage;
+import org.apache.mina.filter.codec.demux.MessageEncoder;
+
+/**
+ * A {@link MessageEncoder} that encodes {@link ClientMessage}.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class ClientMessageEncoder extends AbstractMessageEncoder {
+	private static final Set<Class<ClientMessage>> TYPES;
+
+	static {
+		Set<Class<ClientMessage>> types = new HashSet<Class<ClientMessage>>();
+		types.add(ClientMessage.class);
+		TYPES = Collections.unmodifiableSet(types);
+	}
+
+	/**
+	 * Constructor
+	 */
+	public ClientMessageEncoder() {
+		super(Constants.CLIENT);
+	}
+
+	protected void encodeBody(IoSession session, AbstractMessage message,
+	    IoBuffer out) {
+		ClientMessage m = (ClientMessage) message;
+		StringBuffer sb = m.getStringBuffer();
+		for (int i = 0; i < sb.length(); i++) {
+			out.putChar(sb.charAt(i));
+		}
+	}
+
+	/**
+	 * @see org.apache.mina.filter.codec.demux.MessageEncoder#getMessageTypes()
+	 */
+	public Set<Class<ClientMessage>> getMessageTypes() {
+		return TYPES;
+	}
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ClientMessageEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/Constants.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/Constants.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/Constants.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/Constants.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,46 @@
+/*
+ *   @(#) $Id: Constants.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+/**
+ * Provides XML protocol constants.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class Constants {
+
+	/**
+	 * Server constant
+	 */
+	public static final int SERVER = 0;
+
+	/**
+	 * Client Constant
+	 */
+	public static final int CLIENT = 1;
+
+	private Constants() {
+	}
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/Constants.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageDecoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageDecoder.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageDecoder.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageDecoder.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,69 @@
+/*
+ *   @(#) $Id: ResultMessageDecoder.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.message.AbstractMessage;
+import org.apache.mina.example.xml.message.ServerMessage;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.mina.filter.codec.demux.MessageDecoder;
+
+/**
+ * A {@link MessageDecoder} that decodes {@link ServerMessage}.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class ServerMessageDecoder extends AbstractMessageDecoder {
+	/**
+	 * Constructor
+	 */
+	public ServerMessageDecoder() {
+		super(Constants.SERVER);
+	}
+
+	protected AbstractMessage decodeBody(IoSession session, IoBuffer in) {
+		if (in.remaining() < messageLength) {
+			return null;
+		}
+		int numberOfBytesToRetrieve = messageLength * 2;
+		ServerMessage sm = new ServerMessage();
+		while (numberOfBytesToRetrieve > 0) {
+			char retrieved = in.getChar();
+			sm.getStringBuffer().append(retrieved);
+			numberOfBytesToRetrieve -= 2;
+		}
+		return sm;
+
+	}
+
+	/**
+	 * @see org.apache.mina.filter.codec.demux.MessageDecoder#finishDecode(org.apache.mina.common.IoSession, org.apache.mina.filter.codec.ProtocolDecoderOutput)
+	 */
+	public void finishDecode(IoSession session, ProtocolDecoderOutput out) throws Exception {
+		
+		
+	}
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageDecoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageEncoder.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageEncoder.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageEncoder.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageEncoder.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,75 @@
+/*
+ *   @(#) $Id: ResultMessageEncoder.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.message.AbstractMessage;
+import org.apache.mina.example.xml.message.ServerMessage;
+import org.apache.mina.filter.codec.demux.MessageEncoder;
+
+/**
+ * A {@link MessageEncoder} that encodes {@link ServerMessage}.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class ServerMessageEncoder extends AbstractMessageEncoder {
+	private static final Set<Class<ServerMessage>> TYPES;
+
+	static {
+		Set<Class<ServerMessage>> types = new HashSet<Class<ServerMessage>>();
+		types.add(ServerMessage.class);
+		TYPES = Collections.unmodifiableSet(types);
+	}
+
+	/**
+	 * Constructor
+	 */
+	public ServerMessageEncoder() {
+		super(Constants.SERVER);
+	}
+
+	protected void encodeBody(IoSession session, AbstractMessage message,
+	    IoBuffer out) {
+		ServerMessage sm = (ServerMessage) message;
+		StringBuffer sb = sm.getStringBuffer();
+		for (int i = 0; i < sb.length(); i++) {
+			out.putChar(sb.charAt(i));
+		}
+	}
+
+	
+	/**
+	 * @see org.apache.mina.filter.codec.demux.MessageEncoder#getMessageTypes()
+	 */
+	public Set<Class<ServerMessage>> getMessageTypes() {
+		return TYPES;
+	}
+
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/ServerMessageEncoder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/XMLProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/XMLProtocolCodecFactory.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/XMLProtocolCodecFactory.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/XMLProtocolCodecFactory.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,54 @@
+/*
+ *   @(#) $Id: SumUpProtocolCodecFactory.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.codec;
+
+import org.apache.mina.example.xml.message.AbstractMessage;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory;
+
+/**
+ * A {@link ProtocolCodecFactory} that provides a protocol codec for SumUp
+ * protocol.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class XMLProtocolCodecFactory extends DemuxingProtocolCodecFactory {
+
+	/**
+	 * Register Decoders and Encoders with DemuxingProtoclCodedFactory
+	 * 
+	 * @param server
+	 */
+	public XMLProtocolCodecFactory(boolean server) {
+		if (server) {
+			addMessageDecoder(ClientMessageDecoder.class);
+			addMessageEncoder(AbstractMessage.class, ServerMessageEncoder.class);
+		} else // Client
+		{
+			addMessageEncoder(AbstractMessage.class, ClientMessageEncoder.class);
+			addMessageDecoder(ServerMessageDecoder.class);
+		}
+	}
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/codec/XMLProtocolCodecFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/AbstractMessage.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/AbstractMessage.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/AbstractMessage.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/AbstractMessage.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,85 @@
+/*
+ *   @(#) $Id: AbstractMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.message;
+
+import java.io.Serializable;
+
+/**
+ * A base message for SumUp protocol messages.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public abstract class AbstractMessage implements Serializable {
+
+	private int messageLength;
+
+	private StringBuffer stringbuffer = new StringBuffer();;
+
+	/**
+	 * Get the length of the message
+	 * 
+	 * @return length of message
+	 */
+	public int getMessageLength() {
+		return messageLength;
+	}
+
+	/**
+	 * Set the length of the message
+	 * 
+	 * @param messageLength
+	 */
+	public void setMessageLength(int messageLength) {
+		this.messageLength = messageLength;
+	}
+
+	/**
+	 * Get message as stringbuffer
+	 * 
+	 * @return stringbuffer holding message
+	 */
+	public StringBuffer getStringBuffer() {
+		return stringbuffer;
+	}
+
+	/**
+	 * Set stringbuffer message
+	 * 
+	 * @param stringbuffer
+	 */
+	public void setStringBuffer(StringBuffer stringbuffer) {
+		this.stringbuffer = stringbuffer;
+	}
+
+	/**
+	 * Create stringBuffer of message.toString()
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString() {
+		return stringbuffer.toString();
+	}
+
+}
\ No newline at end of file

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/AbstractMessage.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ClientMessage.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ClientMessage.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ClientMessage.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ClientMessage.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,45 @@
+/*
+ *   @(#) $Id: AddMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.message;
+
+/**
+ * <code>CLIENT XML</code> message in XML protocol.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class ClientMessage extends AbstractMessage {
+	 
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -5400421963970079272L;
+
+	/**
+	 * Empty constructor
+	 */
+	public ClientMessage() {
+	}
+
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ClientMessage.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ServerMessage.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ServerMessage.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ServerMessage.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ServerMessage.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,45 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.message;
+
+/**
+ * <code>SERVER XML</code> message in XML protocol.
+ * 
+ * <BR>
+ * Based upon MINA SumUp example and ACTR-BOT
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
+ */
+public class ServerMessage extends AbstractMessage {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -1639316573469194817L;
+
+	/**
+	 * Empty Constructor
+	 */
+	public ServerMessage() {
+	}
+
+}
\ No newline at end of file

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/message/ServerMessage.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ClientParser.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ClientParser.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ClientParser.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ClientParser.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,56 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.parser;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.ClientSessionHandler;
+
+/**
+ * ClientParser for guiding decoding of XML
+ * 
+ * <BR>
+ * Based upon SumUp example and Netty2
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ */
+public class ClientParser {
+    
+    private MessageClientXMLParser messageClientXMLParser;
+
+    /**
+     * Parser for messages that are received from the server
+     * 
+     */
+    public ClientParser(){
+        this.messageClientXMLParser = new MessageClientXMLParser();
+    }
+
+	/**
+	 * Parse receivedMessage and give to parseDocument
+	 * @param handler
+	 * @param session
+	 * @param receivedMessage
+	 */
+	public void parse(ClientSessionHandler handler, IoSession session, String receivedMessage) {
+		messageClientXMLParser.parseDocument(handler, session, receivedMessage);
+		
+	}
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ClientParser.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParser.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParser.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParser.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParser.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,87 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.parser;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.ClientSessionHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * ClientParser for guiding decoding of XML
+ * 
+ * <BR>
+ * Based upon SumUp example and Netty2
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ */
+public class MessageClientXMLParser {
+
+	@SuppressWarnings("unused")
+	private MessageClientXMLParserHandler contentHandler;
+
+	/**
+	 * Constructor for creating a parser for xml data received from the server
+	 * 
+	 * 
+	 */
+	public MessageClientXMLParser() {
+		this.contentHandler = new MessageClientXMLParserHandler();
+	}
+
+	/**
+	 * Parse the document that contains xml to process
+	 * @param handler 
+	 * @param session 
+	 * 
+	 * @param xmlToProcess
+	 */
+	public void parseDocument(ClientSessionHandler handler,
+			IoSession session, String xmlToProcess) {
+		try {
+			SAXParserFactory factory = SAXParserFactory.newInstance();
+			// factory.setValidating(true);
+			SAXParser saxParser = null;
+			try {
+				saxParser = factory.newSAXParser();
+			} catch (ParserConfigurationException e) {
+				e.printStackTrace();
+			}
+			XMLReader parser = saxParser.getXMLReader();
+			parser.setContentHandler(new MessageClientXMLParserHandler(handler, session,
+					xmlToProcess));// this.contentHandler);
+			parser.parse(new InputSource(new StringReader(xmlToProcess)));
+		} catch (SAXException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}
\ No newline at end of file

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParser.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParserHandler.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParserHandler.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParserHandler.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParserHandler.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,97 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.parser;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.ClientSessionHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * ClientParser for guiding decoding of XML
+ * 
+ * <BR>
+ * Based upon SumUp example and Netty2
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ */
+public class MessageClientXMLParserHandler extends DefaultHandler {
+
+	@SuppressWarnings("unused")
+	private String xmlToProcess;
+
+	@SuppressWarnings("unused")
+	private ClientSessionHandler handler;
+
+	@SuppressWarnings("unused")
+	private IoSession session;
+
+	private StringBuffer sb = new StringBuffer();
+
+	/**
+	 * Handler that parses the content of received xml messages
+	 * 
+	 */
+	public MessageClientXMLParserHandler() {
+
+	}
+
+	/**
+	 * The constructor delivers access to actor and the xml to process
+	 * 
+	 * @param handler
+	 * @param session
+	 * @param xmlToProcess
+	 */
+	public MessageClientXMLParserHandler(ClientSessionHandler handler,
+			IoSession session, String xmlToProcess) {
+		this.xmlToProcess = xmlToProcess;
+		this.handler = handler;
+		this.session = session;
+	}
+
+	/**
+	 * (non-Javadoc)
+	 * 
+	 * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
+	 *      java.lang.String, java.lang.String, org.xml.sax.Attributes)
+	 */
+	public void startElement(@SuppressWarnings("unused")
+	String nsURI, @SuppressWarnings("unused")
+	String strippedName, String tagName, Attributes attributes) {
+
+	}
+
+	/**
+	 * 
+	 * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+	 */
+	public void characters(char ch[], int start, int length) {
+		sb.delete(0, sb.length());
+		for (int i = start; i < start + length; i++) {
+			sb.append(ch[i]);
+		}
+		String message = sb.toString();
+		if (message.equals("HelloApache")) {
+			System.out.println("Server said " + message + " to me?!");
+		}
+	}
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageClientXMLParserHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParser.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParser.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParser.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParser.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,89 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.parser;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.ServerSessionHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * ClientParser for guiding decoding of XML
+ * 
+ * <BR>
+ * Based upon SumUp example and Netty2
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ */
+public class MessageServerXMLParser {
+
+	private static final MessageServerXMLParser INSTANCE = new MessageServerXMLParser();
+
+	private MessageServerXMLParser() {
+
+	}
+
+	/**
+	 * @return Returns instance
+	 */
+	public static MessageServerXMLParser getInstance() {
+		return INSTANCE;
+	}
+
+	/**
+	 * Parse document received from a client its session
+	 * @param handler
+	 * @param session
+	 * @param xmlToProcess
+	 */
+	public void parseDocument(ServerSessionHandler handler,
+			IoSession session, String xmlToProcess) {
+		try {
+			SAXParserFactory factory = SAXParserFactory.newInstance();
+			// factory.setValidating(true);
+			SAXParser saxParser = null;
+			saxParser = factory.newSAXParser();
+
+			XMLReader parser = saxParser.getXMLReader();
+			parser.setContentHandler(new MessageServerXMLParserHandler(handler,
+					session, xmlToProcess));
+			parser.parse(new InputSource(new StringReader(xmlToProcess)));
+
+		} catch (SAXException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (ParserConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+}
\ No newline at end of file

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParser.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParserHandler.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParserHandler.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParserHandler.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParserHandler.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,91 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.parser;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.ServerSessionHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * ClientParser for guiding decoding of XML
+ * 
+ * <BR>
+ * Based upon SumUp example and Netty2
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ */
+public class MessageServerXMLParserHandler extends DefaultHandler {
+
+    @SuppressWarnings("unused")
+	private String xmlToProcess;
+	private ServerSessionHandler handler;
+	@SuppressWarnings("unused")
+	private IoSession session;
+	private StringBuffer sb = new StringBuffer();
+	
+
+    /**
+     * Handles the parsing of xmlToProcess, in case there is a Proxy, it is
+     * forwarded to ProxyMessageHandler, In other cases, it is transformed into
+     * beans that react
+     * @param handler
+     * @param session
+     * @param xmlToProcess
+     */
+    public MessageServerXMLParserHandler(ServerSessionHandler handler, IoSession session, String xmlToProcess) {
+                this.xmlToProcess = xmlToProcess;
+                this.handler = handler;
+                this.session = session;
+    }
+
+    /**
+     * (non-Javadoc)
+     * 
+     * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
+     *      java.lang.String, java.lang.String, org.xml.sax.Attributes)
+     */
+    public void startElement(String nsURI, String strippedName, String tagName,
+            Attributes attributes) {
+
+        if (tagName.equals("test")) {
+        	System.out.println("A client sends a " + attributes.getValue("name") + " tagName to me!!");
+        	
+        }
+        
+    }
+    /** (non-Javadoc)
+     * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+     */
+    public void characters (char ch[], int start, int length){
+    	sb.delete(0, sb.length());
+    	for (int i = start; i < start + length; i++) {
+    		sb.append(ch[i]);
+    	}
+    	String message = sb.toString();
+    	if (message.equals("HelloMina")){
+    		System.out.println("A client said: " + message +  " !");
+    		handler.sendAll("<test name=\"HelloXML\">HelloApache</test>");
+    	}
+    }
+
+
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/MessageServerXMLParserHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ServerParser.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ServerParser.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ServerParser.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ServerParser.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,56 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.parser;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.example.xml.ServerSessionHandler;
+
+/**
+ * ClientParser for guiding decoding of XML
+ * 
+ * <BR>
+ * Based upon SumUp example and Netty2
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ */
+public class ServerParser {
+
+	/**
+	 * Constructor for the parser on the server side
+	 * 
+	 */
+	public ServerParser() {
+
+	}
+
+	/**
+	 * Parse message of a defined client session
+	 * 
+	 * @param handler
+	 * @param session
+	 * @param message
+	 */
+	public void parse(ServerSessionHandler handler, IoSession session,
+			String message) {
+		MessageServerXMLParser.getInstance().parseDocument(handler, session,
+				message);
+	}
+}
\ No newline at end of file

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/ServerParser.java
------------------------------------------------------------------------------
    svn:executable = *

Added: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/SocketAddressParser.java
URL: http://svn.apache.org/viewvc/mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/SocketAddressParser.java?rev=635791&view=auto
==============================================================================
--- mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/SocketAddressParser.java (added)
+++ mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/SocketAddressParser.java Mon Mar 10 20:41:40 2008
@@ -0,0 +1,69 @@
+/*
+ *   @(#) $Id: ResultMessage.java 357871 2005-12-20 01:56:40Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.example.xml.parser;
+
+import java.net.SocketAddress;
+/**
+ * ClientParser for guiding decoding of XML
+ * 
+ * <BR>
+ * Based upon SumUp example and Netty2
+ * 
+ * @see <a href="http://sourceforge.net/projects/act-rbot">ACT-RBOT</a>
+ * @author The Apache Directory Project
+ * @author Martin Helmhout
+ */
+public class SocketAddressParser {
+
+	/**
+	 * Extract and get hostname from SocketAddress String
+	 * @param sa
+	 * @return hostname string
+	 */
+	public static String getHostName(SocketAddress sa) {
+		return parseSocketAddress(sa)[0];
+	}
+	/**
+	 * Extract and get IP number from SocketAddress String
+	 * @param sa
+	 * @return IP string
+	 */
+	public static String getIP(SocketAddress sa) {
+		return parseSocketAddress(sa)[1];
+	}
+	/**
+	 * Extract and get Port number from SocketAddress String
+	 * @param sa
+	 * @return port string
+	 */
+	public static String getPort(SocketAddress sa) {
+		return parseSocketAddress(sa)[2];
+	}
+
+	private static String[] parseSocketAddress(SocketAddress sa) {
+
+		String[] hostname_ipport = sa.toString().split("/");
+		String[] ip_port = hostname_ipport[1].split(":");
+		String[] hostname_ip_port = new String[3];
+		hostname_ip_port[0] = hostname_ipport[0];
+		hostname_ip_port[1] = ip_port[0];
+		hostname_ip_port[2] = ip_port[1];
+		return hostname_ip_port;
+	}
+}

Propchange: mina/sandbox/mwebb/mina/src/main/java/org/apache/mina/example/xml/parser/SocketAddressParser.java
------------------------------------------------------------------------------
    svn:executable = *