Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / spi / DALSPILibrary.java @ 40361

History | View | Annotate | Download (3.05 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 IVER T.I. S.A.   {{Task}}
26
 */
27
package org.gvsig.fmap.dal.spi;
28

    
29
import java.util.ArrayList;
30
import java.util.List;
31

    
32

    
33
import org.gvsig.fmap.dal.DALLocator;
34
import org.gvsig.fmap.dal.feature.spi.memory.MemoryResource;
35
import org.gvsig.fmap.dal.feature.spi.memory.MemoryResourceParameters;
36
import org.gvsig.fmap.dal.resource.ResourceManager;
37
import org.gvsig.fmap.dal.resource.spi.MultiResource;
38
import org.gvsig.fmap.dal.resource.spi.MultiResourceParameters;
39
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
40
import org.gvsig.tools.library.AbstractLibrary;
41
import org.gvsig.tools.library.LibraryException;
42
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
43

    
44
/**
45
 * Initializes gvSIG's desktop DAL by registering the default implementation for
46
 * {@link DataManager} and {@link ResourceManager}.
47
 * 
48
 */
49
public class DALSPILibrary extends AbstractLibrary {
50

    
51
    public void doRegistration() {
52
        registerAs(DALSPILibrary.class,"spi");
53
    }
54

    
55
    protected void doInitialize() throws LibraryException {
56
        // Do nothing
57
    }
58

    
59
    protected void doPostInitialize() throws LibraryException {
60
        List exs = new ArrayList();
61

    
62

    
63
        ResourceManagerProviderServices resourceManager =
64
            (ResourceManagerProviderServices) DALLocator.getResourceManager();
65
        if (resourceManager == null) {
66
            throw new ReferenceNotRegisteredException(
67
                DALLocator.RESOURCE_MANAGER_NAME, DALLocator.getInstance());
68
        }
69

    
70
        if (!resourceManager.getResourceProviders().contains(
71
            MultiResource.TYPE_NAME)) {
72
            resourceManager.register(MultiResource.TYPE_NAME,
73
                MultiResource.DESCRIPTION, MultiResource.class,
74
                MultiResourceParameters.class);
75
        }
76

    
77
        if (!resourceManager.getResourceProviders().contains(
78
            MemoryResource.NAME)) {
79
            resourceManager.register(MemoryResource.NAME,
80
                MemoryResource.DESCRIPTION, MemoryResource.class,
81
                MemoryResourceParameters.class);
82
        }
83

    
84
        if (exs.size() > 0) {
85
            throw new LibraryException(this.getClass(), exs);
86
        }
87
    }
88

    
89
}