KickJava   Java API By Example, From Geeks To Geeks.

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


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 // Build
27
//import org.enhydra.ant.taskdefs.EJBClient;
28

29 // ToolBox
30
import org.enhydra.tool.common.ResUtil;
31 import org.enhydra.tool.archive.xml.EjbDescriptorHandler;
32
33 // JDK
34
import java.io.IOException JavaDoc;
35 import java.io.File JavaDoc;
36 import java.util.ResourceBundle JavaDoc;
37 import java.util.jar.Attributes JavaDoc;
38 import java.util.jar.Manifest JavaDoc;
39
40 //
41
public class EjbBuilder extends JarBuilder {
42
43     //
44
public EjbBuilder() {
45         super();
46     }
47
48     // override JarBuilder
49
protected Manifest JavaDoc buildManifest(Manifest JavaDoc m) {
50         Manifest JavaDoc manifest = super.buildManifest(m);
51         Boolean JavaDoc b = null;
52
53         b = new Boolean JavaDoc(getEjbPlan().isCreateClient());
54         manifest.getMainAttributes().put(new Attributes.Name JavaDoc(CREATE_CLIENT),
55                                          b.toString());
56         return manifest;
57     }
58
59
60     public EjbPlan getEjbPlan() {
61         EjbPlan ep = null;
62
63         if (getPlan() instanceof EjbPlan) {
64             ep = (EjbPlan) getPlan();
65         }
66         return ep;
67     }
68
69     public File JavaDoc buildArchive() throws ArchiveException {
70         File JavaDoc jar = null;
71         String JavaDoc root = null;
72         File JavaDoc[] files = new File JavaDoc[0];
73         Descriptor[] dd = new Descriptor[0];
74
75         jar = openJarStream(getEjbPlan().getArchivePath());
76         root = getEjbPlan().getClassRoot();
77         dd = getEjbPlan().getDescriptors();
78         files = getEjbPlan().getClassFileArray();
79         addJarClasses();
80         for (int i = 0; i < dd.length; i++) {
81             addDescriptor(dd[i], root, files);
82         }
83         closeJarStream();
84         if (getEjbPlan().isCreateClient()) {
85             createClient(jar.getAbsolutePath());
86         }
87         return jar;
88     }
89
90     private void createClient(String JavaDoc path) {
91         String JavaDoc[] args = new String JavaDoc[1];
92
93         args[0] = path;
94 // try {
95
// EJBClient.main(args);
96
// } catch(Exception e) {
97
// e.getMessage();
98
// }
99
}
100
101 }
102
Popular Tags