Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package org.apache.mina.integration.jmx

JMX (Java Management eXtension) integration.

See:
Description

Interface Summary
IoServiceManagerMBean |
IoSessionManagerMBean | MBean interface for the session manager, it's used for instrumenting IoSession

Class Summary
IoServiceManager |
IoSessionManager |

## Package org.apache.mina.integration.jmx Description

JMX (Java Management eXtension) integration.

## Monitoring Your MINA Services and Sessions

### Monitoring an IoService

    acceptor = new SocketAcceptor();

    try
    {
        IoServiceManager iosm = new IoServiceManager(acceptor);
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName name = new ObjectName( "com.acme.test:type=IoServiceManager,name=MyMINAServer" );
        mbs.registerMBean( iosm, name );
    }
    catch( JMException e )
    {
        logger.error( "JMX Exception: ", e );
    }

### Monitoring an IoSession

Each session is registered to MBean server individually.

    acceptor.addListener( new IoServiceListener()
    {
        public void serviceActivated( IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config )
        {
        }

        public void serviceDeactivated( IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config )
        {
        }

        public void sessionCreated( IoSession session )
        {
            try
            {
                IoSessionManager sessMgr = new IoSessionManager( session );
                MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
                ObjectName name = new ObjectName( "com.acme.test.session:type=IoSessionManager,name=" + session.getRemoteAddress().toString().replace( ':', '/' ) );
                mbs.registerMBean( sessMgr, name );
            }
            catch( JMException e )
            {
                logger.error( "JMX Exception: ", e );
            }
        }

        public void sessionDestroyed( IoSession session )
        {
            try
            {
                ObjectName name = new ObjectName( "com.acme.test.session:type=IoSessionManager,name=" + session.getRemoteAddress().toString().replace( ':', '/' ) );
                ManagementFactory.getPlatformMBeanServer().unregisterMBean( name );
            }
            catch( JMException e )
            {
                logger.error( "JMX Exception: ", e );
            }
        }
    });

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

Copyright © 2004-2008 Apache MINA Project. All Rights Reserved.