6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.jpackage.internal; 27 28 import java.io.File; 29 import java.util.Collection; 30 import java.util.Map; 31 32 /** 33 * Bundler 34 * 35 * The basic interface implemented by all Bundlers. 36 */ 37 public interface Bundler { 38 /** 39 * @return User Friendly name of this bundler. 40 */ 41 String getName(); 42 43 /** 44 * @return A more verbose description of the bundler. 45 */ 46 String getDescription(); 47 48 /** 49 * @return Command line identifier of the bundler. Should be unique. 50 */ 51 String getID(); 52 53 /** 54 * @return The bundle type of the bundle that is created by this bundler. 55 */ 56 String getBundleType(); 57 58 /** 59 * The parameters that this bundler uses to generate it's bundle. 60 * @return immutable collection 61 */ 62 Collection<BundlerParamInfo<?>> getBundleParameters(); 63 64 /** 65 * Determines if this bundler will execute with the given parameters. 66 * 67 * @param params The parameters to be validate. Validation may modify 68 * the map, so if you are going to be using the same map 69 * across multiple bundlers you should pass in a deep copy. 70 * @return true if valid 71 * @throws UnsupportedPlatformException If the bundler cannot run on this 72 * platform (i.e. creating mac apps on windows) 73 * @throws ConfigException If the configuration params are incorrect. The 74 * exception may contain advice on how to modify the params map 75 * to make it valid. 76 */ 77 public boolean validate(Map<String, ? super Object> params) 78 throws UnsupportedPlatformException, ConfigException; 79 80 /** 81 * Creates a bundle from existing content. 82 * 83 * If a call to {@link #validate(java.util.Map)} date} returns true with 84 * the parameters map, then you can expect a valid output. 85 * However if an exception was thrown out of validate or it returned 86 * false then you should not expect sensible results from this call. 87 * It may or may not return a value, and it may or may not throw an 88 * exception. But any output should not be considered valid or sane. 89 * 90 * @param params The parameters as specified by getBundleParameters. 91 * Keyed by the id from the ParamInfo. Execution may 92 * modify the map, so if you are going to be using the 93 * same map across multiple bundlers you should pass 94 * in a deep copy. 95 * @param outputParentDir 96 * The parent dir that the returned bundle will be placed in. 97 * @return The resulting bundled file 98 * 99 * For a bundler that produces a single artifact file this will be the 100 * location of that artifact (.exe file, .deb file, etc) 101 * 102 * For a bundler that produces a specific directory format output this will 103 * be the location of that specific directory (.app file, etc). 104 * 105 * For a bundler that produce multiple files, this will be a parent 106 * directory of those files (linux and windows images), whose name is not 107 * relevant to the result. 108 * 109 * @throws java.lang.IllegalArgumentException for any of the following 110 * reasons: 113 * example missing the main class.</li> 114 * <li>A parameter has the wrong type of an object, for example a 115 * String where a File is required</li> 116 * <li>Bundler specific incompatibilities with the parameters, for 117 * example a bad version number format or an application id with 118 * forward slashes.</li> 119 * </ul> 120 */ 121 public File execute(Map<String, ? super Object> params, 122 File outputParentDir) throws PackagerException; 123 124 /** 125 * Removes temporary files that are used for bundling. 126 */ 127 public void cleanup(Map<String, ? super Object> params); 128 129 /** 130 * Returns "true" if this bundler is supported on current platform. 131 */ 132 public boolean supported(boolean runtimeInstaller); 133 } | 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.incubator.jpackage.internal; 27 28 import java.io.File; 29 import java.util.Collection; 30 import java.util.Map; 31 32 /** 33 * Bundler 34 * 35 * The basic interface implemented by all Bundlers. 36 */ 37 public interface Bundler { 38 /** 39 * @return User Friendly name of this bundler. 40 */ 41 String getName(); 42 43 /** 44 * @return Command line identifier of the bundler. Should be unique. 45 */ 46 String getID(); 47 48 /** 49 * @return The bundle type of the bundle that is created by this bundler. 50 */ 51 String getBundleType(); 52 53 /** 54 * Determines if this bundler will execute with the given parameters. 55 * 56 * @param params The parameters to be validate. Validation may modify 57 * the map, so if you are going to be using the same map 58 * across multiple bundlers you should pass in a deep copy. 59 * @return true if valid 60 * @throws ConfigException If the configuration params are incorrect. The 61 * exception may contain advice on how to modify the params map 62 * to make it valid. 63 */ 64 public boolean validate(Map<String, ? super Object> params) 65 throws ConfigException; 66 67 /** 68 * Creates a bundle from existing content. 69 * 70 * If a call to {@link #validate(java.util.Map)} date} returns true with 71 * the parameters map, then you can expect a valid output. 72 * However if an exception was thrown out of validate or it returned 73 * false then you should not expect sensible results from this call. 74 * It may or may not return a value, and it may or may not throw an 75 * exception. But any output should not be considered valid or sane. 76 * 77 * @param params The Bundle parameters, 78 * Keyed by the id from the ParamInfo. Execution may 79 * modify the map, so if you are going to be using the 80 * same map across multiple bundlers you should pass 81 * in a deep copy. 82 * @param outputParentDir 83 * The parent dir that the returned bundle will be placed in. 84 * @return The resulting bundled file 85 * 86 * For a bundler that produces a single artifact file this will be the 87 * location of that artifact (.exe file, .deb file, etc) 88 * 89 * For a bundler that produces a specific directory format output this will 90 * be the location of that specific directory (.app file, etc). 91 * 92 * For a bundler that produce multiple files, this will be a parent 93 * directory of those files (linux and windows images), whose name is not 94 * relevant to the result. 95 * 96 * @throws java.lang.IllegalArgumentException for any of the following 97 * reasons: 100 * example missing the main class.</li> 101 * <li>A parameter has the wrong type of an object, for example a 102 * String where a File is required</li> 103 * <li>Bundler specific incompatibilities with the parameters, for 104 * example a bad version number format or an application id with 105 * forward slashes.</li> 106 * </ul> 107 */ 108 public File execute(Map<String, ? super Object> params, 109 File outputParentDir) throws PackagerException; 110 111 /** 112 * Removes temporary files that are used for bundling. 113 */ 114 public void cleanup(Map<String, ? super Object> params); 115 116 /** 117 * Returns "true" if this bundler is supported on current platform. 118 */ 119 public boolean supported(boolean runtimeInstaller); 120 121 /** 122 * Returns "true" if this bundler is he default for the current platform. 123 */ 124 public boolean isDefault(); 125 } |