if (viewControllerName == null)
{
// The current view does not have any bean that is its "view controller", ie
// which handles the lifecycle events for that view. Therefore we cannot
// do anything more here...
throw new OrchestraException(
"Error while processing bean " + beanName
+ ": no view controller name found for view " + viewId);
}
// Look up the definition with the specified name.
ConfigurableApplicationContext appContext = getApplicationContext();
ConfigurableListableBeanFactory beanFactory = appContext.getBeanFactory();
BeanDefinition beanDefinition = beanFactory.getBeanDefinition(viewControllerName);
if (beanDefinition.getBeanClassName().equals(ScopedProxyFactoryBean.class.getName()))
{
// The BeanDefinition we found is one that contains a nested aop:scopedProxy tag.
// In this case, Spring has actually renamed the original BeanDefinition which
// contains the data we need. So here we need to look up the renamed definition.
//
// It would be nice if the fake definition that Spring creates had some way of
// fetching the definition it wraps, but instead it appears that we need to
// rely on the magic string prefix...
beanDefinition = beanFactory.getBeanDefinition("scopedTarget." + viewControllerName);
}
String scopeName = beanDefinition.getScope();
if (scopeName == null)
{
// should never happen
throw new OrchestraException(
"Error while processing bean " + beanName
+ ": view controller " + viewControllerName + " has no scope.");
}
Scope registeredScope = beanFactory.getRegisteredScope(scopeName);
if (registeredScope == null)
{
throw new OrchestraException(
"Error while processing bean " + beanName
+ ": view controller " + viewControllerName
+ " has unknown scope " + scopeName);
}
if (registeredScope instanceof AbstractSpringOrchestraScope)
{
return ((AbstractSpringOrchestraScope) registeredScope).getConversationNameForBean(viewControllerName);
}
throw new OrchestraException(
"Error while processing bean " + beanName
+ ": the scope " + scopeName
+ " should be of type AbstractSpringOrchestraScope"
+ ", but is type " + registeredScope.getClass().getName());
}