KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > backend > DeployableObjectType


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * DeployableObjectType.java
26  *
27  * Created on December 11, 2001, 10:05 AM
28  */

29
30 package com.sun.enterprise.deployment.backend;
31
32 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
33 import com.sun.enterprise.deployment.util.XModuleType;
34 import java.io.*;
35 import java.util.*;
36 import java.util.jar.*;
37 import java.util.jar.Manifest JavaDoc;
38 import java.util.jar.Attributes JavaDoc;
39 import java.util.jar.Attributes.Name;
40 import java.util.zip.ZipEntry JavaDoc;
41 import com.sun.enterprise.util.io.FileUtils;
42 import com.sun.enterprise.util.i18n.StringManager;
43 import com.sun.enterprise.deployment.util.DeploymentProperties;
44
45 /**
46  *
47  * @author bnevins
48  * @version
49  */

50
51 public class DeployableObjectType
52 {
53     public boolean isEJB()
54     {
55         return this == EJB;
56     }
57     
58     ///////////////////////////////////////////////////////////////////////////
59

60     public boolean isWEB()
61     {
62         return this == WEB;
63     }
64     
65     ///////////////////////////////////////////////////////////////////////////
66

67     public boolean isAPP()
68     {
69         return this == APP;
70     }
71     
72     ///////////////////////////////////////////////////////////////////////////
73

74     public boolean isCONN()
75     {
76         return this == CONN;
77     }
78
79     ///////////////////////////////////////////////////////////////////////////
80

81     public boolean isCAR()
82     {
83         return this == CAR;
84     }
85     
86     public boolean isLCM()
87     {
88         return this == LCM;
89     }
90     
91     public boolean isCMB()
92     {
93         return this == CMB;
94     }
95     
96     ///////////////////////////////////////////////////////////////////////////
97

98     public String JavaDoc toString()
99     {
100         return name;
101     }
102     
103     ///////////////////////////////////////////////////////////////////////////
104

105     public ModuleType JavaDoc getModuleType()
106     {
107         return jsr88Type;
108     }
109     
110     ///////////////////////////////////////////////////////////////////////////
111

112     private DeployableObjectType(String JavaDoc theName,
113         String JavaDoc theDDName, String JavaDoc theRuntimeDD, String JavaDoc ext, ModuleType JavaDoc type) {
114
115         name = theName;
116         ddName = theDDName;
117         runtimeDD = theRuntimeDD;
118         extension = ext;
119         jsr88Type = type;
120         allTypes.add(this);
121    }
122     
123     ///////////////////////////////////////////////////////////////////////////
124

125     public static final DeployableObjectType APP;
126     public static final DeployableObjectType EJB;
127     public static final DeployableObjectType WEB;
128     public static final DeployableObjectType CONN;
129     public static final DeployableObjectType CAR;
130     public static final DeployableObjectType LCM;
131     public static final DeployableObjectType CMB;
132     private final String JavaDoc name;
133     private final String JavaDoc ddName;
134     private final String JavaDoc runtimeDD;
135     private final String JavaDoc extension;
136     private final ModuleType JavaDoc jsr88Type;
137     private static StringManager localStrings = StringManager.getManager(DeployableObjectType.class);
138     private static List allTypes;
139     
140     static {
141         allTypes = new ArrayList(7);
142         APP = new DeployableObjectType("Application",
143                                         "META-INF/application.xml",
144                                         "META-INF/sun-application.xml",
145                                         ".ear", ModuleType.EAR);
146  
147          WEB = new DeployableObjectType("Web Module",
148                                          "WEB-INF/web.xml",
149                                          "WEB-INF/sun-web.xml",
150                                          ".war", ModuleType.WAR);
151  
152          CONN = new DeployableObjectType("Connector Module",
153                                          "META-INF/ra.xml",
154                                          "META-INF/sun-ra.xml",
155                                          ".rar", ModuleType.RAR);
156  
157          CAR = new DeployableObjectType("AppClient Module",
158                                          "META-INF/application-client.xml",
159                                          "META-INF/sun-application-client.xml",
160                                          ".jar", ModuleType.CAR);
161
162          EJB = new DeployableObjectType("EJB Module",
163                                          "META-INF/ejb-jar.xml",
164                                          "META-INF/sun-ejb-jar.xml",
165                                          ".jar", ModuleType.EJB);
166  
167          LCM = new DeployableObjectType("Lifecycle Module",
168                                          null,
169                                          null,
170                                          ".jar", XModuleType.LCM);
171  
172          CMB = new DeployableObjectType("Custom MBean Module",
173                                          null,
174                                          null,
175                                          ".jar", XModuleType.CMB);
176  
177    }
178     
179     
180     ///////////////////////////////////////////////////////////////////////////
181

182     public static void main(String JavaDoc[] args)
183     {
184         String JavaDoc[] files = new String JavaDoc[] { "pkgingEApp.ear", "foof.rar", "hello.war", "foo.jar", "nothere", "junk.ear",
185             "ear", "ejb", "rar", "war"};
186         
187         for(int i = 0; i < files.length; i++)
188         {
189             File f = new File("C:/ias8samples/" + files[i]);
190             
191             try
192             {
193                 // used to display (f.getName() + " is a: " + valueOf(f));
194
}
195             catch (Exception JavaDoc ex)
196             {
197                 ex.printStackTrace();
198             }
199         }
200     }
201 }
202
Popular Tags