public Class<?> generateInterface(String className, IOpenClass openClass, ClassLoader classLoader) throws Exception { boolean f1 = (includes == null) || (includes.length == 0); boolean f2 = (excludes == null) || (excludes.length == 0); if (f1 && f2) { return InterfaceGenerator.generateInterface(className, openClass, classLoader); } else { return InterfaceGenerator.generateInterface(className, openClass, classLoader, includes, excludes); } } }
/** * Generates interface class using methods and fields of given IOpenClass * instance. * * @param className name of result class * @param openClass IOpenClass instance * @param classLoader class loader what will be used to load generated * interface * @return generated interface * @throws Exception if an error has occurred */ public static Class<?> generateInterface(String className, IOpenClass openClass, ClassLoader classLoader) throws Exception { return generateInterface(className, openClass, classLoader, null, null); }
/** * Decorates methods signatures of given clazz. * * @param clazz class to decorate * @param classLoader The classloader where generated class should be * placed. * @return new class with decorated methods signatures: added * {@link IRulesRuntimeContext} as the first parameter for each * method. * @throws Exception */ public static Class<?> decorateClass(Class<?> clazz, ClassLoader classLoader) throws Exception { final Logger log = LoggerFactory.getLogger(RuntimeContextInstantiationStrategyEnhancerHelper.class); Method[] methods = clazz.getMethods(); List<RuleInfo> rules = getRulesDecorated(methods); String className = clazz.getName() + DECORATED_CLASS_NAME_SUFFIX; RuleInfo[] rulesArray = rules.toArray(new RuleInfo[rules.size()]); log.debug("Generating interface for '{}' class", clazz.getName()); return InterfaceGenerator.generateInterface(className, rulesArray, classLoader); }
/** * Decorates methods signatures of given clazz. * * @param clazz class to decorate * @param classLoader The classloader where generated class should be * placed. * @return new class with decorated methods signatures: added * {@link IRulesRuntimeContext} as the first parameter for each * method. * @throws Exception */ public static Class<?> decorateClass(Class<?> clazz, ClassLoader classLoader) throws Exception { final Logger log = LoggerFactory.getLogger(RuntimeContextInstantiationStrategyEnhancerHelper.class); Method[] methods = clazz.getMethods(); List<RuleInfo> rules = getRulesDecorated(methods); String className = clazz.getName() + DECORATED_CLASS_NAME_SUFFIX; RuleInfo[] rulesArray = rules.toArray(new RuleInfo[rules.size()]); log.debug("Generating interface for '{}' class", clazz.getName()); return InterfaceGenerator.generateInterface(className, rulesArray, classLoader); }
/** * Decorates methods signatures of given clazz. New decorated class will * have both original methods and decorated methods with * {@link VariationsPack} as the last parameter and {@link VariationsResult} * as the return type. * * @param clazz class to decorate * @param classLoader The classloader where generated class should be * placed. * @return new class with decorated methods signatures * @throws Exception */ public static Class<?> decorateClass(Class<?> clazz, ClassLoader classLoader) throws Exception { final Logger log = LoggerFactory.getLogger(VariationInstantiationStrategyEnhancerHelper.class); Method[] methods = clazz.getMethods(); List<RuleInfo> rules = getRulesDecorated(methods); String className = clazz.getName() + DECORATED_CLASS_NAME_SUFFIX; RuleInfo[] rulesArray = rules.toArray(new RuleInfo[rules.size()]); log.debug("Generating interface for '{}' class", clazz.getName()); return InterfaceGenerator.generateInterface(className, rulesArray, classLoader); }
/** * Decorates methods signatures of given clazz. New decorated class will * have both original methods and decorated methods with * {@link VariationsPack} as the last parameter and {@link VariationsResult} * as the return type. * * @param clazz class to decorate * @param classLoader The classloader where generated class should be * placed. * @return new class with decorated methods signatures * @throws Exception */ public static Class<?> decorateClass(Class<?> clazz, ClassLoader classLoader) throws Exception { final Logger log = LoggerFactory.getLogger(VariationInstantiationStrategyEnhancerHelper.class); Method[] methods = clazz.getMethods(); List<RuleInfo> rules = getRulesDecorated(methods); String className = clazz.getName() + DECORATED_CLASS_NAME_SUFFIX; RuleInfo[] rulesArray = rules.toArray(new RuleInfo[rules.size()]); log.debug("Generating interface for '{}' class", clazz.getName()); return InterfaceGenerator.generateInterface(className, rulesArray, classLoader); }
return generateInterface(className, EMPTY_RULES, classLoader); return generateInterface(className, rules.toArray(new RuleInfo[0]), classLoader);