/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param methodName The method to call. * @param clazz The list of argument classes for the given method * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Class<?>[] clazz, Object[] params){ try{ Method method = context.getClass().getMethod(methodName, clazz); return executeMethod(method,context,params); } catch (Exception ex){ try{ handleException(ex, methodName); }catch (Throwable t){ throw new RuntimeException(t.getMessage()); } return null; } }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param methodName The method to call. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Object[] params) { try{ return invokeMethod(context, methodName, params); }catch(Throwable t){ throw new RuntimeException(t.getMessage(), t); } }
/** * Construct a new instance of this class, associated with the specified * Context instance. * * @param context The associated Context instance */ public ApplicationContextFacade(ApplicationContext context) { super(); this.context = context; classCache = new HashMap<>(); objectCache = new ConcurrentHashMap<>(); initClassCache(); }
@Override public boolean setInitParameter(String name, String value) { if (SecurityUtil.isPackageProtectionEnabled()) { return ((Boolean) doPrivileged("setInitParameter", new Object[]{name, value})).booleanValue(); } else { return context.setInitParameter(name, value); } }
@Override public int getEffectiveMajorVersion() { if (SecurityUtil.isPackageProtectionEnabled()) { return ((Integer) doPrivileged("getEffectiveMajorVersion", null)).intValue(); } else { return context.getEffectiveMajorVersion(); } }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param methodName The method to invoke. * @param clazz The class where the method is. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Class[] clazz, Object[] params){ try{ Method method = context.getClass() .getMethod(methodName, (Class[])clazz); return executeMethod(method,context,params); } catch (Exception ex){ try{ handleException(ex, methodName); }catch (Throwable t){ throw new RuntimeException(t.getMessage()); } return null; } finally { params = null; } }
@Override public int getEffectiveMinorVersion() { if (SecurityUtil.isPackageProtectionEnabled()) { return ((Integer) doPrivileged("getEffectiveMinorVersion", null)).intValue(); } else { return context.getEffectiveMinorVersion(); } }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param methodName The method to call. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Object[] params) { try{ return invokeMethod(context, methodName, params); }catch(Throwable t){ throw new RuntimeException(t.getMessage(), t); } }
/** * Construct a new instance of this class, associated with the specified * Context instance. * * @param context The associated Context instance */ public ApplicationContextFacade(ApplicationContext context) { super(); this.context = context; classCache = new HashMap(); objectCache = new HashMap(); initClassCache(); }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param methodName The method to invoke. * @param clazz The class where the method is. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Class[] clazz, Object[] params){ try{ Method method = context.getClass() .getMethod(methodName, (Class[])clazz); return executeMethod(method,context,params); } catch (Exception ex){ try{ handleException(ex, methodName); }catch (Throwable t){ throw new RuntimeException(t.getMessage()); } return null; } finally { params = null; } }
@Override public int getSessionTimeout() { if (SecurityUtil.isPackageProtectionEnabled()) { return ((Integer) doPrivileged("getSessionTimeout", null)).intValue(); } else { return context.getSessionTimeout(); } }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param methodName The method to call. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Object[] params) { try{ return invokeMethod(context, methodName, params); }catch(Throwable t){ throw new RuntimeException(t.getMessage(), t); } }
/** * Construct a new instance of this class, associated with the specified * Context instance. * * @param context The associated Context instance */ public ApplicationContextFacade(ApplicationContext context) { super(); this.context = context; classCache = new HashMap<String,Class<?>[]>(); objectCache = new HashMap<String,Method>(); initClassCache(); }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param methodName The method to invoke. * @param clazz The class where the method is. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Class[] clazz, Object[] params){ try{ Method method = context.getClass() .getMethod(methodName, (Class[])clazz); return executeMethod(method,context,params); } catch (Exception ex){ try{ handleException(ex, methodName); }catch (Throwable t){ throw new RuntimeException(t.getMessage()); } return null; } finally { params = null; } }
@Override public void setSessionTimeout(int sessionTimeout) { if (SecurityUtil.isPackageProtectionEnabled()) { doPrivileged("setSessionTimeout", new Object[] { Integer.valueOf(sessionTimeout) }); } else { context.setSessionTimeout(sessionTimeout); } }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * will be invoked * @param methodName The method to call. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, Object[] params){ try{ return invokeMethod(context, methodName, params); }catch(Throwable t){ throw new RuntimeException(t.getMessage()); } }
/** * Construct a new instance of this class, associated with the specified * Context instance. * * @param context The associated Context instance */ public ApplicationContextFacade(ApplicationContext context) { super(); this.context = context; classCache = new HashMap<String,Class<?>[]>(); objectCache = new HashMap<String,Method>(); initClassCache(); }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * @param appContext The ApplicationContext object on which the method * will be invoked * @param methodName The method to call. * @param params The arguments passed to the called method. */ private Object invokeMethod(ApplicationContext appContext, final String methodName, Object[] params) throws Throwable{ try{ Method method = objectCache.get(methodName); if (method == null){ method = appContext.getClass() .getMethod(methodName, classCache.get(methodName)); objectCache.put(methodName, method); } return executeMethod(method,appContext,params); } catch (Exception ex){ handleException(ex); return null; } finally { params = null; } }
@Override public ServletRegistration getServletRegistration(String servletName) { if (SecurityUtil.isPackageProtectionEnabled()) { return (ServletRegistration) doPrivileged( "getServletRegistration", new Object[]{servletName}); } else { return context.getServletRegistration(servletName); } }
/** * Use reflection to invoke the requested method. Cache the method object * to speed up the process * will be invoked * @param methodName The method to call. * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Object[] params){ try{ return invokeMethod(context, methodName, params); }catch(Throwable t){ throw new RuntimeException(t.getMessage(), t); } }