本文整理匯總了Java中org.springframework.context.ApplicationContext.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationContext.getParent方法的具體用法?Java ApplicationContext.getParent怎麽用?Java ApplicationContext.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.ApplicationContext
的用法示例。
在下文中一共展示了ApplicationContext.getParent方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extract
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
private Map<String, Object> extract(ApplicationContext context, ObjectMapper mapper) {
Map<String, Object> result = new LinkedHashMap<>();
ConfigurationBeanFactoryMetaData beanFactoryMetaData = getBeanFactoryMetaData(
context);
Map<String, Object> beans = getConfigurationPropertiesBeans(context,
beanFactoryMetaData);
for (Map.Entry<String, Object> entry : beans.entrySet()) {
String beanName = entry.getKey();
Object bean = entry.getValue();
Map<String, Object> root = new LinkedHashMap<String, Object>();
String prefix = extractPrefix(context, beanFactoryMetaData, beanName, bean);
root.put("prefix", prefix);
root.put("properties", sanitize(prefix, safeSerialize(mapper, bean, prefix)));
result.put(beanName, root);
}
if (context.getParent() != null) {
result.put("parent", extract(context.getParent(), mapper));
}
return result;
}
示例2: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
Map<String,IWebservice> bindingsMap=applicationContext.getBeansOfType(IWebservice.class);
if(applicationContext.getParent()!=null){
bindingsMap.putAll(applicationContext.getParent().getBeansOfType(IWebservice.class));
}
if(bindingsMap.size()>0){
List<Class<?>> list=new ArrayList<Class<?>>();
for(IWebservice binding:bindingsMap.values()){
Class<?>[] c=binding.bindClasses();
if(c!=null){
for(Class<?> clazz:c){
list.add(clazz);
}
}
}
if(list.size()>0){
this.setClassesToBeBound(list.toArray(new Class<?>[list.size()]));
}else{
this.setClassesToBeBound(new Class[]{String.class});
}
}else{
this.setClassesToBeBound(new Class[]{String.class});
}
}
示例3: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
Map<String, HibernateSessionFactoryRepository> map = applicationContext
.getBeansOfType(HibernateSessionFactoryRepository.class);
if (map.size() > 0) {
this.sessionFactoryRepository = map.values().iterator().next();
} else if (applicationContext.getParent() != null) {
map = applicationContext.getParent().getBeansOfType(HibernateSessionFactoryRepository.class);
if (map.size() > 0) {
this.sessionFactoryRepository = map.values().iterator().next();
}
}
}
示例4: initialize
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void initialize(ApplicationContext applicationContext) throws Exception {
logger.info(">>> 初始化應用中不依賴於Servlet環境的係統常量!");
ApplicationContext rootApplicationContext = applicationContext;
if(applicationContext instanceof WebApplicationContext && applicationContext.getParent() != null){//如果當前applicationContext是容器環境下SpringMVC Application上下文
rootApplicationContext = applicationContext.getParent();
}
setFinalFieldValue(ApplicationConstants.class, "APPLICATION_CONTEXT", rootApplicationContext);
SpringUtils.setApplicationContext(rootApplicationContext);
try {
Messages.setMessageSource(rootApplicationContext.getBean(AbstractMessageSource.class));
} catch (Exception e) {
logger.error(e.getMessage());
}
}
示例5: handleEvent
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
/**
* Implementation of the spring event listener interface.
*
* @param event the spring event from the application
*/
@EventListener
public void handleEvent(ApplicationEvent event) {
// checking for start up event
// order of events is BrokerAvailabilityEvent -> ContextRefreshedEvent[parent=null] -> ContextRefreshedEvent[with non-null parent]
// so wait until the latest event is received: ContextRefreshedEvent[with non-null parent]
// skip the BrokerAvailabilityEvent, and ignore all other events (SessionConnectedEvent, ServletRequestHandledEvent, ContextClosedEvent, etc.)
if (!(event instanceof ContextRefreshedEvent)) {
LOGGER.debug("Expecting ContextRefreshedEvent. Skipping.");
return;
}
LOGGER.info("Received ContextRefreshedEvent {}", event);
ContextRefreshedEvent crEvent = (ContextRefreshedEvent) event;
final ApplicationContext applicationContext = crEvent.getApplicationContext();
// skip the ContextRefreshedEvent[parent=null] but check for non-null context first
if (null == applicationContext) {
LOGGER.debug("Expecting non-null ApplicationContext. Skipping.");
return;
}
if (null == applicationContext.getParent()) {
LOGGER.debug("Expecting non-null ApplicationContext parent. Skipping.");
return;
}
processBootstrapConfiguration();
}
示例6: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
interceptors=applicationContext.getBeansOfType(IWebServiceInterceptor.class).values();
if(interceptors.size()==0 && applicationContext.getParent()!=null){
interceptors=applicationContext.getParent().getBeansOfType(IWebServiceInterceptor.class).values();
}
}
示例7: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.applicationContext=applicationContext;
Collection<DataSourceRepository> dataSourceRepositoryCollection=applicationContext.getBeansOfType(DataSourceRepository.class).values();
if(dataSourceRepositoryCollection.size()>0){
this.dataSourceRepository=dataSourceRepositoryCollection.iterator().next();
}else if(applicationContext.getParent()!=null){
dataSourceRepositoryCollection=applicationContext.getParent().getBeansOfType(DataSourceRepository.class).values();
if(dataSourceRepositoryCollection.size()>0){
this.dataSourceRepository=dataSourceRepositoryCollection.iterator().next();
}
}
this.dialects=applicationContext.getBeansOfType(IDialect.class).values();
}
示例8: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.applicationContext=applicationContext;
Map<String,HibernateSessionFactoryRepository> map=applicationContext.getBeansOfType(HibernateSessionFactoryRepository.class);
if(map.size()>0){
this.sessionFactoryRepository = map.values().iterator().next();
}else if(applicationContext.getParent()!=null){
map=applicationContext.getParent().getBeansOfType(HibernateSessionFactoryRepository.class);
if(map.size()>0){
this.sessionFactoryRepository = map.values().iterator().next();
}
}
}
示例9: walkContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
private <T> Collection<T> walkContext(Function<ApplicationContext, T> contextProcessor) {
final List<T> result = new LinkedList<>();
ApplicationContext currentContext = applicationContext;
while (currentContext != null) {
T processingResult = contextProcessor.apply(currentContext);
currentContext = currentContext.getParent();
result.add(processingResult);
}
return result;
}
示例10: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//如果參數applicationContext是容器環境下SpringMVC Application上下文,則取其parent (ROOT)
if(applicationContext instanceof WebApplicationContext && applicationContext.getParent() != null){
this.applicationContext = applicationContext.getParent();
}
}