@Test public void testGetMethods() throws ScriptException { TeiidScriptEngine tse = new TeiidScriptEngine(); Map<String, Method> map = tse.getMethodMap(Object.class); assertEquals(map, tse.getMethodMap(Object.class)); assertEquals(4, map.size()); }
public Map<String, Method> getMethodMap(Class<?> clazz) throws ScriptException { Map<Class<?>, Map<String, Method>> clazzMaps = null; Map<String, Method> methodMap = null; if (properties != null) { clazzMaps = properties.get(); if (clazzMaps != null) { methodMap = clazzMaps.get(clazz); if (methodMap != null) { return methodMap; } } } try { BeanInfo info = Introspector.getBeanInfo(clazz); PropertyDescriptor[] pds = info.getPropertyDescriptors(); methodMap = new LinkedHashMap<String, Method>(); if (pds != null) { for (int j = 0; j < pds.length; j++) { PropertyDescriptor pd = pds[j]; if (pd.getReadMethod() == null || pd instanceof IndexedPropertyDescriptor) { continue; } String name = pd.getName(); Method m = pd.getReadMethod(); methodMap.put(name, m); } } MethodDescriptor[] mds = info.getMethodDescriptors(); if (pds != null) { for (int j = 0; j < mds.length; j++) { MethodDescriptor md = mds[j]; if (md.getMethod() == null || md.getMethod().getParameterTypes().length > 0 || md.getMethod().getReturnType() == Void.class || md.getMethod().getReturnType() == void.class) { continue; } String name = md.getName(); Method m = md.getMethod(); methodMap.put(name, m); } } if (clazzMaps == null) { clazzMaps = Collections.synchronizedMap(new LRUCache<Class<?>, Map<String,Method>>(100)); properties = new SoftReference<Map<Class<?>,Map<String,Method>>>(clazzMaps); } clazzMaps.put(clazz, methodMap); } catch (IntrospectionException e) { throw new ScriptException(e); } return methodMap; }
TeiidScriptEngine extends AbstractScriptEngine implements Compilable { public Map<String, Method> getMethodMap(Class<?> clazz) throws ScriptException { Map<Class<?>, Map<String, Method>> clazzMaps = null; Map<String, Method> methodMap = null; if (properties != null) { clazzMaps = properties.get(); if (clazzMaps != null) { methodMap = clazzMaps.get(clazz); if (methodMap != null) { return methodMap; } } } try { BeanInfo info = Introspector.getBeanInfo(clazz); PropertyDescriptor[] pds = info.getPropertyDescriptors(); methodMap = new LinkedHashMap<String, Method>(); if (pds != null) { for (int j = 0; j < pds.length; j++) { PropertyDescriptor pd = pds[j]; if (pd.getReadMethod() == null || pd instanceof IndexedPropertyDescriptor) { continue; } String name = pd.getName(); Method m = pd.getReadMethod(); methodMap.put(name, m); } } MethodDescriptor[] mds = info.getMethodDescriptors(); if (pds != null) { for (int j = 0; j < mds.length; j++) { MethodDescriptor md = mds[j]; if (md.getMethod() == null || md.getMethod().getParameterTypes().length > 0 || md.getMethod().getReturnType() == Void.class || md.getMethod().getReturnType() == void.class) { continue; } String name = md.getName(); Method m = md.getMethod(); methodMap.put(name, m); } } if (clazzMaps == null) { clazzMaps = Collections.synchronizedMap(new LRUCache<Class<?>, Map<String,Method>>(100)); properties = new SoftReference<Map<Class<?>,Map<String,Method>>>(clazzMaps); } clazzMaps.put(clazz, methodMap); } catch (IntrospectionException e) { throw new ScriptException(e); } return methodMap; } }
TeiidScriptEngine extends AbstractScriptEngine implements Compilable { public Map<String, Method> getMethodMap(Class<?> clazz) throws ScriptException { Map<Class<?>, Map<String, Method>> clazzMaps = null; Map<String, Method> methodMap = null; if (properties != null) { clazzMaps = properties.get(); if (clazzMaps != null) { methodMap = clazzMaps.get(clazz); if (methodMap != null) { return methodMap; } } } try { BeanInfo info = Introspector.getBeanInfo(clazz); PropertyDescriptor[] pds = info.getPropertyDescriptors(); methodMap = new LinkedHashMap<String, Method>(); if (pds != null) { for (int j = 0; j < pds.length; j++) { PropertyDescriptor pd = pds[j]; if (pd.getReadMethod() == null || pd instanceof IndexedPropertyDescriptor) { continue; } String name = pd.getName(); Method m = pd.getReadMethod(); methodMap.put(name, m); } } MethodDescriptor[] mds = info.getMethodDescriptors(); if (pds != null) { for (int j = 0; j < mds.length; j++) { MethodDescriptor md = mds[j]; if (md.getMethod() == null || md.getMethod().getParameterTypes().length > 0 || md.getMethod().getReturnType() == Void.class || md.getMethod().getReturnType() == void.class) { continue; } String name = md.getName(); Method m = md.getMethod(); methodMap.put(name, m); } } if (clazzMaps == null) { clazzMaps = Collections.synchronizedMap(new LRUCache<Class<?>, Map<String,Method>>(100)); properties = new SoftReference<Map<Class<?>,Map<String,Method>>>(clazzMaps); } clazzMaps.put(clazz, methodMap); } catch (IntrospectionException e) { throw new ScriptException(e); } return methodMap; }  }
TeiidScriptEngine extends AbstractScriptEngine implements Compilable { public Map<String, Method> getMethodMap(Class<?> clazz) throws ScriptException { Map<Class<?>, Map<String, Method>> clazzMaps = null; Map<String, Method> methodMap = null; if (properties != null) { clazzMaps = properties.get(); if (clazzMaps != null) { methodMap = clazzMaps.get(clazz); if (methodMap != null) { return methodMap; } } } try { BeanInfo info = Introspector.getBeanInfo(clazz); PropertyDescriptor[] pds = info.getPropertyDescriptors(); methodMap = new LinkedHashMap<String, Method>(); if (pds != null) { for (int j = 0; j < pds.length; j++) { PropertyDescriptor pd = pds[j]; if (pd.getReadMethod() == null || pd instanceof IndexedPropertyDescriptor) { continue; } String name = pd.getName(); Method m = pd.getReadMethod(); methodMap.put(name, m); } } MethodDescriptor[] mds = info.getMethodDescriptors(); if (pds != null) { for (int j = 0; j < mds.length; j++) { MethodDescriptor md = mds[j]; if (md.getMethod() == null || md.getMethod().getParameterTypes().length > 0 || md.getMethod().getReturnType() == Void.class || md.getMethod().getReturnType() == void.class) { continue; } String name = md.getName(); Method m = md.getMethod(); methodMap.put(name, m); } } if (clazzMaps == null) { clazzMaps = Collections.synchronizedMap(new LRUCache<Class<?>, Map<String,Method>>(100)); properties = new SoftReference<Map<Class<?>,Map<String,Method>>>(clazzMaps); } clazzMaps.put(clazz, methodMap); } catch (IntrospectionException e) { throw new ScriptException(e); } return methodMap; }  @Override Bindings createBindings(); @Override CompiledScript compile(String script); Map<String, Method> getMethodMap(Class<?> clazz); @Override CompiledScript compile(Reader script); @Override ScriptEngineFactory getFactory(); Object eval(Reader reader, ScriptContext sc); @Override Object eval(String script, ScriptContext sc); }
TeiidScriptEngine extends AbstractScriptEngine implements Compilable { public Map<String, Method> getMethodMap(Class<?> clazz) throws ScriptException { Map<Class<?>, Map<String, Method>> clazzMaps = null; Map<String, Method> methodMap = null; if (properties != null) { clazzMaps = properties.get(); if (clazzMaps != null) { methodMap = clazzMaps.get(clazz); if (methodMap != null) { return methodMap; } } } try { BeanInfo info = Introspector.getBeanInfo(clazz); PropertyDescriptor[] pds = info.getPropertyDescriptors(); methodMap = new LinkedHashMap<String, Method>(); if (pds != null) { for (int j = 0; j < pds.length; j++) { PropertyDescriptor pd = pds[j]; if (pd.getReadMethod() == null || pd instanceof IndexedPropertyDescriptor) { continue; } String name = pd.getName(); Method m = pd.getReadMethod(); methodMap.put(name, m); } } MethodDescriptor[] mds = info.getMethodDescriptors(); if (pds != null) { for (int j = 0; j < mds.length; j++) { MethodDescriptor md = mds[j]; if (md.getMethod() == null || md.getMethod().getParameterTypes().length > 0 || md.getMethod().getReturnType() == Void.class || md.getMethod().getReturnType() == void.class) { continue; } String name = md.getName(); Method m = md.getMethod(); methodMap.put(name, m); } } if (clazzMaps == null) { clazzMaps = Collections.synchronizedMap(new LRUCache<Class<?>, Map<String,Method>>(100)); properties = new SoftReference<Map<Class<?>,Map<String,Method>>>(clazzMaps); } clazzMaps.put(clazz, methodMap); } catch (IntrospectionException e) { throw new ScriptException(e); } return methodMap; }  @Override Bindings createBindings(); @Override CompiledScript compile(String script); Map<String, Method> getMethodMap(Class<?> clazz); @Override CompiledScript compile(Reader script); @Override ScriptEngineFactory getFactory(); Object eval(Reader reader, ScriptContext sc); @Override Object eval(String script, ScriptContext sc);  }