KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ConnectorModuleDeployer.java
26  *
27  * Created on January 15, 2002, 3:37 PM
28  *
29  * @author bnevins
30  * <BR> <I>$Source: /cvs/glassfish/appserv-core/src/java/com/sun/enterprise/deployment/backend/ConnectorModuleDeployer.java,v $
31  *
32  */

33
34 package com.sun.enterprise.deployment.backend;
35
36 import java.io.IOException JavaDoc;
37 import java.io.File JavaDoc;
38 import java.util.logging.Level JavaDoc;
39 import java.util.Iterator JavaDoc;
40 import java.util.List JavaDoc;
41 import java.util.ArrayList JavaDoc;
42 import com.sun.enterprise.config.ConfigException;
43 import com.sun.enterprise.config.serverbeans.ConnectorModule;
44 import com.sun.enterprise.deployment.Application;
45 import com.sun.enterprise.deployment.archivist.Archivist;
46 import com.sun.enterprise.deployment.ConnectorDescriptor;
47 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
48 import com.sun.enterprise.deployment.deploy.shared.FileArchive;
49 import com.sun.enterprise.deployment.RootDeploymentDescriptor;
50 import com.sun.enterprise.instance.BaseManager;
51 import com.sun.enterprise.instance.ConnectorModulesManager;
52 import com.sun.enterprise.instance.InstanceEnvironment;
53 import com.sun.enterprise.instance.ModuleEnvironment;
54 import com.sun.enterprise.util.i18n.StringManager;
55 import com.sun.enterprise.util.io.FileUtils;
56 import com.sun.enterprise.util.StringUtils;
57 import com.sun.enterprise.util.zip.ZipFileException;
58
59 public class ConnectorModuleDeployer extends ModuleDeployer
60 {
61     ConnectorModuleDeployer(DeploymentRequest r) throws IASDeploymentException
62     {
63         super(r);
64     }
65
66     ///////////////////////////////////////////////////////////////////////////
67

68     protected BaseManager createConfigManager(InstanceEnvironment ienv, ModuleEnvironment menv)
69             throws IASDeploymentException, ConfigException
70     {
71         connModulesMgr = new ConnectorModulesManager(ienv);
72         return connModulesMgr;
73     }
74     
75         /**
76      * @return the module classpath
77      */

78     protected List JavaDoc getModuleClasspath(Archivist archivist,
79                 AbstractArchive archive) throws IASDeploymentException {
80         
81         return new ArrayList JavaDoc();
82     }
83     
84     ///////////////////////////////////////////////////////////////////////////
85

86     protected void preDeploy() throws IASDeploymentException
87     {
88         assert moduleDir != null;
89         assert StringUtils.ok(moduleName);
90
91         try
92         {
93             if(isRegistered()) {
94                 String JavaDoc msg = localStrings.getString(
95                     "enterprise.deployment.backend.deploy_error_module_exists");
96                 throw new IASDeploymentException( msg );
97             }
98
99             // if the directories already exist on disk -- wipe them out
100
// We do this because otherwise they'd never get this Module deployed
101
// without wiping the dirs manually
102
liquidateModuleDirAndStubsDirIfTheyHappenToExist();
103             
104             if(request.isArchive())
105             {
106                 J2EEModuleExploder.explode(request.getFileSource().getFile(), moduleDir, moduleName);
107             }
108                         xmlDir.mkdirs();
109         }
110         catch(Exception JavaDoc e)
111         {
112             throw new IASDeploymentException(e.toString(), e);
113         }
114     }
115     
116     ///////////////////////////////////////////////////////////////////////////
117

118     protected void preRedeploy() throws IASDeploymentException, ConfigException
119     {
120         setOldDirs();
121
122         if(request.isArchive())
123                 {
124                     try
125             {
126                 J2EEModuleExploder.explode(request.getFileSource().getFile(), moduleDir, moduleName);
127
128             }
129             catch(IOException JavaDoc e)
130             {
131                 throw new IASDeploymentException(e.toString(), e);
132             }
133         }
134         
135                 xmlDir.mkdirs();
136     }
137     
138     ///////////////////////////////////////////////////////////////////////////
139

140     protected void deploy() throws IASDeploymentException, ConfigException
141     {
142             runVerifier();
143
144             try {
145                 // copy xml files to generated/xml directory
146
// this work around should be removed once connector team
147
// provide a unified way to copy necessary files to
148
// generated/xml directroy.
149
String JavaDoc appDir =
150                     request.getDeployedDirectory().getCanonicalPath();
151             String JavaDoc generatedXMLDir =
152                     request.getGeneratedXMLDirectory().getCanonicalPath();
153
154             FileArchive srcArchive = new FileArchive();
155             srcArchive.open(appDir);
156             
157                 FileArchive destArchive = new FileArchive();
158             destArchive.open(generatedXMLDir);
159
160                 Archivist.copyExtraElements(srcArchive, destArchive);
161         } catch (Exception JavaDoc e) {
162                 throw new IASDeploymentException(e.getCause());
163             }
164         }
165         // END OF IASRI 4686190
166

167     private ConnectorModulesManager connModulesMgr = null;
168     private static StringManager localStrings = StringManager.getManager(ConnectorModuleDeployer.class);
169 }
170
171
Popular Tags