001package com.ericlam.mc.groovier; 002 003import groovy.lang.GroovyClassLoader; 004 005import java.io.File; 006import java.io.IOException; 007 008/** 009 * a script cache manager 010 */ 011public interface ScriptCacheManager { 012 013 /** 014 * check if the script is cached (with md5 hash mapping) 015 * @param content script content 016 * @return true if cached 017 * @throws IOException error while reading text 018 */ 019 boolean isCached(File content) throws IOException; 020 021 /** 022 * check if the script is cached (with md5 hash mapping) 023 * @param content script content 024 * @return true if cached 025 */ 026 boolean isCached(String content); 027 028 /** 029 * get the script class from cache, if not cached, load it and cache it 030 * @param content script content 031 * @param classLoader groovy class loader 032 * @return script class 033 * @throws Exception error while loading script 034 */ 035 Class<?> getScriptOrLoad(String content, GroovyClassLoader classLoader) throws Exception; 036 037 /** 038 * get the script class from cache, if not cached, load it and cache it 039 * @param file script file 040 * @param classLoader groovy class loader 041 * @return script class 042 * @throws Exception error while loading script 043 */ 044 Class<?> getScriptOrLoad(File file, GroovyClassLoader classLoader) throws Exception; 045 046}