View Javadoc

1   package net.sourceforge.basher.example.tasks.spring;
2   
3   import org.ops4j.gaderian.ApplicationRuntimeException;
4   import org.ops4j.gaderian.Location;
5   import org.ops4j.gaderian.internal.Module;
6   import org.ops4j.gaderian.service.ObjectProvider;
7   import org.springframework.beans.BeansException;
8   import org.springframework.beans.factory.BeanFactory;
9   import org.springframework.beans.factory.NoSuchBeanDefinitionException;
10  import org.springframework.beans.factory.xml.XmlBeanFactory;
11  import org.springframework.core.io.ClassPathResource;
12  
13  /**
14   * @author Johan Lindquist
15   */
16  public class SampleSpringBeanFactory implements BeanFactory
17  {
18      private BeanFactory _beanFactory;
19  
20      public void initializeService()
21      {
22          _beanFactory = new XmlBeanFactory( new ClassPathResource( "basher-spring-beans.xml") );
23      }
24  
25      public Object getBean( final String s ) throws BeansException
26      {
27          return _beanFactory.getBean( s );
28      }
29  
30      public <T> T getBean( final String s, final Class<T> tClass ) throws BeansException
31      {
32          return _beanFactory.getBean( s, tClass );
33      }
34  
35      public <T> T getBean( final Class<T> tClass ) throws BeansException
36      {
37          return _beanFactory.getBean( tClass );
38      }
39  
40      public Object getBean( final String s, final Object... objects ) throws BeansException
41      {
42          return _beanFactory.getBean( s, objects );
43      }
44  
45      public boolean containsBean( final String s )
46      {
47          return _beanFactory.containsBean( s );
48      }
49  
50      public boolean isSingleton( final String s ) throws NoSuchBeanDefinitionException
51      {
52          return _beanFactory.isSingleton( s );
53      }
54  
55      public boolean isPrototype( final String s ) throws NoSuchBeanDefinitionException
56      {
57          return _beanFactory.isPrototype( s );
58      }
59  
60      public boolean isTypeMatch( final String s, final Class aClass ) throws NoSuchBeanDefinitionException
61      {
62          return _beanFactory.isTypeMatch( s, aClass );
63      }
64  
65      public Class<?> getType( final String s ) throws NoSuchBeanDefinitionException
66      {
67          return _beanFactory.getType( s );
68      }
69  
70      public String[] getAliases( final String s )
71      {
72          return _beanFactory.getAliases( s );
73      }
74  }