gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.wmts / org.gvsig.wmts.provider / src / main / java / org / gvsig / wmts / provider / WMTSRasterLibrary.java @ 8842
History | View | Annotate | Download (3.74 KB)
1 | 6532 | fdiaz | package org.gvsig.wmts.provider; |
---|---|---|---|
2 | /* gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright ? 2007-2016 gvSIG Association
|
||
5 | *
|
||
6 | * 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 | *
|
||
11 | * 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 | *
|
||
16 | * 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 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
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 | */
|
||
24 | |||
25 | |||
26 | import java.util.ArrayList; |
||
27 | import java.util.List; |
||
28 | |||
29 | import org.gvsig.fmap.dal.DALFileLibrary; |
||
30 | import org.gvsig.fmap.dal.DALLibrary; |
||
31 | import org.gvsig.fmap.dal.FileHelper; |
||
32 | import org.gvsig.fmap.dal.spi.DALSPILocator; |
||
33 | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
||
34 | import org.gvsig.fmap.mapcontext.MapContextLibrary; |
||
35 | import org.gvsig.metadata.exceptions.MetadataException; |
||
36 | import org.gvsig.tools.library.AbstractLibrary; |
||
37 | import org.gvsig.tools.library.LibraryException; |
||
38 | |||
39 | |||
40 | /**
|
||
41 | * @author fdiaz
|
||
42 | *
|
||
43 | */
|
||
44 | public class WMTSRasterLibrary extends AbstractLibrary{ |
||
45 | |||
46 | @Override
|
||
47 | public void doRegistration() { |
||
48 | registerAsServiceOf(DALLibrary.class); |
||
49 | require(MapContextLibrary.class); |
||
50 | } |
||
51 | |||
52 | @Override
|
||
53 | protected void doInitialize() throws LibraryException { |
||
54 | // TODO Auto-generated method stub
|
||
55 | |||
56 | } |
||
57 | |||
58 | @Override
|
||
59 | protected void doPostInitialize() throws LibraryException { |
||
60 | List<Throwable> exs = new ArrayList<Throwable>(); |
||
61 | |||
62 | try {
|
||
63 | FileHelper.registerParametersDefinition(WMTSRasterProviderParameters.PARAMETERS_DEFINITION_NAME, |
||
64 | WMTSRasterProviderParameters.class, "WMTSRasterParameters.xml");
|
||
65 | } catch (RuntimeException e) { |
||
66 | exs.add(e); |
||
67 | } |
||
68 | |||
69 | try {
|
||
70 | FileHelper.registerMetadataDefinition(WMTSRasterProvider.METADATA_DEFINITION_NAME, WMTSRasterProvider.class, |
||
71 | "WMTSRasterMetadata.xml");
|
||
72 | |||
73 | } catch (MetadataException e) {
|
||
74 | exs.add(e); |
||
75 | } |
||
76 | |||
77 | try {
|
||
78 | FileHelper.registerParametersDefinition(WMTSRasterServerExplorerParameters.PARAMETERS_DEFINITION_NAME, |
||
79 | WMTSRasterServerExplorerParameters.class, "WMTSRasterParameters.xml");
|
||
80 | |||
81 | } catch (RuntimeException e) { |
||
82 | exs.add(e); |
||
83 | } |
||
84 | |||
85 | DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices(); |
||
86 | |||
87 | |||
88 | try {
|
||
89 | if (!dataman.getStoreProviders()
|
||
90 | .contains(WMTSRasterProvider.NAME)) { |
||
91 | dataman.registerStoreProviderFactory( |
||
92 | new WMTSRasterProviderFactory(
|
||
93 | WMTSRasterProvider.NAME, |
||
94 | WMTSRasterProvider.DESCRIPTION)); |
||
95 | } |
||
96 | } catch (RuntimeException e) { |
||
97 | exs.add(e); |
||
98 | } |
||
99 | |||
100 | try {
|
||
101 | if (!dataman.getExplorerProviders().contains(WMTSRasterServerExplorer.NAME)) {
|
||
102 | WMTSRasterServerExplorerFactory factory = new WMTSRasterServerExplorerFactory(WMTSRasterServerExplorer.NAME, WMTSRasterServerExplorer.DESCRIPTION);
|
||
103 | dataman.registerServerExplorerFactory(factory); |
||
104 | } |
||
105 | } catch (RuntimeException e) { |
||
106 | exs.add(e); |
||
107 | } |
||
108 | |||
109 | |||
110 | if (exs.size() > 0) { |
||
111 | throw new LibraryException(this.getClass(), exs); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | } |