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 @ 37489

History | View | Annotate | Download (10.6 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.net.URL;
32
import java.text.MessageFormat;
33

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

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

    
93
    /**
94
     * Package state default values.
95
     */
96
    public static interface STATE {
97

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

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

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

    
121
    /**
122
     * Supported architecture default values.
123
     */
124
    public static interface ARCH {
125

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

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

    
136
        static final String J1_5 = "j1_5";
137
        static final String J1_6 = "j1_6";
138
    }
139

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
325
    public PackageInfoReader getDefaultPackageInfoReader();
326
    
327
    public MakePackageService createMakePackage(File packageFolder, PackageInfo packageInfo);
328
    
329
    public void setDownloadBaseURL(URL url);
330
    
331
    public URL getDownloadBaseURL();
332
    
333
    public void setVersion(String version);
334
    
335
    public String getVersion();
336
        
337
}