class RepositoryRefreshAgent {

    private static AgentLogger LOGGER = AgentLogger.getLogger(RepositoryRefreshAgent.class);

    public static boolean reloadFlag = false;

    /**
     * Reload bean in existing bean manager. Called by a reflection command from BeanRefreshCommand transformer.
     *
     * @param appClassLoader the application class loader
     * @param repoClassName the repo class name
     */
    public static void refreshHandler(ClassLoader appClassLoader, String repoClassName, List repositoryProxies) {

        ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();

        try {
            Thread.currentThread().setContextClassLoader(appClassLoader);
            Class<?> repoClass = appClassLoader.loadClass(repoClassName);

            RepositoryMetadataHandler handler = getInstance(RepositoryMetadataHandler.class);
            if (handler != null) {
                ReflectionHelper.invoke(handler, handler.getClass(), RepositoryTransformer.REINITIALIZE_METHOD, new Class[] { Class.class }, repoClass);
            } else {
                LOGGER.debug("{} bean not found.", RepositoryMetadataHandler.class.getName());
            }

            Method[] delegateMethods = PartialBeanProxyFactory.getInstance().getDelegateMethods(repoClass);
            for (Object proxyObject: repositoryProxies) {
                if (proxyObject instanceof DeltaSpikeProxy) {
                    ((DeltaSpikeProxy) proxyObject).setDelegateMethods(delegateMethods);
                }
            }
            DeltaSpikeProxyInterceptorLookup lookup = getInstance(DeltaSpikeProxyInterceptorLookup.class);
            if (lookup != null) {
                Map cache  = (Map) ReflectionHelper.get(lookup, "cache");
                if (cache != null) {
                    cache.clear();
                }
            }
            LOGGER.info("Deltaspike repository {} refreshed.", repoClassName);
            RepositoryRefreshAgent.reloadFlag = true;
        } catch (ClassNotFoundException e) {
            LOGGER.error("Repository class '{}' not found.", repoClassName, e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldContextClassLoader);
        }
    }

    public static <T> T getInstance(Class<T> beanClass) {
        BeanManager beanManager = CDI.current().getBeanManager();
        Bean<T> bean = resolve(beanManager, beanClass);
        return getInstance(beanManager, bean);
    }

    private static <T> Bean<T> resolve(BeanManager beanManager, Class<T> beanClass) {<FILL_FUNCTION_BODY>}

    private static <T> T getInstance(BeanManager beanManager, Bean<T> bean) {
        Context context = beanManager.getContext(bean.getScope());
        return context.get(bean);
    }
}

        Set<Bean<?>> beans = beanManager.getBeans(beanClass);

        for (Bean<?> bean : beans) {
            if (bean.getBeanClass() == beanClass) {
                return (Bean<T>) beanManager.resolve(Collections.<Bean<?>> singleton(bean));
            }
        }
        return (Bean<T>) beanManager.resolve(beans);
    
<no_super_class>