protected ApplicationContext prepareParentContext(final AcServiceConfig serviceConfig) throws AcServiceException { AcCoreContext coreContext = serviceConfig.getCoreContext(); GenericApplicationContext parentContext = new GenericApplicationContext(); DefaultListableBeanFactory beanFactory = parentContext.getDefaultListableBeanFactory(); // add service config beanFactory.registerSingleton(AcServiceConfig.SERVICE_CONFIG_BEAN_NAME, serviceConfig); // add core context beanFactory.registerSingleton(AcServiceConfig.CORE_CONTEXT_BEAN_NAME, coreContext); // add session beanFactory.registerSingleton(AcServiceConfig.SESSION_BEAN_NAME, coreContext.getSession()); // add profile beanFactory.registerSingleton( AcServiceConfig.PROFILE_BEAN_NAME, coreContext.getSession().getProfile()); // add data repository beanFactory.registerSingleton( AcServiceConfig.REPOSITORY_BEAN_NAME, coreContext.getDataRepository()); // add service preferences beanFactory.registerSingleton( AcServiceConfig.PREFERENCES_BEAN_NAME, serviceConfig.getServicePreferences()); // add dictionary beanFactory.registerSingleton( AcServiceConfig.DICTIONARY_BEAN_NAME, coreContext.getSession().getProfile().getDictionary()); for (String serviceClassName : metadata().getDependsServiceClassNames()) { try { AcService dependService = coreContext.getServiceByClassName(serviceClassName); beanFactory.registerSingleton(serviceClassName, dependService); } catch (Exception e) { throw new AcServiceException("load depend service error: " + serviceClassName, e); } } // ready for parent context parentContext.refresh(); return parentContext; }