Statistics
| Revision:

svn-gvsig-desktop / 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 / InstallerManager.java @ 35979

History | View | Annotate | Download (10.1 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 java.io.File;
31
import java.text.MessageFormat;
32

    
33
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
34
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
35
import org.gvsig.installer.lib.api.execution.InstallPackageService;
36
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
37
import org.gvsig.tools.service.Manager;
38

    
39
/**
40
 * <p>
41
 * This manager is used to register and create the services that are used to
42
 * manage the creation and the execution of installers. An installer is a file
43
 * called <b>bundle</b> that is composed of a set <b>packages</b>.
44
 * </p>
45
 * <p>
46
 * A package has some information that is defined by the {@link PackageInfo}
47
 * class and is composed of a set of attributes. One of these attributes, the
48
 * type, denotes if the package is a plugin, theme, translation, etc.
49
 * </p>
50
 * <p>
51
 * In practice a bundle is just a compressed zip file that has a compressed zip
52
 * file for every package to install. The structure of a bundle file with two
53
 * packages of type plugin could be:
54
 * </p>
55
 * 
56
 * <pre>
57
 * - bundle (compressed file)
58
 *                 - org.gvsig.plugin1-1_0_0-23 (compressed file)
59
 *                         - org.gvsig.plugin1
60
 *                                   - package.info                           
61
 *          - org.gvsig.plugin2-2_0_1-35 (compressed file)
62
 *                  - org.gvsig.plugin1
63
 *                          - package.info
64
 * </pre>
65
 * <p>
66
 * <b>bundle</b> is the compressed file that contains a zip entry for every
67
 * package to install. The name of the zip entry follows next pattern:
68
 * </p>
69
 * 
70
 * <pre>
71
 *                 [package code]-[version]-[build]
72
 * </pre>
73
 * <p>
74
 * Every zip entry contains a main folder inside that contains all the package
75
 * files that are used in the installation process. Depending of the type of
76
 * packages, the information inside this folder can be different, but all the
77
 * types of packages have to have the <b>package.info</b>file that has all the
78
 * package information. To see the <b>package.info</b> description see
79
 * {@link PackageInfo}.
80
 * <p>
81
 * </p>
82
 * The services that offers this managers are basically two: the creation of
83
 * bundles for just one package of plugin type and a service for the
84
 * installation of packages from a bundle.
85
 * </p>
86
 * 
87
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
88
 */
89
public interface InstallerManager extends Manager {
90

    
91
    /**
92
     * Package state default values.
93
     */
94
    public static interface STATE {
95

    
96
        static final String DEVEL = "devel";
97
        static final String TESTING = "testing";
98
        static final String PILOT = "pilot";
99
        static final String PROTOTYPE = "prototype";
100
        static final String ALPHA = "alpha";
101
        static final String BETA = "beta";
102
        static final String RC = "RC";
103
        static final String FINAL = "final";
104
    }
105

    
106
    /**
107
     * Supported operating system default values.
108
     */
109
    public static interface OS {
110

    
111
        static final String ALL = "all";
112
        static final String LINUX = "lin";
113
        static final String WINDOWS = "win";
114
        static final String OSX_10_4 = "osx_10_4";
115
        static final String OSX_10_5 = "osx_10_5";
116
        static final String OSX_10_6 = "osx_10_6";
117
    }
118

    
119
    /**
120
     * Supported architecture default values.
121
     */
122
    public static interface ARCH {
123

    
124
        static final String ALL = "all";
125
        static final String X86 = "x86";
126
        static final String X86_64 = "x86_64";
127
    }
128

    
129
    /**
130
     * Supported Java virtual machine version default values.
131
     */
132
    public static interface JVM {
133

    
134
        static final String J1_5 = "j1_5";
135
        static final String J1_6 = "j1_6";
136
    }
137

    
138
    /**
139
     * Fields into the bundle file name message format.
140
     * 
141
     * @see InstallerManager#getPackageSetNameFormat()
142
     * @see InstallerManager#setPackageSetNameFormat(String)
143
     */
144
    public static interface PACKAGE_FILE_NAME_FIELDS {
145

    
146
        static final int GVSIG_VERSION = 0;
147
        static final int NAME = 1;
148
        static final int VERSION = 2;
149
        static final int BUILD = 3;
150
        static final int STATE = 4;
151
        static final int OS = 5;
152
        static final int ARCH = 6;
153
        static final int JVM = 7;
154
    }
155

    
156
    /**
157
     * It registers a class that implements the service for the creation of
158
     * bundle that contains inside a package of type plugin. The registered
159
     * class
160
     * have to implement the {@link MakePluginPackageService} interface.
161
     * 
162
     * @param clazz
163
     *            class that implements the {@link MakePluginPackageService}
164
     *            interface.
165
     */
166
    public void registerMakePluginPackageService(
167
        Class<? extends MakePluginPackageService> clazz);
168

    
169
    /**
170
     * It creates and returns an object that is used to create a bundle
171
     * that contains inside a package of type plugin. All the parameters
172
     * are set using the {@link MakePluginPackageService} interface. *
173
     * 
174
     * @return
175
     *         an object that is used to create a plugin installer
176
     * @throws MakePluginPackageServiceException
177
     *             when there is a problem creating the service
178
     */
179
    public MakePluginPackageService getMakePluginPackageService(
180
        File pluginsDirectory) throws MakePluginPackageServiceException;
181

    
182
    /**
183
     * Returns a list of package infos for the already installed plugins.
184
     * 
185
     * @param pluginsDirectory
186
     *            where to look for the installed plugins
187
     * @return the list of package infos for the already installed plugins
188
     * @throws MakePluginPackageServiceException
189
     *             if there is an error loading
190
     *             the information of the installed plugins
191
     */
192
    public PackageInfo[] getInstalledPackages(File pluginsDirectory)
193
        throws MakePluginPackageServiceException;
194

    
195
    /**
196
     * Returns the package bundle file name format.
197
     * <p>
198
     * The string has to use a suitable {@link MessageFormat} format, and the
199
     * available field numbers are the ones defined in the
200
     * BUNDLE_FILE_NAME_FIELDS interface.
201
     * </p>
202
     * 
203
     * @return the package bundle file name format.
204
     */
205
    public String getPackageSetNameFormat();
206

    
207
    /**
208
     * Sets the package bundle file name format.
209
     * 
210
     * @see InstallerManager#getPackageSetNameFormat()
211
     * @param packageBundleNameFormat
212
     *            the package bundle file name format.
213
     */
214
    public void setPackageSetNameFormat(String packageBundleNameFormat);
215

    
216
    /**
217
     * Returns the name of the package set file for a given package info.
218
     * 
219
     * @param info
220
     *            of the plugin
221
     * @return the name of the package set file
222
     */
223
    public String getPackageSetFileName(PackageInfo info);
224

    
225
    /**
226
     * Returns the name of the package file for a given package info.
227
     * 
228
     * @param info
229
     *            of the plugin
230
     * @return the name of the package file
231
     */
232
    public String getPackageFileName(PackageInfo info);
233

    
234
    /**
235
     * Returns the name of the package index file for a given package info.
236
     * 
237
     * @param info
238
     *            of the plugin
239
     * @return the name of the package index file
240
     */
241
    public String getPackageIndexFileName(PackageInfo info);
242

    
243
    /**
244
     * It registers a class that implements the service for the installation
245
     * of a package that is inside a bundle. This class has to implement
246
     * the {@link InstallPackageService} interface.
247
     * 
248
     * @param clazz
249
     *            class that implements the {@link InstallPackageService}
250
     *            interface.
251
     */
252
    public void registerInstallPackageService(
253
        Class<? extends InstallPackageService> clazz);
254

    
255
    /**
256
     * It creates and returns an object that is used to install a package
257
     * in gvSIG. All the parameters are set using the
258
     * {@link InstallPackageService} interface.
259
     * 
260
     * @return
261
     *         an object that is used to install the package.
262
     * @throws InstallPackageServiceException
263
     *             when there is a problem creating the service.
264
     */
265
    public InstallPackageService getInstallPackageService()
266
        throws InstallPackageServiceException;
267

    
268
    /**
269
     * Returns the default extensions of the package files.
270
     * 
271
     * @return the default extensions of the package files
272
     */
273
    public String getDefaultPackageFileExtension();
274

    
275
    /**
276
     * Returns the default extensions of the package set files.
277
     * 
278
     * @return the default extensions of the package set files
279
     */
280
    public String getDefaultPackageSetFileExtension();
281

    
282
    /**
283
     * Return the OS code of the system
284
     *   
285
     * @return os code of the system
286
     */
287
        public String getOperatingSystem();
288
        
289
        /**
290
         * Create a empty dependency object.
291
         * 
292
         * @return the dependency
293
         */
294
        public Dependency createDependency();
295
        
296
        /**
297
         * Create a dependency instance with the data of the
298
         * package.
299
         * 
300
         * @param packageInfo
301
         * @return a dependency of the package
302
         */
303
        public Dependency createDependency(PackageInfo packageInfo);
304
        
305
        /**
306
         * Create a dependencies calculator.
307
         * 
308
         * @return the dependencias calculator
309
         */
310
        public DependenciesCalculator createDependenciesCalculator(InstallPackageService installService);
311
        
312
        /**
313
         * Create a version instance
314
         * 
315
         * @return the version
316
         */
317
        public Version createVersion();
318
}