You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Mitchell Berg <mi...@seattlebergs.com> on 2008/08/16 00:03:37 UTC

How to ByPass ProtocolCodecFilter for FileInputStream Object

Hi,

I have a client/server app that sends both commands and files between the
client and the server.  The commands use a certain custom protocol (i.e. a
header added to each message sent that allows each side to identify the type
of message).  I would like to be able to send files over the
same connection.  So my thought was to 1) modify the StreamWriteFilter so
that the appropriate header is added to each message sent - meaning the
protocol is added at the modified StreamWriterFilter


FileInputStream fis = *new* FileInputStream(fileToTransfer);
WriteFuture future = ioSession.write(fis);
future.join();
and 2) to have all FileInputStream messages bypass the protocolCodecFilter.

I just cannot figure out how to bypass the protocolCodecFilter for
FileInputStream objects??

Any ideas?

Thanks,
Mitch

Re: How to ByPass ProtocolCodecFilter for FileInputStream Object

Posted by Mitchell Berg <mi...@seattlebergs.com>.
Barend,

Thanks so much - that was exactly what I was looking for!

Mitch

On Sat, Aug 16, 2008 at 9:34 AM, W.B. Garvelink
<ba...@gmail.com>wrote:

> ProtocolCodecFilter is a nonfinal class, so if I understand your
> requirements correctly, you can override its filterWrite() method to
> invoke super.filterWrite() for 'normal' WriteRequests, and
> nextFilter.filterWrite() for FileInputStream WriteRequests to get the
> desired behaviour.
>
> Barend
>
>
>
>
>
>
> On Sat, Aug 16, 2008 at 12:03 AM, Mitchell Berg <mi...@seattlebergs.com>
> wrote:
> > Hi,
> >
> > I have a client/server app that sends both commands and files between the
> > client and the server.  The commands use a certain custom protocol (i.e.
> a
> > header added to each message sent that allows each side to identify the
> type
> > of message).  I would like to be able to send files over the
> > same connection.  So my thought was to 1) modify the StreamWriteFilter so
> > that the appropriate header is added to each message sent - meaning the
> > protocol is added at the modified StreamWriterFilter
> >
> >
> > FileInputStream fis = *new* FileInputStream(fileToTransfer);
> > WriteFuture future = ioSession.write(fis);
> > future.join();
> > and 2) to have all FileInputStream messages bypass the
> protocolCodecFilter.
> >
> > I just cannot figure out how to bypass the protocolCodecFilter for
> > FileInputStream objects??
> >
> > Any ideas?
> >
> > Thanks,
> > Mitch
> >
>

RE: How to ByPass ProtocolCodecFilter for FileInputStream Object

Posted by Wenrui Guo <we...@ericsson.com>.
In my application, I add special decision inside ProtocolEncoder /
ProtocolDecoder to bypass certain data type.

I don't know if override ProtocolCodecFilter.filterWrite() is a better
way. If it is, why not add a template method inside it thus child class
can easily write its own implementation
to bypass special data packet.

BR
anderson

-----Original Message-----
From: W.B. Garvelink [mailto:barend.garvelink@gmail.com] 
Sent: Saturday, August 16, 2008 9:35 PM
To: users@mina.apache.org
Subject: Re: How to ByPass ProtocolCodecFilter for FileInputStream
Object

ProtocolCodecFilter is a nonfinal class, so if I understand your
requirements correctly, you can override its filterWrite() method to
invoke super.filterWrite() for 'normal' WriteRequests, and
nextFilter.filterWrite() for FileInputStream WriteRequests to get the
desired behaviour.

Barend






On Sat, Aug 16, 2008 at 12:03 AM, Mitchell Berg <mi...@seattlebergs.com>
wrote:
> Hi,
>
> I have a client/server app that sends both commands and files between 
> the client and the server.  The commands use a certain custom protocol

> (i.e. a header added to each message sent that allows each side to 
> identify the type of message).  I would like to be able to send files 
> over the same connection.  So my thought was to 1) modify the 
> StreamWriteFilter so that the appropriate header is added to each 
> message sent - meaning the protocol is added at the modified 
> StreamWriterFilter
>
>
> FileInputStream fis = *new* FileInputStream(fileToTransfer); 
> WriteFuture future = ioSession.write(fis); future.join(); and 2) to 
> have all FileInputStream messages bypass the protocolCodecFilter.
>
> I just cannot figure out how to bypass the protocolCodecFilter for 
> FileInputStream objects??
>
> Any ideas?
>
> Thanks,
> Mitch
>

Re: How to ByPass ProtocolCodecFilter for FileInputStream Object

Posted by "W.B. Garvelink" <ba...@gmail.com>.
ProtocolCodecFilter is a nonfinal class, so if I understand your
requirements correctly, you can override its filterWrite() method to
invoke super.filterWrite() for 'normal' WriteRequests, and
nextFilter.filterWrite() for FileInputStream WriteRequests to get the
desired behaviour.

Barend






On Sat, Aug 16, 2008 at 12:03 AM, Mitchell Berg <mi...@seattlebergs.com> wrote:
> Hi,
>
> I have a client/server app that sends both commands and files between the
> client and the server.  The commands use a certain custom protocol (i.e. a
> header added to each message sent that allows each side to identify the type
> of message).  I would like to be able to send files over the
> same connection.  So my thought was to 1) modify the StreamWriteFilter so
> that the appropriate header is added to each message sent - meaning the
> protocol is added at the modified StreamWriterFilter
>
>
> FileInputStream fis = *new* FileInputStream(fileToTransfer);
> WriteFuture future = ioSession.write(fis);
> future.join();
> and 2) to have all FileInputStream messages bypass the protocolCodecFilter.
>
> I just cannot figure out how to bypass the protocolCodecFilter for
> FileInputStream objects??
>
> Any ideas?
>
> Thanks,
> Mitch
>