• Bug
  • Status: Closed
  • Resolution: Fixed
  • drb
  • Reporter: sourceforgetracker
  • September 21, 2009
  • 0
  • Watchers: 0
  • September 22, 2009
  • September 22, 2009

Description

Less reliance on static methods would allow EhCache to behave more like a black-box and promote better unit testing. Elimination of static methods would also make EhCache more configurable by IOC containers. For example: Instead of net.sf.ehcache.management.ManagementService.registerMBeans();, One could have an IOC container construct the ManagementService and inject the MBeanServer and the CacheManager.

Sourceforge Ticket ID: 1958670 - Opened By: nobody - 6 May 2008 11:56 UTC

Comments

Sourceforge Tracker 2009-09-21

Logged In: YES user_id=693320 Originator: NO

I have removed most of this stuff explicitly to allow and IoC and mocking. Paul Hammant and Jo Walnes spent an afternoon beating me up on it.

I have fixed ManagementService. There is now a test as follows:

/**
 * Integration test for the registration service using a contructed ManagementService as would be done
 * by an IoC container.
 */
public void testRegistrationServiceFourTrueUsing14MBeanServerWithConstructorInjection() throws Exception {
    mBeanServer = create14MBeanServer();
    ManagementService managementService = new ManagementService(manager, mBeanServer, true, true, true, true);
    managementService.init();
    assertEquals(OBJECTS_IN_TEST_EHCACHE, mBeanServer.queryNames(new ObjectName("net.sf.ehcache:*"), null).size());
}

The fix is in trunk and will be in 1.5.

This will give you all you need from your IoC container. If you notice anything else please let me know. Comment by: gregluck - 7 May 2008 23:25 UTC

Fiona OShea 2009-09-22

Re-opening so that I can properly close out these issues and have correct Resolution status in Jira