class ServiceProxy implements MethodInterceptor {

    protected ClassLoader serviceClassLoader;

    public ServiceProxy(ClassLoader serviceClassLoader) {
        this.serviceClassLoader = serviceClassLoader;
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {<FILL_FUNCTION_BODY>}

    protected void pushThreadContextClassLoader(ClassLoader newContextClassLoader) {
        if (newContextClassLoader != null) {
            Thread.currentThread().setContextClassLoader(newContextClassLoader);
        }
    }

    protected void popThreadContextClassLoader(ClassLoader tcl) {
        Thread.currentThread().setContextClassLoader(tcl);
    }

    protected String getCommonInvocationLog(String start, MethodInvocation invocation,
                                            long startTime) {
        String appStart = "";

        if (StringUtils.hasText(appStart)) {
            appStart = "-" + start;
        }

        long endTime = System.currentTimeMillis();

        StringBuilder sb = new StringBuilder("SOFA-Reference" + appStart + "(");

        sb.append(invocation.getMethod().getName()).append(",");
        for (Object o : invocation.getArguments()) {
            sb.append(o);
            sb.append(",");
        }
        sb.append((endTime - startTime)).append("ms").append(")");

        return sb.toString();
    }

    public ClassLoader getServiceClassLoader() {
        return serviceClassLoader;
    }

    /**
     * Actually do invoke.
     *
     * @param invocation invocation
     * @return invoke result
     * @throws Throwable invoke exception
     */
    protected abstract Object doInvoke(MethodInvocation invocation) throws Throwable;

    /**
     * Hook to handle exception.
     *
     * @param invocation invocation
     * @param e exception
     * @param startTime start time
     */
    protected abstract void doCatch(MethodInvocation invocation, Throwable e, long startTime);

    /**
     * Hook to handle after invocatino.
     *
     * @param invocation invocation
     * @param startTime start time
     */
    protected abstract void doFinally(MethodInvocation invocation, long startTime);
}

        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        long startTime = System.currentTimeMillis();
        try {
            Thread.currentThread().setContextClassLoader(serviceClassLoader);
            return doInvoke(invocation);
        } catch (Throwable e) {
            doCatch(invocation, e, startTime);
            throw e;
        } finally {
            doFinally(invocation, startTime);
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
    
<no_super_class>