synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u...@apache.org
Subject svn commit: r599348 - in /webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse: ./ config/xml/ core/axis2/
Date Thu, 29 Nov 2007 08:55:37 GMT
Author: upul
Date: Thu Nov 29 00:55:36 2007
New Revision: 599348

URL: http://svn.apache.org/viewvc?rev=599348&view=rev
Log:
added feature pinning proxy services to given synapse server name list

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java?rev=599348&r1=599347&r2=599348&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java
Thu Nov 29 00:55:36 2007
@@ -222,4 +222,7 @@
     public static final String FORMAT_GET = "get";
     public static final String FORMAT_SOAP11 = "soap11";
     public static final String FORMAT_SOAP12 = "soap12";    
+    
+    /** Synapse server instance name */
+    public static final String SYNAPSE_SERVER_NAME = "SynapseServerName";
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java?rev=599348&r1=599347&r2=599348&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
Thu Nov 29 00:55:36 2007
@@ -19,27 +19,29 @@
 
 package org.apache.synapse.config.xml;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
+import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.config.xml.endpoints.EndpointAbstractFactory;
 import org.apache.synapse.config.xml.endpoints.EndpointFactory;
 import org.apache.synapse.core.axis2.ProxyService;
-import org.apache.axis2.wsdl.WSDLConstants;
-
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.StringTokenizer;
-import java.util.ArrayList;
-import java.net.URI;
-import java.net.URISyntaxException;
 
 /**
  * Creates a ProxyService instance using the XML fragment specification
  * <p/>
- * <proxy-service name="string" [transports="(http |https |jms )+|all"] [trace="enable|disable"]>
+ * <proxy-service name="string" [transports="(http |https |jms )+|all"] [pinnedServers="(serverName)+"]
[trace="enable|disable"]>
  *    <description>..</description>?
  *    <target [inSequence="name"] [outSequence="name"] [faultSequence="name"] [endpoint="name"]>
  *       <endpoint>...</endpoint>
@@ -105,6 +107,25 @@
                 proxy.setTransports(transportList);
             }
         }
+        
+        OMAttribute pinnedServers = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE,
"pinnedServers"));
+        if (pinnedServers != null) {
+            String pinnedServersValue = pinnedServers.getAttributeValue();
+            if (pinnedServersValue == null) {
+                // default to all servers
+            } else {
+                StringTokenizer st = new StringTokenizer(pinnedServersValue, " ,");
+                List pinnedServersList = new ArrayList();
+                while (st.hasMoreTokens()) {
+                    String token = st.nextToken();
+                    if (token.length() != 0) {
+                      pinnedServersList.add(token);
+                    }
+                }
+                proxy.setPinnedServers(pinnedServersList);
+            }
+        }
+        
         OMAttribute trace = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE,
XMLConfigConstants.TRACE_ATTRIB_NAME));
         if (trace != null) {
             String traceValue = trace.getAttributeValue();

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java?rev=599348&r1=599347&r2=599348&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
Thu Nov 29 00:55:36 2007
@@ -19,19 +19,24 @@
 
 package org.apache.synapse.config.xml;
 
-import org.apache.axiom.om.*;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.SynapseException;
-import org.apache.synapse.mediators.base.SequenceMediator;
-import org.apache.synapse.endpoints.Endpoint;
 import org.apache.synapse.config.xml.endpoints.EndpointAbstractSerializer;
 import org.apache.synapse.config.xml.endpoints.EndpointSerializer;
 import org.apache.synapse.core.axis2.ProxyService;
-
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.net.URI;
+import org.apache.synapse.endpoints.Endpoint;
+import org.apache.synapse.mediators.base.SequenceMediator;
 
 /**
  * <proxyService name="string" [transports="(http |https |jms )+|all"]>
@@ -85,6 +90,15 @@
             proxy.addAttribute(fac.createOMAttribute("transports", nullNS, transportStr));
         }
 
+        List pinnedServers = service.getPinnedServers();
+        if (pinnedServers != null && !pinnedServers.isEmpty()) {
+          String pinnedServersStr = "" + pinnedServers.get(0);
+          for (int i = 1; i < pinnedServers.size(); i++) {
+            pinnedServersStr = pinnedServersStr + " " + pinnedServers.get(i);
+          }
+          proxy.addAttribute(fac.createOMAttribute("pinnedServers", nullNS, pinnedServersStr));
+        }
+        
         if (service.isStartOnLoad()) {
             proxy.addAttribute(fac.createOMAttribute(
                     "startOnLoad", nullNS, "true"));

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java?rev=599348&r1=599347&r2=599348&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
Thu Nov 29 00:55:36 2007
@@ -84,6 +84,10 @@
      */
     private ArrayList transports;
     /**
+     * Server names for which this service should be exposed
+     */
+    private List pinnedServers = new ArrayList();
+    /**
      * The target endpoint key
      */
     private String targetEndpoint = null;
@@ -712,6 +716,14 @@
 
     public void setTargetInLineFaultSequence(SequenceMediator targetInLineFaultSequence)
{
         this.targetInLineFaultSequence = targetInLineFaultSequence;
+    }
+
+    public List getPinnedServers() {
+      return pinnedServers;
+    }
+
+    public void setPinnedServers(List pinnedServers) {
+      this.pinnedServers = pinnedServers;
     }
 
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java?rev=599348&r1=599347&r2=599348&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java
(original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseInitializationModule.java
Thu Nov 29 00:55:36 2007
@@ -104,10 +104,41 @@
             sandesha2.init(configurationContext, sandeshaAxisModule);
         }
 
+        // this server name given by system property SynapseServerName
+        // otherwise take host-name
+        // else assume localhost
+        String thisServerName = System.getProperty(SynapseConstants.SYNAPSE_SERVER_NAME);
+        if(thisServerName == null || thisServerName.equals("")) {
+          try {
+            InetAddress addr = InetAddress.getLocalHost();
+            thisServerName = addr.getHostName();
+
+          } catch (UnknownHostException e) {
+            log.warn("Could not get local host name", e);
+          }
+          
+          if(thisServerName == null || thisServerName.equals("")) {
+            thisServerName = "localhost";
+          }
+        }
+        log.info("Synapse server name : " + thisServerName);
+        
         log.info("Deploying Proxy services...");
         Iterator iter = synCfg.getProxyServices().iterator();
         while (iter.hasNext()) {
             ProxyService proxy = (ProxyService) iter.next();
+
+            // start proxy service if,
+            // pinned server name list is empty
+            // else pinned server list has this server name
+            List pinnedServers = proxy.getPinnedServers();
+            if(pinnedServers != null && !pinnedServers.isEmpty()) {
+              if(!pinnedServers.contains(thisServerName)) {
+                log.info("Server name not in pinned servers list. Not deploying Proxy service
: " + proxy.getName());
+                continue;
+              }
+            }
+            
             proxy.buildAxisService(synCfg, axisCfg);
             log.info("Deployed Proxy service : " + proxy.getName());
             if (!proxy.isStartOnLoad()) {



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


Mime
View raw message