root / 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 @ 37829
History | View | Annotate | Download (12.2 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 |
import java.util.List; |
34 |
|
35 |
import org.gvsig.installer.lib.api.creation.MakePackageService; |
36 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
37 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
38 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
39 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
40 |
import org.gvsig.tools.service.Manager; |
41 |
|
42 |
/**
|
43 |
* <p>
|
44 |
* This manager is used to register and create the services that are used to
|
45 |
* manage the creation and the execution of installers. An installer is a file
|
46 |
* called <b>bundle</b> that is composed of a set <b>packages</b>.
|
47 |
* </p>
|
48 |
* <p>
|
49 |
* A package has some information that is defined by the {@link PackageInfo}
|
50 |
* class and is composed of a set of attributes. One of these attributes, the
|
51 |
* type, denotes if the package is a plugin, theme, translation, etc.
|
52 |
* </p>
|
53 |
* <p>
|
54 |
* In practice a bundle is just a compressed zip file that has a compressed zip
|
55 |
* file for every package to install. The structure of a bundle file with two
|
56 |
* packages of type plugin could be:
|
57 |
* </p>
|
58 |
*
|
59 |
* <pre>
|
60 |
* - bundle (compressed file)
|
61 |
* - org.gvsig.plugin1-1_0_0-23 (compressed file)
|
62 |
* - org.gvsig.plugin1
|
63 |
* - package.info
|
64 |
* - org.gvsig.plugin2-2_0_1-35 (compressed file)
|
65 |
* - org.gvsig.plugin1
|
66 |
* - package.info
|
67 |
* </pre>
|
68 |
* <p>
|
69 |
* <b>bundle</b> is the compressed file that contains a zip entry for every
|
70 |
* package to install. The name of the zip entry follows next pattern:
|
71 |
* </p>
|
72 |
*
|
73 |
* <pre>
|
74 |
* [package code]-[version]-[build]
|
75 |
* </pre>
|
76 |
* <p>
|
77 |
* Every zip entry contains a main folder inside that contains all the package
|
78 |
* files that are used in the installation process. Depending of the type of
|
79 |
* packages, the information inside this folder can be different, but all the
|
80 |
* types of packages have to have the <b>package.info</b>file that has all the
|
81 |
* package information. To see the <b>package.info</b> description see
|
82 |
* {@link PackageInfo}.
|
83 |
* <p>
|
84 |
* </p>
|
85 |
* The services that offers this managers are basically two: the creation of
|
86 |
* bundles for just one package of plugin type and a service for the
|
87 |
* installation of packages from a bundle. </p>
|
88 |
*
|
89 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</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 have to implement the {@link MakePluginPackageService} interface.
|
162 |
*
|
163 |
* @param clazz
|
164 |
* class that implements the {@link MakePluginPackageService}
|
165 |
* interface.
|
166 |
*/
|
167 |
public void registerMakePluginPackageService( |
168 |
Class<? extends MakePluginPackageService> clazz); |
169 |
|
170 |
// /**
|
171 |
// * It creates and returns an object that is used to create a bundle that
|
172 |
// * contains inside a package of type plugin. All the parameters are set
|
173 |
// * using the {@link MakePluginPackageService} interface. *
|
174 |
// *
|
175 |
// * @return 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 |
* It creates and returns an object that is used to create a bundle that
|
184 |
* contains inside a package of type plugin. All the parameters are set
|
185 |
* using the {@link MakePluginPackageService} interface. *
|
186 |
*
|
187 |
* @return an object that is used to create a plugin installer
|
188 |
* @throws MakePluginPackageServiceException
|
189 |
* @throws MakePluginPackageServiceException
|
190 |
* when there is a problem creating the service
|
191 |
*/
|
192 |
public MakePluginPackageService getMakePluginPackageService()
|
193 |
throws MakePluginPackageServiceException;
|
194 |
|
195 |
/**
|
196 |
* Returns a list of package infos for the already installed plugins.
|
197 |
*
|
198 |
* @param pluginsDirectory
|
199 |
* where to look for the installed plugins
|
200 |
* @return the list of package infos for the already installed plugins
|
201 |
* @throws MakePluginPackageServiceException
|
202 |
* if there is an error loading the information of the installed
|
203 |
* plugins
|
204 |
*/
|
205 |
public PackageInfo[] getInstalledPackages(File pluginsDirectory) |
206 |
throws MakePluginPackageServiceException;
|
207 |
|
208 |
/**
|
209 |
* Returns a list of package infos for the already installed plugins.
|
210 |
*
|
211 |
* @return the list of package infos for the already installed plugins
|
212 |
* @throws MakePluginPackageServiceException
|
213 |
* if there is an error loading the information of the installed
|
214 |
* plugins
|
215 |
*/
|
216 |
public PackageInfo[] getInstalledPackages() |
217 |
throws MakePluginPackageServiceException;
|
218 |
|
219 |
/**
|
220 |
* Returns the package bundle file name format.
|
221 |
* <p>
|
222 |
* The string has to use a suitable {@link MessageFormat} format, and the
|
223 |
* available field numbers are the ones defined in the
|
224 |
* BUNDLE_FILE_NAME_FIELDS interface.
|
225 |
* </p>
|
226 |
*
|
227 |
* @return the package bundle file name format.
|
228 |
*/
|
229 |
public String getPackageSetNameFormat(); |
230 |
|
231 |
/**
|
232 |
* Sets the package bundle file name format.
|
233 |
*
|
234 |
* @see InstallerManager#getPackageSetNameFormat()
|
235 |
* @param packageBundleNameFormat
|
236 |
* the package bundle file name format.
|
237 |
*/
|
238 |
public void setPackageSetNameFormat(String packageBundleNameFormat); |
239 |
|
240 |
/**
|
241 |
* Returns the name of the package set file for a given package info.
|
242 |
*
|
243 |
* @param info
|
244 |
* of the plugin
|
245 |
* @return the name of the package set file
|
246 |
*/
|
247 |
public String getPackageSetFileName(PackageInfo info); |
248 |
|
249 |
/**
|
250 |
* Returns the name of the package file for a given package info.
|
251 |
*
|
252 |
* @param info
|
253 |
* of the plugin
|
254 |
* @return the name of the package file
|
255 |
*/
|
256 |
public String getPackageFileName(PackageInfo info); |
257 |
|
258 |
/**
|
259 |
* Returns the name of the package index file for a given package info.
|
260 |
*
|
261 |
* @param info
|
262 |
* of the plugin
|
263 |
* @return the name of the package index file
|
264 |
*/
|
265 |
public String getPackageIndexFileName(PackageInfo info); |
266 |
|
267 |
/**
|
268 |
* It registers a class that implements the service for the installation of
|
269 |
* a package that is inside a bundle. This class has to implement the
|
270 |
* {@link InstallPackageService} interface.
|
271 |
*
|
272 |
* @param clazz
|
273 |
* class that implements the {@link InstallPackageService}
|
274 |
* interface.
|
275 |
*/
|
276 |
public void registerInstallPackageService( |
277 |
Class<? extends InstallPackageService> clazz); |
278 |
|
279 |
/**
|
280 |
* It creates and returns an object that is used to install a package in
|
281 |
* gvSIG. All the parameters are set using the {@link InstallPackageService}
|
282 |
* interface.
|
283 |
*
|
284 |
* @return an object that is used to install the package.
|
285 |
* @throws InstallPackageServiceException
|
286 |
* when there is a problem creating the service.
|
287 |
*/
|
288 |
public InstallPackageService getInstallPackageService()
|
289 |
throws InstallPackageServiceException;
|
290 |
|
291 |
/**
|
292 |
* Returns the default extensions of the package files.
|
293 |
*
|
294 |
* @return the default extensions of the package files
|
295 |
*/
|
296 |
public String getDefaultPackageFileExtension(); |
297 |
|
298 |
/**
|
299 |
* Returns the default extensions of the package set files.
|
300 |
*
|
301 |
* @return the default extensions of the package set files
|
302 |
*/
|
303 |
public String getDefaultPackageSetFileExtension(); |
304 |
|
305 |
/**
|
306 |
* Returns the default extensions of the index set files.
|
307 |
*
|
308 |
* @return the default extensions of the index set files
|
309 |
*/
|
310 |
public String getDefaultIndexSetFileExtension(); |
311 |
|
312 |
/**
|
313 |
* Return the OS code of the system
|
314 |
*
|
315 |
* @return os code of the system
|
316 |
*/
|
317 |
public String getOperatingSystem(); |
318 |
|
319 |
/**
|
320 |
* Returns the Architecture code of the system
|
321 |
*
|
322 |
* @return architecture code of the system
|
323 |
*/
|
324 |
public String getArchitecture(); |
325 |
|
326 |
/**
|
327 |
* Create a empty dependency object.
|
328 |
*
|
329 |
* @return the dependency
|
330 |
*/
|
331 |
public Dependency createDependency();
|
332 |
|
333 |
/**
|
334 |
* Create a dependency instance with the data of the package.
|
335 |
*
|
336 |
* @param packageInfo
|
337 |
* @return a dependency of the package
|
338 |
*/
|
339 |
public Dependency createDependency(PackageInfo packageInfo);
|
340 |
|
341 |
/**
|
342 |
* Create a dependencies calculator.
|
343 |
*
|
344 |
* @return the dependencias calculator
|
345 |
*/
|
346 |
public DependenciesCalculator createDependenciesCalculator(
|
347 |
InstallPackageService installService); |
348 |
|
349 |
/**
|
350 |
* Create a version instance
|
351 |
*
|
352 |
* @return the version
|
353 |
*/
|
354 |
public Version createVersion();
|
355 |
|
356 |
public PackageInfo createPackageInfo();
|
357 |
|
358 |
public PackageInfoWriter getDefaultPackageInfoWriter();
|
359 |
|
360 |
public PackageInfoReader getDefaultPackageInfoReader();
|
361 |
|
362 |
public MakePackageService createMakePackage(File packageFolder, |
363 |
PackageInfo packageInfo); |
364 |
|
365 |
public void setDownloadBaseURL(URL url); |
366 |
|
367 |
public URL getDownloadBaseURL(); |
368 |
|
369 |
public void setVersion(String version); |
370 |
|
371 |
public String getVersion(); |
372 |
|
373 |
/**
|
374 |
* Gets a List of all the folders where there might be addons folders
|
375 |
* (addons repositories).
|
376 |
*
|
377 |
* @return list of repositories paths
|
378 |
*/
|
379 |
public List<File> getLocalAddonRepositories(); |
380 |
|
381 |
/**
|
382 |
* Adds an addon repository path to the manager list.
|
383 |
*
|
384 |
* @param path
|
385 |
* of the repository
|
386 |
*/
|
387 |
public void addLocalAddonRepository(File path); |
388 |
|
389 |
/**
|
390 |
* Gets a List of all the addon folders. An addon folder is a folder inside
|
391 |
* any addon repository with a package.info file inside. (addons
|
392 |
* repositories).
|
393 |
*
|
394 |
* @return list of addon paths folders.
|
395 |
*/
|
396 |
public List<File> getAddonFolders(); |
397 |
|
398 |
/**
|
399 |
* Gets the folder of the addon with the code provided, or null if not
|
400 |
* found.
|
401 |
*
|
402 |
* @param code
|
403 |
* of the addon
|
404 |
*
|
405 |
* @return File of the folder of the addon.
|
406 |
*/
|
407 |
public File getAddonFolder(String code); |
408 |
|
409 |
public void setDefaultLocalAddonRepository(File defaultAddonsRepository); |
410 |
|
411 |
public File getDefaultLocalAddonRepository(); |
412 |
|
413 |
} |