ehcache / ehcache-jcache

The Ehcache 2.x implementation of JSR107 (JCACHE)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JCacheManager.enableManagement spec violation

Mobe91 opened this issue · comments

The spec says:
"The platform MBeanServer is obtained using ManagementFactory.getPlatformMBeanServer()"

but the current enableManagement implementation uses registerObject which is implemented as follows

private void registerObject(final JCacheMXBean cacheMXBean) throws NotCompliantMBeanException,
        InstanceAlreadyExistsException, MBeanRegistrationException, MalformedObjectNameException {
        final ObjectName objectName = new ObjectName(cacheMXBean.getObjectName());
        if(mBeanServer.queryNames(objectName, null).isEmpty()) {
            mBeanServer.registerMBean(cacheMXBean, objectName);
        }
    }

mBeanServer is a newly created MBeanServer and is not obtained using ManagementFactory.getPlatformMBeanServer().

We should make this configurable. Probably defaulting to the platform MBeanServer indeed.
It should be configurable because of how the TCK wants to test for this. Probably should try to get rid of the tck package from within the implementation as well.

Started a thread on the subject on our dev-mailing list https://groups.google.com/forum/#!topic/ehcache-dev/rCvdLPBzYFw
Not quite sure how we best fix this...