Statistics
| Revision:

svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.png / src / main / java / org / gvsig / fmap / dal / file / png / PngLibrary.java @ 43803

History | View | Annotate | Download (3.09 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23

    
24
package org.gvsig.fmap.dal.file.png;
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.DALFileLocator;
31
import org.gvsig.fmap.dal.DALLibrary;
32
import org.gvsig.fmap.dal.FileHelper;
33
import org.gvsig.fmap.dal.spi.DALSPILocator;
34
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
35
import org.gvsig.metadata.exceptions.MetadataException;
36
import org.gvsig.tools.library.AbstractLibrary;
37
import org.gvsig.tools.library.LibraryException;
38

    
39
/**
40
 * Png Library to register provider components
41
 * @author fdiaz
42
 *
43
 */
44
public class PngLibrary extends AbstractLibrary {
45

    
46
    @Override
47
    public void doRegistration() {
48
        registerAsServiceOf(DALLibrary.class);
49
        require(DALFileLibrary.class);
50

    
51
    }
52

    
53
        @Override
54
        protected void doInitialize() throws LibraryException {
55
        }
56

    
57
        @Override
58
        protected void doPostInitialize() throws LibraryException {
59
                List<Throwable> exs = new ArrayList<Throwable>();
60

    
61
                FileHelper.registerParametersDefinition(
62
                                PngStoreProviderParameters.PARAMETERS_DEFINITION_NAME,
63
                                PngStoreProviderParameters.class, PngStoreProvider.NAME+"Parameters.xml");
64
                try {
65
                        FileHelper.registerMetadataDefinition(
66
                                        PngStoreProvider.METADATA_DEFINITION_NAME,
67
                                        PngStoreProvider.class, PngStoreProvider.NAME+"Metadata.xml");
68
                } catch (MetadataException e) {
69
                        exs.add(e);
70
                }
71

    
72
                DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices();
73

    
74

    
75
                try {
76
            if (!dataman.getStoreProviders()
77
                .contains(PngStoreProvider.NAME)) {
78
                dataman.registerStoreProviderFactory(
79
                    new PngStoreProviderFactory(
80
                        PngStoreProvider.NAME,
81
                        PngStoreProvider.DESCRIPTION));
82
            }
83
                } catch (RuntimeException e) {
84
                        exs.add(e);
85
                }
86

    
87
                //FIXME: Cambiar usando la factoria
88
                try {
89
                        DALFileLocator.getFilesystemServerExplorerManager()
90
                                        .registerProvider(PngStoreProvider.NAME,
91
                                            PngStoreProvider.DESCRIPTION,
92
                                                        PngFileSystemServerProvider.class);
93
                } catch (RuntimeException e) {
94
                        exs.add(e);
95
                }
96

    
97
                if (exs.size() > 0) {
98
                        throw new LibraryException(this.getClass(), exs);
99
                }
100
        }
101
}