Merge of BRANCHES/DEV/4.2_ENT_DEV/ADMIN_CONSOLE2 - Admin Console 46775:47636

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47742 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2013-03-07 11:36:01 +00:00
parent 0831ef655a
commit b86cd5e5b2
8 changed files with 242 additions and 154 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -27,6 +27,7 @@ import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
/**
* A factory bean, used in conjunction with {@link ChildApplicationContextManager} allowing selected interfaces to be
@@ -63,10 +64,20 @@ public class ChainingSubsystemProxyFactory extends ProxyFactoryBean
{
for (String instance : applicationContextManager.getInstanceIds())
{
ApplicationContext context;
try
{
context = ChainingSubsystemProxyFactory.this.applicationContextManager
.getApplicationContext(instance);
}
catch (RuntimeException e)
{
// This subsystem won't start. The reason would have been logged. Ignore and continue.
continue;
}
if (ChainingSubsystemProxyFactory.this.sourceBeanName == null)
{
Map<?, ?> beans = ChainingSubsystemProxyFactory.this.applicationContextManager
.getApplicationContext(instance).getBeansOfType(method.getDeclaringClass());
Map<?, ?> beans = context.getBeansOfType(method.getDeclaringClass());
Object activeBean = null;
for (Object bean : beans.values())
{
@@ -93,9 +104,7 @@ public class ChainingSubsystemProxyFactory extends ProxyFactoryBean
{
try
{
Object bean = ChainingSubsystemProxyFactory.this.applicationContextManager
.getApplicationContext(instance).getBean(
ChainingSubsystemProxyFactory.this.sourceBeanName);
Object bean = context.getBean(ChainingSubsystemProxyFactory.this.sourceBeanName);
// Ignore inactive beans
if (!(bean instanceof ActivateableBean) || ((ActivateableBean) bean).isActive())
@@ -138,7 +147,7 @@ public class ChainingSubsystemProxyFactory extends ProxyFactoryBean
* (non-Javadoc)
* @see org.springframework.aop.framework.AdvisedSupport#setInterfaces(java.lang.Class[])
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("rawtypes")
@Override
public void setInterfaces(Class[] interfaces)
{

View File

@@ -37,7 +37,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.ListFactoryBean;
@@ -553,6 +552,9 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
/** The child application context. */
private ClassPathXmlApplicationContext applicationContext;
/** Error when we last tried to start. */
private RuntimeException lastStartupError;
/**
* Instantiates a new application context state.
@@ -632,6 +634,7 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
throw new IllegalStateException("Illegal write to property \""
+ ChildApplicationContextFactory.TYPE_NAME_PROPERTY + "\"");
}
this.lastStartupError = null;
Class<?> type = ChildApplicationContextFactory.this.compositePropertyTypes.get(name);
if (type != null)
{
@@ -727,14 +730,32 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
// properties.
if (this.applicationContext == null)
{
// The properties haven't been edited since we last tried to start up and fail, so rethrow the exception
// without logging
if (this.lastStartupError != null)
{
throw this.lastStartupError;
}
ChildApplicationContextFactory.logger
.info("Starting '" + getCategory() + "' subsystem, ID: " + getId());
ClassPathXmlApplicationContext applicationContext = ChildApplicationContextFactory.this.new ChildApplicationContext(
this.properties, this.compositeProperties);
applicationContext.refresh();
this.applicationContext = applicationContext;
ChildApplicationContextFactory.logger.info("Startup of '" + getCategory() + "' subsystem, ID: "
+ getId() + " complete");
try
{
applicationContext.refresh();
this.applicationContext = applicationContext;
ChildApplicationContextFactory.logger.info("Startup of '" + getCategory() + "' subsystem, ID: "
+ getId() + " complete");
}
catch (RuntimeException e)
{
// Log startup errors and remember for next time
ChildApplicationContextFactory.logger.warn("Startup of '" + getCategory() + "' subsystem, ID: "
+ getId() + " failed", e);
this.lastStartupError = e;
throw e;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -291,9 +291,26 @@ public class DefaultChildApplicationContextManager extends AbstractPropertyBacke
*/
public void start()
{
boolean oneSuccess = false;
RuntimeException lastError = null;
for (String instance : getInstanceIds())
{
getApplicationContext(instance);
try
{
getApplicationContext(instance);
oneSuccess = true;
}
catch (RuntimeException e)
{
// One of the subsystems failed to initialize. The cause would have been logged. Treat this as
// non-fatal
lastError = e;
}
}
// If we weren't able to start any subsystems, then pass on the last error
if (lastError != null && !oneSuccess)
{
throw lastError;
}
}