01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.catalog.adaptable;
17:
18: import java.net.URI;
19: import java.util.ArrayList;
20: import java.util.Iterator;
21: import java.util.List;
22: import java.util.Map;
23:
24: import org.geotools.catalog.Service;
25: import org.geotools.catalog.ServiceFinder;
26:
27: /**
28: * ServiceFinder decorator for adapting catalog.
29: *
30: * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
31: *
32: */
33: public class AdaptingServiceFinder implements ServiceFinder {
34:
35: AdaptingCatalog catalog;
36: ServiceFinder finder;
37:
38: public AdaptingServiceFinder(AdaptingCatalog catalog,
39: ServiceFinder finder) {
40: this .catalog = catalog;
41: this .finder = finder;
42: }
43:
44: public List aquire(Map params) {
45: return wrap(finder.aquire(params));
46: }
47:
48: public List aquire(URI target) {
49: return wrap(finder.aquire(target));
50: }
51:
52: public List aquire(URI id, Map params) {
53: return wrap(finder.aquire(id, params));
54: }
55:
56: public List wrap(List services) {
57:
58: if (services == null || services.isEmpty())
59: return services;
60:
61: List adapting = new ArrayList(services.size());
62: for (Iterator s = services.iterator(); s.hasNext();) {
63: Service service = (Service) s.next();
64: adapting.add(new AdaptingService(service, catalog
65: .getResolveAdapterFactoryFinder()));
66: }
67:
68: return adapting;
69: }
70:
71: }
|