Author: chamikara
Date: Tue Nov 22 22:12:24 2005
New Revision: 348383

URL: http://svn.apache.org/viewcvs?rev=348383&view=rev
Log:
Added a PropertyManager class.
This is responsible for loading properties from a sandesha2.properties file in 
the classpath. If the file is not found properties will be loaded from 
Constants.

Added:
    
webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java
    
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java
Modified:
    webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
    
webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaDynamicProperties.java
    
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyBean.java
    
webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java
    
webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMPolicyManager.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java 
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java Tue Nov 
22 22:12:24 2005
@@ -120,13 +120,13 @@
        }

 

        public interface WSP {

-               long RETRANSMISSION_INTERVAL = 20000;

-

-               long ACKNOWLEDGEMENT_INTERVAL = 4000;

-

-               boolean EXPONENTION_BACKOFF = true;

-

-               long INACTIVITY_TIMEOUT_INTERVAL = 5000000;

+//             long RETRANSMISSION_INTERVAL = 20000;

+//

+//             long ACKNOWLEDGEMENT_INTERVAL = 4000;

+//

+//             boolean EXPONENTION_BACKOFF = true;

+//

+//             long INACTIVITY_TIMEOUT_INTERVAL = 5000000;

 

                String RM_POLICY_BEAN = "RMPolicyBean";

        }

@@ -284,12 +284,43 @@
                }

        }

 

+       public interface Properties {

+               

+               String RetransmissionInterval = "RetransmissionInterval";

+               

+               String AcknowledgementInterval = "AcknowledgementInterval";

+               

+               String ExponentialBackoff = "ExponentialBackoff";

+               

+               String InactivityTimeout = "InactivityTimeout";

+               

+               String InactivityTimeoutMeasure = "InactivityTimeoutMeasure";

+               

+               String StorageManager = "StorageManager";

+               

+               public interface DefaultValues {

+                       

+                       int RetransmissionInterval = 10000;

+                       

+                       int AcknowledgementInterval = 4000;

+                       

+                       boolean ExponentialBackoff = true;

+                       

+                       int InactivityTimeout = -1;

+                       

+                       String InactivityTimeoutMeasure = "seconds";   //this 
can be - seconds,minutes,hours,days

+                       

+                       String StorageManager = 
"org.apache.sandesha2.storage.inmemory.InMemoryStorageManager";

+               }

+               

+       }

+       

        //TODO remove following three

-       int STORAGE_TYPE_IN_MEMORY = 1;

+       //int STORAGE_TYPE_IN_MEMORY = 1;

 

-       int STORAGE_TYPE_PERSISTANCE = 2;

+       //int STORAGE_TYPE_PERSISTANCE = 2;

 

-       int DEFAULT_STORAGE_TYPE = STORAGE_TYPE_IN_MEMORY;

+       //int DEFAULT_STORAGE_TYPE = STORAGE_TYPE_IN_MEMORY;

 

        String IN_HANDLER_NAME = "SandeshaInHandler";

 

@@ -329,5 +360,7 @@
        String STORAGE_MANAGER_IMPL = 
"org.apache.sandesha2.storage.inmemory.InMemoryStorageManager";

 

        int MAXIMUM_RETRANSMISSION_ATTEMPTS = 5;

+       

+       String PROPERTY_FILE = "sandesha2.properties";

 

 }

Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaDynamicProperties.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaDynamicProperties.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaDynamicProperties.java
 (original)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaDynamicProperties.java
 Tue Nov 22 22:12:24 2005
