public Subscription register(final Object mBean, final String name){
        try {
            if (mbeanSupport.get()) {
                final ObjectName objectName = new ObjectName(name);
                server.registerMBean(mBean, objectName);
                return new Subscription() {
                    @Override
                    public void unsubscribe() {
                        try {
                            server.unregisterMBean(objectName);
                        } catch (JMException e) {
                            throw new RuntimeException("Can not unsubscribe!", e);
                        }
                    }
                };
            } else {
                return new Subscription() {
                    @Override
                    public void unsubscribe() {
                    }
                };
            }
        } catch (Exception e) {
            throw new RuntimeException("Can not register MBean!", e);
        }
    }
public Subscription register ( final Object mBean , final String name ) { try { if ( mbeanSupport . get ( ) ) { final ObjectName objectName = new ObjectName ( name ) ; server . registerMBean ( mBean , objectName ) ; return new Subscription ( ) { @ Override public void unsubscribe ( ) { try { server . unregisterMBean ( objectName ) ; } catch ( JMException e ) { throw new RuntimeException ( "Can not unsubscribe!" , e ) ; } } } ; } else { return new Subscription ( ) { @ Override public void unsubscribe ( ) { } } ; } } catch ( Exception e ) { throw new RuntimeException ( "Can not register MBean!" , e ) ; } }
Register the given MBean based on the given name
@param mBean the bean
@param name the name
@return the subscription that can be used to unregister the bean