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 / creation / MakePluginPackageService.java @ 33743

History | View | Annotate | Download (6.78 KB)

1 32269 jpiera
/* gvSIG. Geographic Information System of the Valencian Government
2 33692 cordinyana
 *
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 32269 jpiera
23
/*
24 33692 cordinyana
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27
28 32269 jpiera
package org.gvsig.installer.lib.api.creation;
29
30
import java.io.File;
31
import java.io.OutputStream;
32
33 32597 jpiera
import org.gvsig.installer.lib.api.InstallerManager;
34 32562 jpiera
import org.gvsig.installer.lib.api.PackageInfo;
35 32400 jpiera
import org.gvsig.tools.service.Service;
36 32269 jpiera
37
/**
38 32333 jpiera
 * <p>
39 32597 jpiera
 * This service is used to create a bundle that contains a package of plugin
40 33692 cordinyana
 * 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 32333 jpiera
 * <p>
44 33692 cordinyana
 * 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 32333 jpiera
 * <p>
48 32597 jpiera
 * 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 32333 jpiera
 * </p>
52 33692 cordinyana
 *
53 32333 jpiera
 * <pre>
54 32597 jpiera
 * - bundle (compressed file)
55
 *                 - org.gvsig.plugin1-1_0_0-23 (compressed file)
56
 *                         - org.gvsig.plugin1
57
 *                                   - package.info
58 32333 jpiera
 *                          - install.xml
59
 *                          - files
60 32451 jpiera
 *                                  - gvSIG
61
 *                                          - extensiones
62 32597 jpiera
 *                                                  - org.gvsig.plugin2
63 32451 jpiera
 *                                                          - file1
64
 *                                                          - file2
65 32333 jpiera
 * </pre>
66
 * <p>
67 32597 jpiera
 * This structure has some extra files:
68 33692 cordinyana
 * </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 32333 jpiera
 * <p>
75 33692 cordinyana
 * 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 32333 jpiera
 * </p>
81 32597 jpiera
 * <p>
82 33692 cordinyana
 * 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 32597 jpiera
 * </p>
86 33692 cordinyana
 *
87 32269 jpiera
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
88
 */
89 33692 cordinyana
public interface MakePluginPackageService extends Service {
90 32269 jpiera
91 33692 cordinyana
    /**
92
     * @return
93
     *         the directory when the gvSIG plugins are located.
94
     */
95
    public File getPluginsDirectory();
96
97
    /**
98
     * It creates a bundle with a plugin package inside.
99
     *
100
     * @param packageInfo
101
     *            the package that has to be included in the bundle.
102
     * @param bundleStream
103
     *            the stream where the the bundle is created.
104
     * @throws MakePluginPackageServiceException
105
     *             it is thrown when there is an exception creating the bundle.
106
     */
107
    public void createPluginPackage(PackageInfo packageInfo,
108
        OutputStream bundleStream) throws MakePluginPackageServiceException;
109
110
    /**
111 33697 cordinyana
     * Writes a package info file with the information provided.
112
     *
113
     * @param packageInfo
114
     *            the package that has to be written into the file
115
     * @param folder
116
     *            the folder where the file is to be created
117
     * @throws MakePluginPackageServiceException
118
     *             it is thrown when there is an exception writing the file
119
     */
120
    public void writePackageInfo(PackageInfo packageInfo, File folder)
121
        throws MakePluginPackageServiceException;
122
123
    /**
124 33692 cordinyana
     * It returns the number of plugin packages that are installed in the folder
125
     * that has been added using the constructor. It can be used in an iteration
126
     * process combined with the {@link #getPluginPackageInfo(int)} method to
127
     * know all the installed plugins.
128
     *
129
     * @return
130
     *         the number of plugins installed in a directory.
131
     */
132
    public int getPluginPackageCount();
133
134
    /**
135
     * It returns an instance of an {@link PackageInfo} class, that is a
136
     * class that contains all the package information (name, version...).
137
     *
138
     * @param index
139
     *            the position of the plugin that has to be retrieved.
140
     * @return
141
     *         the installer information of a plugin package.
142
     *         Returns <code>null</code> if the package doesn't exist.
143
     */
144
    public PackageInfo getPluginPackageInfo(int index);
145
146
    /**
147
     * It returns an instance of an {@link PackageInfo} class, that is a
148
     * class that contains all the package information (name, version...).
149
     *
150
     * @param code
151
     *            code of the plugin, defined in the <b>package.info</b> file
152
     *            like a
153
     *            property.
154
     * @return
155
     *         the installer information of a plugin package.
156
     *         Returns <code>null</code> if the package doesn't exist.
157
     */
158
    public PackageInfo getPluginPackageInfo(String code);
159
160
    /**
161
     * This method returns the default ant script that
162
     * will be used by some plugins to copy some external files
163
     * in the installation process.
164
     *
165
     * @return
166
     *         a string that contains the standard ant script
167
     * @throws MakePluginPackageServiceException
168
     *             if there is a problem reading the file
169
     * @deprecated
170
     *             don't use this method, because all the files that a plugin
171
     *             needs to work should be contained in its directory.
172
     */
173
    @Deprecated
174
    public String getDefaultAntScript()
175
        throws MakePluginPackageServiceException;
176
177 33743 cordinyana
    /**
178
     * Returns the list of packages already installed in the application.
179
     *
180
     * @return the list of packages already installed in the application
181
     * @throws MakePluginPackageServiceException
182
     *             if there is an error getting
183
     *             the installed packages
184
     */
185
    public PackageInfo[] getInstalledPackages()
186
        throws MakePluginPackageServiceException;
187 32269 jpiera
}