La création d'un bean géré en Java

Je suis en train de faire une classe implémente une Interface de MBean afin que je puisse interroger les propriétés à l'exécution. La classe je suis en train de les interroger est comme suit

public class ProfileCache implements ProfileCacheInterfaceMBean{

    private Logger logger = Logger.getLogger(ProfileCache.class);
    private ConcurrentMap<String, Profile> cache;


    public ProfileCache(ConcurrentMap<String, Profile> cache){
        this.cache = cache;     
    }

    /**
     * Update the cache entry for a given user id
     * @param userid the user id to update for 
     * @param profile the new profile to store
     * @return true if the cache update
     */
    public boolean updateCache(String userid, Profile profile) {
        if (cache == null || cache.size() == 0) {
            throw new RuntimeException("Unable to update the cache");
        }
        if (cache.containsKey(userid)) {
            if (profile != null) {
                cache.put(userid, profile);
                logger.info("Updated the cache for user: "
                            + userid + "  profile: " + profile);
                return true;
            }
        }
        return false;
    }

    @Override
    public ConcurrentMap<String, Profile> getCache() {
        if(cache == null){
            cache = new ConcurrentHashMap<String, Profile>();
        }
        return cache;
    }


}

L'interface ressemble à ceci

import com.vimba.profile.Profile;

public interface ProfileCacheInterfaceMBean {

    ConcurrentMap<String, Profile> getCache();

}

Et je commence le MBean comme ce

        cacheImpl = new ProfileCache(factory.createCacheFromDB());
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName profileCache = new ObjectName("org.javalobby.tnt.jmx:type=ProfileCacheInterfaceMBean");  
        mbs.registerMBean(cacheImpl, profileCache);

Cependant, je reçois le ci-dessous exception et je ne suis pas sûr de ce que j'ai besoin de changer

javax.management.NotCompliantMBeanException: MBean class com.vimba.cache.ProfileCache does not implement DynamicMBean, and neither follows the Standard MBean conventions (javax.management.NotCompliantMBeanException: Class com.vimba.cache.ProfileCache is not a JMX compliant Standard MBean) nor the MXBean conventions (javax.management.NotCompliantMBeanException: com.vimba.cache.ProfileCache: Class com.vimba.cache.ProfileCache is not a JMX compliant MXBean)

Je pense que potentiellement c'est parce qu'elle renvoie à une Carte?

Je vous remercie pour ce commentaire, si j'ai bien compris ce que voulait dire que je n'aurais pas posté ici. Pas de doute, votre sarcasme devrait vous aider à obtenir un peu plus de points - bon travail
C'était une véritable question. De toute façon, la partie de l'exception ne comprenez-vous pas? Pour commencer, à "ne pas mettre en œuvre" --> Indique que votre classe doit implémenter l'interface.
C'est la source de ma confusion que j'ai suivi le tutoriel n'a pas implémenter cette interface - peut-être que je devrais juste aller et rtfm
Renommer le Managed Bean nom de la classe à la fin de "YourClasssNameMXBean" a fonctionné pour moi.

OriginalL'auteur Biscuit128 | 2014-08-14