gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / service / impl / DefaultProviderRegistration.java @ 1739
History | View | Annotate | Download (2.2 KB)
1 | 802 | cordinyana | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 18 | cordinyana | *
|
4 | 802 | cordinyana | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | *
|
||
6 | 18 | cordinyana | * This program is free software; you can redistribute it and/or
|
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | 802 | cordinyana | *
|
11 | 18 | cordinyana | * This program 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
|
||
14 | * GNU General Public License for more details.
|
||
15 | 802 | cordinyana | *
|
16 | 18 | cordinyana | * You should have received a copy of the GNU General Public License
|
17 | * along with this program; if not, write to the Free Software
|
||
18 | 802 | cordinyana | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 18 | cordinyana | * MA 02110-1301, USA.
|
20 | 802 | cordinyana | *
|
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 18 | cordinyana | */
|
24 | /*
|
||
25 | * AUTHORS (In addition to CIT):
|
||
26 | * 2009 {} {{Task}}
|
||
27 | */
|
||
28 | package org.gvsig.tools.service.impl; |
||
29 | |||
30 | import java.util.Set; |
||
31 | |||
32 | import org.gvsig.tools.ToolsLocator; |
||
33 | import org.gvsig.tools.service.spi.AbstractProviderRegistration; |
||
34 | import org.gvsig.tools.service.spi.ProviderFactory; |
||
35 | import org.gvsig.tools.service.spi.ProviderRegistration; |
||
36 | import org.gvsig.tools.util.ServiceLoader; |
||
37 | |||
38 | /**
|
||
39 | * {@link ProviderRegistration} implementation which finds
|
||
40 | * {@link ProviderFactory} objects automatically using the {@link ServiceLoader}
|
||
41 | * .
|
||
42 | *
|
||
43 | * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
||
44 | */
|
||
45 | public class DefaultProviderRegistration extends AbstractProviderRegistration { |
||
46 | |||
47 | private final ServiceLoader serviceLoader; |
||
48 | |||
49 | public DefaultProviderRegistration() {
|
||
50 | this(ToolsLocator.getServiceLoader());
|
||
51 | } |
||
52 | |||
53 | public DefaultProviderRegistration(ServiceLoader serviceLoader) {
|
||
54 | this.serviceLoader = serviceLoader;
|
||
55 | } |
||
56 | |||
57 | private ServiceLoader getServiceLoader() {
|
||
58 | return serviceLoader;
|
||
59 | } |
||
60 | |||
61 | protected Set findProviderFactories(Class providerInterface) { |
||
62 | return getServiceLoader().load(providerInterface);
|
||
63 | } |
||
64 | |||
65 | protected Set findProviderFactories(Class providerInterface, |
||
66 | ClassLoader classLoader) {
|
||
67 | return getServiceLoader().load(providerInterface, classLoader);
|
||
68 | } |
||
69 | } |