You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by ch...@apache.org on 2007/03/15 06:29:53 UTC

svn commit: r518488 - in /webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse: config/xml/endpoints/ config/xml/endpoints/utils/ endpoints/ mediators/builtin/

Author: chathura_ce
Date: Wed Mar 14 22:29:52 2007
New Revision: 518488

URL: http://svn.apache.org/viewvc?view=rev&rev=518488
Log:
Moved the EndpointDefinition factory code to AddressEndpointFactory. This is used only inside the AddressEndpointFactory. WSDL endpoints may use XML based configuration to override the WSDL details. But in that case, it is better to have a WSDLEndpointFactory specific EndpointDefinition builder.

Removed:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/EndpointDefinitionFactory.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/utils/EndpointDefinitionSerializer.java
Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointFactory.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializer.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointFactory.java?view=diff&rev=518488&r1=518487&r2=518488
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointFactory.java Wed Mar 14 22:29:52 2007
@@ -36,9 +36,12 @@
  * Creates AddressEndpoint using a XML configuration.
  *
  * <endpoint [name="name"]>
- *    <address uri="uri">
- *       configuration for the epr. see EndpointDefintionFactory.
- *    </address>
+ *   <address uri="url" [format="soap|pox"] [optimize="mtom|swa"]>
+ *      .. extensibility ..
+ *
+ *      <enableRM [policy="key"]/>+ <enableSec [policy="key"]/>+ <enableAddressing
+ *      separateListener="true|false"/>+
+ *   </address>
  * </endpoint>
  */
 public class AddressEndpointFactory implements EndpointFactory {
@@ -86,12 +89,20 @@
         return null;
     }
 
-    private EndpointDefinition createEndpointDefinition(OMElement elem) {
-        
+    /**
+     * Creates an EndpointDefinition instance using the XML fragment specification. Configuration for
+     * EndpointDefinition always resides inside a configuration of an AddressEndpoint. This factory
+     * extracts the details related to the EPR provided for address endpoint.
+     *
+     * @param elem XML configuration element
+     * @return EndpointDefinition object containing the endpoint details.
+     */
+    public EndpointDefinition createEndpointDefinition(OMElement elem) {
+
         OMAttribute address = elem.getAttribute(new QName(
                 org.apache.synapse.config.xml.Constants.NULL_NAMESPACE, "uri"));
-        OMAttribute force = elem.getAttribute(new QName(
-                org.apache.synapse.config.xml.Constants.NULL_NAMESPACE, "force"));
+        OMAttribute format = elem.getAttribute(new QName(
+                org.apache.synapse.config.xml.Constants.NULL_NAMESPACE, "format"));
         OMAttribute optimize = elem.getAttribute(new QName(
                 org.apache.synapse.config.xml.Constants.NULL_NAMESPACE, "optimize"));
 
@@ -104,9 +115,9 @@
                     + "anonymous endpoint");
         }
 
