01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package edu.iu.uis.eden.messaging.config;
17:
18: import java.util.List;
19:
20: import org.apache.log4j.Logger;
21: import org.kuali.rice.lifecycle.BaseLifecycle;
22: import org.kuali.rice.resourceloader.SimpleServiceLocator;
23:
24: import edu.iu.uis.eden.messaging.resourceloading.KSBResourceLoaderFactory;
25:
26: public class ServicesOverrideLifecycle extends BaseLifecycle {
27:
28: private static final Logger LOG = Logger
29: .getLogger(ServicesOverrideLifecycle.class);
30:
31: private List<ServiceHolder> overrideServices;
32:
33: public ServicesOverrideLifecycle(
34: List<ServiceHolder> overrideServices) {
35: this .setOverrideServices(overrideServices);
36: }
37:
38: public void start() throws Exception {
39: if (this .getOverrideServices() == null) {
40: return;
41: }
42: SimpleServiceLocator locator = (SimpleServiceLocator) KSBResourceLoaderFactory
43: .getRootResourceLoader().getServiceLocator();
44: for (ServiceHolder serviceHolder : this .getOverrideServices()) {
45: if (LOG.isDebugEnabled()) {
46: LOG.debug("Loading override service "
47: + serviceHolder.getServiceName() + " "
48: + serviceHolder.getService());
49: }
50: locator.addService(serviceHolder.getServiceName(),
51: serviceHolder.getService());
52: }
53: setStarted(true);
54: }
55:
56: public List<ServiceHolder> getOverrideServices() {
57: return this .overrideServices;
58: }
59:
60: public void setOverrideServices(List<ServiceHolder> overrideServices) {
61: this.overrideServices = overrideServices;
62: }
63:
64: }
|