1 package com.atlassian.config.bootstrap;
2
3 import com.atlassian.config.spring.BootstrappedContainerContext;
4 import com.atlassian.config.spring.BootstrappedContextLoader;
5 import com.atlassian.config.util.BootstrapUtils;
6 import com.atlassian.spring.container.ContainerContextLoaderListener;
7 import com.atlassian.spring.container.SpringContainerContext;
8 import com.atlassian.config.db.DatabaseHelper;
9 import org.apache.log4j.Logger;
10 import org.springframework.web.context.ContextLoader;
11
12 import javax.servlet.ServletContextListener;
13 import javax.servlet.ServletContextEvent;
14 import java.util.Properties;
15
16
17
18
19
20 public class BootstrappedContextLoaderListener extends ContainerContextLoaderListener implements ServletContextListener
21 {
22 private static final Logger log = Logger.getLogger(BootstrappedContextLoaderListener.class);
23
24 public boolean canInitialiseContainer()
25 {
26 AtlassianBootstrapManager bootstrapManager = BootstrapUtils.getBootstrapManager();
27
28 if (bootstrapManager == null)
29 return false;
30
31 if (!bootstrapManager.isBootstrapped())
32 return false;
33
34 boolean hibernateSetup = bootstrapManager.getHibernateConfig().isHibernateSetup();
35
36 if (!hibernateSetup && BootstrapUtils.getBootstrapManager().isSetupComplete())
37 {
38 log.error("Hibernate not yet setup, but setup complete - can't initalise container - corrupt project.cfg.xml?");
39 }
40
41 return hibernateSetup;
42 }
43
44 protected SpringContainerContext getNewSpringContainerContext()
45 {
46 return new BootstrappedContainerContext();
47 }
48
49
50
51
52 public ContextLoader createContextLoader()
53 {
54 return new BootstrappedContextLoader();
55 }
56 }