|
|
|
@ -144,6 +144,9 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader |
|
|
|
/** Unique id for this context, if any */ |
|
|
|
/** Unique id for this context, if any */ |
|
|
|
private String id = ObjectUtils.identityToString(this); |
|
|
|
private String id = ObjectUtils.identityToString(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Display name */ |
|
|
|
|
|
|
|
private String displayName = ObjectUtils.identityToString(this); |
|
|
|
|
|
|
|
|
|
|
|
/** Parent context */ |
|
|
|
/** Parent context */ |
|
|
|
private ApplicationContext parent; |
|
|
|
private ApplicationContext parent; |
|
|
|
|
|
|
|
|
|
|
|
@ -151,9 +154,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader |
|
|
|
private final List<BeanFactoryPostProcessor> beanFactoryPostProcessors = |
|
|
|
private final List<BeanFactoryPostProcessor> beanFactoryPostProcessors = |
|
|
|
new ArrayList<BeanFactoryPostProcessor>(); |
|
|
|
new ArrayList<BeanFactoryPostProcessor>(); |
|
|
|
|
|
|
|
|
|
|
|
/** Display name */ |
|
|
|
|
|
|
|
private String displayName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** System time in milliseconds when this context started */ |
|
|
|
/** System time in milliseconds when this context started */ |
|
|
|
private long startupDate; |
|
|
|
private long startupDate; |
|
|
|
|
|
|
|
|
|
|
|
@ -213,10 +213,32 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader |
|
|
|
this.id = id; |
|
|
|
this.id = id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return the unique id of this application context. |
|
|
|
|
|
|
|
* @return the unique id of the context, or <code>null</code> if none |
|
|
|
|
|
|
|
*/ |
|
|
|
public String getId() { |
|
|
|
public String getId() { |
|
|
|
return this.id; |
|
|
|
return this.id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set a friendly name for this context. |
|
|
|
|
|
|
|
* Typically done during initialization of concrete context implementations. |
|
|
|
|
|
|
|
* <p>Default is the object id of the context instance. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setDisplayName(String displayName) { |
|
|
|
|
|
|
|
Assert.hasLength(displayName, "Display name must not be empty"); |
|
|
|
|
|
|
|
this.displayName = displayName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return a friendly name for this context. |
|
|
|
|
|
|
|
* @return a display name for this context (never <code>null</code>) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String getDisplayName() { |
|
|
|
|
|
|
|
return this.displayName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the parent context, or <code>null</code> if there is no parent |
|
|
|
* Return the parent context, or <code>null</code> if there is no parent |
|
|
|
* (that is, this context is the root of the context hierarchy). |
|
|
|
* (that is, this context is the root of the context hierarchy). |
|
|
|
@ -234,21 +256,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader |
|
|
|
return getBeanFactory(); |
|
|
|
return getBeanFactory(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set a friendly name for this context. |
|
|
|
|
|
|
|
* Typically done during initialization of concrete context implementations. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setDisplayName(String displayName) { |
|
|
|
|
|
|
|
this.displayName = displayName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return a friendly name for this context. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String getDisplayName() { |
|
|
|
|
|
|
|
return (this.displayName != null ? this.displayName : getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the timestamp (ms) when this context was first loaded. |
|
|
|
* Return the timestamp (ms) when this context was first loaded. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -267,7 +274,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader |
|
|
|
public void publishEvent(ApplicationEvent event) { |
|
|
|
public void publishEvent(ApplicationEvent event) { |
|
|
|
Assert.notNull(event, "Event must not be null"); |
|
|
|
Assert.notNull(event, "Event must not be null"); |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
logger.trace("Publishing event in context [" + getId() + "]: " + event); |
|
|
|
logger.trace("Publishing event in " + getDisplayName() + ": " + event); |
|
|
|
} |
|
|
|
} |
|
|
|
getApplicationEventMulticaster().multicastEvent(event); |
|
|
|
getApplicationEventMulticaster().multicastEvent(event); |
|
|
|
if (this.parent != null) { |
|
|
|
if (this.parent != null) { |
|
|
|
@ -417,15 +424,9 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader |
|
|
|
protected ConfigurableListableBeanFactory obtainFreshBeanFactory() { |
|
|
|
protected ConfigurableListableBeanFactory obtainFreshBeanFactory() { |
|
|
|
refreshBeanFactory(); |
|
|
|
refreshBeanFactory(); |
|
|
|
ConfigurableListableBeanFactory beanFactory = getBeanFactory(); |
|
|
|
ConfigurableListableBeanFactory beanFactory = getBeanFactory(); |
|
|
|
|
|
|
|
|
|
|
|
if (logger.isInfoEnabled()) { |
|
|
|
|
|
|
|
logger.info("Bean factory for application context [" + getId() + "]: " + |
|
|
|
|
|
|
|
ObjectUtils.identityToString(beanFactory)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug(beanFactory.getBeanDefinitionCount() + " beans defined in " + this); |
|
|
|
logger.debug("Bean factory for " + getDisplayName() + ": " + beanFactory); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return beanFactory; |
|
|
|
return beanFactory; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1161,16 +1162,15 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String toString() { |
|
|
|
public String toString() { |
|
|
|
StringBuilder sb = new StringBuilder(getId()); |
|
|
|
StringBuilder sb = new StringBuilder(getDisplayName()); |
|
|
|
sb.append(": display name [").append(getDisplayName()); |
|
|
|
sb.append(": startup date [").append(new Date(getStartupDate())); |
|
|
|
sb.append("]; startup date [").append(new Date(getStartupDate())); |
|
|
|
|
|
|
|
sb.append("]; "); |
|
|
|
sb.append("]; "); |
|
|
|
ApplicationContext parent = getParent(); |
|
|
|
ApplicationContext parent = getParent(); |
|
|
|
if (parent == null) { |
|
|
|
if (parent == null) { |
|
|
|
sb.append("root of context hierarchy"); |
|
|
|
sb.append("root of context hierarchy"); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
sb.append("parent: ").append(parent.getId()); |
|
|
|
sb.append("parent: ").append(parent.getDisplayName()); |
|
|
|
} |
|
|
|
} |
|
|
|
return sb.toString(); |
|
|
|
return sb.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|