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 / DefaultInstallerManager.java @ 32451
History | View | Annotate | Download (4.15 KB)
1 | 32269 | jpiera | /* 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.api.InstallerManager; |
||
31 | import org.gvsig.installer.lib.api.creation.InstallerCreationService; |
||
32 | import org.gvsig.installer.lib.api.creation.InstallerCreationServiceException; |
||
33 | import org.gvsig.installer.lib.api.execution.InstallerExecutionService; |
||
34 | import org.gvsig.installer.lib.api.execution.InstallerExecutionServiceException; |
||
35 | import org.gvsig.tools.ToolsLocator; |
||
36 | 32400 | jpiera | import org.gvsig.tools.dynobject.DynObject; |
37 | 32269 | jpiera | import org.gvsig.tools.extensionpoint.ExtensionPoint; |
38 | import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
||
39 | 32400 | jpiera | import org.gvsig.tools.service.AbstractManager; |
40 | import org.gvsig.tools.service.Service; |
||
41 | import org.gvsig.tools.service.ServiceException; |
||
42 | 32269 | jpiera | |
43 | /**
|
||
44 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
||
45 | */
|
||
46 | 32400 | jpiera | public class DefaultInstallerManager extends AbstractManager implements InstallerManager{ |
47 | 32269 | jpiera | private static final String INSTALLER_MANAGER_EXTENSION_POINT = "InstallerManagerExtensionPoint"; |
48 | private static final String INSTALLER_CREATION_SERVICE_NAME = "InstallerCreationService"; |
||
49 | private static final String INSTALLER_EXECUTION_SERVICE_NAME = "InstallerExecutionService"; |
||
50 | private ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
|
||
51 | |||
52 | 32400 | jpiera | public DefaultInstallerManager() {
|
53 | super(new DefaultInstallerProviderManager()); |
||
54 | } |
||
55 | |||
56 | |||
57 | 32269 | jpiera | public InstallerCreationService getInstallerCreationService() throws InstallerCreationServiceException { |
58 | ExtensionPoint ep = extensionPoints.add(INSTALLER_MANAGER_EXTENSION_POINT); |
||
59 | try {
|
||
60 | 32400 | jpiera | Object[] args = new Object[1]; |
61 | args[0] = this; |
||
62 | return (InstallerCreationService)ep.create(INSTALLER_CREATION_SERVICE_NAME, args);
|
||
63 | 32269 | jpiera | } catch (Exception e) { |
64 | throw new InstallerCreationServiceException("Exception creating the installer service to create installers", e); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | public InstallerExecutionService getInstallerExecutionService() throws InstallerExecutionServiceException { |
||
69 | ExtensionPoint ep = extensionPoints.add(INSTALLER_MANAGER_EXTENSION_POINT); |
||
70 | try {
|
||
71 | 32400 | jpiera | Object[] args = new Object[1]; |
72 | args[0] = this; |
||
73 | return (InstallerExecutionService)ep.create(INSTALLER_EXECUTION_SERVICE_NAME, args);
|
||
74 | 32269 | jpiera | } catch (Exception e) { |
75 | throw new InstallerExecutionServiceException("Exception creating the installer service to install plugins", e); |
||
76 | } |
||
77 | } |
||
78 | public void registerInstallerCreationService(Class clazz) { |
||
79 | if (!InstallerCreationService.class.isAssignableFrom(clazz)) {
|
||
80 | throw new IllegalArgumentException(clazz.getName() |
||
81 | + " must implement the InstallerCreationService interface");
|
||
82 | } |
||
83 | ExtensionPoint extensionPoint = extensionPoints.add(INSTALLER_MANAGER_EXTENSION_POINT, "");
|
||
84 | extensionPoint.append(INSTALLER_CREATION_SERVICE_NAME, "", clazz);
|
||
85 | } |
||
86 | |||
87 | public void registerInstallerExecutionService(Class clazz) { |
||
88 | if (!InstallerExecutionService.class.isAssignableFrom(clazz)) {
|
||
89 | throw new IllegalArgumentException(clazz.getName() |
||
90 | + " must implement the InstallerExecutionService interface");
|
||
91 | } |
||
92 | ExtensionPoint extensionPoint = extensionPoints.add(INSTALLER_MANAGER_EXTENSION_POINT, "");
|
||
93 | extensionPoint.append(INSTALLER_EXECUTION_SERVICE_NAME, "", clazz);
|
||
94 | } |
||
95 | 32400 | jpiera | |
96 | |||
97 | public Service getService(DynObject parameters) throws ServiceException { |
||
98 | return null; |
||
99 | } |
||
100 | 32269 | jpiera | } |