Apachecon Eu 2008 Mina

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Apachecon Eu 2008 Mina - Presentation Transcript

    1. ApacheCon EU 2008
    2. Niklas Gustavsson [email_address] http://protocol7.com
        • MINA commiter since 2007
        • On FtpServer since 2005
        • So, what's MINA ?
        • Java API for network applications
        • Event driven
        • Asynchronous
        • Server side
        • Client side
        • Pluggable implementations
        • You will probably use
        • the NIO implementation
        • ...and the VmPipe
        • Separation of concerns
        • Wire ↔ Business logic
        • MINA architecture
    3. IoService IoConnector IoAcceptor
        • IoFilter
        • Protocol codec
        • Lots of free stuff!
        • Traffic shapers
        • SSL
        • Compression
        • Session based logging
        • Firewall
        • IoHandler
        • Concurrency... yeay!
        • Acceptor thread
        • Connector thread
        • I/O processor thread
        • Cores + 1
        • ExecutorFilter
        • Fine, so what's best for me?
        • What's new in MINA 2.0
        • Thread model redesigned
        • Simplified configuration
        • ByteBuffer now IoBuffer
        • and default to heap allocation
        • IoSessionLogger removed
        • And lots and lots of
        • Cleanup and improvements
        • So, which version should I use?
        • MINA 1.0
        • MINA 1.1
        • MINA 2.0
        • Migrating from 1.x
        • Review thread model
        • Update configuration
        • Remove IoSessionLogger
        • Update class and package names
        • DEMO!
        • Simple chat server in MINA
        • public final static Chat INSTANCE = new Chat();
        • private List<User> users = new ArrayList<User>();
        • public void addUser(User user) {
        • users.add(user);
        • }
        • public void removeUser(User user) {
        • users.remove(user);
        • }
        • public void talkToAll(Message msg) {
        • for(User user : users) {
        • user.talkTo(msg);
        • }
        • }
        • public class ChatDecoder extends CumulativeProtocolDecoder {
        • protected boolean doDecode(IoSession session, IoBuffer buffer, ProtocolDecoderOutput out) throws Exception {
        • if(do we have all the data we need?) {
        • Message msg = new Message(user, text);
        • out.write(msg);
        • return true;
        • } else {
        • return false;
        • }
        • }
        • }
        • public class ChatHandler extends IoHandlerAdapter {
        • public void sessionCreated(IoSession session) throws Exception {
        • User user = new MinaUser(session);
        • session.setAttribute(USER_ATTRIBUTE, user);
        • Chat.INSTANCE.addUser(user);
        • }
        • ChatHandler continued...
        • public void messageReceived(IoSession session, Object o) throws Exception {
        • Message msg = (Message) o;
        • if(msg.getText().equalsIgnoreCase(&quot;QUIT&quot;)) {
        • session.closeOnFlush();
        • } else {
        • Chat.INSTANCE.talkToAll(msg);
        • }
        • }
        • ...
        • }
        • SocketAcceptor acceptor = new NioSocketAcceptor();
        • acceptor.getFilterChain().addLast(&quot;codec&quot;, new ProtocolCodecFilter(new ChatCodecFactory()) );
        • acceptor.setIdleTime(IdleStatus.BOTH_IDLE, 60);
        • acceptor.setHandler(new ChatHandler());
        • acceptor .bind(new InetSocketAddress(6789));
    4. Fire up your terminals telnet 62.12.11.90 6789
    5. http://mina.apache.org
    6. [email_address]
    7. Questions ?
    8. http://flickr.com/photos/samiksha/408007916/ http://flickr.com/photos/henrikmoltke/142750871/

    + Niklas GustavssonNiklas Gustavsson, 6 months ago

    custom

    234 views, 0 favs, 0 embeds more stats

    More info about this document

    CC Attribution License

    Go to text version

    • Total Views 234
      • 234 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 10
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories