KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > appclient > StandAloneAppClientInfo


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 package com.sun.enterprise.appclient;
25
26 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException;
27 import com.sun.enterprise.deployment.ApplicationClientDescriptor;
28 import com.sun.enterprise.deployment.archivist.Archivist;
29 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
30 import com.sun.enterprise.deployment.deploy.shared.InputJarArchive;
31 import com.sun.enterprise.deployment.RootDeploymentDescriptor;
32 import com.sun.enterprise.deployment.util.AnnotationDetector;
33 import java.io.File JavaDoc;
34 import java.io.FileNotFoundException JavaDoc;
35 import java.io.IOException JavaDoc;
36 import java.net.MalformedURLException JavaDoc;
37 import java.net.URI JavaDoc;
38 import java.net.URISyntaxException JavaDoc;
39 import java.net.URL JavaDoc;
40 import java.util.jar.JarEntry JavaDoc;
41 import java.util.jar.JarFile JavaDoc;
42 import java.util.logging.Logger JavaDoc;
43 import org.xml.sax.SAXParseException JavaDoc;
44
45 /**
46  * Represents an app client that is in a stand-alone archive, not inside an
47  * enterprise app archive and not a .class file.
48  * @author tjquinn
49  */

50 public class StandAloneAppClientInfo extends AppClientInfo {
51     
52     public StandAloneAppClientInfo(
53             boolean isJWS, Logger JavaDoc logger, File JavaDoc archive,
54             Archivist archivist, String JavaDoc mainClassFromCommandLine)
55         throws IOException JavaDoc, ClassNotFoundException JavaDoc,
56                URISyntaxException JavaDoc, SAXParseException JavaDoc {
57         super(isJWS, logger, archive, archivist, mainClassFromCommandLine);
58     }
59
60     protected AbstractArchive expand(File JavaDoc file)
61         throws IOException JavaDoc, Exception JavaDoc {
62         InputJarArchive appArchive = new InputJarArchive ();
63         appArchive.open(file.getAbsolutePath());
64         return appArchive;
65     }
66
67     protected boolean deleteAppClientDir() {
68         return false;
69     }
70
71     protected void messageDescriptor(RootDeploymentDescriptor d,
72         Archivist archivist, AbstractArchive archive)
73             throws IOException JavaDoc, AnnotationProcessorException {
74         ApplicationClientDescriptor appClient = (ApplicationClientDescriptor)d;
75         appClient.getModuleDescriptor().setStandalone(true);
76     }
77
78     protected boolean classContainsAnnotation(
79             String JavaDoc entry, AnnotationDetector detector,
80             AbstractArchive archive, ApplicationClientDescriptor descriptor)
81             throws FileNotFoundException JavaDoc, IOException JavaDoc {
82         JarFile JavaDoc jar = null;
83         try {
84             jar = new JarFile JavaDoc(archive.getArchiveUri());
85             JarEntry JavaDoc mainClassEntry = jar.getJarEntry(entry);
86             return detector.containsAnnotation(jar, mainClassEntry);
87         } catch (Throwable JavaDoc thr) {
88             throw new RuntimeException JavaDoc(localStrings.getString(
89                 "appclient.errorCheckingAnnos"), thr);
90         } finally {
91             if (jar != null) {
92                 try {
93                     jar.close();
94                 } catch (IOException JavaDoc ioe) {
95                     throw new RuntimeException JavaDoc(localStrings.getString(
96                         "appclient.errorClosingJar", archive.getArchiveUri()), ioe);
97                 }
98             }
99         }
100     }
101 }
102
Popular Tags