Statistics
| Revision:

root / trunk / libraries / libMetadata / src / org / gvsig / metadata / MDLocator.java @ 20940

History | View | Annotate | Download (2.53 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
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30

    
31
package org.gvsig.metadata;
32

    
33
import java.lang.reflect.Constructor;
34
import java.lang.reflect.InvocationTargetException;
35

    
36
import org.gvsig.metadata.simple.SimpleMDManager;
37

    
38

    
39
public class MDLocator {
40
        
41
        private static MDManager manager = null;
42
        private static Constructor constructor = null;
43
        
44
        public MDLocator() {
45
                install(SimpleMDManager.class);
46
        }
47
        
48
        public void install(Class mdManager) {
49
                try {
50
                        constructor = mdManager.getDeclaredConstructor(null);
51
                } catch (SecurityException e) {
52
                        // TODO Auto-generated catch block
53
                        e.printStackTrace();
54
                } catch (NoSuchMethodException e) {
55
                        // TODO Auto-generated catch block
56
                        e.printStackTrace();
57
                }
58
        }
59
        
60
        private static MDManager create() {
61
                MDManager imdm = null;
62
                try {
63
                        imdm = (MDManager) constructor.newInstance(new Object[] {});
64
                } catch (IllegalArgumentException e) {
65
                        // TODO Auto-generated catch block
66
                        e.printStackTrace();
67
                } catch (InstantiationException e) {
68
                        // TODO Auto-generated catch block
69
                        e.printStackTrace();
70
                } catch (IllegalAccessException e) {
71
                        // TODO Auto-generated catch block
72
                        e.printStackTrace();
73
                } catch (InvocationTargetException e) {
74
                        // TODO Auto-generated catch block
75
                        e.printStackTrace();
76
                }
77
                return imdm;
78
        }
79
        
80
        public static MDManager getManager() {
81
                if ( manager == null ) {
82
                        //manager = new org.gvsig.metadata.simple.MDManager();
83
                        manager = create();
84
                }
85
                return manager;
86
        }
87
        
88
}