KickJava   Java API By Example, From Geeks To Geeks.

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


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.deployment.backend;
25
26 import java.util.logging.Level JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.List JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.io.IOException JavaDoc;
31 import com.sun.enterprise.deployment.Application;
32 import com.sun.enterprise.deployment.RootDeploymentDescriptor;
33 import com.sun.enterprise.deployment.ApplicationClientDescriptor;
34 import com.sun.enterprise.util.zip.ZipFileException;
35 import com.sun.enterprise.util.zip.ZipItem;
36 import com.sun.enterprise.util.io.FileUtils;
37 import com.sun.enterprise.instance.InstanceEnvironment;
38 import com.sun.enterprise.instance.ModuleEnvironment;
39 import com.sun.enterprise.instance.BaseManager;
40 import com.sun.enterprise.config.ConfigException;
41 import com.sun.enterprise.instance.AppclientModulesManager;
42 import com.sun.enterprise.util.StringUtils;
43 import com.sun.enterprise.util.i18n.StringManager;
44 import com.sun.enterprise.deployment.archivist.*;
45 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
46 import com.sun.enterprise.loader.EJBClassPathUtils;
47 import com.sun.enterprise.deployment.phasing.DeploymentServiceUtils;
48
49 public class AppClientModuleDeployer extends ModuleDeployer
50 {
51     AppClientModuleDeployer(DeploymentRequest r) throws IASDeploymentException
52     {
53     super(r);
54     }
55     
56     ///////////////////////////////////////////////////////////////////////////
57

58     protected BaseManager createConfigManager(InstanceEnvironment ienv, ModuleEnvironment menv)
59     throws IASDeploymentException, ConfigException
60     {
61     return new AppclientModulesManager(ienv);
62     }
63     
64     ///////////////////////////////////////////////////////////////////////////
65

66     protected void preDeploy() throws IASDeploymentException
67     {
68     assert moduleDir != null;
69     assert StringUtils.ok(moduleName);
70     
71     try
72     {
73         if(isRegistered()) {
74         String JavaDoc msg = localStrings.getString(
75         "enterprise.deployment.backend.deploy_error_module_exists");
76         throw new IASDeploymentException( msg );
77         }
78         
79         // if the directories already exist on disk -- wipe them out
80
// We do this because otherwise they'd never get this Module deployed
81
// without wiping the dirs manually
82
liquidateModuleDirAndStubsDirIfTheyHappenToExist();
83         
84         if(request.isArchive()) {
85         J2EEModuleExploder.explodeJar(request.getFileSource().getFile(), moduleDir);
86         }
87
88         xmlDir.mkdirs();
89         jwsDir.mkdirs();
90     }
91     catch(Exception JavaDoc e)
92     {
93         throw new IASDeploymentException(e.toString(), e);
94     }
95     }
96     
97     protected boolean needsStubs()
98     {
99     // override this for any module that needs stubs created
100
return true;
101     }
102     
103     ///////////////////////////////////////////////////////////////////////////
104

105     protected void preRedeploy() throws IASDeploymentException, ConfigException
106     {
107     setOldDirs();
108     
109     if(request.isArchive())
110     {
111         try
112         {
113         J2EEModuleExploder.explodeJar(request.getFileSource().getFile(), moduleDir);
114         
115         }
116         catch(IOException JavaDoc e)
117         {
118         throw new IASDeploymentException(e.toString(), e);
119         }
120     }
121
122         xmlDir.mkdir();
123         jwsDir.mkdirs();
124     }
125     
126     ///////////////////////////////////////////////////////////////////////////
127

128     protected void deploy() throws IASDeploymentException, ConfigException
129     {
130         loadDescriptors();
131         runVerifier();
132         checkAppclientsMainClasses();
133         xmlDir.mkdirs();
134         // Set the generated XML directory in application desc
135
request.getDescriptor().setGeneratedXMLDirectory(xmlDir.getAbsolutePath());
136     ZipItem[] clientStubs = runEJBC();
137     createClientJar(clientStubs);
138     }
139     
140     
141     ///////////////////////////////////////////////////////////////////////////
142

143
144     
145     private static StringManager localStrings =
146     StringManager.getManager( AppClientModuleDeployer.class );
147 }
148
149
Popular Tags