You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ja...@apache.org on 2006/03/06 21:27:10 UTC

svn commit: r383649 - /webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java

Author: jaliya
Date: Mon Mar  6 12:27:07 2006
New Revision: 383649

URL: http://svn.apache.org/viewcvs?rev=383649&view=rev
Log:
Fixed a threading issue

Modified:
    webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java

Modified: webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java?rev=383649&r1=383648&r2=383649&view=diff
==============================================================================
--- webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java (original)
+++ webservices/sandesha/branches/sandesha_1_0/src/org/apache/sandesha/SandeshaContext.java Mon Mar  6 12:27:07 2006
@@ -72,7 +72,7 @@
     private boolean sendOffer;
     private long messageNumber;
     private boolean sync;
-    
+
     static int clientListnerPort = -1;
     public final int MIN_PORT = 0;
     public final int MAX_PORT = 65525;
@@ -152,17 +152,17 @@
     }
 
     public SandeshaContext() throws AxisFault {
-    	initSandeshaAsync();
+        initSandeshaAsync();
     }
-    
-    private void initSandeshaAsync () throws AxisFault {
+
+    private void initSandeshaAsync() throws AxisFault {
         messageNumber = 0;
         key = System.currentTimeMillis();
         SandeshaContext.insideServer = false;
         init(true);
         startListener();
         seqMap.put(new Long(key), this);
-        report = new RMReport();	
+        report = new RMReport();
     }
 
     public SandeshaContext(int sync) throws AxisFault {
@@ -174,13 +174,13 @@
         seqMap.put(new Long(key), this);
         report = new RMReport();
     }
-    
-    public SandeshaContext (Integer port) throws AxisFault {
-    	int portVal = port.intValue();
-    	if(portVal>MIN_PORT && portVal<MAX_PORT) {
-    		 this.clientListnerPort = portVal;
-    		 initSandeshaAsync();
-    	}
+
+    public SandeshaContext(Integer port) throws AxisFault {
+        int portVal = port.intValue();
+        if (portVal > MIN_PORT && portVal < MAX_PORT) {
+            this.clientListnerPort = portVal;
+            initSandeshaAsync();
+        }
     }
 
     public SandeshaContext(boolean insideServer) throws AxisFault {
@@ -232,7 +232,7 @@
         this.callMap = callMap;
     }
 
-    public static IStorageManager init(boolean client) throws AxisFault {
+    public synchronized static IStorageManager init(boolean client) throws AxisFault {
         if (client) {
             IStorageManager storageManager = new ClientStorageManager();
             if (!cleintSenderStarted) {
@@ -258,29 +258,31 @@
         }
     }
 
-    private static void startClientSender(IStorageManager storageManager) throws AxisFault {
+    private synchronized static void startClientSender(IStorageManager storageManager) throws AxisFault {
         if (log.isDebugEnabled()) {
             log.debug(Constants.InfomationMessage.SENDER_STARTED);
         }
-
-        cleintSender = new Sender(storageManager);
-        SimpleChain reqChain = null;
-        SimpleChain resChain = null;
-        try {
-            reqChain = getRequestChain();
-            resChain = getResponseChain();
-        } catch (Exception e) {
-            throw new AxisFault(e.getMessage());
+           System.out.println("How can i come to this");
+        if (!cleintSenderStarted) {
+            cleintSender = new Sender(storageManager);
+            SimpleChain reqChain = null;
+            SimpleChain resChain = null;
+            try {
+                reqChain = getRequestChain();
+                resChain = getResponseChain();
+            } catch (Exception e) {
+                throw new AxisFault(e.getMessage());
+            }
+            if (reqChain != null)
+                cleintSender.setRequestChain(reqChain);
+            if (resChain != null)
+                cleintSender.setResponseChain(resChain);
+            cleintSender.startSender();
+            cleintSenderStarted = true;
         }
-        if (reqChain != null)
-            cleintSender.setRequestChain(reqChain);
-        if (resChain != null)
-            cleintSender.setResponseChain(resChain);
-        cleintSender.startSender();
-        cleintSenderStarted = true;
     }
 
-    private static void startServerSender() throws AxisFault{
+    private synchronized static void startServerSender() throws AxisFault {
         if (log.isDebugEnabled()) {
             log.debug(Constants.InfomationMessage.SENDER_STARTED);
         }
@@ -296,22 +298,22 @@
         if (outChain != null)
             serverSender.setRequestChain(outChain);
         if (inChain != null)
-        	serverSender.setResponseChain(inChain);
+            serverSender.setResponseChain(inChain);
         serverSender.startSender();
         serverSenderStarted = true;
     }
 
     private static SimpleChain getServerSenderINChain() {
-    	 ArrayList arr = PropertyLoader.getServerSenderINHandlers();
-         return ClientHandlerUtil.getHandlerChain(arr);
-	}
-
-	private static SimpleChain getServerSenderOUTChain() {
-		ArrayList arr = PropertyLoader.getServerSenderOUTHandlers();
-		 return ClientHandlerUtil.getHandlerChain(arr);
-	}
+        ArrayList arr = PropertyLoader.getServerSenderINHandlers();
+        return ClientHandlerUtil.getHandlerChain(arr);
+    }
 
-	private void validateProperties(Call call, String targetUrl, String action, short MEP)
+    private static SimpleChain getServerSenderOUTChain() {
+        ArrayList arr = PropertyLoader.getServerSenderOUTHandlers();
+        return ClientHandlerUtil.getHandlerChain(arr);
+    }
+
+    private void validateProperties(Call call, String targetUrl, String action, short MEP)
             throws AxisFault {
         if (action == null)
             throw new AxisFault("Please sepeicfy Action");
@@ -402,10 +404,10 @@
 
             String sourceURL = null;
 
-        	int listnerPort = clientListnerPort;
-        	if (listnerPort<0)
-        		listnerPort = PropertyLoader.getClientSideListenerPort();
-        	
+            int listnerPort = clientListnerPort;
+            if (listnerPort < 0)
+                listnerPort = PropertyLoader.getClientSideListenerPort();
+
             sourceURL = Constants.HTTP + Constants.COLON + Constants.SLASH +
                     Constants.SLASH + addr.getHostAddress() + Constants.COLON +
                     listnerPort + Constants.URL_RM_SERVICE;
@@ -422,9 +424,9 @@
             if (!listenerStarted) {
                 listenerStarted = true;
                 try {
-                	int listnerPort = clientListnerPort;
-                	if (listnerPort<0)
-                		listnerPort = PropertyLoader.getClientSideListenerPort();
+                    int listnerPort = clientListnerPort;
+                    if (listnerPort < 0)
+                        listnerPort = PropertyLoader.getClientSideListenerPort();
                     clientListner = new ClientListener(listnerPort);
                     clientListner.start();
                 } catch (IOException e) {



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