@@ -24,60 +24,60 @@
 

 public class SandeshaDynamicProperties {

 

-       private String storageManagerImpl = Constants.STORAGE_MANAGER_IMPL;

-

-       private RMPolicyBean policyBean = null;

-

-       //private String SOAPVersionURI = null;

-

-       public SandeshaDynamicProperties() {

-

-               loadPolicyBeanFromConstants();

-       }

-

-       private void loadPolicyBeanFromConstants() {

-               //loading default properties. these will be overriden later 
(most of

-               // the time).

-               policyBean = new RMPolicyBean();

-               policyBean

-                               
.setAcknowledgementInterval(Constants.WSP.ACKNOWLEDGEMENT_INTERVAL);

-               policyBean

-                               
.setRetransmissionInterval(Constants.WSP.RETRANSMISSION_INTERVAL);

-               
policyBean.setExponentialBackoff(Constants.WSP.EXPONENTION_BACKOFF);

-               policyBean

-                               
.setInactiveTimeoutInterval(Constants.WSP.INACTIVITY_TIMEOUT_INTERVAL);

-

-               //              if 
(Constants.SOAPVersion.DEFAULT==Constants.SOAPVersion.v1_1){

-               //                      SOAPVersionURI = 
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;

-               //              }else {

-               //                      SOAPVersionURI = 
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;

-               //              }

-

-               //default is SOAP 1.1

-               //SOAPVersionURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;

-       }

-

-       public RMPolicyBean getPolicyBean() {

-               return policyBean;

-       }

-

-       public void setPolicyBean(RMPolicyBean policyBean) {

-               this.policyBean = policyBean;

-       }

-

-       //      public String getSOAPVersionURI() {

-       //              return SOAPVersionURI;

-       //      }

-       //      

-       //      public void setSOAPVersionURI(String versionURI) {

-       //              SOAPVersionURI = versionURI;

-       //      }

-

-       public String getStorageManagerImpl() {

-               return storageManagerImpl;

-       }

-

-       public void setStorageManagerImpl(String storageManagerImpl) {

-               this.storageManagerImpl = storageManagerImpl;

-       }

+//     private String storageManagerImpl = Constants.STORAGE_MANAGER_IMPL;

+//

+//     private RMPolicyBean policyBean = null;

+//

+//     //private String SOAPVersionURI = null;

+//

+//     public SandeshaDynamicProperties() {

+//

+//             loadPolicyBeanFromConstants();

+//     }

+//

+//     private void loadPolicyBeanFromConstants() {

+//             //loading default properties. these will be overriden later 
(most of

+//             // the time).

+//             policyBean = new RMPolicyBean();

+//             policyBean

+//                             
.setAcknowledgementInterval(Constants.WSP.ACKNOWLEDGEMENT_INTERVAL);

+//             policyBean

+//                             
.setRetransmissionInterval(Constants.WSP.RETRANSMISSION_INTERVAL);

+//             
policyBean.setExponentialBackoff(Constants.WSP.EXPONENTION_BACKOFF);

+//             policyBean

+//                             
.setInactiveTimeoutInterval(Constants.WSP.INACTIVITY_TIMEOUT_INTERVAL);

+//

+//             //              if 
(Constants.SOAPVersion.DEFAULT==Constants.SOAPVersion.v1_1){

+//             //                      SOAPVersionURI = 
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;

+//             //              }else {

+//             //                      SOAPVersionURI = 
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;

+//             //              }

+//

+//             //default is SOAP 1.1

+//             //SOAPVersionURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;

+//     }

+//

+//     public RMPolicyBean getPolicyBean() {

+//             return policyBean;

+//     }

+//

+//     public void setPolicyBean(RMPolicyBean policyBean) {

+//             this.policyBean = policyBean;

+//     }

+//

+//     //      public String getSOAPVersionURI() {

+//     //              return SOAPVersionURI;

+//     //      }

+//     //      

+//     //      public void setSOAPVersionURI(String versionURI) {

+//     //              SOAPVersionURI = versionURI;

+//     //      }

+//

+//     public String getStorageManagerImpl() {

+//             return storageManagerImpl;

+//     }

+//

+//     public void setStorageManagerImpl(String storageManagerImpl) {

+//             this.storageManagerImpl = storageManagerImpl;

+//     }

 }

Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
 (original)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
 Tue Nov 22 22:12:24 2005
@@ -52,6 +52,7 @@
 import org.apache.sandesha2.storage.beans.SequencePropertyBean;

 import org.apache.sandesha2.storage.beans.StorageMapBean;

 import org.apache.sandesha2.util.MsgInitializer;

+import org.apache.sandesha2.util.PropertyManager;

 import org.apache.sandesha2.util.RMMsgCreator;

 import org.apache.sandesha2.util.SOAPAbstractFactory;

 import org.apache.sandesha2.util.SandeshaUtil;

@@ -390,7 +391,7 @@
 

                        RMPolicyBean policyBean = (RMPolicyBean) rmMsgCtx

                                        
.getProperty(Constants.WSP.RM_POLICY_BEAN);

-                       long ackInterval = 
Constants.WSP.ACKNOWLEDGEMENT_INTERVAL;

+                       long ackInterval = 
PropertyManager.getInstance().getAcknowledgementInterval();

                        if (policyBean != null) {

                                ackInterval = 
policyBean.getAcknowledgementInaterval();

                        }


Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyBean.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyBean.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyBean.java 
(original)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyBean.java 
Tue Nov 22 22:12:24 2005
@@ -25,10 +25,10 @@
 import org.apache.sandesha2.Constants;
 
 public class RMPolicyBean {
-    private long inactiveTimeoutInterval = 
Constants.WSP.INACTIVITY_TIMEOUT_INTERVAL;
-    private long acknowledgementInterval = 
Constants.WSP.ACKNOWLEDGEMENT_INTERVAL;
-    private long retransmissionInterval = 
Constants.WSP.RETRANSMISSION_INTERVAL;
-    private boolean exponentialBackoff = Constants.WSP.EXPONENTION_BACKOFF;
+    private long inactiveTimeoutInterval;
+    private long acknowledgementInterval;
+    private long retransmissionInterval;
+    private boolean exponentialBackoff;
     
     public RMPolicyBean () {
        loadValuesFromPropertyFile ();

Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java
 (original)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java
 Tue Nov 22 22:12:24 2005
@@ -45,7 +45,8 @@
                RMPolicyBean policyBean = (RMPolicyBean) messageContext

                                .getProperty(Constants.WSP.RM_POLICY_BEAN);

                if (policyBean == null) {

-                       policyBean = new 
SandeshaDynamicProperties().getPolicyBean();

+                       //loading default policies.

+                       policyBean = 
PropertyManager.getInstance().getRMPolicyBean();

                }

 

                retransmitterBean.setSentCount(retransmitterBean.getSentCount() 
+ 1);


Added: 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java?rev=348383&view=auto
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java 
(added)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java 
Tue Nov 22 22:12:24 2005
@@ -0,0 +1,219 @@
+/*

+ * Copyright  1999-2004 The Apache Software Foundation.

+ *

+ *  Licensed under the Apache License, Version 2.0 (the "License");

+ *  you may not use this file except in compliance with the License.

+ *  You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ *  Unless required by applicable law or agreed to in writing, software

+ *  distributed under the License is distributed on an "AS IS" BASIS,

+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ *  See the License for the specific language governing permissions and

+ *  limitations under the License.

+ *

+ */

+

+package org.apache.sandesha2.util;

+

+import java.io.IOException;

+import java.io.InputStream;

+import java.util.Properties;

+

+import org.apache.axis2.InavalidModuleImpl;

+import org.apache.sandesha2.Constants;

+import org.apache.sandesha2.SandeshaException;

+import org.apache.sandesha2.policy.RMPolicyBean;

+

+/**

+ * @author Chamikara Jayalath <[EMAIL PROTECTED]>

+ */

+

+public class PropertyManager {

+

+       public static PropertyManager instance = null;

+       

+       private SandeshaPropertyBean propertyBean = null;

+        

+       private PropertyManager () {

+               propertyBean = new SandeshaPropertyBean ();

+               loadProperties(null);

+       }

+       

+       private void loadProperties (InputStream in) {

+               try {

+                       if (in==null)

+                               in = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(Constants.PROPERTY_FILE);

+                       

+                       if (in==null)

+                               throw new IOException ("sandesha2 property file 
not found");

+                       

+                       Properties properties = new Properties ();

+                       properties.load(in);

+                       

+                       loadPropertiesToBean (properties);

+               } catch (IOException e) {

+                       System.out.println("A valid property file was not 
found. Using default values...");

+               }

+       }

+       

+       public static PropertyManager getInstance () {

+               if (instance==null) {

+                       instance = new PropertyManager ();      

+               }

+               

+               return instance;

+       }

+       

+       public void reload (InputStream stream) {

+               loadProperties(stream);

+       }

+       

+       

+       private void loadPropertiesToBean (Properties properties) {

+               

+               loadExponentialBackoff(properties);

+               loadRetransmissionInterval(properties);

+               loadAcknowledgementInterval(properties);

+               loadInactivityTimeout(properties);

+               loadStoragemanagerClass(properties);

+               

+       }

+       

+       private void loadExponentialBackoff (Properties properties) {

+               

+               String expoBackoffStr = 
properties.getProperty(Constants.Properties.ExponentialBackoff);

+               boolean loaded = false;

+               

+               if (expoBackoffStr!=null) {

+                       expoBackoffStr = expoBackoffStr.trim();

+                       if (expoBackoffStr.equals("true")) {

+                               propertyBean.setExponentialBackoff(true);

+                               loaded = true;

+                       }else if (expoBackoffStr.equals("false")){

+                               propertyBean.setExponentialBackoff(false);

+                               loaded = true;

+                       }

+               }

+               

+               if (!loaded)

+                       
propertyBean.setExponentialBackoff(Constants.Properties.DefaultValues.ExponentialBackoff);

+       }

+       

+       private void loadRetransmissionInterval (Properties properties) {

+               

+               String retransmissionIntStr = 
properties.getProperty(Constants.Properties.RetransmissionInterval);

+               boolean loaded = false;

+               

+               if (retransmissionIntStr!=null) {

+                       try {

+                               retransmissionIntStr = 
retransmissionIntStr.trim();

+                               int retransmissionInterval = 
Integer.parseInt(retransmissionIntStr);

+                               if (retransmissionInterval>0) {

+                                       
propertyBean.setRetransmissionInterval(retransmissionInterval);

+                                       loaded = true;

+                               }

+                       } catch (NumberFormatException e) {

+                               e.printStackTrace();

+                               loaded = false;

+                       }

+               }

+               

+               if (!loaded)

+                       
propertyBean.setRetransmissionInterval(Constants.Properties.DefaultValues.RetransmissionInterval);

+       }

+       

+       private void loadAcknowledgementInterval (Properties properties) {

+               

+               String acknowledgementIntStr = 
properties.getProperty(Constants.Properties.AcknowledgementInterval);

+               boolean loaded = false;

+               

+               if (acknowledgementIntStr!=null) {

+                       try {

+                               acknowledgementIntStr = 
acknowledgementIntStr.trim();

+                               int acknowledgementInt = 
Integer.parseInt(acknowledgementIntStr);

+                               if (acknowledgementInt>0) {

+                                       
propertyBean.setAcknowledgementInterval(acknowledgementInt);

+                                       loaded = true;

+                               }

+                       } catch (NumberFormatException e) {

+                               e.printStackTrace();

+                               loaded = false;

+                       }

+               }

+               

+               if (!loaded)

+                       
propertyBean.setAcknowledgementInterval(Constants.Properties.DefaultValues.AcknowledgementInterval);

+       }

+       

+       private void loadInactivityTimeout (Properties properties) {

+               

+               String inactivityTimeoutStr = 
properties.getProperty(Constants.Properties.InactivityTimeout);

+               String inactivityTimeoutMeasure = 
properties.getProperty(Constants.Properties.InactivityTimeoutMeasure);

+               

+               

+               boolean loaded = false;

+               

+               if (inactivityTimeoutStr!=null && 
inactivityTimeoutMeasure!=null) {

+                       try {

+                               inactivityTimeoutStr = 
inactivityTimeoutStr.trim();

+                               inactivityTimeoutMeasure = 
inactivityTimeoutMeasure.trim();

+                               

+                               int inactivityTimeoutVal = 
Integer.parseInt(inactivityTimeoutStr);

+                               if (inactivityTimeoutVal>0) {

+                                       
propertyBean.setInactiveTimeoutInterval(inactivityTimeoutVal,inactivityTimeoutMeasure);

+                                       loaded = true;

+                               }

+                       } catch (NumberFormatException e) {

+                               e.printStackTrace();

+                               loaded = false;

+                       }

+               }

+               

+               if (!loaded)

+                       
propertyBean.setInactiveTimeoutInterval(Constants.Properties.DefaultValues.InactivityTimeout,Constants.Properties.DefaultValues.InactivityTimeoutMeasure);

+       }

+       

+       private void loadStoragemanagerClass (Properties properties) {

+               String storageMgrClassStr = 
properties.getProperty(Constants.Properties.StorageManager);

+               boolean loaded = false;

+               

+               if (storageMgrClassStr!=null) {

+                       storageMgrClassStr = storageMgrClassStr.trim();

+                       propertyBean.setStorageManagerClass(storageMgrClassStr);

+                       loaded = true;

+               }

+               

+               if (!loaded)

+                       
propertyBean.setStorageManagerClass(Constants.Properties.DefaultValues.StorageManager);

+       }

+       

+       

+       

+       public boolean isExponentialBackoff () {

+               

+               return propertyBean.isExponentialBackoff();

+       }

+       

+       public long getRetransmissionInterval () {

+               return propertyBean.getRetransmissionInterval();

+       }

+       

+       public long getAcknowledgementInterval () {

+               return propertyBean.getAcknowledgementInaterval();

+       }

+       

+       public long getInactivityTimeout () {

+               return propertyBean.getInactiveTimeoutInterval();

+       }

+       

+       public String getStorageManagerClass () {

+               return propertyBean.getStorageManagerClass();

+       }

+       

+       public RMPolicyBean getRMPolicyBean () {

+               return propertyBean.getPolicyBean();

+       }

+       

+}


Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java 
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java 
Tue Nov 22 22:12:24 2005
@@ -61,9 +61,8 @@
 

        private static void setUpMessage(MessageContext rmMsgCtx) {

                //Seting RMPolicyBean

-               RMPolicyBean policyBean = new RMPolicyBean();

-               rmMsgCtx.setProperty(Constants.WSP.RM_POLICY_BEAN, policyBean);

-

+               if (rmMsgCtx.getProperty(Constants.WSP.RM_POLICY_BEAN)==null)

+                       rmMsgCtx.setProperty(Constants.WSP.RM_POLICY_BEAN, 
PropertyManager.getInstance().getRMPolicyBean());

        }

 

        public static RMMsgContext createCreateSeqMsg(


Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMPolicyManager.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMPolicyManager.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMPolicyManager.java 
(original)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMPolicyManager.java 
Tue Nov 22 22:12:24 2005
@@ -28,7 +28,9 @@
 public class RMPolicyManager {

 

        public static RMPolicyBean getPolicyBean(RMMsgContext msgContext) {

-               RMPolicyBean policyBean = new RMPolicyBean();

+               //TODO extract policies from the msgCtx.

+               

+               RMPolicyBean policyBean = 
PropertyManager.getInstance().getRMPolicyBean();

                return policyBean;

        }

 }

Added: 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java?rev=348383&view=auto
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java
 (added)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java
 Tue Nov 22 22:12:24 2005
@@ -0,0 +1,90 @@
+/*

+ * Copyright  1999-2004 The Apache Software Foundation.

+ *

+ *  Licensed under the Apache License, Version 2.0 (the "License");

+ *  you may not use this file except in compliance with the License.

+ *  You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ *  Unless required by applicable law or agreed to in writing, software

+ *  distributed under the License is distributed on an "AS IS" BASIS,

+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ *  See the License for the specific language governing permissions and

+ *  limitations under the License.

+ *

+ */

+

+package org.apache.sandesha2.util;

+

+import org.apache.sandesha2.policy.RMPolicyBean;

+

+/**

+ * @author Chamikara Jayalath <[EMAIL PROTECTED]>

+ */

+

+public class SandeshaPropertyBean {

+

+       RMPolicyBean policyBean = new RMPolicyBean ();

+       String storageManagerClass = null;

+    

+    public long getInactiveTimeoutInterval() {

+        return policyBean.getInactiveTimeoutInterval();

+    }

+    

+    public long getAcknowledgementInaterval() {

+        return policyBean.getAcknowledgementInaterval();

+    }

+    

+    public long getRetransmissionInterval() {

+        return policyBean.getRetransmissionInterval();

+    }

+    

+    public boolean isExponentialBackoff() {

+        return policyBean.isExponentialBackoff();

+    }

+    

+    public void setExponentialBackoff(boolean exponentialBackoff) {

+        policyBean.setExponentialBackoff(exponentialBackoff);    

+    }

+    

+    public void setRetransmissionInterval(long retransmissionInterval) {

+        policyBean.setRetransmissionInterval(retransmissionInterval);

+    }

+    

+    public void setInactiveTimeoutInterval(int value, String measure) {

+       long timeOut = -1;

+       

+        if (measure==null) {

+               policyBean.setInactiveTimeoutInterval(timeOut);

+               return;

+        } else if ("seconds".equals(measure)){

+               timeOut = value*1000;

+        } else if ("minutes".equals(measure)){

+               timeOut = value*60*1000;

+        } else if ("hours".equals(measure)){

+               timeOut = value*60*60*1000;

+        } else if ("days".equals(measure)){

+               timeOut = value*24*60*60*1000;

+        }

+        

+        policyBean.setInactiveTimeoutInterval(timeOut);

+        

+    }

+    

+    public void setAcknowledgementInterval(long acknowledgementInterval) {

+        policyBean.setAcknowledgementInterval(acknowledgementInterval);

+    }

+       

+       public String getStorageManagerClass() {

+               return storageManagerClass;

+       }

+       

+       public void setStorageManagerClass(String storageManagerClass) {

+               this.storageManagerClass = storageManagerClass;

+       }

+       

+       public RMPolicyBean getPolicyBean () {

+               return policyBean;

+       }

+}


Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java 
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java 
Tue Nov 22 22:12:24 2005
@@ -32,7 +32,12 @@
 import org.apache.axis2.context.ConfigurationContext;

 import org.apache.axis2.context.MessageContext;

 import org.apache.axis2.context.OperationContext;

+import org.apache.axis2.context.ServiceContext;

+import org.apache.axis2.context.ServiceGroupContext;

 import org.apache.axis2.description.AxisOperation;

+import org.apache.axis2.description.AxisService;

+import org.apache.axis2.description.AxisServiceGroup;

+import org.apache.axis2.engine.AxisConfiguration;

 import org.apache.axis2.i18n.Messages;

 import org.apache.axis2.om.OMElement;

 import org.apache.axis2.om.impl.llom.builder.StAXBuilder;

@@ -453,34 +458,58 @@
                                        .getMessageContext();

                        ConfigurationContext configContext = referenceMessage

                                        .getSystemContext();

+                       AxisConfiguration axisConfiguration = 
configContext.getAxisConfiguration();

+                       

                        MessageContext newMessageContext = new 
MessageContext(configContext);

 

                        if (referenceMessage.getAxisServiceGroup() != null) {

                                
newMessageContext.setAxisServiceGroup(referenceMessage

                                                .getAxisServiceGroup());

-                       }

-

-                       if (referenceMessage.getAxisService() != null) {

-                               
newMessageContext.setAxisService(referenceMessage

-                                               .getAxisService());

-                       }

-

-                       newMessageContext.setAxisOperation(operation);

-

-                       if (referenceMessage.getServiceGroupContext() != null) {

                                
newMessageContext.setServiceGroupContext(referenceMessage

                                                .getServiceGroupContext());

                                
newMessageContext.setServiceGroupContextId(referenceMessage

                                                .getServiceGroupContextId());

+                       } else {

+                               AxisServiceGroup axisServiceGroup = new 
AxisServiceGroup (axisConfiguration);

+                               ServiceGroupContext serviceGroupContext = new 
ServiceGroupContext (configContext,axisServiceGroup);

+                               

+                               
newMessageContext.setAxisServiceGroup(axisServiceGroup);

+                               newMessageContext.setServiceGroupContext 
(serviceGroupContext);

                        }

 

-                       if (referenceMessage.getServiceContext() != null) {

+                       if (referenceMessage.getAxisService() != null) {

+                               
newMessageContext.setAxisService(referenceMessage

+                                               .getAxisService());

                                
newMessageContext.setServiceContext(referenceMessage

                                                .getServiceContext());

                                
newMessageContext.setServiceContextID(referenceMessage

                                                .getServiceContextID());

+                       } else {

+                               AxisService axisService = new AxisService (new 
QName ("AnonymousRMService")); //just a dummy name.

+                               ServiceContext serviceContext = new 
ServiceContext (axisService,newMessageContext.getServiceGroupContext());

+                               

+                               newMessageContext.setAxisService(axisService);

+                               
newMessageContext.setServiceContext(serviceContext);

                        }

 

+                       newMessageContext.setAxisOperation(operation);

+

+//                     if (referenceMessage.getServiceGroupContext() != null) {

+//                             
newMessageContext.setServiceGroupContext(referenceMessage

+//                                             .getServiceGroupContext());

+//                             
newMessageContext.setServiceGroupContextId(referenceMessage

+//                                             .getServiceGroupContextId());

+//                     }

+//

+//                     if (referenceMessage.getServiceContext() != null) {

+//                             
newMessageContext.setServiceContext(referenceMessage

+//                                             .getServiceContext());

+//                             
newMessageContext.setServiceContextID(referenceMessage

+//                                             .getServiceContextID());

+//                     } else {

+//                             

+//                     }

+

                        OperationContext operationContext = new 
OperationContext(operation);

                        newMessageContext.setOperationContext(operationContext);

                        operationContext.addMessageContext(newMessageContext);

@@ -501,6 +530,9 @@
                        
newMessageContext.setProperty(HTTPConstants.HTTPOutTransportInfo,

                                        referenceMessage

                                                        
.getProperty(HTTPConstants.HTTPOutTransportInfo));

+                       
newMessageContext.setProperty(Constants.WSP.RM_POLICY_BEAN,

+                                       referenceMessage

+                                       
.getProperty(Constants.WSP.RM_POLICY_BEAN));

 

                        return newMessageContext;

 


Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java?rev=348383&r1=348382&r2=348383&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java 
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java Tue 
Nov 22 22:12:24 2005
@@ -108,6 +108,7 @@
                                                }

 

                                                try {

+                                                       
System.out.println("Sending message:" + 
SandeshaUtil.getMessageTypeString(rmMsgCtx.getMessageType()));

                                                        new 
AxisEngine(context).send(msgCtx);

                                                } catch (Exception e) {

                                                        //Exception is sending. 
retry later




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to