1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.data.provider;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.krad.data.KradDataServiceLocator;
20 import org.springframework.beans.factory.InitializingBean;
21
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.List;
25
26
27
28
29
30
31
32
33
34 public class ProviderRegistrar implements InitializingBean {
35
36 private static final Logger LOG = Logger.getLogger(ProviderRegistrar.class);
37
38
39
40
41 protected ProviderRegistry providerRegistry;
42
43
44
45
46 protected List<Provider> providers = Collections.unmodifiableList(Collections.<Provider>emptyList());
47
48
49
50
51 @Override
52 public void afterPropertiesSet() throws Exception {
53 if ( getProviders() != null ) {
54 if ( getProviderRegistry() != null ) {
55 for ( Provider provider : getProviders() ) {
56 LOG.info( "Registering data module provider for "+ provider);
57 getProviderRegistry().registerProvider(provider);
58 }
59 } else {
60 LOG.error( "Provider registry not initialized.");
61 }
62 }
63 }
64
65
66
67
68
69
70 public void setProviders(List<Provider> providers) {
71 this.providers = Collections.unmodifiableList(new ArrayList<Provider>(providers));
72 }
73
74
75
76
77
78
79 public List<Provider> getProviders() {
80 return providers;
81 }
82
83
84
85
86
87
88 public ProviderRegistry getProviderRegistry() {
89 if(this.providerRegistry == null){
90 return KradDataServiceLocator.getProviderRegistry();
91 }
92 return this.providerRegistry;
93 }
94
95
96
97
98
99
100 public void setProviderRegistry(ProviderRegistry providerRegistry) {
101 this.providerRegistry = providerRegistry;
102 }
103
104 }