class StandardSofaRuntimeManager implements SofaRuntimeManager, ApplicationContextAware {

    private final String                     appName;

    private final List<RuntimeShutdownAware> runtimeShutdownAwareList = new CopyOnWriteArrayList<>();

    private ComponentManagerImpl             componentManager;

    private ClientFactoryInternal            clientFactoryInternal;

    private SofaRuntimeContext               sofaRuntimeContext;

    private ClassLoader                      appClassLoader;

    private ApplicationContext               rootApplicationContext;

    public StandardSofaRuntimeManager(String appName, ClassLoader appClassLoader,
                                      ClientFactoryInternal clientFactoryInternal) {
        this.appName = appName;
        this.appClassLoader = appClassLoader;
        this.clientFactoryInternal = clientFactoryInternal;
        this.componentManager = new ComponentManagerImpl(clientFactoryInternal, appClassLoader);
        this.sofaRuntimeContext = new SofaRuntimeContext(this);
        this.componentManager.setSofaRuntimeContext(sofaRuntimeContext);
    }

    @Override
    public ComponentManager getComponentManager() {
        return componentManager;
    }

    @Override
    public ClientFactoryInternal getClientFactoryInternal() {
        return clientFactoryInternal;
    }

    @Override
    public SofaRuntimeContext getSofaRuntimeContext() {
        return sofaRuntimeContext;
    }

    @Override
    public String getAppName() {
        return appName;
    }

    @Override
    public ClassLoader getAppClassLoader() {
        return appClassLoader;
    }

    /**
     * shutdown sofa runtime manager
     *
     * @throws ServiceRuntimeException exception occur
     */
    @Override
    public void shutdown() throws ServiceRuntimeException {<FILL_FUNCTION_BODY>}

    @Override
    public void shutDownExternally() throws ServiceRuntimeException {
        try {
            AbstractApplicationContext applicationContext = (AbstractApplicationContext) rootApplicationContext;
            // only need shutdown when root context is active
            if (applicationContext.isActive()) {
                applicationContext.close();
            }
            appClassLoader = null;
        } catch (Throwable throwable) {
            throw new ServiceRuntimeException(ErrorCode.convert("01-03100"), throwable);
        }
    }

    @Override
    public void registerShutdownAware(RuntimeShutdownAware callback) {
        runtimeShutdownAwareList.add(callback);
    }

    @Override
    public ApplicationContext getRootApplicationContext() {
        return rootApplicationContext;
    }

    protected void clear() {
        componentManager = null;
        sofaRuntimeContext = null;
        clientFactoryInternal = null;
        runtimeShutdownAwareList.clear();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        rootApplicationContext = applicationContext;
    }
}

        try {
            for (RuntimeShutdownAware shutdownAware : runtimeShutdownAwareList) {
                shutdownAware.shutdown();
            }

            if (componentManager != null) {
                componentManager.shutdown();
            }

            clear();
        } catch (Throwable throwable) {
            throw new ServiceRuntimeException(ErrorCode.convert("01-03100"), throwable);
        }
    
<no_super_class>