KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > client > DeployAction


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.client;
25
26 import com.sun.appserv.management.base.AMX;
27 import com.sun.appserv.management.client.AppserverConnectionSource;
28 import com.sun.appserv.management.client.ConnectionSource;
29 import com.sun.appserv.management.client.ProxyFactory;
30 import com.sun.appserv.management.deploy.DeploymentMgr;
31 import com.sun.appserv.management.deploy.DeploymentProgress;
32 import com.sun.appserv.management.deploy.DeploymentProgressImpl;
33 import com.sun.appserv.management.deploy.DeploymentSourceImpl;
34 import com.sun.appserv.management.deploy.DeploymentSupport;
35 import com.sun.enterprise.deployapi.ProgressObjectImpl;
36 import com.sun.enterprise.deployapi.SunTarget;
37 import com.sun.enterprise.deployment.backend.DeploymentStatus;
38 import com.sun.enterprise.deployment.deploy.shared.Archive;
39 import com.sun.enterprise.deployment.deploy.shared.MemoryMappedArchive;
40 import com.sun.enterprise.deployment.util.DeploymentProperties;
41 import com.sun.enterprise.deployment.util.FileUploadUtil;
42 import com.sun.logging.LogDomains;
43 import com.sun.enterprise.util.i18n.StringManager;
44
45 import java.io.BufferedInputStream JavaDoc;
46 import java.io.ByteArrayInputStream JavaDoc;
47 import java.io.EOFException JavaDoc;
48 import java.io.File JavaDoc;
49 import java.io.FileInputStream JavaDoc;
50 import java.io.IOException JavaDoc;
51 import java.net.URI JavaDoc;
52 import java.net.InetAddress JavaDoc;
53 import java.net.UnknownHostException JavaDoc;
54 import java.util.HashMap JavaDoc;
55 import java.util.Map JavaDoc;
56 import java.util.Set JavaDoc;
57 import java.util.logging.*;
58
59 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
60 import javax.enterprise.deploy.shared.StateType JavaDoc;
61 import javax.enterprise.deploy.spi.Target JavaDoc;
62 import javax.management.Notification JavaDoc;
63
64 public class DeployAction extends ProgressObjectImpl {
65
66     private DeploymentMgr deplMgr = null;
67     private static int SLEEP_TIME = 100;
68     private static long TIMEOUT_LOOPS = 1000000000 / SLEEP_TIME;
69
70     // if this system property is set, it will use jmx upload mechanism
71
// with the specified chunk size
72
private static String JavaDoc JMX_UPLOAD_CHUNK_SIZE = "jmx.upload.chunk.size";
73     // if this system property is set, it will use jmx upload mechanism
74
private static String JavaDoc HTTP_PROXYHOST = "http.proxyHost";
75
76     private String JavaDoc jmxUploadChunkSizeProp =
77         System.getProperty(JMX_UPLOAD_CHUNK_SIZE);
78
79     private String JavaDoc httpProxyHostProp = System.getProperty(HTTP_PROXYHOST);
80
81     private static StringManager localStrings = StringManager.getManager(DeployAction.class);
82     private static Logger _logger =
83         LogDomains.getLogger(LogDomains.DPL_LOGGER);
84     
85     public DeployAction(SunTarget[] targets) {
86         super(targets);
87     }
88
89     /*
90      * Uploads an archive using deploymentMgrMBean
91      */

92     private Object JavaDoc uploadArchive(Archive module) throws IOException JavaDoc {
93
94         long totalSize = module.getArchiveSize();
95         int chunkSize = 32 * 1024;
96         if (jmxUploadChunkSizeProp != null &&
97             jmxUploadChunkSizeProp.length() > 0) {
98             chunkSize = Integer.parseInt(jmxUploadChunkSizeProp);
99         }
100         Object JavaDoc uploadID = null;
101         long remaining = totalSize;
102         BufferedInputStream JavaDoc bis = null;
103         try {
104             String JavaDoc name = getArchiveName(module);
105             if (module instanceof MemoryMappedArchive) {
106                 //i.e. module.getArchiveUri() == null
107
byte[] bytes = ((MemoryMappedArchive) module).getByteArray();
108                 bis = new BufferedInputStream JavaDoc(new ByteArrayInputStream JavaDoc(bytes));
109             } else {
110                 bis = new BufferedInputStream JavaDoc(new FileInputStream JavaDoc(new File JavaDoc(module.getURI().getPath())));
111             }
112             uploadID = deplMgr.initiateFileUpload(name, totalSize);
113             while(remaining != 0) {
114                 int actual = (remaining < chunkSize) ? (int) remaining : chunkSize;
115                 byte[] bytes = new byte[actual];
116                 try {
117                     bis.read(bytes);
118                 } catch (EOFException JavaDoc eof) {
119                     break;
120                 }
121                 _logger.log(Level.FINE, "Uploading one chunk...");
122                 deplMgr.uploadBytes(uploadID, bytes);
123                 remaining -= actual;
124             }
125         } finally {
126             if(bis!=null) {
127                 bis.close();
128             }
129         }
130         return uploadID;
131     }
132
133     // upload an archive using UploadServlet
134
private String JavaDoc uploadArchiveOverHTTP(ServerConnectionIdentifier serverId,
135         Archive module) throws Exception JavaDoc {
136         return FileUploadUtil.uploadToServlet(serverId.getHostName(),
137             Integer.toString(serverId.getHostPort()), serverId.getUserName(),
138             serverId.getPassword(), module);
139     }
140
141     public void run() {
142         ConnectionSource dasConnection= (ConnectionSource) args[0];
143         Archive deployArchive = (Archive) args[1];
144         Archive deployPlan = (Archive) args[2];
145         Map JavaDoc deployOptions = (Map JavaDoc) args[3];
146         SunTarget[] targetList = (SunTarget[]) args[4];
147         SunTarget domain = (SunTarget) args[5];
148         boolean isLocalConnectionSource = ((Boolean JavaDoc) args[6]).booleanValue();
149         ServerConnectionIdentifier serverId =
150             (ServerConnectionIdentifier) args[7];
151         Object JavaDoc archiveUploadID = null;
152         Object JavaDoc planUploadID = null;
153         Map JavaDoc deployedTargets = null;
154         Object JavaDoc deployActionID = null;
155         boolean isDirectoryDeploy = false;
156         boolean isRedeploy = false;
157
158         //Make sure the file permission is correct when deploying a file
159
//Note that if using JSR88 deploying from InputStream, the
160
//deployArchive.getArchiveUri() would be null, and not directory
161
//deploy
162
if (deployArchive == null) {
163             setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.archive_not_specified"), domain);
164             return;
165         }
166         if (deployArchive.getURI() != null) {
167             
168             File JavaDoc tmpFile = new File JavaDoc(deployArchive.getURI().getPath());
169             if(!tmpFile.exists()) {
170                 setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.archive_not_in_location"), domain);
171                 return;
172             }
173             if(!tmpFile.canRead()) {
174                 setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.archive_no_read_permission"), domain);
175                 return;
176             }
177             if (tmpFile.isDirectory()) {
178                 isDirectoryDeploy = true;
179             }
180         }
181         
182         try {
183             // Get the module ID
184
this.moduleID = (String JavaDoc)deployOptions.get(DeploymentProperties.DEPLOY_OPTION_NAME_KEY);
185             
186             // for redeploy, force should be true - enforce it here it self
187
if(("false".equals(deployOptions.get(DeploymentProperties.DEPLOY_OPTION_FORCE_KEY))) &&
188                (isModuleDeployed(dasConnection, moduleID)) ) {
189                 setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.deploy_error_module_exists"), domain);
190                 return;
191             }
192
193             deplMgr = ProxyFactory.getInstance(dasConnection).getDomainRoot().getDeploymentMgr();
194             
195             /**
196              * If there is only one target and that target is a stand alone server target, set WSDL_TARGET_HINT
197              * in options to enable WSDL generation with the target's host and port. Refer to bug 6157923 for more info
198              */

199             if( (targetList.length == 1) && (TargetType.STAND_ALONE_SERVER.equals(targetList[0].getTargetType())) && !("server".equals(targetList[0].getName())) ) {
200                 deployOptions.put(DeploymentProperties.WSDL_TARGET_HINT, targetList[0].getName());
201             }
202
203             // Do redeploy if force=true and the module is already deployed
204
if( ("true".equals(deployOptions.get(DeploymentProperties.DEPLOY_OPTION_FORCE_KEY))) &&
205                 (isModuleDeployed(dasConnection, moduleID)) ) {
206                 isRedeploy = true;
207
208                 // Get list of all targets on which this module is already deployed
209
deployedTargets = DeploymentClientUtils.getDeployedTargetList(dasConnection, moduleID);
210               
211                 // Check if any of the specified targets is not part of the deployed target list
212
// If so, it means user has to use create-app-ref and not redeploy; flag error
213
if(DeploymentClientUtils.isNewTarget(deployedTargets, targetList)) {
214                     setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.useCreateAppRef",
215                                         moduleID), domain);
216                 }
217                 
218                 // if there is already app ref associated with this app
219
if (deployedTargets.size() > 0) {
220                     // if it's redeploy to domain, then it's equivalent
221
// to redeploy to all targets
222
if ((TargetType.DOMAIN.equals(targetList[0].getName()))) {
223                         DeploymentFacility deploymentFacility;
224                         if(isLocalConnectionSource) {
225                             deploymentFacility = DeploymentFacilityFactory.getLocalDeploymentFacility();
226                         } else {
227                             deploymentFacility = DeploymentFacilityFactory.getDeploymentFacility();
228                         }
229                         deploymentFacility.connect(
230                             targetList[0].getConnectionInfo());
231                         Set JavaDoc nameSet = deployedTargets.keySet();
232                         String JavaDoc[] targetNames = (String JavaDoc[])nameSet.toArray(
233                             new String JavaDoc[nameSet.size()]);
234                         Target[] targetList2 =
235                             deploymentFacility.createTargets(targetNames);
236                         if (targetList2 == null) {
237                             setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.createTargetsFailed"), domain);
238                             return;
239                         }
240                         targetList = new SunTarget[targetList2.length];
241                         for (int ii = 0; ii < targetList2.length; ii++) {
242                             targetList[ii] = (SunTarget)targetList2[ii];
243                         }
244                     }
245                     // if all targets on which the app is deployed is not
246
// given, return error
247
else if (!DeploymentClientUtils.isTargetListComplete(
248                         deployedTargets, targetList)) {
249                         setupForAbnormalExit(
250                            localStrings.getString("enterprise.deployment.client.specifyAllTargets", moduleID, "redeploy"),
251                            domain);
252                         return;
253                     }
254
255                     // Stop all apps;
256
Map JavaDoc options = new HashMap JavaDoc();
257                     options.putAll(deployOptions);
258                     RollBackAction undeplRollback = new RollBackAction(RollBackAction.DELETE_APP_REF_OPERATION,
259                                                                 moduleID, deployOptions);
260                     for(int i=0; i<targetList.length; i++) {
261                         options.put(DeploymentProperties.DEPLOY_OPTION_CASCADE_KEY, "true");
262
263                         // We dont rollback for stop failure because the failure may be because of server being down
264
// We just add DeploymentStatus of this phase to the complete DeploymentStatus
265

266                         DeploymentClientUtils.setResourceOptions(
267                             options,
268                             DeploymentProperties.RES_UNDEPLOYMENT,
269                             targetList[i].getName());
270                         DeploymentStatus stat =
271                             DeploymentClientUtils.stopApplication(
272                                 dasConnection.getExistingMBeanServerConnection(),
273                                 moduleID, targetList[i], options);
274                         checkStatusAndAddStage(targetList[i], null, localStrings.getString("enterprise.deployment.client.redeploy_stop", targetList[i].getName()) , dasConnection, stat);
275                         
276                         // del-app-ref from all targets
277
options.put(DeploymentProperties.DEPLOY_OPTION_CASCADE_KEY, "false");
278                         stat = DeploymentClientUtils.deleteApplicationReference(
279                                 dasConnection.getExistingMBeanServerConnection(),
280                                 moduleID, targetList[i], options);
281                         if(!checkStatusAndAddStage(targetList[i], undeplRollback, localStrings.getString("enterprise.deployment.client.redeploy_remove_ref", targetList[i].getName()), dasConnection, stat)) {
282                             return;
283                         }
284                         undeplRollback.addTarget(targetList[i], RollBackAction.APP_REF_DELETED);
285                     }
286                 }
287             }
288
289             // Get a deploy ID
290
deployActionID = deplMgr.initDeploy();
291             
292             // Make a copy of deployOptions and set the ENABLE flag in this copy to true
293
// This is so that the enabled flag during deploy-to-domain is always true
294
// This might need to be replaced with an efficient logic to look up the current enabled flag
295
// using AMX
296
Map JavaDoc dupOptions = new HashMap JavaDoc();
297             dupOptions.putAll(deployOptions);
298             dupOptions.put(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY, Boolean.TRUE.toString());
299      
300             // if deploy to "domain" or redeploy to "domain" with no
301
// existing application-ref
302
if ((TargetType.DOMAIN.equals(targetList[0].getName()))) {
303                 if (isRedeploy) {
304                     DeploymentClientUtils.setResourceOptions(
305                         dupOptions,
306                         DeploymentProperties.RES_REDEPLOYMENT,
307                         targetList);
308                 } else {
309                     DeploymentClientUtils.setResourceOptions(
310                         dupOptions,
311                         DeploymentProperties.RES_DEPLOYMENT,
312                         targetList);
313                 }
314             } else {
315                 DeploymentClientUtils.setResourceOptions(
316                     dupOptions,
317                     DeploymentProperties.RES_NO_OP,
318                     targetList);
319             }
320             
321             // Now start a fresh deploy in domain
322
// upload file only if this not a directory deploy AND it is not a local connection source (not from gui)
323
if(!isDirectoryDeploy && !isLocalConnectionSource) {
324                 // upload the archive
325

326                 long startTime = System.currentTimeMillis();
327                 long endTime = startTime;
328
329                 // we use jmx upload for following scenarios:
330
// 1. for secure connection: https
331
// 2. if the JMX_UPLOAD_CHUNK_SIZE system property is set
332
// 3. if the HTTP_PROXYHOST system property is set
333
if ( serverId.isSecure() ||
334                      (jmxUploadChunkSizeProp != null &&
335                       jmxUploadChunkSizeProp.length() > 0) ||
336                      (httpProxyHostProp != null &&
337                       httpProxyHostProp.length() > 0) ){
338                     // using jmx
339
archiveUploadID = uploadArchive(deployArchive);
340                     
341                     // If there is a plan, upload the plan
342
if (deployPlan != null){
343                         if (deployPlan.getURI()!=null) {
344                             File JavaDoc f = new File JavaDoc(deployPlan.getURI().getPath());
345                             if (f.length()!= 0) {
346                                 planUploadID = uploadArchive(deployPlan);
347                             }
348                         }
349                     }
350
351                     endTime = System.currentTimeMillis();
352
353                     // Call DeploymentMgr to start deploy
354
deplMgr.startDeploy(deployActionID, archiveUploadID, planUploadID, dupOptions);
355                 } else {
356                     // using http
357
String JavaDoc archivePath = uploadArchiveOverHTTP(serverId,
358                         deployArchive);
359                     DeploymentSourceImpl archiveSource =
360                         new DeploymentSourceImpl(archivePath, true,
361                             new String JavaDoc[1], new String JavaDoc[1], new String JavaDoc[1],
362                             new HashMap JavaDoc());
363
364                     String JavaDoc planPath = null;
365                     DeploymentSourceImpl planSource = null;
366
367                     // If there is a plan, upload the plan
368
if (deployPlan != null){
369                         if (deployPlan.getURI()!=null){
370                             File JavaDoc f = new File JavaDoc(deployPlan.getURI().getPath());
371                             if (f.length()!= 0) {
372                                 planPath = uploadArchiveOverHTTP(serverId, deployPlan);
373                                 planSource =
374                                     new DeploymentSourceImpl(planPath, true,
375                                     new String JavaDoc[1], new String JavaDoc[1], new String JavaDoc[1],
376                                     new HashMap JavaDoc());
377                             }
378                         }
379                     }
380
381                     endTime = System.currentTimeMillis();
382
383                     deplMgr.startDeploy(deployActionID, archiveSource.asMap(),
384                         planSource == null ? null : planSource.asMap(),
385                         dupOptions);
386                 }
387                 _logger.log(Level.FINE,
388                     "time in upload: " + (endTime-startTime));
389             } else {
390                 // Directory deploy is supported only on DAS - check that here
391
if((isDirectoryDeploy) && (!isDomainLocal(domain))) {
392                     setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.domainNotLocal"),
393                         domain);
394                     return;
395                 }
396                 DeploymentSourceImpl archive = new DeploymentSourceImpl(deployArchive.getURI().getPath(), true,
397                                                     new String JavaDoc[1], new String JavaDoc[1], new String JavaDoc[1], new HashMap JavaDoc());
398                 // we do not support deployment plan for directory deployment
399
// currently
400
deplMgr.startDeploy(deployActionID, archive.asMap(), null, dupOptions);
401             }
402
403             // if deployActionID is still null, then there is some failure - report this and die
404
if(deployActionID == null) {
405                 setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.no_deployment_id"), domain);
406                 return;
407             }
408
409             // Wait till deploy is over
410
boolean done = false;
411             int waitLoopCount = 0;
412             com.sun.appserv.management.deploy.DeploymentStatus finalStatusFromMBean = null;
413             do {
414                 Notification JavaDoc[] notifs = deplMgr.takeNotifications(deployActionID);
415                 for(int i=0; i<notifs.length; i++) {
416                     Map JavaDoc notifType = (Map JavaDoc) notifs[i].getUserData();
417                     if(notifType.get(deplMgr.NOTIF_DEPLOYMENT_COMPLETED_STATUS_KEY) != null) {
418                         finalStatusFromMBean =
419                             DeploymentSupport.mapToDeploymentStatus((Map JavaDoc)deplMgr.getFinalDeploymentStatus(deployActionID));
420                         done = true;
421                     } else if(notifType.get(deplMgr.NOTIF_DEPLOYMENT_PROGRESS_KEY) != null) {
422                         DeploymentProgress prog = DeploymentSupport.mapToDeploymentProgress((Map JavaDoc)notifType.get(deplMgr.NOTIF_DEPLOYMENT_PROGRESS_KEY));
423                         String JavaDoc progStr = prog.getDescription() + " : " + prog.getProgressPercent() + "%";
424                         fireProgressEvent(StateType.RUNNING, progStr, domain);
425                     }
426                 }
427                 if(!done) {
428                     if(waitLoopCount > TIMEOUT_LOOPS) {
429                         setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.deployment_time_out"), domain);
430                         return;
431                     }
432                     try {
433                         Thread.sleep(SLEEP_TIME);
434                     } catch(InterruptedException JavaDoc e) {
435                         //Swallowing this exception deliberately; we dont want to do anything but wait
436
}
437                 }
438                 waitLoopCount++;
439             } while(!done);
440
441             DeploymentStatus tmp = DeploymentClientUtils.getDeploymentStatusFromAdminStatus(finalStatusFromMBean);
442
443             if(!checkStatusAndAddStage(
444                 domain, null,
445                 localStrings.getString("enterprise.deployment.client.deploy_in_domain"),
446                 dasConnection, tmp)) {
447                 return;
448             }
449
450             //Take the one returned from the server
451
if (moduleID == null) {
452                 moduleID = tmp.getProperty(DeploymentStatus.MODULE_ID);
453             }
454
455             String JavaDoc key = moduleID + DeploymentStatus.KEY_SEPARATOR + DeploymentStatus.MODULE_TYPE;
456             this.moduleType = ModuleType.getModuleType(
457                                 (new Integer JavaDoc(tmp.getProperty(key))).intValue());
458
459             // Start keeping track of actions to be rolled back
460
RollBackAction rollback = new RollBackAction(RollBackAction.DEPLOY_OPERATION, moduleID, deployOptions);
461
462             // Deploy is done; create app ref if target[0] was not a domain
463
if(!(TargetType.DOMAIN.equals(targetList[0].getName()))) {
464                 for(int i=0; i<targetList.length; i++) {
465                     
466                     // If this is a redeploy, set enable flag of options as per state of the app before redeploy
467
if(deployedTargets != null) {
468                         dupOptions.put(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY, deployedTargets.get(targetList[i].getName()).toString());
469                     } else {
470                         dupOptions.put(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY, deployOptions.get(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY));
471                     }
472                     DeploymentStatus stat =
473                         DeploymentClientUtils.createApplicationReference(
474                             dasConnection.getExistingMBeanServerConnection(),
475                             moduleID, targetList[i], dupOptions);
476                     if(!checkStatusAndAddStage(targetList[i], rollback,
477                        localStrings.getString("enterprise.deployment.client.deploy_create_ref", targetList[i].getName()), dasConnection, stat)) {
478                         return;
479                     }
480                     rollback.addTarget(targetList[i], rollback.APP_REF_CREATED);
481
482                     // Start the apps only if enable is true; if this is a redeploy, then check what was the
483
// state before redeploy
484
/*
485                       XXX Start the application regardless the value of "enable"
486                       Otherwise no DeployEvent would be sent to the listeners on
487                       a remote instance, which would in turn synchronize the app
488                       bits. Note that the synchronization is only called during
489                       applicationDeployed, not applicationEnabled. To make sure
490                       the deployment code can work with both the new and the old
491                       mbeans, we will call the start for now (as the old mbeans
492                       would do). The backend listeners are already enhanced to
493                       make sure the apps are not actually loaded unless the enable
494                       attributes are true for both the application and
495                       application-ref elements.
496                     */

497                     if ((deployedTargets != null) &&
498                          (Boolean.FALSE.equals(deployedTargets.get(targetList[i].getName())))) {
499                              continue;
500                     }
501                     
502                     // We dont rollback for start failure because start failure may be because of server being down
503
// We just add DeploymentStatus of this phase to the complete DeploymentStatus
504

505                     if (isRedeploy) {
506                         DeploymentClientUtils.setResourceOptions(
507                             deployOptions,
508                             DeploymentProperties.RES_REDEPLOYMENT,
509                             targetList[i].getName());
510                     } else {
511                         DeploymentClientUtils.setResourceOptions(
512                             deployOptions,
513                             DeploymentProperties.RES_DEPLOYMENT,
514                             targetList[i].getName());
515                     }
516
517                     stat = DeploymentClientUtils.startApplication(
518                             dasConnection.getExistingMBeanServerConnection(),
519                             moduleID, targetList[i], deployOptions);
520                     checkStatusAndAddStage(targetList[i], null,
521                         localStrings.getString("enterprise.deployment.client.deploy_start", targetList[i].getName()), dasConnection, stat, true);
522                 }
523             }
524
525             // Do WSDL publishing only if the caller is not GUI
526
if ( !isLocalConnectionSource ) {
527                 try {
528                     DeploymentClientUtils.doWsdlFilePublishing(tmp, dasConnection);
529                 } catch (Exception JavaDoc wsdlEx) {
530                     DeploymentStatus newStatus = new DeploymentStatus();
531                     newStatus.setStageStatus(DeploymentStatus.FAILURE);
532                     newStatus.setStageStatusMessage(wsdlEx.getMessage());
533                     newStatus.setStageException(wsdlEx);
534                     checkStatusAndAddStage(domain, rollback,
535                         localStrings.getString("enterprise.deployment.client.deploy_publish_wsdl"), dasConnection, newStatus);
536                     String JavaDoc msg = localStrings.getString("enterprise.deployment.client.deploy_publish_wsdl_exception", wsdlEx.getMessage());
537                     setupForAbnormalExit(msg, domain);
538                     return;
539                 }
540             }
541             
542             initializeTargetModuleIDForAllServers(
543                     tmp, dasConnection.getMBeanServerConnection(false));
544
545             setupForNormalExit(localStrings.getString("enterprise.deployment.client.deploy_application", moduleID), domain);
546         } catch (Throwable JavaDoc ioex) {
547             finalDeploymentStatus.setStageException(ioex);
548             setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.deploy_application_failed", ioex.getMessage()), domain);
549             return;
550         }
551     }
552
553     private boolean isModuleDeployed(ConnectionSource dasConnection, String JavaDoc moduleID) throws Exception JavaDoc {
554         return DeploymentClientUtils.isModuleDeployed(
555             dasConnection.getExistingMBeanServerConnection(), moduleID);
556     }
557     
558     private boolean isDomainLocal(SunTarget domain) {
559         // host = "localhost", it is local
560
if("localhost".equalsIgnoreCase(domain.getHostName())) {
561             return true;
562         }
563         
564         // get localhost details and see if the host name or IP address matches with that of the domain
565
try {
566             InetAddress JavaDoc lh = InetAddress.getLocalHost();
567             if(domain.getHostName().equalsIgnoreCase(lh.getCanonicalHostName())) {
568                 return true;
569             }
570             if(domain.getHostName().equalsIgnoreCase(lh.getHostName())) {
571                 return true;
572             }
573             if(domain.getHostName().equalsIgnoreCase(lh.getHostAddress())) {
574                 return true;
575             }
576         } catch (UnknownHostException JavaDoc ex) {
577             return false;
578         }
579         return false;
580     }
581
582     private String JavaDoc getArchiveName(Archive archive) {
583         
584         if (archive.getURI()==null){
585             return null;
586         }
587         String JavaDoc name = archive.getURI().getPath();
588         if (name != null) {
589             return name.substring(name.lastIndexOf("/")+1);
590         }
591         return name;
592     }
593 }
594
Popular Tags