Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2021 / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.api / src / main / java / org / gvsig / installer / lib / api / creation / MakePluginPackageService.java @ 34107

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

    
30
import java.io.File;
31
import java.io.OutputStream;
32

    
33
import org.gvsig.installer.lib.api.InstallerManager;
34
import org.gvsig.installer.lib.api.PackageInfo;
35
import org.gvsig.tools.service.Service;
36

    
37
/**
38
 * <p>
39
 * This service is used to create a bundle that contains a package of plugin
40
 * type. It supports just one package for every installer. It contains a method
41
 * to set the plugin path and some methods to set the installer information.
42
 * </p>
43
 * <p>
44
 * It has also methods to load the installed plugins from a directory (if
45
 * exists) and methods to create the bundle file in an {@link OutputStream}.
46
 * </p>
47
 * <p>
48
 * A plugin package has the same structure of a standard package defined in
49
 * {@link InstallerManager} but it adds some new files. An example of the
50
 * structure of a bundle with a plugin package could be:
51
 * </p>
52
 * 
53
 * <pre>
54
 * - bundle (compressed file)
55
 *                 - org.gvsig.plugin1-1_0_0-23 (compressed file)
56
 *                         - org.gvsig.plugin1
57
 *                                   - package.info   
58
 *                          - install.xml
59
 *                          - files
60
 *                                  - gvSIG
61
 *                                          - extensiones
62
 *                                                  - org.gvsig.plugin2
63
 *                                                          - file1
64
 *                                                          - file2
65
 * </pre>
66
 * <p>
67
 * This structure has some extra files:
68
 * </p>
69
 * <lu> <li><b>install.xml</b>: ant file that is executed in the execution of
70
 * the installer to do some extra actions in the installation process. One of
71
 * these actions is copy all the files located in the files directory</li> <li>
72
 * <b>files directory</b>: it contains some files of other extensions that have
73
 * to be copied using the ant script.</li> </lu>
74
 * <p>
75
 * The usage of the ant script to copy files from other plugins is not
76
 * recommended because it is possible that different installers overrides the
77
 * same file. The suggestion it that one plugin has to have all the files that
78
 * it needs to work inside the plugin and it never has to override some external
79
 * files.
80
 * </p>
81
 * <p>
82
 * The implementations of this interface have to have a constructor with a File
83
 * parameter that is the directory when the plugins are located. If the
84
 * directory doens't exists the creation throws an exception.
85
 * </p>
86
 * 
87
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
88
 */
89
public interface MakePluginPackageService extends Service {
90

    
91
    /**
92
     * @return
93
     *         the directory when the gvSIG plugins are located.
94
     */
95
    public File getPluginsDirectory();
96

    
97
    /**
98
     * It creates a package set with a single plugin package inside.
99
     * 
100
     * @param packageInfo
101
     *            the information of the plugin that has to be included in the
102
     *            package set
103
     * @param packageStream
104
     *            the stream where the the package set will be created
105
     * @throws MakePluginPackageServiceException
106
     *             it is thrown when there is an exception creating the package
107
     *             set
108
     */
109
    public void createPackageSet(PackageInfo packageInfo,
110
        OutputStream packageStream) throws MakePluginPackageServiceException;
111

    
112
    /**
113
     * It creates a package of a plugin.
114
     * 
115
     * @param packageInfo
116
     *            the information of the plugin that has to be included in the
117
     *            package
118
     * @param packageStream
119
     *            the stream where the the package will be created
120
     * @throws MakePluginPackageServiceException
121
     *             it is thrown when there is an exception creating the
122
     *             package
123
     */
124
    public void createPackage(PackageInfo packageInfo,
125
        OutputStream packageStream) throws MakePluginPackageServiceException;
126

    
127
    /**
128
     * Writes a package info file with the information provided.
129
     * 
130
     * @param packageInfo
131
     *            the package that has to be written into the file
132
     * @param folder
133
     *            the folder where the file is to be created
134
     * @throws MakePluginPackageServiceException
135
     *             it is thrown when there is an exception writing the file
136
     */
137
    public void writePackageInfo(PackageInfo packageInfo, File folder)
138
        throws MakePluginPackageServiceException;
139

    
140
    /**
141
     * It returns the number of plugin packages that are installed in the folder
142
     * that has been added using the constructor. It can be used in an iteration
143
     * process combined with the {@link #getPluginPackageInfo(int)} method to
144
     * know all the installed plugins.
145
     * 
146
     * @return
147
     *         the number of plugins installed in a directory.
148
     */
149
    public int getPluginPackageCount();
150

    
151
    /**
152
     * It returns an instance of an {@link PackageInfo} class, that is a
153
     * class that contains all the package information (name, version...).
154
     * 
155
     * @param index
156
     *            the position of the plugin that has to be retrieved.
157
     * @return
158
     *         the installer information of a plugin package.
159
     *         Returns <code>null</code> if the package doesn't exist.
160
     */
161
    public PackageInfo getPluginPackageInfo(int index);
162

    
163
    /**
164
     * It returns an instance of an {@link PackageInfo} class, that is a
165
     * class that contains all the package information (name, version...).
166
     * 
167
     * @param code
168
     *            code of the plugin, defined in the <b>package.info</b> file
169
     *            like a
170
     *            property.
171
     * @return
172
     *         the installer information of a plugin package.
173
     *         Returns <code>null</code> if the package doesn't exist.
174
     */
175
    public PackageInfo getPluginPackageInfo(String code);
176

    
177
    /**
178
     * This method returns the default ant script that
179
     * will be used by some plugins to copy some external files
180
     * in the installation process.
181
     * 
182
     * @return
183
     *         a string that contains the standard ant script
184
     * @throws MakePluginPackageServiceException
185
     *             if there is a problem reading the file
186
     * @deprecated
187
     *             don't use this method, because all the files that a plugin
188
     *             needs to work should be contained in its directory.
189
     */
190
    @Deprecated
191
    public String getDefaultAntScript()
192
        throws MakePluginPackageServiceException;
193

    
194
    /**
195
     * Returns the list of packages already installed in the application.
196
     * 
197
     * @return the list of packages already installed in the application
198
     * @throws MakePluginPackageServiceException
199
     *             if there is an error getting
200
     *             the installed packages
201
     */
202
    public PackageInfo[] getInstalledPackages()
203
        throws MakePluginPackageServiceException;
204
}