register ConfigurableListableBeanFactory, ServletContext and ServletConfig 
objects with 

org.springframework.web.context.support.WebApplicationContextUtils.registerEnvironmentBeans(bf,sc,config)

 

once inside registerEnvironmentBeans method bith the servletContext and 
servletConfig parameters will register as Singletons:
  if (sc != null && 
!bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
   bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc);
  }

  if (config != null && 
!bf.containsBean(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME)) {
   
bf.registerSingleton(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME,
 config);
  }


implemented in 
org.springframework.web.context.support.GenericWebApplicationContext here:

 

public class GenericWebApplicationContext extends GenericApplicationContext  
implements WebApplicationContext, ThemeSource {

/**
  * Register ServletContextAwareProcessor.
  * @see ServletContextAwareProcessor

  *called after setBeanFactory()

  *called before afterPropertiesSet()

http://www.javabeat.net/articles/49-life-cycle-management-of-a-spring-bean-1.html
  */
 @Override
 protected void postProcessBeanFactory(ConfigurableListableBeanFactory 
beanFactory) {
  beanFactory.addBeanPostProcessor(new 
ServletContextAwareProcessor(this.servletContext));
  beanFactory.ignoreDependencyInterface(ServletContextAware.class);

  WebApplicationContextUtils.registerWebApplicationScopes(beanFactory, 
this.servletContext);


  WebApplicationContextUtils.registerEnvironmentBeans(beanFactory, 
this.servletContext);
 }

 

does this help?
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.



 

> Date: Thu, 10 Feb 2011 11:43:19 -0500
> Subject: getting the container (or Configuration/ConfigurationManager) in a 
> non-container-instantiated object
> From: w...@wantii.com
> To: dev@struts.apache.org
> 
> Guys,
> 
> I am in a non-struts environment (spring class, loaded by a customer
> ServletContextListener), and I am trying to get my hands on the Struts
> 2 configuration. I first tried to do -
> 
> Dispatcher.getInstance().getContainer()
> 
> But, the dispatcher instance is a threadlocal. I don't really care
> about the dispatcher, I'd just like to get a ref to the container.
> 
> Any ideas?
> 
> -Wes
> 
> -- 
> Wes Wannemacher
> 
> Head Engineer, WanTii, Inc.
> Need Training? Struts, Spring, Maven, Tomcat...
> Ask me for a quote!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
> 
                                          

Reply via email to