CXF-5718 Suppose to override the instance.id of the managed endpoint with 
persistent one


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5ff29eb8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5ff29eb8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5ff29eb8

Branch: refs/heads/2.6.x-fixes
Commit: 5ff29eb828b101a5c4e3baa5006fab916215fab5
Parents: e4da1a1
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Wed Apr 30 16:41:32 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Wed Apr 30 16:44:56 2014 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/cxf/endpoint/ManagedEndpoint.java    | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5ff29eb8/api/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java 
b/api/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
index de53e8b..b6861be 100644
--- a/api/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
+++ b/api/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
@@ -36,6 +36,7 @@ import org.apache.cxf.management.annotation.ManagedResource;
 public class ManagedEndpoint implements ManagedComponent, 
ServerLifeCycleListener {
     public static final String ENDPOINT_NAME = "managed.endpoint.name";
     public static final String SERVICE_NAME = "managed.service.name";
+    public static final String INSTANCE_ID = "managed.instance.id";
 
     private Bus bus;
     private Endpoint endpoint;
@@ -108,8 +109,12 @@ public class ManagedEndpoint implements ManagedComponent, 
ServerLifeCycleListene
         }
         endpointName = ObjectName.quote(endpointName);
         
buffer.append(ManagementConstants.PORT_NAME_PROP).append('=').append(endpointName).append(',');
+        String instanceId = (String)endpoint.get(INSTANCE_ID);
+        if (StringUtils.isEmpty(instanceId)) {
+            instanceId = new 
StringBuffer().append(endpoint.hashCode()).toString();
+        }
         // Added the instance id to make the ObjectName unique
-        
buffer.append(ManagementConstants.INSTANCE_ID_PROP).append('=').append(endpoint.hashCode());
+        
buffer.append(ManagementConstants.INSTANCE_ID_PROP).append('=').append(instanceId);
         
         //Use default domain name of server
         return new ObjectName(buffer.toString());

Reply via email to