KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > DeploymentContext


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 package com.sun.enterprise.deployment;
24
25 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
26 import com.sun.enterprise.util.Utility;
27 import com.sun.logging.*;
28
29 import java.io.*;
30 import java.util.logging.*;
31
32 /**
33  * The class contains all the information relative to a particular deployment
34  * Its lifetime isl imited to the actual deployment process.
35  *
36  * @author Jerome Dochez
37  * @version
38  */

39 public class DeploymentContext extends java.lang.Object JavaDoc {
40
41     /**
42      * the application descriptor we are deploying
43      */

44     private Application application;
45     
46     /**
47      * Archive abstraction of the deployable application
48      */

49     private AbstractArchive archive=null;
50     
51     /**
52      * Temporary directory used to generating the implementation classes
53      */

54     private File appTmpDir=null;
55     
56
57     static Logger _logger = LogDomains.getLogger(LogDomains.DPL_LOGGER);
58     
59     /**
60      * Creates new DeploymentContext
61      *
62      * @param application descriptor to be deployed
63      */

64     public DeploymentContext(AbstractArchive archive, Application application) {
65         this.application = application;
66         this.archive = archive;
67     }
68
69     /**
70      * @return the Application object we are deploying
71      */

72     public Application getApplication() {
73         return application;
74     }
75     
76     /**
77      * @return the archive abstraction used to represent the application
78      * bunlde being deployed
79      */

80     public AbstractArchive getArchive() {
81         return archive;
82     }
83     
84     /**
85      * @return the tmp output directory used to generate files that will be
86      * added later to the cooked archive file
87      */

88     public File getOutputDirectory() {
89         return new File(archive.getArchiveUri());
90     }
91     
92     /**
93      * @return the source directory where the content of this deployment has
94      * been saved in
95      */

96     public File getSourceDirectory() {
97         return new File(archive.getArchiveUri());
98     }
99     
100     /**
101      * @return the class loader that should be used for loading classes during
102      * deployment
103      */

104     public ClassLoader JavaDoc getClassLoader() {
105         return application.getClassLoader();
106     }
107        
108     /**
109      * delete all content of a given directory
110      */

111     public static void deleteDirectory(File dir) {
112     File[] files = dir.listFiles();
113     if (files != null) {
114         for(int i=0; i < files.length; ++i) {
115         File child = files[i];
116         if(child.isDirectory()) {
117             deleteDirectory(child);
118         }
119         child.delete();
120         }
121     }
122     dir.delete();
123     }
124     
125 }
126
Popular Tags