commit f0142d3924373deb9f728468d785af345553e27b
Author: ChaoWang <chaowan@redhat.com>
Date:   Tue Jan 8 13:19:37 2013 +0800

    AS7-5444,runtime-name is used when logging deploy and undeploy

diff --git a/server/src/main/java/org/jboss/as/server/ServerLogger.java b/server/src/main/java/org/jboss/as/server/ServerLogger.java
index bb1df1c..5404c58 100644
--- a/server/src/main/java/org/jboss/as/server/ServerLogger.java
+++ b/server/src/main/java/org/jboss/as/server/ServerLogger.java
@@ -136,12 +136,12 @@ public interface ServerLogger extends BasicLogger {
     void undeploymentRolledBackWithNoMessage(String deployment);
 
     @LogMessage(level = INFO)
-    @Message(id = 18558, value = "Undeployed \"%s\"")
-    void deploymentUndeployed(String deploymentName);
+    @Message(id = 18558, value = "Undeployed \"%s\" (runtime-name: \"%s\")")
+    void deploymentUndeployed(String managementName, String deploymentUnitName);
 
     @LogMessage(level = INFO)
-    @Message(id = 18559, value = "Deployed \"%s\"")
-    void deploymentDeployed(String deploymentUnitName);
+    @Message(id = 18559, value = "Deployed \"%s\" (runtime-name : \"%s\")")
+    void deploymentDeployed(String managementName, String deploymentUnitName);
 
     @LogMessage(level = ERROR)
     @Message(id = 15860, value = "Redeploy of deployment \"%s\" was rolled back with the following failure message: %s")
@@ -208,12 +208,12 @@ public interface ServerLogger extends BasicLogger {
     void startedWitErrors(String prettyVersionString, long time, int startedServices, int allServices, int problemServices, int passiveOnDemandServices);
 
     @LogMessage(level = INFO)
-    @Message(id = 15876, value = "Starting deployment of \"%s\"")
-    void startingDeployment(String deployment);
+    @Message(id = 15876, value = "Starting deployment of \"%s\" (runtime-name: \"%s\")")
+    void startingDeployment(String managementName, String deploymentUnitName);
 
     @LogMessage(level = INFO)
-    @Message(id = 15877, value = "Stopped deployment %s in %dms")
-    void stoppedDeployment(String deployment, int elapsedTime);
+    @Message(id = 15877, value = "Stopped deployment %s (runtime-name: %s) in %dms")
+    void stoppedDeployment(String managementName, String deploymentUnitName, int elapsedTime);
 
     @LogMessage(level = INFO)
     @Message(id = 15878, value = "Deployment '%s' started successfully")
diff --git a/server/src/main/java/org/jboss/as/server/deployment/AbstractDeploymentUnitService.java b/server/src/main/java/org/jboss/as/server/deployment/AbstractDeploymentUnitService.java
index 46aa0ff..34802ae 100644
--- a/server/src/main/java/org/jboss/as/server/deployment/AbstractDeploymentUnitService.java
+++ b/server/src/main/java/org/jboss/as/server/deployment/AbstractDeploymentUnitService.java
@@ -63,12 +63,14 @@ public abstract class AbstractDeploymentUnitService implements Service<Deploymen
         final String deploymentName = context.getController().getName().getSimpleName();
         final DeploymentServiceListener listener = new DeploymentServiceListener(deploymentName);
         this.listener = listener;
-        ServerLogger.DEPLOYMENT_LOGGER.startingDeployment(deploymentName);
         // Create the first phase deployer
         target.addListener(ServiceListener.Inheritance.ALL, listener);
         deploymentUnit = createAndInitializeDeploymentUnit(context.getController().getServiceContainer());
         deploymentUnit.putAttachment(Attachments.STATUS_LISTENER, listener);
 
+        final String managementName = deploymentUnit.getAttachment(Attachments.MANAGEMENT_NAME);
+        ServerLogger.DEPLOYMENT_LOGGER.startingDeployment(managementName, deploymentName);
+
         final ServiceName serviceName = deploymentUnit.getServiceName().append(FIRST_PHASE_NAME);
         final Phase firstPhase = Phase.values()[0];
         final DeploymentUnitPhaseService<?> phaseService = DeploymentUnitPhaseService.create(deploymentUnit, firstPhase);
@@ -88,8 +90,9 @@ public abstract class AbstractDeploymentUnitService implements Service<Deploymen
 
     public synchronized void stop(final StopContext context) {
         final String deploymentName = context.getController().getName().getSimpleName();
+        final String managementName = deploymentUnit.getAttachment(Attachments.MANAGEMENT_NAME);
+        ServerLogger.DEPLOYMENT_LOGGER.stoppedDeployment(managementName, deploymentName, (int) (context.getElapsedTime() / 1000000L));
         deploymentUnit = null;
-        ServerLogger.DEPLOYMENT_LOGGER.stoppedDeployment(deploymentName, (int) (context.getElapsedTime() / 1000000L));
     }
 
     public synchronized DeploymentUnit getValue() throws IllegalStateException, IllegalArgumentException {
diff --git a/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java b/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java
index 5887fdc..a2b7274 100644
--- a/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java
+++ b/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtil.java
@@ -134,7 +134,7 @@ public class DeploymentHandlerUtil {
                                         ServerLogger.ROOT_LOGGER.deploymentRolledBackWithNoMessage(deploymentUnitName);
                                     }
                                 } else {
-                                    ServerLogger.ROOT_LOGGER.deploymentDeployed(deploymentUnitName);
+                                    ServerLogger.ROOT_LOGGER.deploymentDeployed(managementName, deploymentUnitName);
                                 }
                             }
                         });
@@ -300,7 +300,7 @@ public class DeploymentHandlerUtil {
         }
     }
 
-    public static void undeploy(final OperationContext context, final String deploymentUnitName, final AbstractVaultReader vaultReader) {
+    public static void undeploy(final OperationContext context, final String managementName, final String deploymentUnitName, final AbstractVaultReader vaultReader) {
         if (context.isNormalServer()) {
             final Resource deployment = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
             final ImmutableManagementResourceRegistration registration = context.getResourceRegistration();
@@ -331,7 +331,7 @@ public class DeploymentHandlerUtil {
                                     ServerLogger.ROOT_LOGGER.undeploymentRolledBackWithNoMessage(deploymentUnitName);
                                 }
                             } else {
-                                ServerLogger.ROOT_LOGGER.deploymentUndeployed(deploymentUnitName);
+                                ServerLogger.ROOT_LOGGER.deploymentUndeployed(managementName, deploymentUnitName);
                             }
                         }
                     });
diff --git a/server/src/main/java/org/jboss/as/server/deployment/DeploymentRemoveHandler.java b/server/src/main/java/org/jboss/as/server/deployment/DeploymentRemoveHandler.java
index 5a85877..00c6e06 100644
--- a/server/src/main/java/org/jboss/as/server/deployment/DeploymentRemoveHandler.java
+++ b/server/src/main/java/org/jboss/as/server/deployment/DeploymentRemoveHandler.java
@@ -88,6 +88,9 @@ public class DeploymentRemoveHandler implements OperationStepHandler {
                     context.completeStep(new OperationContext.ResultHandler() {
                         @Override
                         public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) {
+                            final ModelNode opAddr = operation.get(OP_ADDR);
+                            PathAddress address = PathAddress.pathAddress(opAddr);
+                            final String managementName = address.getLastElement().getValue();
                             if (resultAction == OperationContext.ResultAction.ROLLBACK) {
                                 if (enabled) {
                                     recoverServices(context, model, deployment, deploymentUnitName, contentNode,
@@ -101,7 +104,7 @@ public class DeploymentRemoveHandler implements OperationStepHandler {
                                 }
                             } else {
                                 if (enabled) {
-                                    ServerLogger.ROOT_LOGGER.deploymentUndeployed(deploymentUnitName);
+                                    ServerLogger.ROOT_LOGGER.deploymentUndeployed(managementName, deploymentUnitName);
                                 }
 
                                 for (byte[] hash : removedHashes) {
diff --git a/server/src/main/java/org/jboss/as/server/deployment/DeploymentUndeployHandler.java b/server/src/main/java/org/jboss/as/server/deployment/DeploymentUndeployHandler.java
index 3cd1bb1..d7b3795 100644
--- a/server/src/main/java/org/jboss/as/server/deployment/DeploymentUndeployHandler.java
+++ b/server/src/main/java/org/jboss/as/server/deployment/DeploymentUndeployHandler.java
@@ -18,6 +18,7 @@
  */
 package org.jboss.as.server.deployment;
 
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.UNDEPLOY;
 import static org.jboss.as.server.controller.resources.DeploymentAttributes.ENABLED;
 import static org.jboss.as.server.controller.resources.DeploymentAttributes.RUNTIME_NAME;
@@ -49,7 +50,11 @@ public class DeploymentUndeployHandler implements OperationStepHandler {
         final String deploymentUnitName = RUNTIME_NAME.resolveModelAttribute(context, model).asString();
         model.get(ENABLED.getName()).set(false);
 
-        DeploymentHandlerUtil.undeploy(context, deploymentUnitName, vaultReader);
+        final ModelNode opAddr = operation.get(OP_ADDR);
+        PathAddress address = PathAddress.pathAddress(opAddr);
+        final String managementName = address.getLastElement().getValue();
+
+        DeploymentHandlerUtil.undeploy(context, managementName, deploymentUnitName, vaultReader);
 
         context.stepCompleted();
     }
