Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 44744 invoked from network); 15 Apr 2005 13:59:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Apr 2005 13:59:24 -0000 Received: (qmail 62347 invoked by uid 500); 15 Apr 2005 13:59:24 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 62284 invoked by uid 500); 15 Apr 2005 13:59:22 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 62239 invoked by uid 99); 15 Apr 2005 13:59:21 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 15 Apr 2005 06:59:18 -0700 Received: (qmail 44696 invoked by uid 65534); 15 Apr 2005 13:59:14 -0000 Message-ID: <20050415135914.44695.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Fri, 15 Apr 2005 13:59:14 -0000 Subject: svn commit: r161461 - in directory/network/trunk/src/java/org/apache/mina: io/ io/datagram/ io/socket/ protocol/ protocol/codec/ protocol/handler/ To: commits@directory.apache.org From: trustin@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: trustin Date: Fri Apr 15 06:59:12 2005 New Revision: 161461 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D161461 Log: * Renamed MessageCodecFactory to DemuxingProtocolCodecFactory * Moved DemuxingProtocolHandler to separate package called 'handler' and ex= tracted inner classes to separate classes. * Fixed JavaDoc warnings Added: directory/network/trunk/src/java/org/apache/mina/protocol/codec/Demuxin= gProtocolCodecFactory.java (with props) directory/network/trunk/src/java/org/apache/mina/protocol/handler/ directory/network/trunk/src/java/org/apache/mina/protocol/handler/Demux= ingProtocolHandler.java (with props) directory/network/trunk/src/java/org/apache/mina/protocol/handler/Messa= geHandler.java (with props) directory/network/trunk/src/java/org/apache/mina/protocol/handler/Unkno= wnMessageTypeException.java (with props) Removed: directory/network/trunk/src/java/org/apache/mina/protocol/DemuxingProto= colHandler.java directory/network/trunk/src/java/org/apache/mina/protocol/codec/Message= CodecFactory.java Modified: directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFi= lterChain.java directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSe= ssionConfig.java directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilter= Chain.java directory/network/trunk/src/java/org/apache/mina/protocol/codec/Message= Decoder.java directory/network/trunk/src/java/org/apache/mina/protocol/codec/Message= Encoder.java Modified: directory/network/trunk/src/java/org/apache/mina/io/IoConnector.j= ava URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/io/IoConnector.java?view=3Ddiff&r1=3D161460&r2=3D161461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java (o= riginal) +++ directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java Fr= i Apr 15 06:59:12 2005 @@ -67,7 +67,7 @@ * @param localAddress the local address the channel is bound to * @throws IOException if failed to connect */ - IoSession connect( SocketAddress address, SocketAddress loadlAddress, + IoSession connect( SocketAddress address, SocketAddress localAddress, IoHandler handler ) throws IOException; =20 /** Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/Data= gramFilterChain.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/io/datagram/DatagramFilterChain.java?view=3Ddiff&r1=3D161460&r2=3D= 161461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFi= lterChain.java (original) +++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFi= lterChain.java Fri Apr 15 06:59:12 2005 @@ -2,6 +2,7 @@ =20 import org.apache.mina.common.ByteBuffer; import org.apache.mina.io.AbstractIoHandlerFilterChain; +import org.apache.mina.io.IoHandlerFilterChain; import org.apache.mina.io.IoSession; import org.apache.mina.util.Queue; =20 Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/Data= gramSessionConfig.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/io/datagram/DatagramSessionConfig.java?view=3Ddiff&r1=3D161460&r2= =3D161461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSe= ssionConfig.java (original) +++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSe= ssionConfig.java Fri Apr 15 06:59:12 2005 @@ -22,6 +22,8 @@ import java.nio.channels.DatagramChannel; =20 import org.apache.mina.common.SessionConfig; +import org.apache.mina.io.IoSession; +import org.apache.mina.protocol.ProtocolSession; import org.apache.mina.util.BasicSessionConfig; =20 /** Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/Socket= FilterChain.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/io/socket/SocketFilterChain.java?view=3Ddiff&r1=3D161460&r2=3D1614= 61 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilter= Chain.java (original) +++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilter= Chain.java Fri Apr 15 06:59:12 2005 @@ -2,6 +2,7 @@ =20 import org.apache.mina.common.ByteBuffer; import org.apache.mina.io.AbstractIoHandlerFilterChain; +import org.apache.mina.io.IoHandlerFilterChain; import org.apache.mina.io.IoSession; import org.apache.mina.util.Queue; =20 Added: directory/network/trunk/src/java/org/apache/mina/protocol/codec/Demu= xingProtocolCodecFactory.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/protocol/codec/DemuxingProtocolCodecFactory.java?view=3Dauto&rev= =3D161461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/protocol/codec/Demuxin= gProtocolCodecFactory.java (added) +++ directory/network/trunk/src/java/org/apache/mina/protocol/codec/Demuxin= gProtocolCodecFactory.java Fri Apr 15 06:59:12 2005 @@ -0,0 +1,225 @@ +/* + * @(#) $Id$ + * + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.mina.protocol.codec; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.apache.mina.common.ByteBuffer; +import org.apache.mina.protocol.ProtocolCodecFactory; +import org.apache.mina.protocol.ProtocolDecoder; +import org.apache.mina.protocol.ProtocolDecoderOutput; +import org.apache.mina.protocol.ProtocolEncoder; +import org.apache.mina.protocol.ProtocolEncoderOutput; +import org.apache.mina.protocol.ProtocolSession; +import org.apache.mina.protocol.ProtocolViolationException; + +/** + * A composite {@link ProtocolCodecFactory} that consists of multiple + * {@link MessageEncoder}s and {@link MessageDecoder}s. + * {@link ProtocolEncoder} and {@link ProtocolDecoder} this factory + * returns demultiplex incoming messages and buffers to + * appropriate {@link MessageEncoder}s and {@link MessageDecoder}s.=20 + *=20 + * @author The Apache Directory Project (dev@directory.apache.org) + * @author Trustin Lee (trustin@apache.org) + * @version $Rev$, $Date$ + *=20 + * @see MessageEncoder + * @see MessageDecoder + */ +public class DemuxingProtocolCodecFactory implements ProtocolCodecFactory = { + + private MessageDecoder[] decoders =3D new MessageDecoder[0]; + private final Map encoders =3D new HashMap(); + =20 + private final ProtocolEncoder protocolEncoder =3D new ProtocolEncoderI= mpl(); + + private final ProtocolDecoder protocolDecoder =3D new ProtocolDecoderI= mpl(); + =20 + public DemuxingProtocolCodecFactory() + { + } + =20 + public void register( MessageEncoder encoder ) + { + Iterator it =3D encoder.getMessageTypes().iterator(); + while( it.hasNext() ) + { + Class type =3D (Class) it.next(); + encoders.put( type, encoder ); + } + } + =20 + public void register( MessageDecoder decoder ) + { + if( decoder =3D=3D null ) + { + throw new NullPointerException( "decoder" ); + } + MessageDecoder[] decoders =3D this.decoders; + MessageDecoder[] newDecoders =3D new MessageDecoder[ decoders.leng= th + 1 ]; + System.arraycopy( decoders, 0, newDecoders, 0, decoders.length ); + newDecoders[ decoders.length ] =3D decoder; + this.decoders =3D newDecoders; + } + =20 + public ProtocolEncoder newEncoder() { + return protocolEncoder; + } + + public ProtocolDecoder newDecoder() { + return protocolDecoder; + } + =20 + private class ProtocolEncoderImpl implements ProtocolEncoder + { + public void encode( ProtocolSession session, Object message, + ProtocolEncoderOutput out ) throws ProtocolVio= lationException + { + Class type =3D message.getClass(); + MessageEncoder encoder =3D findEncoder( type ); + if( encoder =3D=3D null ) + { + throw new ProtocolViolationException( "Unexpected message = type: " + type ); + } + =20 + encoder.encode( session, message, out ); + } + =20 + private MessageEncoder findEncoder( Class type ) + { + MessageEncoder encoder =3D ( MessageEncoder ) encoders.get( ty= pe ); + if( encoder =3D=3D null ) + { + encoder =3D findEncoder( type, new HashSet() ); + } + + return encoder; + } + + private MessageEncoder findEncoder( Class type, Set triedClasses ) + { + MessageEncoder encoder; + + if( triedClasses.contains( type ) ) + return null; + triedClasses.add( type ); + + encoder =3D ( MessageEncoder ) encoders.get( type ); + if( encoder =3D=3D null ) + { + encoder =3D findEncoder( type, triedClasses ); + if( encoder !=3D null ) + return encoder; + + Class[] interfaces =3D type.getInterfaces(); + for( int i =3D 0; i < interfaces.length; i ++ ) + { + encoder =3D findEncoder( interfaces[ i ], triedClasses= ); + if( encoder !=3D null ) + return encoder; + } + + return null; + } + else + return encoder; + } + } + =20 + private class ProtocolDecoderImpl extends CumulativeProtocolDecoder + { + private MessageDecoder currentDecoder; + + protected ProtocolDecoderImpl() + { + super( 16 ); + } + + protected boolean doDecode( ProtocolSession session, ByteBuffer in= , + ProtocolDecoderOutput out) throws Prot= ocolViolationException + { + if( currentDecoder =3D=3D null ) + { + MessageDecoder[] decoders =3D DemuxingProtocolCodecFactory= .this.decoders; + int undecodables =3D 0; + for( int i =3D decoders.length - 1; i >=3D 0; i -- )=20 + { + MessageDecoder decoder =3D decoders[i]; + int limit =3D in.limit(); + in.position( 0 ); + MessageDecoderResult result =3D decoder.decodable( ses= sion, in ); + in.position( 0 ); + in.limit( limit ); + =20 + if( result =3D=3D MessageDecoder.OK ) + { + currentDecoder =3D decoder; + break; + } + else if( result =3D=3D MessageDecoder.NOT_OK ) + { + undecodables ++; + } + else if( result !=3D MessageDecoder.NEED_DATA ) + { + throw new IllegalStateException( "Unexpected decod= e result (see your decodable()): " + result ); + } + } + =20 + if( undecodables =3D=3D decoders.length ) + { + // Throw an exception if all decoders cannot decode da= ta. + in.position( in.limit() ); // Skip data + throw new ProtocolViolationException( + "No appropriate message decoder: " + in.getHex= Dump() ); + } + =20 + if( currentDecoder =3D=3D null ) + { + // Decoder is not determined yet (i.e. we need more da= ta) + return false; + } + } + =20 + MessageDecoderResult result =3D currentDecoder.decode( session= , in, out ); + if( result =3D=3D MessageDecoder.OK ) + { + currentDecoder =3D null; + return true; + } + else if( result =3D=3D MessageDecoder.NEED_DATA ) + { + return false; + } + else if( result =3D=3D MessageDecoder.NOT_OK ) + { + throw new ProtocolViolationException( "Message decoder ret= urned NOT_OK." ); + } + else + { + throw new IllegalStateException( "Unexpected decode result= (see your decode()): " + result ); + } + } + } +} Propchange: directory/network/trunk/src/java/org/apache/mina/protocol/codec= /DemuxingProtocolCodecFactory.java ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision Modified: directory/network/trunk/src/java/org/apache/mina/protocol/codec/M= essageDecoder.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/protocol/codec/MessageDecoder.java?view=3Ddiff&r1=3D161460&r2=3D16= 1461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/protocol/codec/Message= Decoder.java (original) +++ directory/network/trunk/src/java/org/apache/mina/protocol/codec/Message= Decoder.java Fri Apr 15 06:59:12 2005 @@ -30,7 +30,7 @@ * @author Trustin Lee (trustin@apache.org) * @version $Rev$, $Date$ *=20 - * @see MessageCodecFactory + * @see DemuxingProtocolCodecFactory */ public interface MessageDecoder { /** Modified: directory/network/trunk/src/java/org/apache/mina/protocol/codec/M= essageEncoder.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/protocol/codec/MessageEncoder.java?view=3Ddiff&r1=3D161460&r2=3D16= 1461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/protocol/codec/Message= Encoder.java (original) +++ directory/network/trunk/src/java/org/apache/mina/protocol/codec/Message= Encoder.java Fri Apr 15 06:59:12 2005 @@ -29,7 +29,7 @@ * @author Trustin Lee (trustin@apache.org) * @version $Rev$, $Date$ *=20 - * @see MessageCodecFactory + * @see DemuxingProtocolCodecFactory */ public interface MessageEncoder extends ProtocolEncoder { =20 Added: directory/network/trunk/src/java/org/apache/mina/protocol/handler/De= muxingProtocolHandler.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/protocol/handler/DemuxingProtocolHandler.java?view=3Dauto&rev=3D16= 1461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/protocol/handler/Demux= ingProtocolHandler.java (added) +++ directory/network/trunk/src/java/org/apache/mina/protocol/handler/Demux= ingProtocolHandler.java Fri Apr 15 06:59:12 2005 @@ -0,0 +1,117 @@ +/* + * @(#) $Id$ + */ +package org.apache.mina.protocol.handler; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.mina.protocol.ProtocolHandler; +import org.apache.mina.protocol.ProtocolSession; + +/** + * A {@link ProtocolHandler} that demuxes messageReceived eve= nts + * to the appropriate {@link MessageHandler}. + *=20 + * You can freely register and deregister {@link MessageHandler}s using + * {@link #registerMessageType(Class, MessageHandler)} and + * {@link #deregisterMessageType(Class)}. + *=20 + * @author The Apache Directory Project + * @version $Rev$, $Date$ + */ +public abstract class DemuxingProtocolHandler implements ProtocolHandler +{ + private final Map type2handler =3D new HashMap(); + + /** + * Creates a new instance with no registered {@link MessageHandler}s. + */ + protected DemuxingProtocolHandler() + { + } + + /** + * Registers a {@link MessageHandler} that receives the messages of + * the specified type. + */ + protected void registerMessageType( Class type, MessageHandler handler= ) + { + synchronized( type2handler ) + { + type2handler.put( type, handler ); + } + } + + /** + * Deregisters a {@link MessageHandler} that receives the messages of + * the specified type. + */ + protected void deregisterMessageType( Class clazz ) + { + synchronized( type2handler ) + { + type2handler.remove( clazz ); + } + } + + /** + * Forwards the received events into the appropriate {@link MessageHan= dler} + * which is registered by {@link #registerMessageType(Class, MessageHa= ndler)}. + */ + public void messageReceived( ProtocolSession session, Object message ) + { + MessageHandler handler =3D findHandler( message.getClass() ); + if( handler !=3D null ) + { + handler.messageReceived( session, message ); + } + else + { + throw new UnknownMessageTypeException( + "No message handler found for message: " + message ); + } + } + + private MessageHandler findHandler( Class type ) + { + MessageHandler handler =3D ( MessageHandler ) type2handler.get( ty= pe ); + if( handler =3D=3D null ) + { + handler =3D findHandler( type, new HashSet() ); + } + + return handler; + } + + private MessageHandler findHandler( Class type, Set triedClasses ) + { + MessageHandler handler; + + if( triedClasses.contains( type ) ) + return null; + triedClasses.add( type ); + + handler =3D ( MessageHandler ) type2handler.get( type ); + if( handler =3D=3D null ) + { + handler =3D findHandler( type, triedClasses ); + if( handler !=3D null ) + return handler; + + Class[] interfaces =3D type.getInterfaces(); + for( int i =3D 0; i < interfaces.length; i ++ ) + { + handler =3D findHandler( interfaces[ i ], triedClasses ); + if( handler !=3D null ) + return handler; + } + + return null; + } + else + return handler; + } +} Propchange: directory/network/trunk/src/java/org/apache/mina/protocol/handl= er/DemuxingProtocolHandler.java ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision Added: directory/network/trunk/src/java/org/apache/mina/protocol/handler/Me= ssageHandler.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/protocol/handler/MessageHandler.java?view=3Dauto&rev=3D161461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/protocol/handler/Messa= geHandler.java (added) +++ directory/network/trunk/src/java/org/apache/mina/protocol/handler/Messa= geHandler.java Fri Apr 15 06:59:12 2005 @@ -0,0 +1,50 @@ +/* + * @(#) $Id$ + * + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.mina.protocol.handler; + +import org.apache.mina.protocol.ProtocolSession; + +/** + * A handler interface that {@link DemuxingProtocolHandler} forwards + * messageReceived events to. You have to register your + * handler with the type of message you want to get notified using + * {@link DemuxingProtocolHandler#registerMessageType(Class, MessageHandle= r)}. + *=20 + * @author The Apache Directory Project + * @version $Rev$, $Date$ + */ +public interface MessageHandler +{ + /** + * A {@link MessageHandler} that does nothing. This is usefule when + * you want to ignore messages of the specific type silently. + */ + static MessageHandler NOOP =3D new MessageHandler() + { + public void messageReceived( ProtocolSession session, Object messa= ge ) + { + } + }; + =20 + /** + * Invoked when the specific type of message is received from the + * specified session. + */ + void messageReceived( ProtocolSession session, Object message ); +} \ No newline at end of file Propchange: directory/network/trunk/src/java/org/apache/mina/protocol/handl= er/MessageHandler.java ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision Added: directory/network/trunk/src/java/org/apache/mina/protocol/handler/Un= knownMessageTypeException.java URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apa= che/mina/protocol/handler/UnknownMessageTypeException.java?view=3Dauto&rev= =3D161461 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/network/trunk/src/java/org/apache/mina/protocol/handler/Unkno= wnMessageTypeException.java (added) +++ directory/network/trunk/src/java/org/apache/mina/protocol/handler/Unkno= wnMessageTypeException.java Fri Apr 15 06:59:12 2005 @@ -0,0 +1,54 @@ +/* + * @(#) $Id$ + * + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.mina.protocol.handler; + + +/** + * An exception that is thrown when {@link DemuxingProtocolHandler} + * cannot find any {@link MessageHandler}s associated with the specific + * message type. You have to use + * {@link DemuxingProtocolHandler#registerMessageType(Class, MessageHandle= r)} + * to associate a message type and a message handler.=20 + *=20 + * @author The Apache Directory Project + * @version $Rev$, $Date$ + */ +public class UnknownMessageTypeException extends RuntimeException +{ + private static final long serialVersionUID =3D 3257290227428047158L; + + public UnknownMessageTypeException() + { + } + + public UnknownMessageTypeException( String message, Throwable cause ) + { + super( message, cause ); + } + + public UnknownMessageTypeException( String message ) + { + super( message ); + } + + public UnknownMessageTypeException( Throwable cause ) + { + super( cause ); + } +} \ No newline at end of file Propchange: directory/network/trunk/src/java/org/apache/mina/protocol/handl= er/UnknownMessageTypeException.java ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision