// beanFactory = new FileSystemXmlApplicationContext(configFile);
File f = new File( configFile );
FileSystemResource fsr = new FileSystemResource( f );
GenericApplicationContext appCtx = new GenericApplicationContext();
Scope requestScope = new ThreadLocalScope();
appCtx.getBeanFactory().registerScope( "request", requestScope );
Scope sessionScope = new ThreadLocalScope();
appCtx.getBeanFactory().registerScope( "session", sessionScope );
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader( appCtx );
xmlReader.loadBeanDefinitions( fsr );
beanFactory = appCtx;
} else {
if ( !( context instanceof ConfigurableApplicationContext ) ) {
String msg =
Messages.getInstance()
.getErrorString( "StandalonePentahoObjectFactory.ERROR_0001_CONTEXT_NOT_SUPPORTED", //$NON-NLS-1$
getClass().getSimpleName(), "GenericApplicationContext", context.getClass().getName() ); //$NON-NLS-1$
throw new IllegalArgumentException( msg );
}
ConfigurableApplicationContext configAppCtx = (ConfigurableApplicationContext) context;
if ( configAppCtx.getBeanFactory().getRegisteredScope( "request" ) == null ) {
Scope requestScope = new ThreadLocalScope();
configAppCtx.getBeanFactory().registerScope( "request", requestScope );
}
if ( configAppCtx.getBeanFactory().getRegisteredScope( "session" ) == null ) {
Scope sessionScope = new ThreadLocalScope();
configAppCtx.getBeanFactory().registerScope( "session", sessionScope );
}
setBeanFactory( configAppCtx );
}