1   package org.apache.maven.continuum.management.util;
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  import org.codehaus.plexus.spring.PlexusXmlBeanDefinitionReader;
23  import org.springframework.beans.BeansException;
24  import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
25  import org.springframework.beans.factory.support.DefaultListableBeanFactory;
26  import org.springframework.beans.factory.xml.ResourceEntityResolver;
27  import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
28  import org.springframework.context.ApplicationContext;
29  import org.springframework.context.support.FileSystemXmlApplicationContext;
30  
31  import java.io.IOException;
32  
33  public class PlexusFileSystemXmlApplicationContext
34      extends FileSystemXmlApplicationContext
35  {
36      private static PlexusApplicationContextDelegate delegate = new PlexusApplicationContextDelegate();
37  
38      public PlexusFileSystemXmlApplicationContext( String configLocation )
39      {
40          super( configLocation );
41      }
42  
43      public PlexusFileSystemXmlApplicationContext( String[] configLocations )
44      {
45          super( configLocations );
46      }
47  
48      public PlexusFileSystemXmlApplicationContext( String[] configLocations, ApplicationContext parent )
49      {
50          super( configLocations, parent );
51      }
52  
53      public PlexusFileSystemXmlApplicationContext( String[] configLocations, boolean refresh )
54      {
55          super( configLocations, refresh );
56      }
57  
58      public PlexusFileSystemXmlApplicationContext( String[] configLocations, boolean refresh, ApplicationContext parent )
59      {
60          super( configLocations, refresh, parent );
61      }
62  
63      
64  
65  
66  
67  
68      protected void loadBeanDefinitions( XmlBeanDefinitionReader reader )
69          throws BeansException, IOException
70      {
71          delegate.loadBeanDefinitions( reader );
72          super.loadBeanDefinitions( reader );
73      }
74  
75      
76  
77  
78  
79  
80  
81  
82  
83      protected void loadBeanDefinitions( DefaultListableBeanFactory beanFactory )
84          throws IOException
85      {
86          
87          XmlBeanDefinitionReader beanDefinitionReader = new PlexusXmlBeanDefinitionReader( beanFactory );
88  
89          
90          
91          beanDefinitionReader.setResourceLoader( this );
92          beanDefinitionReader.setEntityResolver( new ResourceEntityResolver( this ) );
93  
94          
95          
96          initBeanDefinitionReader( beanDefinitionReader );
97          loadBeanDefinitions( beanDefinitionReader );
98      }
99  
100     
101 
102 
103 
104 
105     protected void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory )
106     {
107         delegate.postProcessBeanFactory( beanFactory, this );
108     }
109 
110     
111 
112 
113 
114 
115     protected void doClose()
116     {
117         delegate.doClose();
118         super.doClose();
119     }
120 }