class SessionFactoryProxy {

    /** The proxied factories. */
    private static Map<Configuration, SessionFactoryProxy> proxiedFactories = new HashMap<>();

    /**
     * Gets the wrapper.
     *
     * @param configuration
     *            the configuration
     * @return the wrapper
     */
    public static SessionFactoryProxy getWrapper(Configuration configuration) {<FILL_FUNCTION_BODY>}

    /**
     * Refresh proxied factories.
     */
    public static void refreshProxiedFactories() {
        synchronized (proxiedFactories) {
            for (SessionFactoryProxy wrapper : proxiedFactories.values()) {
                try {
                    wrapper.refreshProxiedFactory();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /** The configuration. */
    private Configuration configuration;

    /** The current instance. */
    private volatile SessionFactory currentInstance;

    /**
     * Instantiates a new session factory proxy.
     *
     * @param configuration
     *            the configuration
     */
    private SessionFactoryProxy(Configuration configuration) {
        this.configuration = configuration;
    }

    /**
     * Refresh proxied factory.
     *
     * @throws NoSuchMethodException
     *             the no such method exception
     * @throws InvocationTargetException
     *             the invocation target exception
     * @throws IllegalAccessException
     *             the illegal access exception
     */
    public void refreshProxiedFactory() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ReInitializable r = ReInitializable.class.cast(configuration);
        r.hotSwap();
        currentInstance = r._buildSessionFactory();
    }

    /**
     * Proxy.
     *
     * @param sessionFactory
     *            the session factory
     * @return the session factory
     */
    public SessionFactory proxy(SessionFactory sessionFactory) {
        try {
            this.currentInstance = sessionFactory;

            ProxyFactory factory = new ProxyFactory();
            factory.setSuperclass(SessionFactoryImpl.class);
            factory.setInterfaces(new Class[] { SessionFactory.class, SessionFactoryImplementor.class });

            MethodHandler handler = new MethodHandler() {
                @Override
                public Object invoke(Object self, Method overridden, Method forwarder, Object[] args) throws Throwable {
                    return overridden.invoke(currentInstance, args);
                }
            };

            Object instance;
            try {
                Constructor<?> constructor = sun.reflect.ReflectionFactory.getReflectionFactory()//
                        .newConstructorForSerialization(factory.createClass(), Object.class.getDeclaredConstructor(new Class[0]));
                instance = constructor.newInstance();
                ((Proxy) instance).setHandler(handler);
            } catch (Exception e) {
                e.printStackTrace();
                throw new Error("Unable instantiate SessionFactory proxy", e);
            }

            return (SessionFactory) instance;
        } catch (Exception e) {
            e.printStackTrace();
            throw new Error("Unable instantiate SessionFactory proxy", e);
        }
    }
}

        synchronized (proxiedFactories) {
            if (!proxiedFactories.containsKey(configuration)) {
                proxiedFactories.put(configuration, new SessionFactoryProxy(configuration));
            }
            return proxiedFactories.get(configuration);
        }
    
<no_super_class>