@ Validate public void start ( ) { Boolean enabled = configuration . getBooleanWithDefault ( "ehcache.enabled" , true ) ; if ( ! enabled ) { return ; } File config = new File ( configuration . getBaseDir ( ) , CUSTOM_CONFIGURATION ) ; final ClassLoader original = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( this . getClass ( ) . getClassLoader ( ) ) ; if ( config . isFile ( ) ) { manager = CacheManager . create ( config . getAbsolutePath ( ) ) ; } else { URL url = EhCacheService . class . getClassLoader ( ) . getResource ( INTERNAL_CONFIGURATION ) ; if ( url != null ) { manager = CacheManager . create ( url ) ; } else { throw new ExceptionInInitializerError ( "Cannot instantiate EhCache, " + "cannot load " + INTERNAL_CONFIGURATION + " file" ) ; } } manager . addCache ( WISDOM_KEY ) ; cache = manager . getCache ( WISDOM_KEY ) ; registration = context . registerService ( Cache . class , this , new Hashtable < String , Object > ( ) ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( original ) ; } }
Creates the EhCache - based implementation of the Cache Service .