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 org.slf4j.Logger;
9 import org.slf4j.LoggerFactory;
10 import org.springframework.web.context.ContextLoader;
11
12 import javax.servlet.ServletContextListener;
13
14
15
16
17
18 public class BootstrappedContextLoaderListener extends ContainerContextLoaderListener implements ServletContextListener
19 {
20 private static final Logger log = LoggerFactory.getLogger(BootstrappedContextLoaderListener.class);
21
22 public boolean canInitialiseContainer()
23 {
24 AtlassianBootstrapManager bootstrapManager = BootstrapUtils.getBootstrapManager();
25
26 if (bootstrapManager == null)
27 return false;
28
29 if (!bootstrapManager.isBootstrapped())
30 return false;
31
32 boolean hibernateSetup = bootstrapManager.getHibernateConfig().isHibernateSetup();
33
34 if (!hibernateSetup && BootstrapUtils.getBootstrapManager().isSetupComplete())
35 {
36 log.error("Hibernate not yet setup, but setup complete - can't initalise container - corrupt project.cfg.xml?");
37 }
38
39 return hibernateSetup;
40 }
41
42 protected SpringContainerContext getNewSpringContainerContext()
43 {
44 return new BootstrappedContainerContext();
45 }
46
47
48
49
50 public ContextLoader createContextLoader()
51 {
52 return new BootstrappedContextLoader();
53 }
54 }