Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.impl / src / main / java / org / gvsig / installer / lib / impl / DefaultInstallerProviderManager.java @ 33743

History | View | Annotate | Download (3.51 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.impl;
29

    
30
import org.gvsig.installer.lib.impl.execution.NotInstallerExecutionProviderException;
31
import org.gvsig.installer.lib.spi.InstallPackageProviderServices;
32
import org.gvsig.installer.lib.spi.InstallerProviderManager;
33
import org.gvsig.installer.lib.spi.execution.InstallPackageProvider;
34
import org.gvsig.tools.ToolsLocator;
35
import org.gvsig.tools.dynobject.DynClass;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.dynobject.DynObjectManager;
38
import org.gvsig.tools.service.Service;
39
import org.gvsig.tools.service.ServiceException;
40
import org.gvsig.tools.service.spi.AbstractProviderManager;
41
import org.gvsig.tools.service.spi.NotRegisteredException;
42
import org.gvsig.tools.service.spi.Provider;
43
import org.gvsig.tools.service.spi.ProviderServices;
44

    
45
/**
46
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
47
 */
48
public class DefaultInstallerProviderManager extends AbstractProviderManager
49
    implements InstallerProviderManager {
50

    
51
    public static final String PROVIDERS_NAMESPACE = "Installer.providers";
52
    public static final String PROVIDERS_NAME = "Installer.providers";
53
    public static final String PROVIDERS_DESCRIPTION = "Installer providers";
54
    public DynObjectManager dynObjectManager = null;
55

    
56
    public DefaultInstallerProviderManager() {
57
        super();
58
        this.dynObjectManager = ToolsLocator.getDynObjectManager();
59
    }
60

    
61
    @Override
62
    protected String getRegistryDescription() {
63
        return PROVIDERS_DESCRIPTION;
64
    }
65

    
66
    @Override
67
    protected String getRegistryKey() {
68
        return PROVIDERS_NAME;
69
    }
70

    
71
    public ProviderServices createProviderServices(Service service) {
72
        return new DefaultInstallerProviderServices();
73
    }
74

    
75
    public InstallPackageProvider createExecutionProvider(String providerName)
76
        throws ServiceException {
77
        DynClass dynClass = dynObjectManager.get(providerName);
78
        if (dynClass == null) {
79
            throw new NotRegisteredException(providerName);
80
        }
81
        DynObject serviceParameters =
82
            dynObjectManager.createDynObject(dynClass);
83
        Provider provider =
84
            createProvider(serviceParameters,
85
                new DefaultInstallerProviderServices());
86
        if (!(provider instanceof InstallPackageProvider)) {
87
            throw new NotInstallerExecutionProviderException(providerName);
88
        }
89
        return (InstallPackageProvider) provider;
90
    }
91

    
92
    public InstallPackageProviderServices createInstallerProviderServices() {
93
        return new DefaultInstallerProviderServices();
94
    }
95

    
96
}