Maarten,
then, i need to make an filter a cast of the object to bytebuffer? and
because in the example it does filter ?


thanks
On Jan 30, 2008 11:44 AM, Maarten Bosteels <[EMAIL PROTECTED]> wrote:

> Brenno,
>
> The Object passed in via messageReceived will always be an IoBuffer (or
> ByteBuffer in mina 1.x)
> when there is no ProtocolCodecFilter in your filter chain (or another
> filter
> that transforms IoBuffers into something else).
>
> see also
> http://mina.apache.org/tutorial-on-protocolcodecfilter.html
> http://mina.apache.org/tutorial-on-protocolcodecfilter-for-mina-2x.html
>
> Maarten
>
> On Jan 30, 2008 4:32 PM, Brenno Hayden <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> >   I was studying the example of Mina, discovered that in the example
> > netcat, he makes a cast in hanlder
> > public void messageReceived(IoSession session, Object message) {
> >        ByteBuffer buf = (ByteBuffer) message;
> > ..
> > }
> > More without adding any filter, the more the same error occurs earlier.
> > Some
> > tips ?
> >
> >
> > Thanks
> >
> > On Jan 29, 2008 1:35 PM, Brenno Hayden <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Julien,
> > > Thank you, helped a lot! The source-code is fine, now.
> > >
> > > thanks
> > >
> > >
> > > On Jan 29, 2008 1:20 PM, Julien Vermillard <[EMAIL PROTECTED]>
> > wrote:
> > >
> > > > Hi,
> > > >
> > > > MINA provide  you by default buffer of bytes and not Strings, you
> > > > shoudl take a look at this example :
> > > >
> > > >
> >
> http://svn.apache.org/viewvc/mina/branches/1.0/example/src/main/java/org/apache/mina/example/reverser/
> > > >
> > > > And specificly to this code :
> > > >
> > > >
> > > >        SocketAcceptorConfig cfg = new SocketAcceptorConfig();
> > > >
> > > >        cfg.getFilterChain().addLast(
> > > >                "codec",
> > > >                new ProtocolCodecFilter(new
> > TextLineCodecFactory(Charset
> > > >                        .forName("UTF-8"))));
> > > >
> > > > It's adding a codec filter for decoding raw bytes into String
> > > >
> > > > HTH,
> > > >
> > > > Julien
> > > >
> > > > On Tue, 29 Jan 2008 13:12:02 -0400
> > > > "Brenno Hayden" <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > Hi,
> > > > >  I have one problem. When I do a cast in the code below
> > > > >
> > > > > Public class MyHanlder extends IoHandlerAdapter {
> > > > > public void messageReceived(IoSession session, Object message) {
> > > > > String s  = (String)message;
> > > > >
> > > > > Has the following problem
> > > > > org.apache.mina.util.SessionLog warn
> > > > > WARNING: [/127.0.0.1:3696] EXCEPTION, please implement
> > > > > mypackage.MyHandler.exceptionCaught() for proper handling:
> > > > > java.lang.ClassCastException:
> > > > > org.apache.mina.common.PooledByteBufferAllocator$PooledByteBuffer
> > > > >     at mypackage.MyHandler.messageReceived(MyHandler.java:52)
> > > > >
> > > > >
> > > > > ps: I'm using java 5 e framework 1.1.5 for java 5
> > > > > ________________________
> > > > > Brenno Hayden F. Dantas
> > > >
> > >
> > >
> > >
> > > --
> > > ________________________
> > > Brenno Hayden F. Dantas
> >
> >
> >
> >
> > --
> > ________________________
> > Brenno Hayden F. Dantas
> >
>



-- 
________________________
Brenno Hayden F. Dantas

Reply via email to