1 23 24 package com.sun.enterprise.deployment.client; 25 26 import com.sun.appserv.management.client.ConnectionSource; 27 import com.sun.appserv.management.client.ProxyFactory; 28 import com.sun.enterprise.deployapi.ProgressObjectImpl; 29 import com.sun.enterprise.deployapi.SunTarget; 30 import com.sun.enterprise.deployapi.SunTargetModuleID; 31 import com.sun.enterprise.deployment.backend.DeploymentStatus; 32 import com.sun.enterprise.util.i18n.StringManager; 33 34 import java.io.IOException ; 35 import java.util.ArrayList ; 36 37 import javax.enterprise.deploy.shared.CommandType ; 38 import javax.enterprise.deploy.shared.ModuleType ; 39 import javax.enterprise.deploy.shared.StateType ; 40 import javax.enterprise.deploy.spi.Target ; 41 import javax.enterprise.deploy.spi.TargetModuleID ; 42 43 public class ChangeStateAction extends ProgressObjectImpl { 44 45 public ChangeStateAction(SunTarget[] targets) { 46 super(targets); 47 } 48 49 public void run() { 50 ConnectionSource dasConnection= (ConnectionSource) args[0]; 51 SunTarget[] targets = (SunTarget[]) args[1]; 52 String moduleID = (String ) args[2]; 53 CommandType newState = (CommandType ) args[3]; 54 SunTarget domain = (SunTarget) args[4]; 55 StringManager localStrings = StringManager.getManager(getClass()); 56 57 ModuleType moduleType; 58 try { 59 moduleType = DeploymentClientUtils.getModuleType( 60 dasConnection.getExistingMBeanServerConnection(), moduleID); 61 } catch (Throwable ioex) { 62 finalDeploymentStatus.setStageException(ioex); 63 setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.unrecognized_module_type", moduleID ,ioex.getMessage()), 64 domain); 65 return; 66 } 67 68 boolean state = false; 69 String action = "Disable"; 70 if (CommandType.START.equals(newState)) { 71 state = true; 72 action = "Enable"; 73 } 74 75 ArrayList resultTargetModuleIDs = new ArrayList (); 77 78 for(int i=0; i<targets.length; i++) { 79 DeploymentStatus stat = new DeploymentStatus(); 80 stat.setStageDescription( 81 localStrings.getString("enterprise.deployment.client.state_change_desc", action, moduleID)); 82 try { 83 DeploymentClientUtils.changeStateOfModule(dasConnection.getExistingMBeanServerConnection(), moduleID, 84 ((moduleType == null) ? null : moduleType.toString()), targets[i], state); 85 stat.setStageStatus(DeploymentStatus.SUCCESS); 86 stat.setStageStatusMessage( 87 localStrings.getString("enterprise.deployment.client.state_change_success", action, moduleID)); 88 } catch (Throwable ex) { 89 stat.setStageException(ex); 90 stat.setStageStatus(DeploymentStatus.FAILURE); 91 stat.setStageStatusMessage(ex.getMessage()); 92 } 93 if(!checkStatusAndAddStage(targets[i], null, 94 localStrings.getString("enterprise.deployment.client.change_state", action, moduleID, targets[i].getName()), dasConnection, stat, state)) { 95 return; 96 } 97 resultTargetModuleIDs.add(new SunTargetModuleID(moduleID, targets[i])); 98 } 99 100 this.targetModuleIDs = new TargetModuleID[resultTargetModuleIDs.size()]; 103 this.targetModuleIDs = 104 (TargetModuleID[])resultTargetModuleIDs.toArray(this.targetModuleIDs); 105 106 setupForNormalExit(localStrings.getString("enterprise.deployment.client.change_state_all", action), domain); 107 } 108 } 109 | Popular Tags |