-        if (force != null)
+        if (format != null)
         {
-            String forceValue = force.getAttributeValue().trim().toLowerCase();
+            String forceValue = format.getAttributeValue().trim().toLowerCase();
             if (forceValue.equals("pox")) {
                 endpoint.setForcePOX(true);
             } else if (forceValue.equals("soap")) {
@@ -161,7 +172,7 @@
         }
 
         return endpoint;
-    }
+    }    
 
     private static void handleException(String msg) {
         log.error(msg);

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializer.java?view=diff&rev=518488&r1=518487&r2=518488
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializer.java Wed Mar 14 22:29:52 2007
@@ -27,18 +27,39 @@
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.Constants;
 import org.apache.synapse.endpoints.utils.EndpointDefinition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Serializes AddressEndpoint to XML.
  *
  * <endpoint [name="name"]>
- *    <address uri="uri">
- *       configuration for the epr. see EndpointDefintionFactory.
- *    </address>
+ *  <address uri="url">
+ *
+ *    .. extensibility ..
+ *
+ *    <!-- Axis2 Rampart configurations : may be obsolete soon -->
+ *    <parameter name="OutflowSecurity">
+ *      ...
+ *    </parameter>+
+ *
+ *    <!-- Apache Sandesha configurations : may be obsolete soon -->
+ *    <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"..
+ *      xmlns:wsrm="http://ws.apache.org/sandesha2/policy" wsu:Id="RMPolicy">
+ *      ...
+ *    </Policy>+
+ *
+ *    <enableRM/>+
+ *    <enableSec/>+
+ *    <enableAddressing/>+
+ *
+ *  </address>
  * </endpoint>
  */
 public class AddressEndpointSerializer implements EndpointSerializer {
 
+    private static Log log = LogFactory.getLog(AddressEndpointSerializer.class);
+
     private OMFactory fac = null;
 
     public OMElement serializeEndpoint(Endpoint endpoint) {
@@ -57,24 +78,72 @@
         }
 
         EndpointDefinition epAddress = addressEndpoint.getEndpoint();
-        OMElement addressElement = serializeAddress(epAddress);
+        OMElement addressElement = serializeEndpointDefinition(epAddress);
         endpointElement.addChild(addressElement);
 
         return endpointElement;
     }
 
-    public OMElement serializeAddress(EndpointDefinition address) {
+    public OMElement serializeEndpointDefinition(EndpointDefinition endpt) {
+
+        OMElement address = fac.createOMElement("address", Constants.SYNAPSE_OMNAMESPACE);
+
+        if (endpt.isForcePOX()) {
+            address.addAttribute(fac.createOMAttribute("format", null, "pox"));
+        } else if (endpt.isForceSOAP()) {
+            address.addAttribute(fac.createOMAttribute("format", null, "soap"));
+        }
 
-        OMElement addressElement = fac.createOMElement("address", Constants.SYNAPSE_OMNAMESPACE);
-        String uri = address.getAddress();
-        if (uri != null) {
-            addressElement.addAttribute("uri", uri, null);
+        if (endpt.getAddress() != null) {
+            address.addAttribute(fac.createOMAttribute(
+                    "uri", null, endpt.getAddress()));
+        } else {
+            handleException("Invalid Endpoint. Address is required");
         }
 
-        if (address.isAddressingOn()) {
-            addressElement.addChild(fac.createOMElement("enableAddressing", Constants.SYNAPSE_OMNAMESPACE));
+        int isEnableStatistics = endpt.getStatisticsEnable();
+        String statisticsValue = null;
+        if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
+            statisticsValue = org.apache.synapse.config.xml.Constants.STATISTICS_ENABLE;
+        } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
+            statisticsValue = org.apache.synapse.config.xml.Constants.STATISTICS_DISABLE;
         }
+        if (statisticsValue != null) {
+            address.addAttribute(fac.createOMAttribute(
+                    org.apache.synapse.config.xml.Constants.STATISTICS_ATTRIB_NAME, null, statisticsValue));
+        }
+        if (endpt.isAddressingOn()) {
+            OMElement addressing = fac.createOMElement("enableAddressing", Constants.SYNAPSE_OMNAMESPACE);
+            if (endpt.isUseSeparateListener()) {
+                addressing.addAttribute(fac.createOMAttribute(
+                        "separateListener", null, "true"));
+            }
+            address.addChild(addressing);
+        }
+
+        if (endpt.isReliableMessagingOn()) {
+            OMElement rm = fac.createOMElement("enableRM", Constants.SYNAPSE_OMNAMESPACE);
+            if (endpt.getWsRMPolicyKey() != null) {
+                rm.addAttribute(fac.createOMAttribute(
+                        "policy", null, endpt.getWsRMPolicyKey()));
+            }
+            address.addChild(rm);
+        }
+
+        if (endpt.isSecurityOn()) {
+            OMElement sec = fac.createOMElement("enableSec", Constants.SYNAPSE_OMNAMESPACE);
+            if (endpt.getWsSecPolicyKey() != null) {
+                sec.addAttribute(fac.createOMAttribute(
+                        "policy", null, endpt.getWsSecPolicyKey()));
+            }
+            address.addChild(sec);
+        }
+
+        return address;
+    }
 
-        return addressElement;
+    private static void handleException(String msg) {
+        log.error(msg);
+        throw new SynapseException(msg);
     }
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java?view=diff&rev=518488&r1=518487&r2=518488
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java Wed Mar 14 22:29:52 2007
@@ -69,7 +69,7 @@
         this.active = active;
     }
 
-    public void send(MessageContext synCtx) {
+    public void send(MessageContext synCtx) {        
 
         String eprAddress = null;
         if (endpoint.getAddress() != null) {

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java?view=diff&rev=518488&r1=518487&r2=518488
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java Wed Mar 14 22:29:52 2007
@@ -45,7 +45,7 @@
         // We have to build the envelop if we are supporting failover.
         // Failover should sent the original message multiple times if failures occur. So we have to
         // access the envelop multiple times.
-        synMessageContext.getEnvelope().build();
+        synMessageContext.getEnvelope().build();        
 
         if (currentEndpoint.isActive()) {
             currentEndpoint.send(synMessageContext);

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java?view=diff&rev=518488&r1=518487&r2=518488
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/SendMediator.java Wed Mar 14 22:29:52 2007
@@ -23,6 +23,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.Constants;
 import org.apache.synapse.MessageContext;
+import org.apache.synapse.core.axis2.Axis2MessageContext;
 import org.apache.synapse.endpoints.Endpoint;
 import org.apache.synapse.mediators.AbstractMediator;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org