KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > archive > ArchiveTool


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  * Paul Mahar
22  *
23  */

24 package org.enhydra.tool.archive;
25
26 //
27
import org.enhydra.tool.archive.wizard.ArchiveWizard;
28 import org.enhydra.tool.common.PathHandle;
29
30 // Standard imports
31
import java.io.File JavaDoc;
32 import java.util.Properties JavaDoc;
33
34 //
35
public class ArchiveTool {
36
37     // not to be resourced
38
private final String JavaDoc NULL_PLAN = "Archive plan is null"; // nores
39

40     public ArchiveTool() {}
41
42     public File JavaDoc buildArchive(EarPlan plan) throws ArchiveException {
43         EarBuilder builder = null;
44         File JavaDoc file = null;
45
46         if (plan == null) {
47             throw new ArchiveException(NULL_PLAN);
48         }
49         builder = new EarBuilder();
50         builder.setPlan(plan);
51         file = builder.buildArchive();
52         return file;
53     }
54
55     public File JavaDoc buildArchive(EjbPlan plan) throws ArchiveException {
56         EjbBuilder builder = null;
57         File JavaDoc file = null;
58
59         if (plan == null) {
60             throw new ArchiveException(NULL_PLAN);
61         }
62         builder = new EjbBuilder();
63         builder.setPlan(plan);
64         file = builder.buildArchive();
65         return file;
66     }
67
68     public File JavaDoc buildArchive(WarPlan plan) throws ArchiveException {
69         WarBuilder builder = null;
70         File JavaDoc file = null;
71
72         if (plan == null) {
73             throw new ArchiveException(NULL_PLAN);
74         }
75         builder = new WarBuilder();
76         builder.setPlan(plan);
77         file = builder.buildArchive();
78         return file;
79     }
80
81     public File JavaDoc buildArchive(JarPlan plan) throws ArchiveException {
82         JarBuilder builder = null;
83         File JavaDoc file = null;
84
85         if (plan instanceof EjbPlan) {
86             file = buildArchive((EjbPlan) plan);
87         } else if (plan instanceof EarPlan) {
88             file = buildArchive((EarPlan) plan);
89         } else if (plan instanceof WarPlan) {
90             file = buildArchive((WarPlan) plan);
91         } else {
92             if (plan == null) {
93                 throw new ArchiveException(NULL_PLAN);
94             }
95             builder = new JarBuilder();
96             builder.setPlan(plan);
97             file = builder.buildArchive();
98         }
99         return file;
100     }
101
102     public static JarPlan runWizard(int i) {
103         ArchiveWizard handler = null;
104         JarPlan plan = null;
105
106         handler = new ArchiveWizard();
107         handler.showDialog(null);
108         plan = handler.getPlan();
109         handler = null;
110         return plan;
111
112     }
113     public static String JavaDoc runWizard() {
114         JarPlan plan = null;
115         String JavaDoc newArchive = null;
116         plan = ArchiveTool.runWizard(0);
117         if (plan != null) {
118             newArchive =
119                 PathHandle.createPathString(plan.getArchivePath());
120         }
121         return newArchive;
122     }
123
124 }
125
Popular Tags