Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.api / src / main / java / org / gvsig / installer / lib / api / InstallerLocator.java @ 32467

History | View | Annotate | Download (2.78 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (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 {Prodevelop}   {Task}
26
*/
27
 
28
package org.gvsig.installer.lib.api;
29

    
30
import org.gvsig.tools.locator.AbstractLocator;
31
import org.gvsig.tools.locator.Locator;
32
import org.gvsig.tools.locator.LocatorException;
33

    
34
/**
35
 * This Locator provides the entry point for the gvSIG {@link InstallerManager}
36
 * 
37
 * @see {@link Locator}
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
39
 */
40
public class InstallerLocator extends AbstractLocator {
41
        private static final String LOCATOR_NAME = "InstallerLocator";
42
        /**
43
         * InstallerManager name used by the locator to access the instance
44
         */
45
        public static final String INSTALLER_MANAGER_NAME = "InstallerManager";
46
        private static final String INSTALLER_MANAGER_DESCRIPTION = "InstallerManager of gvSIG";
47

    
48

    
49
        /**
50
         * Unique instance.
51
         */
52
        private static final InstallerLocator instance = new InstallerLocator();
53
        
54
        /**
55
         * @see Locator#getLocatorName()
56
         */
57
        public String getLocatorName() {
58
                return LOCATOR_NAME;
59
        }
60
        
61
        /**
62
         * Return a reference to {@link InstallerManager}.
63
         *
64
         * @return a reference to InstallerManager
65
         * @throws LocatorException
66
         *             if there is no access to the class or the class cannot be
67
         *             instantiated
68
         * @see Locator#get(String)
69
         */
70
        public static InstallerManager getInstallerManager() throws LocatorException {
71
                return (InstallerManager) getInstance().get(INSTALLER_MANAGER_NAME);
72
        }
73
        
74
        /**
75
         * Return the singleton instance.
76
         *
77
         * @return the singleton instance
78
         */
79
        public static InstallerLocator getInstance() {
80
                return instance;
81
        }
82
        
83
        /**
84
         * Registers the Class implementing the {@link InstallerManager} interface.
85
         *
86
         * @param clazz
87
         * implementing the InstallerManager interface
88
         */
89
        @SuppressWarnings("unchecked")
90
        public static void registerInstallerManager(Class clazz) {
91
                
92
                getInstance().register(INSTALLER_MANAGER_NAME, 
93
                                INSTALLER_MANAGER_DESCRIPTION,
94
                                clazz);
95
        }
96
}
97