I'm starting work on consolidating the Spring configuration files and 
switching to standard ways of loading and accessing the context XML.

My plan is to create a properties/contexts/ folder that all Spring 
context XML files reside in. The context files will be loaded by a 
ContextLoaderListener into a single WebApplicationContext. The 
WebApplicationContext is then accessible via the 
WebApplicationContextUtils class which requires a reference to the 
ServletContext object for loading.

The ContextLoaderListener and WebApplicationContextUtils classes are 
replacing a custom PortalApplicationContextFacade class which loads 
/properties/beanRefFactory.xml and provides static method accessors to 
the loaded BeanFactory.

The problem is in some places that the PortalApplicationContextFacade is 
used to access the BeanFactory there is no access to a ServletContext 
which the WebApplicationContextUtils needs to access the replacement 
WebApplicationContext.
The affected areas are:
CError - constructor, loads a IThrowableToElement implementation which 
defines ways to render certain exceptions
PersonDirectory - getPersonAttributeDao, loads the root 
IPersonAttributeDao for use by other parts of the framework. This method 
is called from: Authentication, PersonAttributeGroupStore, 
CPersonAttributes, and PersonDirNameFinder

I'm not sure what the best solution for this is. I'd like to avoid as 
much custom Spring related code as possible but we may still need a 
static accessor that doesn't require the ServletContext to access the 
WebApplicationContext object.


My one idea right now is to add a custom ServletContextListener that 
listens for start/stop events and holds a static reference to the 
ServletContext and internally uses WebApplicationContextUtils to service 
static request for the WebApplicationContext. This should still deal 
with the Spring context getting reloaded and the Servlet context getting 
reloaded. I would also like to make it deprecated from the get-go to 
discourage usage of this pattern.

-Eric


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to