01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.kuali.rice.resourceloader;
18:
19: import java.util.HashMap;
20: import java.util.Map;
21:
22: import javax.xml.namespace.QName;
23:
24: import org.kuali.rice.lifecycle.BaseLifecycle;
25:
26: /**
27: * A simple {@link ServiceLocator} that allows users to put services into workflow's resource loading
28: * wihout creating their own {@link ServiceLocator}.
29: *
30: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
31: *
32: */
33: public class SimpleServiceLocator extends BaseLifecycle implements
34: ServiceLocator {
35:
36: private Map<QName, Object> services = new HashMap<QName, Object>();
37:
38: public String getContents(String indent, boolean servicePerLine) {
39: String contents = indent + "SpringLoader " + this
40: + " services =";
41:
42: for (Map.Entry<QName, Object> serviceEntry : this .services
43: .entrySet()) {
44: if (servicePerLine) {
45: contents += indent + "+++" + serviceEntry.getKey()
46: + "=" + serviceEntry.getValue() + "\n";
47: } else {
48: contents += serviceEntry.getKey() + "="
49: + serviceEntry.getValue() + ", ";
50: }
51: }
52:
53: return contents;
54: }
55:
56: public Object getService(QName qname) {
57: return this .services.get(qname);
58: }
59:
60: public void addService(QName name, Object service) {
61: this .services.put(name, service);
62: }
63:
64: public void removeService(QName name) {
65: this.services.remove(name);
66: }
67: }
|