class MojarraPlugin {
    private static AgentLogger LOGGER = AgentLogger.getLogger(MojarraPlugin.class);

    @Init
    Scheduler scheduler;

    @Init
    ClassLoader appClassLoader;

    Set<Object> registeredRBMaps = Collections.newSetFromMap(new WeakHashMap<Object, Boolean>());

    @Init
    public void init(PluginConfiguration pluginConfiguration) {
        LOGGER.info("Mojarra plugin initialized.");
    }

    @OnClassLoadEvent(classNameRegexp = "com.sun.faces.config.ConfigManager")
    public static void facesConfigManagerInitialized(CtClass ctClass) throws NotFoundException, CannotCompileException {
        CtMethod init = ctClass.getDeclaredMethod("initialize");
        init.insertAfter(PluginManagerInvoker.buildInitializePlugin(MojarraPlugin.class));
        LOGGER.debug("com.sun.faces.config.ConfigManager enhanced with plugin initialization.");
    }

    @OnClassLoadEvent(classNameRegexp = "com.sun.faces.application.ApplicationResourceBundle")
    public static void facesApplicationAssociateInitialized(CtClass ctClass) throws NotFoundException, CannotCompileException {
        String registerResourceBundle = PluginManagerInvoker.buildCallPluginMethod(MojarraPlugin.class, "registerApplicationResourceBundle",
                "baseName", "java.lang.String", "resources", "java.lang.Object");
        String buildInitializePlugin = PluginManagerInvoker.buildInitializePlugin(MojarraPlugin.class);

        for (CtConstructor constructor : ctClass.getDeclaredConstructors()) {
            constructor.insertAfter(buildInitializePlugin);
            constructor.insertAfter(registerResourceBundle);
        }
        LOGGER.debug("com.sun.faces.application.ApplicationAssociate enhanced with resource bundles registration.");
    }

    public void registerApplicationResourceBundle(String baseName, Object resourceBundle) {
        registeredRBMaps.add(resourceBundle);
        LOGGER.debug("JsfPlugin - resource bundle '" + baseName + "' registered");
    }

    @OnResourceFileEvent(path = "/", filter = ".*.properties")
    public void refreshJsfResourceBundles() {
        scheduler.scheduleCommand(refreshResourceBundles);
    }

    @OnClassLoadEvent(classNameRegexp = ".*", events = LoadEvent.REDEFINE)
    public void reloadManagedBean(Class<?> beanClass) {
        if (!AnnotationHelper.hasAnnotation(beanClass, MANAGED_BEAN_ANNOTATION)) {
            return;
        }

        ReloadManagedBeanCommand command = new ReloadManagedBeanCommand(beanClass, appClassLoader);
        scheduler.scheduleCommand(command);
    }

    @OnClassFileEvent(classNameRegexp = ".*", events = FileEvent.CREATE)
    public void registerManagedBean(CtClass beanCtClass) throws Exception {
        if (!AnnotationHelper.hasAnnotation(beanCtClass, MANAGED_BEAN_ANNOTATION)) {
            return;
        }

        ReloadManagedBeanCommand command = new ReloadManagedBeanCommand(beanCtClass, appClassLoader);
        scheduler.scheduleCommand(command);
    }

    private Command refreshResourceBundles = new Command() {
        public void executeCommand() {<FILL_FUNCTION_BODY>}
    };

    private Class<?> resolveClass(String name) throws ClassNotFoundException {
        return Class.forName(name, true, appClassLoader);
    }

}

            LOGGER.debug("Refreshing JSF resource bundles.");
            try {
                Class<?> clazz = resolveClass("java.util.ResourceBundle");
                Method clearCacheMethod = clazz.getDeclaredMethod("clearCache", ClassLoader.class);
                clearCacheMethod.invoke(null, appClassLoader);
                for (Object resourceMap : registeredRBMaps) {
                    if (resourceMap instanceof Map) {
                        ((Map) resourceMap).clear();
                    }
                }
            } catch (Exception e) {
                LOGGER.error("Error clear JSF resource bundles cache", e);
            }
        
<no_super_class>