1 package org.apache.archiva.metadata.repository;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 import org.springframework.beans.factory.config.AbstractFactoryBean;
25
26 import java.util.Properties;
27
28
29
30
31
32 public class RepositorySessionFactoryBean
33 extends AbstractFactoryBean<RepositorySessionFactory>
34 {
35
36 private Logger logger = LoggerFactory.getLogger( getClass() );
37
38 private static final String BEAN_ID_SYS_PROPS = "archiva.repositorySessionFactory.id";
39
40 private Properties properties;
41
42 private String id;
43
44 public RepositorySessionFactoryBean( Properties properties )
45 {
46 this.properties = properties;
47
48 String value = System.getProperty( BEAN_ID_SYS_PROPS );
49 if ( value != null )
50 {
51 this.properties.put( BEAN_ID_SYS_PROPS, value );
52 }
53 id = properties.getProperty( BEAN_ID_SYS_PROPS );
54 }
55
56 @Override
57 public Class<RepositorySessionFactory> getObjectType()
58 {
59 return RepositorySessionFactory.class;
60 }
61
62 @Override
63 protected RepositorySessionFactory createInstance()
64 throws Exception
65 {
66 RepositorySessionFactory repositorySessionFactory =
67 getBeanFactory().getBean( "repositorySessionFactory#" + id, RepositorySessionFactory.class );
68 logger.info( "create RepositorySessionFactory with id {} instance of {}",
69 id,
70 repositorySessionFactory.getClass().getName() );
71 return repositorySessionFactory;
72 }
73
74 public String getId()
75 {
76 return id;
77 }
78
79 public void setId( String id )
80 {
81 this.id = id;
82 }
83
84 public Properties getProperties()
85 {
86 return properties;
87 }
88
89 public void setProperties( Properties properties )
90 {
91 this.properties = properties;
92 }
93 }