/**
  * Looks up the specified key in the error message resource bundle. If the bundle is missing or if
  * the resource cannot be found, will return null instead of throwing an exception.
  *
  * @param locale the locale in which to lookup the resource
  * @param key the exact resource key to lookup
  * @return the resource String or null
  */
 public static String getErrorMessage(Locale locale, String key) {
   try {
     Configuration config = StripesFilter.getConfiguration();
     ResourceBundle bundle = config.getLocalizationBundleFactory().getErrorMessageBundle(locale);
     return bundle.getString(key);
   } catch (MissingResourceException mre) {
     return null;
   }
 }
  /**
   * calling injectors post creation on Action beans and Interceptors
   *
   * @param context
   * @return
   * @throws Exception
   */
  public Resolution intercept(ExecutionContext context) throws Exception {
    Configuration conf = StripesFilter.getConfiguration();

    FilterConfig filterConfig = conf.getBootstrapPropertyResolver().getFilterConfig();
    String className = filterConfig.getInitParameter(INJECTOR_FACTORY_CLASS);
    String methodName = filterConfig.getInitParameter(INJECTOR_FACTORY_METHOD);

    Injector injector = null;
    try {
      Class clazz = Class.forName(className);
      Method method = clazz.getMethod(methodName);
      injector = (Injector) method.invoke(null);
    } catch (ClassNotFoundException e) {
      log.error("Injector factory class not found - " + className, e);
      throw new Exception("Injector factory class not found - " + methodName, e);
    } catch (NoSuchMethodException e) {
      log.error("Injector factory method not found - " + methodName + " in class " + className, e);
      throw new Exception(
          "Injector factory method not found - " + methodName + " in class " + className, e);
    } catch (SecurityException e) {
      log.error(
          "SecurityException when trying to invoke - " + methodName + " in class " + className, e);
      throw new Exception(
          "SecurityException when trying to invoke - " + methodName + " in class " + className, e);
    } catch (IllegalAccessException e) {
      log.error(
          "IllegalAccessException when trying to invoke - " + methodName + " in class " + className,
          e);
      throw new Exception(
          "IllegalAccessException when trying to invoke - " + methodName + " in class " + className,
          e);
    } catch (IllegalArgumentException e) {
      log.error(
          "IllegalArgumentException when trying to invoke - "
              + methodName
              + " in class "
              + className,
          e);
      throw new Exception(
          "IllegalArgumentException when trying to invoke - "
              + methodName
              + " in class "
              + className,
          e);
    } catch (InvocationTargetException e) {
      log.error(
          "InvocationTargetException when trying to invoke - "
              + methodName
              + " in class "
              + className,
          e);
      throw new Exception(
          "InvocationTargetException when trying to invoke - "
              + methodName
              + " in class "
              + className,
          e);
    }

    //    if (context.getActionBean() != null) injector.injectMembers(context.getActionBean());
    if (context.getActionBeanContext() != null)
      injector.injectMembers(context.getActionBeanContext());

    for (Interceptor interceptor : conf.getInterceptors(context.getLifecycleStage())) {
      if (interceptor != null) injector.injectMembers(interceptor);
    }

    return context.proceed();
  }