Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.metadata.basic / org.gvsig.metadata.basic.swing / org.gvsig.metadata.swing.basic.api / src / main / java / org / gvsig / metadata / swing / basic / api / MetadataSwingLibrary.java @ 40608

History | View | Annotate | Download (3.22 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2010 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 Institute of New Imaging Technologies (INIT): 
26
 *   http://www.init.uji.es
27
 * Geographic Information research group: 
28
 *   http://www.geoinfo.uji.es
29
 * Universitat Jaume I UJI, Spain
30
 */
31

    
32
package org.gvsig.metadata.swing.basic.api;
33

    
34
import org.gvsig.metadata.MetadataLocator;
35
import org.gvsig.metadata.MetadataManager;
36
import org.gvsig.tools.library.AbstractLibrary;
37
import org.gvsig.tools.library.LibraryException;
38
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
39
import org.gvsig.tools.swing.api.ToolsSwingLibrary;
40

    
41
/**
42
 * 
43
 * Initialization of the basic Metadata API Library.
44
 * 
45
 * @author gvSIG Team
46
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
47
 * @version $Id$
48
 * 
49
 */
50
public class MetadataSwingLibrary extends AbstractLibrary {
51

    
52
        public void doRegistration() {
53
                super.doRegistration();
54
                registerAsAPI(MetadataSwingLibrary.class);
55
        require(ToolsSwingLibrary.class);
56
    }
57
    
58
        /**
59
         * Performs all the initializations of the library, only related to himself:
60
         * register implementation classes through the Locator, start services, etc.
61
         * 
62
         * @throws LibraryException
63
         *             if there is an error while performing the initialization of
64
         *             the library
65
         */
66
        protected void doInitialize() throws LibraryException {
67

    
68
        }
69

    
70
        /**
71
         * Performs all the initializations or validations related to the library
72
         * dependencies, as getting references to objects through other libraries
73
         * Locators.
74
         * 
75
         * @throws LibraryException
76
         *             if there is an error while loading an implementation of the
77
         *             library
78
         */
79
        protected void doPostInitialize() throws LibraryException {
80
            // Validate there is any implementation registered.
81
        MetadataManager manager = MetadataLocator.getMetadataManager();
82
        
83
        if (manager == null) {
84
            throw new ReferenceNotRegisteredException(
85
                    MetadataLocator.METADATA_MANAGER_NAME, MetadataLocator.getInstance());
86
        }
87
                /*
88
                 * Validates if there is at least an implementation of the
89
                 * MetadataManager registered.
90
                 */
91
                MetadataSwingManager swingManager = MetadataSwingLocator.getMetadataSwingManager();
92

    
93
                if (swingManager == null) {
94
                        throw new ReferenceNotRegisteredException(
95
                                        MetadataSwingLocator.METADATA_MANAGER_NAME,
96
                                        MetadataSwingLocator.getInstance());
97
                }
98
        }
99
}