public final boolean registerProgramAsMBean(final Class<?> clazz) {
		RemoteProgram remoteProgram = RemotePrograms.getRemoteProgram(clazz.getCanonicalName());
		if (remoteProgram==null) {
			LaunchingMessageKind.EJMX0003.format(clazz.getCanonicalName());
			return false;
		}
		if (this.mbs == null) {
			LaunchingMessageKind.EJMX0002.format();
			return false;
		}
		try {
			final String fqnName = remoteProgram.getAdapterClass().getCanonicalName();
			final String domain = fqnName.substring(0, fqnName.lastIndexOf('.'));
			final String type = fqnName.substring(fqnName.lastIndexOf('.') + 1);

			if (Arrays.asList(clazz.getInterfaces()).contains(
					Adapter.class)) {
				final DynamicLegacyProgram dprogram = new DynamicLegacyProgram(
						remoteProgram);
				final ObjectName objectName = new ObjectName(String.format(
						beanNameFormat, domain, type));
				this.beanNames.add(objectName);

				if (!mbs.isRegistered(objectName)) {
					LaunchingMessageKind.IJMX0004.format(objectName);
					mbs.registerMBean(dprogram, objectName);
					LaunchingMessageKind.IJMX0005.format(objectName);
				}
			} else {
				LaunchingMessageKind.EJMX0003.format(clazz);
				return false;
			}
		} catch (MalformedObjectNameException e) {
			LaunchingMessageKind.EJMX0004.format(clazz.getCanonicalName(), e);
			return false;
		} catch (NullPointerException e) {
			LaunchingMessageKind.EJMX0004.format(clazz.getCanonicalName(), e);
			return false;
		} catch (InstanceAlreadyExistsException e) {
			LaunchingMessageKind.EJMX0004.format(clazz.getCanonicalName(), e);
			return false;
		} catch (MBeanRegistrationException e) {
			LaunchingMessageKind.EJMX0004.format(clazz.getCanonicalName(), e);
			return false;
		} catch (NotCompliantMBeanException e) {
			LaunchingMessageKind.EJMX0004.format(clazz.getCanonicalName(), e);
			return false;
		}
		return true;
	}
public final boolean registerProgramAsMBean ( final Class < ? > clazz ) { RemoteProgram remoteProgram = RemotePrograms . getRemoteProgram ( clazz . getCanonicalName ( ) ) ; if ( remoteProgram == null ) { LaunchingMessageKind . EJMX0003 . format ( clazz . getCanonicalName ( ) ) ; return false ; } if ( this . mbs == null ) { LaunchingMessageKind . EJMX0002 . format ( ) ; return false ; } try { final String fqnName = remoteProgram . getAdapterClass ( ) . getCanonicalName ( ) ; final String domain = fqnName . substring ( 0 , fqnName . lastIndexOf ( '.' ) ) ; final String type = fqnName . substring ( fqnName . lastIndexOf ( '.' ) + 1 ) ; if ( Arrays . asList ( clazz . getInterfaces ( ) ) . contains ( Adapter . class ) ) { final DynamicLegacyProgram dprogram = new DynamicLegacyProgram ( remoteProgram ) ; final ObjectName objectName = new ObjectName ( String . format ( beanNameFormat , domain , type ) ) ; this . beanNames . add ( objectName ) ; if ( ! mbs . isRegistered ( objectName ) ) { LaunchingMessageKind . IJMX0004 . format ( objectName ) ; mbs . registerMBean ( dprogram , objectName ) ; LaunchingMessageKind . IJMX0005 . format ( objectName ) ; } } else { LaunchingMessageKind . EJMX0003 . format ( clazz ) ; return false ; } } catch ( MalformedObjectNameException e ) { LaunchingMessageKind . EJMX0004 . format ( clazz . getCanonicalName ( ) , e ) ; return false ; } catch ( NullPointerException e ) { LaunchingMessageKind . EJMX0004 . format ( clazz . getCanonicalName ( ) , e ) ; return false ; } catch ( InstanceAlreadyExistsException e ) { LaunchingMessageKind . EJMX0004 . format ( clazz . getCanonicalName ( ) , e ) ; return false ; } catch ( MBeanRegistrationException e ) { LaunchingMessageKind . EJMX0004 . format ( clazz . getCanonicalName ( ) , e ) ; return false ; } catch ( NotCompliantMBeanException e ) { LaunchingMessageKind . EJMX0004 . format ( clazz . getCanonicalName ( ) , e ) ; return false ; } return true ; }
This method try to register a type annotated with @Program as
a MBean in the JMX server

@param beanClass the class name of the Program