You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2010/08/23 18:06:56 UTC

svn commit: r988169 - in /synapse/trunk/java/modules/core/src/main/java/org/apache/synapse: config/xml/endpoints/EndpointFactory.java config/xml/endpoints/EndpointSerializer.java endpoints/AbstractEndpoint.java endpoints/Endpoint.java

Author: ruwan
Date: Mon Aug 23 16:06:56 2010
New Revision: 988169

URL: http://svn.apache.org/viewvc?rev=988169&view=rev
Log:
Adding the description to the endpoints

Modified:
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointFactory.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointSerializer.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/Endpoint.java

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointFactory.java?rev=988169&r1=988168&r2=988169&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointFactory.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointFactory.java Mon Aug 23 16:06:56 2010
@@ -64,6 +64,9 @@ public abstract class EndpointFactory im
 
     private static final String ENDPOINT_NAME_PREFIX = "endpoint_";
 
+    private static final QName DESCRIPTION_Q
+            = new QName(SynapseConstants.SYNAPSE_NAMESPACE, "description");
+
     /**
      * Core method which is exposed for the external use, and this will find the proper
      * {@link EndpointFactory} and create the endpoint which is of the format {@link Endpoint}.
@@ -106,13 +109,18 @@ public abstract class EndpointFactory im
     /**
      *  Make sure that the endpoints created by the factory has a name
      * 
-     * @param epConfig          OMElement conatining the endpoint configuration.
+     * @param epConfig          OMElement containing the endpoint configuration.
      * @param anonymousEndpoint false if the endpoint has a name. true otherwise.
      * @return Endpoint implementation for the given configuration.
      */
     private Endpoint createEndpointWithName(OMElement epConfig, boolean anonymousEndpoint) {
         
         Endpoint ep = createEndpoint(epConfig, anonymousEndpoint);
+        OMElement descriptionElem = epConfig.getFirstChildWithName(DESCRIPTION_Q);
+        if (descriptionElem != null) {
+            ep.setDescription(descriptionElem.getText());
+        }
+
         // if the endpoint doesn't have a name we will generate a unique name.
         if (anonymousEndpoint && ep.getName() == null) {
             String uuid = UUIDGenerator.getUUID();

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointSerializer.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointSerializer.java?rev=988169&r1=988168&r2=988169&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointSerializer.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointSerializer.java Mon Aug 23 16:06:56 2010
@@ -33,6 +33,7 @@ import org.apache.synapse.config.xml.Med
 import org.apache.synapse.endpoints.*;
 import org.apache.synapse.endpoints.EndpointDefinition;
 
+import javax.xml.namespace.QName;
 import java.util.Collection;
 
 /**
@@ -61,7 +62,15 @@ public abstract class EndpointSerializer
      * @return XML format of the serialized endpoint
      */
     public static OMElement getElementFromEndpoint(Endpoint endpoint) {
-        return getEndpointSerializer(endpoint).serializeEndpoint(endpoint);
+
+        EndpointSerializer endpointSerializer = getEndpointSerializer(endpoint);
+        OMElement elem = endpointSerializer.serializeEndpoint(endpoint);
+
+        OMElement descriptionElem = endpointSerializer.getSerializedDescription(endpoint);
+        if (descriptionElem != null) {
+            elem.addChild(descriptionElem);
+        }
+        return elem;
     }
 
     /**
@@ -72,8 +81,21 @@ public abstract class EndpointSerializer
      */
     protected abstract OMElement serializeEndpoint(Endpoint endpoint);
 
+    private OMElement getSerializedDescription(Endpoint endpoint) {
+
+        OMElement descriptionElem = fac.createOMElement(
+                new QName(SynapseConstants.SYNAPSE_NAMESPACE, "description"));
+
+        if (endpoint.getDescription() != null) {
+            descriptionElem.setText(endpoint.getDescription());
+            return descriptionElem;
+        } else {
+            return null;
+        }
+    }
+
     /**
-     * Serializes the QoS infomation of the endpoint to the XML element
+     * Serializes the QoS information of the endpoint to the XML element
      *
      * @param endpointDefinition specifies the QoS information of the endpoint
      * @param element            to which the QoS information will be serialized

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java?rev=988169&r1=988168&r2=988169&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java Mon Aug 23 16:06:56 2010
@@ -48,6 +48,9 @@ public abstract class AbstractEndpoint e
     /** Hold the logical name of an endpoint */
     private String endpointName = null;
 
+    /** Hold the description of an endpoint */
+    private String description = null;
+
     /** The parent endpoint for this endpoint */
     private Endpoint parentEndpoint = null;
 
@@ -140,6 +143,14 @@ public abstract class AbstractEndpoint e
         this.anonymous = anonymous;
     }
 
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return this.description;
+    }
+
     public String toString() {
         if (endpointName != null) {
             return "Endpoint [" + endpointName + "]";

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/Endpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/Endpoint.java?rev=988169&r1=988168&r2=988169&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/Endpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/Endpoint.java Mon Aug 23 16:06:56 2010
@@ -21,6 +21,8 @@ package org.apache.synapse.endpoints;
 
 import org.apache.synapse.ManagedLifecycle;
 import org.apache.synapse.MessageContext;
+import org.apache.synapse.Nameable;
+import org.apache.synapse.SynapseArtifact;
 
 import java.util.List;
 
@@ -33,7 +35,7 @@ import java.util.List;
  * endpoint url. Endpoints may contain zero or more endpoints in them and build up a hierarchical
  * structure of endpoints.
  */
-public interface Endpoint extends ManagedLifecycle {
+public interface Endpoint extends ManagedLifecycle, SynapseArtifact, Nameable {
 
     /**
      * Sends the message context according to an endpoint specific behavior.
@@ -62,21 +64,6 @@ public interface Endpoint extends Manage
     public void setParentEndpoint(Endpoint parentEndpoint);
 
     /**
-     * Returns the name of the endpoint.
-     *
-     * @return Endpoint name.
-     */
-    public String getName();
-
-    /**
-     * Sets the name of the endpoint. Local registry use this name as the key for storing the
-     * endpoint.
-     *
-     * @param name Name for the endpoint.
-     */
-    public void setName(String name);
-
-    /**
      * An event notification whenever endpoint invocation is successful
      * Can be used to clear a timeout status etc
      */