Strabon

changeset 517:7ac79e2d67c9

add ConfigureCommon listener to load Common bean
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Jul 27 20:49:11 2012 +0300 (2012-07-27)
parents 6e9ac9b3a9e9
children a915117ecad3
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/ConfigureCommon.java
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/ConfigureCommon.java	Fri Jul 27 20:49:11 2012 +0300
     1.3 @@ -0,0 +1,34 @@
     1.4 +/**
     1.5 + * 
     1.6 + */
     1.7 +package eu.earthobservatory.org.StrabonEndpoint;
     1.8 +
     1.9 +import javax.servlet.ServletContextEvent;
    1.10 +import javax.servlet.ServletContextListener;
    1.11 +
    1.12 +import org.springframework.web.context.WebApplicationContext;
    1.13 +import org.springframework.web.context.support.WebApplicationContextUtils;
    1.14 +
    1.15 +/**
    1.16 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    1.17 + *
    1.18 + */
    1.19 +public class ConfigureCommon implements ServletContextListener {
    1.20 +
    1.21 +	private Common commonBean;
    1.22 +
    1.23 +	@Override
    1.24 +	public void contextDestroyed(ServletContextEvent event) {
    1.25 +	}
    1.26 +
    1.27 +	@Override
    1.28 +	public void contextInitialized(ServletContextEvent event) {
    1.29 +		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
    1.30 +		//event.getServletContext().setAttribute("commonBean", (Common) applicationContext.getBean("commonBean"));
    1.31 +		commonBean = (Common) applicationContext.getBean("commonBean");
    1.32 +		event.getServletContext().setAttribute("commonBean", this.commonBean);
    1.33 +		
    1.34 +		System.out.println("HOOLA HOOLA HOOLA HOOLA HOOLA HOOLA HOOLA HOOLA");
    1.35 +		System.out.println(commonBean);
    1.36 +	}
    1.37 +}