ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sanka Samaranayake <ssa...@gmail.com>
Subject [Sandesha2] svn commit: r371847 src/org/apache/sandesha2/ src/org/apache/sandesha2/policy/ src/org/apache/sandesha2/policy/processors/ src/org/apache/sandesha2/util/
Date Tue, 24 Jan 2006 07:07:36 GMT
Hi All,

This mail was bounced back due to some reason and I am resending to
the dev-mailing list for information purposes.

Best,
Sanka

--- Below this line is a copy of the message.

Return-Path: <sanka@apache.org>
Received: (qmail 41351 invoked by uid 500); 24 Jan 2006 06:58:53 -0000
Delivered-To: apmail-ws-sandesha-cvs@ws.apache.org
Received: (qmail 41348 invoked by uid 99); 24 Jan 2006 06:58:53 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49)
   by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jan 2006 22:58:53 -0800
X-ASF-Spam-Status: No, hits=-8.6 required=10.0
       tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME
X-Spam-Check-By: apache.org
Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194)
   by apache.org (qpsmtpd/0.29) with SMTP; Mon, 23 Jan 2006 22:58:50 -0800
Received: (qmail 89205 invoked by uid 65534); 24 Jan 2006 06:58:30 -0000
Message-ID: <20060124065830.89203.qmail@minotaur.apache.org>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r371847 - in /webservices/sandesha/trunk: config/
 src/org/apache/sandesha2/ src/org/apache/sandesha2/policy/
 src/org/apache/sandesha2/policy/processors/ src/org/apache/sandesha2/util/
Date: Tue, 24 Jan 2006 06:58:26 -0000
To: sandesha-cvs@ws.apache.org
From: sanka@apache.org
X-Mailer: svnmailer-1.0.5
X-Virus-Checked: Checked by ClamAV on apache.org

Author: sanka
Date: Mon Jan 23 22:58:06 2006
New Revision: 371847

URL: http://svn.apache.org/viewcvs?rev=371847&view=rev
Log:
Added: RMPolicyProcessor to build configuration information form
Sandesha2 Policy Assertions.
Modified: PropertyManager to load configuration from Sandesha2 Policy
Assertions declared in module.xml


Added:
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicy.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyToken.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMProcessorContext.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/AcknowledgementIntervalProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/ExponentialBackoffProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutMeasureProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InvokeInOrderProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/MessageTypesToDropProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/RetransmissionItervalProcessor.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/StorageManagersProcessor.java
Modified:
   webservices/sandesha/trunk/config/module.xml
   webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
   webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java

Modified: webservices/sandesha/trunk/config/module.xml
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/config/module.xml?rev=371847&r1=371846&r2=371847&view=diff
==============================================================================
--- webservices/sandesha/trunk/config/module.xml (original)
+++ webservices/sandesha/trunk/config/module.xml Mon Jan 23 22:58:06 2006
@@ -27,36 +27,37 @@
        <parameter name="wsamapping"
locked="xsd:false">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</parameter>
    </operation>

-
-    <!--  PARAMETERS FOR SANDESHA2                     -->
-    <!--  ========================                     -->
-
-    <!--  RM Policy values for the server              -->
-
-    <parameter name="RetransmissionInterval"
locked="xsd:false">10000</parameter>
-    <parameter name="AcknowledgementInterval"
locked="xsd:false">4000</parameter>
-    <parameter name="ExponentialBackoff" locked="xsd:false">false</parameter>
-    <parameter name="InactivityTimeout" locked="xsd:false">5</parameter>
-    <parameter name="InactivityTimeoutMeasure"
locked="xsd:false">days</parameter>
-
-
-    <!--  Storage Manager Class                         -->
+
+
+   <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+       xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+    xmlns:wsrm="http://ws.apache.org/sandesha2/policy" wsu:Id="RMPolicy">
+
+      <wsrm:AcknowledgementInterval>4000</wsrm:AcknowledgementInterval>
+
+
+      <wsrm:RetransmissionInterval>10000</wsrm:RetransmissionInterval>
+
+      <wsrm:ExponentialBackoff>true</wsrm:ExponentialBackoff>
+
+      <wsrm:InactivityTimeout>5</wsrm:InactivityTimeout>
+
+      <wsrm:InactivityTimeoutMeasure>days</wsrm:InactivityTimeoutMeasure>
+
+      <wsrm:InvokeInOrder>true</wsrm:InvokeInOrder>
+
+      <wsrm:MessageTypesToDrop>none</wsrm:MessageTypesToDrop>
+
+       <wsrm:StorageManagers>

-    <parameter name="StorageManager"
locked="xsd:false">org.apache.sandesha2.storage.inmemory.InMemoryStorageManager</parameter>
-    <!-- <parameter name="StorageManager"
locked="xsd:false">org.apache.sandesha2.storage.persistent.hibernate.PersistentStorageManager</parameter>
-->
-
-
-    <!-- Delivery Assurance                             -->
-
-    <parameter name="InvokeInOrder" locked="xsd:false">true</parameter>
-
-
-    <!-- System Configurations (only for advance users)  -->
-    <!-- ==============================================  -->
-
-    <!-- SenderConfiguration                             -->
-
-    <parameter name="MessageTypesToDrop" locked="xsd:false">none</parameter>
-
-
+        <wsrm:PermanentStorageManager>
+        </wsrm:PermanentStorageManager>
+
+        <wsrm:InmemoryStorageManager>
+          org.apache.sandesha2.storage.inmemory.InMemoryStorageManager
+        </wsrm:InmemoryStorageManager>
+
+      </wsrm:StorageManagers>
+
+</wsp:Policy>
 </module>

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java?rev=371847&r1=371846&r2=371847&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
Mon Jan 23 22:58:06 2006
@@ -17,6 +17,9 @@

 package org.apache.sandesha2;

+import java.beans.beancontext.BeanContext;
+import java.util.ArrayList;
+
 import javax.xml.namespace.QName;

 import org.apache.axis2.AxisFault;
@@ -25,10 +28,15 @@
 import org.apache.axis2.description.ModuleDescription;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.modules.Module;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyProcessor;
+import org.apache.sandesha2.policy.RMProcessorContext;
 import org.apache.sandesha2.storage.StorageManager;
 import org.apache.sandesha2.util.PropertyManager;
 import org.apache.sandesha2.util.SandeshaPropertyBean;
 import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.ws.policy.Policy;
+

 /**
 * The Module class of Sandesha2.
@@ -38,67 +46,62 @@

 public class SandeshaModule implements Module {

-
       // initialize the module
-       public void init(ConfigurationContext configContext,
ModuleDescription module) throws AxisFault {
-
-               //continueUncompletedSequences (storageManager,configCtx);
-
-               //loading properties to property manager.
-              
PropertyManager.getInstance().loadPropertiesFromModuleDesc(module);
+       public void init(ConfigurationContext configContext,
+                       ModuleDescription module) throws AxisFault {

+               // continueUncompletedSequences (storageManager,configCtx);
+
+               // loading properties to property manager.
+               
PropertyManager.getInstance().loadPropertiesFromModuleDesc(module);
       }
-
-
+
       public void engageNotify(AxisDescription axisDescription)
throws AxisFault {
-
+
               // TODO add notify logic.
-
+
       }

+       private void continueUncompletedSequences(StorageManager storageManager,
+                       ConfigurationContext configCtx) {
+               // server side continues
+               // SandeshaUtil.startInvokerIfStopped(configCtx);
+
+               // server side re-injections
+
+               // reinject everything that has been acked within the
in-handler but
+               // have not been invoked.

+               // client side continues
+               // SandeshaUtil.startSenderIfStopped(configCtx);

+               // client side re-injections

-       private void continueUncompletedSequences (StorageManager
storageManager,ConfigurationContext configCtx) {
-               //server side continues
-               //SandeshaUtil.startInvokerIfStopped(configCtx);
-
-               //server side re-injections
-
-               //reinject everything that has been acked within the
in-handler but have not been invoked.
-
-
-               //client side continues
-               //SandeshaUtil.startSenderIfStopped(configCtx);
-
-               //client side re-injections
-
-
       }

       // shutdown the module
       public void shutdown(AxisConfiguration axisSystem) throws AxisFault {

       }
-
-       //Removing data of uncontinuuable sequences so that the
sandesha2 system will not be confused
-       private void cleanStorage (StorageManager storageManager)
throws AxisFault {
-
+
+       // Removing data of uncontinuuable sequences so that the
sandesha2 system
+       // will not be confused
+       private void cleanStorage(StorageManager storageManager)
throws AxisFault {
+
               storageManager.initStorage();
-
-               //server side cleaning
-
-               //cleaning NextMsgData
-               //Cleaning InvokerData
-
-
-               //client side cleaning
-
-               //cleaning RetransmitterData
-               //cleaning CreateSequenceData
-
-               //cleaning sequence properties
-
+
+               // server side cleaning
+
+               // cleaning NextMsgData
+               // Cleaning InvokerData
+
+               // client side cleaning
+
+               // cleaning RetransmitterData
+               // cleaning CreateSequenceData
+
+               // cleaning sequence properties
+
       }
-
+
 }

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,106 @@
+package org.apache.sandesha2.policy;
+
+public class PolicyEngineData {
+
+       private long acknowledgementInterval;
+       private boolean exponentialBackoff;
+       private long inactivityTimeout;
+       private String inactivityTimeoutMeassure;
+       private boolean invokeInOrder;
+       private String messageTypesToDrop;
+       private long retransmissionInterval;
+       private String permanentStorageMgr;
+       private String inmemoryStorageManager;
+
+
+       public boolean isExponentialBackoff() {
+               return exponentialBackoff;
+       }
+
+       public void setExponentialBackoff(boolean exponentialBackoff) {
+               this.exponentialBackoff = exponentialBackoff;
+       }
+
+       public long getInactivityTimeout() {
+               return inactivityTimeout;
+       }
+
+       public void setInactivityTimeout(long inactivityTimeout) {
+               this.inactivityTimeout = inactivityTimeout;
+       }
+
+       public String getInactivityTimeoutMeassure() {
+               return inactivityTimeoutMeassure;
+       }
+
+       public void setInactivityTimeoutMeassure(String
inactivityTimeoutMeassure) {
+               this.inactivityTimeoutMeassure = inactivityTimeoutMeassure;
+       }
+
+       public boolean isInvokeInOrder() {
+               return invokeInOrder;
+       }
+
+       public void setInvokeInOrder(boolean invokeInOrder) {
+               this.invokeInOrder = invokeInOrder;
+       }
+
+       public String getMessageTypesToDrop() {
+               return messageTypesToDrop;
+       }
+
+       public void setMessageTypesToDrop(String messageTypesToDrop) {
+               this.messageTypesToDrop = messageTypesToDrop;
+       }
+
+       public long getRetransmissionInterval() {
+               return retransmissionInterval;
+       }
+
+       public void setRetransmissionInterval(long retransmissionInterval) {
+               this.retransmissionInterval = retransmissionInterval;
+       }
+
+       public String getPermanentStorageManager() {
+               return permanentStorageMgr;
+       }
+
+       public void setPermanentStorageManager(String storageManager) {
+               this.permanentStorageMgr = storageManager;
+       }
+
+       public void initializeWithDefaults() {
+
+       }
+
+       public PolicyEngineData copy() {
+               PolicyEngineData ped = new PolicyEngineData();
+
+              
ped.setAcknowledgementInterval(this.getAcknowledgementInterval());
+               ped.setExponentialBackoff(this.isExponentialBackoff());
+               ped.setInactivityTimeout(this.getInactivityTimeout());
+              
ped.setInactivityTimeoutMeassure(this.getInactivityTimeoutMeassure());
+               ped.setInvokeInOrder(this.isInvokeInOrder());
+               ped.setMessageTypesToDrop(this.getMessageTypesToDrop());
+               ped.setRetransmissionInterval(this.getRetransmissionInterval());
+              
ped.setPermanentStorageManager(this.getPermanentStorageManager());
+
+               return ped;
+       }
+
+       public void setAcknowledgementInterval(long acknowledgementInterval) {
+               this.acknowledgementInterval = acknowledgementInterval;
+       }
+
+       public long getAcknowledgementInterval() {
+               return acknowledgementInterval;
+       }
+
+       public void setInmemoryStorageManager(String inmemoryStorageManager) {
+               this.inmemoryStorageManager = inmemoryStorageManager;
+       }
+
+       public String getInmemoryStorageManager() {
+               return inmemoryStorageManager;
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicy.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicy.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicy.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicy.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,45 @@
+package org.apache.sandesha2.policy;
+
+
+public class RMPolicy {
+
+       public static final RMPolicyToken retransmissionIterval = new
RMPolicyToken(
+                       "RetransmissionInterval", RMPolicyToken.SIMPLE_TOKEN,
+                       new String[] { "Milliseconds" });
+
+       public static final RMPolicyToken acknowledgementInterval =
new RMPolicyToken(
+                       "AcknowledgementInterval", RMPolicyToken.SIMPLE_TOKEN,
+                       new String[] {});
+
+       public static final RMPolicyToken exponentialBackoff = new
RMPolicyToken(
+                       "ExponentialBackoff",
RMPolicyToken.SIMPLE_TOKEN, new String[] {});
+
+       public static final RMPolicyToken inactiveTimeout = new RMPolicyToken(
+                       "InactivityTimeout",
RMPolicyToken.SIMPLE_TOKEN, new String[] {});
+
+       public static final RMPolicyToken inactiveTimeoutMeasure = new
RMPolicyToken(
+                       "InactivityTimeoutMeasure", RMPolicyToken.SIMPLE_TOKEN,
+                       new String[] {});
+
+       public static final RMPolicyToken invokeInOrder = new RMPolicyToken(
+                       "InvokeInOrder", RMPolicyToken.SIMPLE_TOKEN,
new String[] {});
+
+       public static final RMPolicyToken messageTypeToDrop = new RMPolicyToken(
+                       "MessageTypesToDrop",
RMPolicyToken.SIMPLE_TOKEN, new String[] {});
+
+       public static final RMPolicyToken storageManagers = new RMPolicyToken(
+                       "StorageManagers",
RMPolicyToken.COMPLEX_TOKEN, new String[] {});
+
+       public static final RMPolicyToken permenentStorageManager =
new RMPolicyToken(
+                       "PermanentStorageManager",
RMPolicyToken.SIMPLE_TOKEN, new String[]{});
+
+       public static final RMPolicyToken inmemoryStorageManager = new
RMPolicyToken(
+                       "InmemoryStorageManager",
RMPolicyToken.SIMPLE_TOKEN, new String[]{});
+
+       public static final String includeNever =
"http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never";
+
+       public static final String includeOnce =
"http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Once";
+
+       public static final String includeAlways =
"http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always";
+
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,326 @@
+package org.apache.sandesha2.policy;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.processors.AcknowledgementIntervalProcessor;
+import org.apache.sandesha2.policy.processors.ExponentialBackoffProcessor;
+import org.apache.sandesha2.policy.processors.InactivityTimeoutMeasureProcessor;
+import org.apache.sandesha2.policy.processors.InactivityTimeoutProcessor;
+import org.apache.sandesha2.policy.processors.InvokeInOrderProcessor;
+import org.apache.sandesha2.policy.processors.MessageTypesToDropProcessor;
+import org.apache.sandesha2.policy.processors.RetransmissionItervalProcessor;
+import org.apache.sandesha2.policy.processors.StorageManagersProcessor;
+import org.apache.ws.policy.AndCompositeAssertion;
+import org.apache.ws.policy.Assertion;
+import org.apache.ws.policy.Policy;
+import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.ws.policy.XorCompositeAssertion;
+import org.apache.ws.policy.util.PolicyFactory;
+import org.apache.ws.policy.util.PolicyReader;
+
+public class RMPolicyProcessor {
+
+       Log logger = LogFactory.getLog(this.getClass().getName());
+
+       PolicyReader prdr = null;
+
+       RMPolicyToken topLevel = new RMPolicyToken("_TopLevel_",
+                       RMPolicyToken.COMPLEX_TOKEN, null);
+
+       RMProcessorContext rmProcessorContext = null;
+
+       public boolean setup() throws NoSuchMethodException {
+               logger.debug("RMPolicyProcessor:setUp");
+
+               prdr =
PolicyFactory.getPolicyReader(PolicyFactory.OM_POLICY_READER);
+               /*
+                * Initialize the top level security policy token.
+                */
+               RMPolicyToken rpt = null;
+
+               RetransmissionItervalProcessor rip = new
RetransmissionItervalProcessor();
+               rpt = RMPolicy.retransmissionIterval.copy();
+               rpt.setProcessTokenMethod(rip);
+               topLevel.setChildToken(rpt);
+
+               AcknowledgementIntervalProcessor aip = new
AcknowledgementIntervalProcessor();
+               rpt = RMPolicy.acknowledgementInterval.copy();
+               rpt.setProcessTokenMethod(aip);
+               topLevel.setChildToken(rpt);
+
+               ExponentialBackoffProcessor ebp = new
ExponentialBackoffProcessor();
+               rpt = RMPolicy.exponentialBackoff.copy();
+               rpt.setProcessTokenMethod(ebp);
+               topLevel.setChildToken(rpt);
+
+               InactivityTimeoutMeasureProcessor itmp = new
InactivityTimeoutMeasureProcessor();
+               rpt = RMPolicy.inactiveTimeoutMeasure.copy();
+               rpt.setProcessTokenMethod(itmp);
+               topLevel.setChildToken(rpt);
+
+               InactivityTimeoutProcessor itp = new
InactivityTimeoutProcessor();
+               rpt = RMPolicy.inactiveTimeout.copy();
+               rpt.setProcessTokenMethod(itp);
+               topLevel.setChildToken(rpt);
+
+               InvokeInOrderProcessor iiop = new InvokeInOrderProcessor();
+               rpt = RMPolicy.invokeInOrder.copy();
+               rpt.setProcessTokenMethod(iiop);
+               topLevel.setChildToken(rpt);
+
+               MessageTypesToDropProcessor mttdp = new
MessageTypesToDropProcessor();
+               rpt = RMPolicy.messageTypeToDrop.copy();
+               rpt.setProcessTokenMethod(mttdp);
+               topLevel.setChildToken(rpt);
+
+               StorageManagersProcessor smp = new StorageManagersProcessor();
+               rpt = RMPolicy.storageManagers.copy();
+               rpt.setProcessTokenMethod(smp);
+               topLevel.setChildToken(rpt);
+
+               /*
+                * Now get the initial PolicyEngineData, initialize it
and put it onto
+                * the PED stack.
+                */
+               PolicyEngineData ped = new PolicyEngineData();
+               ped.initializeWithDefaults();
+
+               /*
+                * Now get a context and push the top level token onto
the token stack.
+                * The top level token is a special token that acts as
anchor to start
+                * parsing.
+                */
+               rmProcessorContext = new RMProcessorContext();
+               rmProcessorContext.pushRMToken(topLevel);
+               rmProcessorContext.pushPolicyEngineData(ped);
+
+               return true;
+       }
+
+       /**
+        * This method takes a normalized policy object, processes it
and returns
+        * true if all assertion can be fulfilled.
+        *
+        * Each policy must be nromalized accordig to the WS Policy framework
+        * specification. Therefore a policy has one child
(wsp:ExactlyOne) that is
+        * a XorCompositeAssertion. This child may contain one or more
other terms
+        * (alternatives). To match the policy one of these terms (alternatives)
+        * must match. If none of the contained terms match this
policy cannot be
+        * enforced.
+        *
+        * @param policy
+        *            The policy to process
+        * @return True if this policy can be enforced by the policy enforcement
+        *         implmentation
+        */
+       public boolean processPolicy(Policy policy) {
+               logger.debug("RMPolicyProcessor:processPolicy");
+
+               if (!policy.isNormalized()) {
+                       policy = (Policy) policy.normalize();
+               }
+
+               XorCompositeAssertion xor = (XorCompositeAssertion)
policy.getTerms()
+                               .get(0);
+               List listOfPolicyAlternatives = xor.getTerms();
+
+               boolean success = false;
+               int numberOfAlternatives = listOfPolicyAlternatives.size();
+
+               for (int i = 0; !success && i < numberOfAlternatives; i++) {
+                       AndCompositeAssertion aPolicyAlternative =
(AndCompositeAssertion) listOfPolicyAlternatives
+                                       .get(i);
+
+                       List listOfAssertions = aPolicyAlternative.getTerms();
+
+                       Iterator iterator = listOfAssertions.iterator();
+                       /*
+                        * Loop over all assertions in this
alternative. If all assertions
+                        * can be fulfilled then we choose this
alternative and signal a
+                        * success.
+                        */
+                       boolean all = true;
+                       while (all && iterator.hasNext()) {
+                               Assertion assertion = (Assertion)
iterator.next();
+
+                               /*
+                                * At this point we expect
PrimitiveAssertions only.
+                                */
+                               if (!(assertion instanceof
PrimitiveAssertion)) {
+                                       logger.debug("Got a unexpected
assertion type: "
+                                                       +
assertion.getClass().getName());
+                                       continue;
+                               }
+                               /*
+                                * We need to pick only the primitive
assertions which contain a
+                                * WSRM policy assertion. For that
we'll check the namespace of
+                                * the primitive assertion
+                                */
+                               PrimitiveAssertion pa =
(PrimitiveAssertion) assertion;
+                               if (!(pa.getName().getNamespaceURI()
+                                              
.equals("http://ws.apache.org/sandesha2/policy"))) {
+                                       logger.debug("Got a unexpected
assertion: "
+                                                       +
pa.getName().getLocalPart());
+                                       continue;
+                               }
+                               all =
processPrimitiveAssertion((PrimitiveAssertion) assertion);
+                       }
+                       /*
+                        * copy the status of assertion processing. If
all is true then this
+                        * alternative is "success"ful
+                        */
+                       success = all;
+               }
+               return success;
+       }
+
+       boolean processPrimitiveAssertion(PrimitiveAssertion pa) {
+               logger.debug("RMPolicyManager:processPrimitiveAssertion");
+
+               boolean commit = true;
+
+               commit = startPolicyTransaction(pa);
+
+               List terms = pa.getTerms();
+               if (commit && terms.size() > 0) {
+                       for (int i = 0; commit && i < terms.size(); i++) {
+                               Assertion assertion = (Assertion)
pa.getTerms().get(i);
+                               if (assertion instanceof Policy) {
+                                       commit =
processPolicy((Policy) assertion);
+                               } else if (assertion instanceof
PrimitiveAssertion) {
+                                       commit =
processPrimitiveAssertion((PrimitiveAssertion) assertion);
+                               }
+                       }
+               }
+               if (commit) {
+                       commitPolicyTransaction(pa);
+               } else {
+                       abortPolicyTransaction(pa);
+               }
+               return commit;
+       }
+
+       public boolean startPolicyTransaction(PrimitiveAssertion pa) {
+               logger.debug("RMPolicyProcessor:startPolicyTransaction");
+
+               String tokenName = pa.getName().getLocalPart();
+
+               RMPolicyToken rmpt = null;
+
+               /*
+                * Get the current rm policy token from the context
and check if the
+                * current token supports/contains this assertion as
token. If yes set
+                * this token as current token (push onto stack), set
the assertion into
+                * context and call the processing method for this token.
+                */
+               RMPolicyToken currentToken = rmProcessorContext
+                               .readCurrentSecurityToken();
+               if (currentToken == null) {
+                       logger.error("Internal error on token stack -
No current token");
+                       System.exit(1);
+               }
+               rmpt = currentToken.getChildToken(tokenName);
+               rmProcessorContext.pushRMToken(rmpt);
+               rmProcessorContext.setAssertion(pa);
+               rmProcessorContext.setAction(RMProcessorContext.START);
+
+               /*
+                * Get the current state of the PolicyEngineData, make
a copy of it and
+                * push the copy onto the PED stack. The token method
works on this
+                * copy, adding its data.
+                */
+               PolicyEngineData ped =
rmProcessorContext.readCurrentPolicyEngineData();
+               ped = ped.copy();
+               rmProcessorContext.pushPolicyEngineData(ped);
+               if (rmpt == null) {
+                       logger
+                                       .debug("RM token: '" + tokenName
+                                                       + "' unknown
in context of '"
+                                                       +
currentToken.getTokenName());
+                       return false;
+               }
+               boolean ret = false;
+
+               try {
+                       ret = rmpt.invokeProcessTokenMethod(rmProcessorContext);
+               } catch (Exception ex) {
+                       logger.error("Exception occured when invoking
processTokenMethod",
+                                       ex);
+               } finally {
+                       rmProcessorContext.setAction(RMProcessorContext.NONE);
+               }
+               return ret;
+       }
+
+       public void abortPolicyTransaction(PrimitiveAssertion pa) {
+               logger.debug("RMPolicyProcessor:abortPolicyTransaction");
+
+               RMPolicyToken currentToken = rmProcessorContext
+                               .readCurrentSecurityToken();
+               if (currentToken == null) {
+                       logger.debug("Abort transaction because of
unknown token: '"
+                                       + pa.getName().getLocalPart() + "'");
+
+                       rmProcessorContext.popRMToken();
+                       return;
+               }
+
+               rmProcessorContext.setAssertion(pa);
+               rmProcessorContext.setAction(RMProcessorContext.ABORT);
+               try {
+                      
currentToken.invokeProcessTokenMethod(rmProcessorContext);
+
+               } catch (Exception ex) {
+                       logger.error("Exception occured when invoking
processTokenMethod:",
+                                       ex);
+
+               } finally {
+                       rmProcessorContext.setAction(RMProcessorContext.NONE);
+                       rmProcessorContext.popRMToken();
+                       rmProcessorContext.popPolicyEngineData();
+
+               }
+       }
+
+       public void commitPolicyTransaction(PrimitiveAssertion pa) {
+               logger.debug("RMPolicyProcessor:commitPolicyTransaction");
+
+               RMPolicyToken currentToken = rmProcessorContext
+                               .readCurrentSecurityToken();
+               if (currentToken == null) {
+                       logger.error("Internal error on token stack -
Commiting an unknown token: "
+                                                       +
pa.getName().getLocalPart() + "'");
+                       System.exit(1);
+               }
+               rmProcessorContext.setAssertion(pa);
+               rmProcessorContext.setAction(RMProcessorContext.COMMIT);
+               try {
+                      
currentToken.invokeProcessTokenMethod(rmProcessorContext);
+               } catch (IllegalArgumentException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (IllegalAccessException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (InvocationTargetException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } finally {
+                       rmProcessorContext.setAction(RMProcessorContext.NONE);
+                       rmProcessorContext.popRMToken();
+                       rmProcessorContext.commitPolicyEngineData();
+               }
+       }
+
+       public RMProcessorContext getContext() {
+               return rmProcessorContext;
+       }
+
+       public void setContext(RMProcessorContext rmProcessorContext) {
+               this.rmProcessorContext = rmProcessorContext;
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyToken.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyToken.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyToken.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyToken.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,147 @@
+package org.apache.sandesha2.policy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class RMPolicyToken {
+       /**
+        * The following values describe the type of the rm pocliy
token. A complex
+        * token starts a transaction because it contains nested
tokens. A simple
+        * token does not contain nested tokens but stands allone an defines a
+        * simple assertion or property.
+        *
+        * If Content is set then this token contains additional text
content, e.g.
+        * XPath expressions.
+        */
+       public static final int COMPLEX_TOKEN = 1;
+
+       public static final int SIMPLE_TOKEN = 2;
+
+       public static final int WITH_CONTENT = 100;
+
+       private String tokenName;
+
+       private int tokenType = 0;
+
+       // private boolean supported = false;
+
+       private String[] attributes = null;
+
+       private Object handler = null;
+
+       private Method processTokenMethod = null;
+
+       private ArrayList childTokens = null;
+
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public RMPolicyToken(String token, int type, String[] attribs,
+                       Object h) throws SecurityException,
NoSuchMethodException {
+               this(token, type, attribs);
+               setProcessTokenMethod(h);
+       }
+
+       public RMPolicyToken(String token, int type, String[] attribs) {
+              
logger.debug("RMPolicyToken:RMPolicyTokey(String,int,String[])");
+               tokenName = token;
+               tokenType = type;
+               attributes = attribs;
+
+               if (tokenType == COMPLEX_TOKEN) {
+                       childTokens = new ArrayList();
+               }
+       }
+
+       /**
+        * @return Returns the attributes.
+        */
+       public String[] getAttributes() {
+               return attributes;
+       }
+
+       public void setProcessTokenMethod(Object h) throws
NoSuchMethodException {
+               logger.debug("RMPolicyToken:setProcessTokenMethod");
+
+               if (h == null) {
+                       return;
+               }
+               handler = h;
+               Class handlerCls = h.getClass();
+               Class[] parameters = new Class[] { RMProcessorContext.class };
+
+               processTokenMethod = handlerCls.getDeclaredMethod("do"
+ tokenName,
+                               parameters);
+       }
+
+       public boolean invokeProcessTokenMethod(RMProcessorContext spc)
+                       throws IllegalArgumentException, IllegalAccessException,
+                       InvocationTargetException {
+               logger.debug("RMPolicyToken:invokeProcessTokenMethod");
+
+               if (processTokenMethod == null) {
+                       return false;
+               }
+               Object[] parameter = new Object[] { spc };
+               Object ret = processTokenMethod.invoke(handler, parameter);
+               Boolean bool;
+               if (ret instanceof Boolean) {
+                       bool = (Boolean) ret;
+                       return bool.booleanValue();
+               }
+               return false;
+       }
+
+       public String getTokenName() {
+               logger.debug("RMPolicyToken:getTokenName");
+               return tokenName;
+       }
+
+       public void setChildToken(RMPolicyToken spt) {
+               logger.debug("RMPolicyToken:setChildToken");
+               childTokens.add(spt);
+       }
+
+       public RMPolicyToken getChildToken(String sptName) {
+               logger.debug("RMPolicyToken:getChildToken");
+               Iterator it = childTokens.iterator();
+               while (it.hasNext()) {
+                       RMPolicyToken tmpSpt = (RMPolicyToken) it.next();
+                       if (sptName.equals(tmpSpt.getTokenName())) {
+                               return tmpSpt;
+                       }
+               }
+               return null;
+       }
+
+
+       public void removeChildToken(String sptName) {
+               logger.debug("RMPolicyToken:removeChildToken");
+               Iterator it = childTokens.iterator();
+               while (it.hasNext()) {
+                       RMPolicyToken tmpSpt = (RMPolicyToken) it.next();
+                       if (sptName.equals(tmpSpt.getTokenName())) {
+                               childTokens.remove(tmpSpt);
+                               return;
+                       }
+               }
+       }
+
+       public RMPolicyToken copy() {
+               logger.debug("RMPolicyToken:copy");
+               RMPolicyToken spt = new RMPolicyToken(tokenName, tokenType,
+                               attributes);
+               if (childTokens != null) {
+                       Iterator it = childTokens.iterator();
+                       while (it.hasNext()) {
+                               RMPolicyToken tmpSpt = (RMPolicyToken)
it.next();
+                               spt.setChildToken(tmpSpt);
+                       }
+               }
+               return spt;
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMProcessorContext.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMProcessorContext.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMProcessorContext.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMProcessorContext.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,115 @@
+package org.apache.sandesha2.policy;
+
+import java.util.ArrayList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.policy.PrimitiveAssertion;
+
+
+public class RMProcessorContext {
+       public static final int NONE = 0;
+       public static final int START = 1;
+       public static final int COMMIT = 2;
+       public static final int ABORT = 3;
+
+       public static final String[] ACTION_NAMES = new
String[]{"NONE", "START", "COMMIT", "ABORT"};
+
+       private ArrayList tokenStack = new ArrayList();
+
+       private int tokenStackPointer = 0;
+
+    private ArrayList pedStack = new ArrayList();
+
+    private int pedStackPointer = 0;
+
+    private PrimitiveAssertion assertion = null;
+
+       private int action = NONE;
+
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public RMProcessorContext() {
+       }
+
+       public int getAction() {
+               return action;
+       }
+
+       public void setAction(int act) {
+               this.action = act;
+       }
+
+       public PrimitiveAssertion getAssertion() {
+               return assertion;
+       }
+
+       public void setAssertion(PrimitiveAssertion asrt) {
+               this.assertion = asrt;
+       }
+
+       public void pushRMToken(RMPolicyToken spt) {
+               logger.debug("RMProcessorContext:pushRMToken");
+               tokenStack.add(tokenStackPointer, spt);
+               tokenStackPointer++;
+       }
+
+       public RMPolicyToken popRMToken() {
+               logger.debug("RMProcessorContext:popRMToken");
+               if (tokenStackPointer > 0) {
+                       tokenStackPointer--;
+                       return (RMPolicyToken)
tokenStack.get(tokenStackPointer);
+               } else {
+                       return null;
+               }
+       }
+
+       public RMPolicyToken readCurrentSecurityToken() {
+               logger.debug("RMProcessorContext:readCurrentSecurityToken");
+               if (tokenStackPointer > 0) {
+                       return (RMPolicyToken)
tokenStack.get(tokenStackPointer - 1);
+               } else {
+                       return null;
+               }
+       }
+
+    public void pushPolicyEngineData(PolicyEngineData ped) {
+       logger.debug("RMProcessorContext:pushPolicyEngineData");
+        pedStack.add(pedStackPointer, ped);
+        pedStackPointer++;
+    }
+
+    public PolicyEngineData popPolicyEngineData() {
+       logger.debug("RMProcessorContext:popPolicyEngineData");
+        if (pedStackPointer > 0) {
+            pedStackPointer--;
+            return (PolicyEngineData) pedStack.get(pedStackPointer);
+        } else {
+            return null;
+        }
+    }
+
+    public PolicyEngineData readCurrentPolicyEngineData() {
+       logger.debug("RMProcessorContext:readCurrentPolicyEngineData");
+        if (pedStackPointer > 0) {
+            return (PolicyEngineData) pedStack.get(pedStackPointer - 1);
+        } else {
+            return null;
+        }
+    }
+
+    public PolicyEngineData commitPolicyEngineData() {
+       logger.debug("RMProcessorContext:commitPolicyEngineData");
+
+        if (pedStackPointer > 1) {
+            pedStackPointer--;
+            PolicyEngineData ped = (PolicyEngineData)
pedStack.get(pedStackPointer);
+            pedStackPointer--;
+            pedStack.add(pedStackPointer, ped);
+            pedStackPointer++;
+            return ped;
+        } else {
+            return null;
+        }
+    }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/AcknowledgementIntervalProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/AcknowledgementIntervalProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/AcknowledgementIntervalProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/AcknowledgementIntervalProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,59 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+public class AcknowledgementIntervalProcessor {
+
+       private boolean initializedAcknowledgementInterval = false;
+
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeAcknowledgementIterval(RMPolicyToken rmpt)
+                       throws NoSuchMethodException {
+               logger
+                              
.debug("AcknowledgementIntervalProcessor:initializeAcknowledgementInterval");
+
+       }
+
+       public Object doAcknowledgementInterval(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedAcknowledgementInterval) {
+                               try {
+                                       initializeAcknowledgementIterval(rmpt);
+                                      
initializedAcknowledgementInterval = true;
+                               } catch (NoSuchMethodException e) {
+                                      
logger.error("AcknowledgementIntervalProcessor:doAcknowledgementInterval",
e);
+                                       return new Boolean(false);
+                               }
+                       }
+                       logger.debug(rmpt.getTokenName());
+
+               case RMProcessorContext.COMMIT:
+
+                       // //////////
+
+                       PolicyEngineData engineData =
rmpc.readCurrentPolicyEngineData();
+                       String txt = rmpc.getAssertion().getStrValue();
+                      
engineData.setAcknowledgementInterval(Long.parseLong(txt.trim()));
+
+                       // /////////////////////////////////
+
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/ExponentialBackoffProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/ExponentialBackoffProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/ExponentialBackoffProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/ExponentialBackoffProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,57 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+public class ExponentialBackoffProcessor {
+
+       private boolean initializedExponentialBackoff = false;
+
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeExponentialBackoff(RMPolicyToken rmpt)
+                       throws NoSuchMethodException {
+              
logger.debug("ExponentialBackoffProcessor:initalizeExponentialBackoff");
+
+       }
+
+       public Object doExponentialBackoff(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedExponentialBackoff) {
+                               try {
+                                       initializeExponentialBackoff(rmpt);
+                                       initializedExponentialBackoff = true;
+                               } catch (NoSuchMethodException e) {
+                                       logger.error("Exception
occured when invoking processTokenMethod", e);
+                                       return new Boolean(false);
+                               }
+                       }
+                       logger.debug(rmpt.getTokenName());
+
+               case RMProcessorContext.COMMIT:
+
+                       // ///////
+
+                       PolicyEngineData ped =
rmpc.readCurrentPolicyEngineData();
+                       String text = rmpc.getAssertion().getStrValue();
+                       ped.setExponentialBackoff(new
Boolean(text.trim()).booleanValue());
+
+                       // ///////
+
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutMeasureProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutMeasureProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutMeasureProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutMeasureProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,56 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+public class InactivityTimeoutMeasureProcessor {
+       private boolean initializedInactivityTimeoutMeasure = false;
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeInactivityTimeoutMeasure(RMPolicyToken rmpt)
+                       throws NoSuchMethodException {
+              
logger.debug("InactivityTimeoutMeasureProcessor:initializeInactivityTimeoutMeasure");
+
+       }
+
+       public Object doInactivityTimeoutMeasure(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedInactivityTimeoutMeasure) {
+                               try {
+                                      
initializeInactivityTimeoutMeasure(rmpt);
+                                      
initializedInactivityTimeoutMeasure = true;
+                               } catch (NoSuchMethodException e) {
+                                       logger.error("Exception
occured when initializeInactivityTimeoutMeasure", e);
+                                       return new Boolean(false);
+                               }
+                       }
+                       logger.debug(rmpt.getTokenName());
+
+               case RMProcessorContext.COMMIT:
+
+                       //////////////
+
+                       PolicyEngineData ped =
rmpc.readCurrentPolicyEngineData();
+                       String value = rmpc.getAssertion().getStrValue();
+                       ped.setInactivityTimeoutMeassure(value);
+
+                       //////////////
+
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InactivityTimeoutProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,54 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+
+public class InactivityTimeoutProcessor {
+       private boolean initializedInactivityTimeout = false;
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeInactivityTimeout(RMPolicyToken spt)
+                       throws NoSuchMethodException {
+              
logger.debug("InactivityTimeoutProcessor:initializeInactivityTimeout");
+       }
+
+       public Object doInactivityTimeout(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedInactivityTimeout) {
+                               try {
+                                       initializeInactivityTimeout(rmpt);
+                                       initializedInactivityTimeout = true;
+                               } catch (NoSuchMethodException e) {
+                                       logger.error("Exception
occured in initializeInactivityTimeout", e);
+                                       return new Boolean(false);
+                               }
+                       }
+                       logger.debug(rmpt.getTokenName());
+
+               case RMProcessorContext.COMMIT:
+
+                       ///////////////
+                       PolicyEngineData ped =
rmpc.readCurrentPolicyEngineData();
+                       String text = rmpc.getAssertion().getStrValue();
+                       ped.setInactivityTimeout(Long.parseLong(text));
+                       ///////////////
+
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InvokeInOrderProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InvokeInOrderProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InvokeInOrderProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/InvokeInOrderProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,50 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+
+public class InvokeInOrderProcessor {
+       private boolean initializedInvokeInOrder = false;
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeInvokeInOrder(RMPolicyToken spt)
+                       throws NoSuchMethodException {
+               logger.debug("InvokeInOrderProcessor:initializeInvokeInOrder");
+       }
+
+       public Object doInvokeInOrder(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedInvokeInOrder) {
+                               try {
+                                       initializeInvokeInOrder(rmpt);
+                                       initializedInvokeInOrder = true;
+                               } catch (NoSuchMethodException e) {
+                                       logger.error("Exception
occured in initializeInvokeInOrder", e);
+                                       return new Boolean(false);
+                               }
+                       }
+                       logger.debug(rmpt.getTokenName());
+
+               case RMProcessorContext.COMMIT:
+
+                       PolicyEngineData ped =
rmpc.readCurrentPolicyEngineData();
+                       String text = rmpc.getAssertion().getStrValue();
+                       ped.setInvokeInOrder(new Boolean(text).booleanValue());
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/MessageTypesToDropProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/MessageTypesToDropProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/MessageTypesToDropProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/MessageTypesToDropProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,56 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+public class MessageTypesToDropProcessor {
+       private boolean initializedMessageTypesToDrop = false;
+
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeMessageTypesToDrop(RMPolicyToken spt)
+                       throws NoSuchMethodException {
+              
logger.debug("MessgeTypesToDropProcessor:initializeMessgeTypesToDrop");
+       }
+
+       public Object doMessageTypesToDrop(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedMessageTypesToDrop) {
+                               try {
+                                       initializeMessageTypesToDrop(rmpt);
+                                       initializedMessageTypesToDrop = true;
+                               } catch (NoSuchMethodException e) {
+                                       logger
+                                                       .error(
+                                                                     
 "Exception occured in initializeMessageTypesToDrop",
+                                                                       e);
+                                       return new Boolean(false);
+                               }
+                       }
+                       logger.debug(rmpt.getTokenName());
+
+               case RMProcessorContext.COMMIT:
+
+                       // ////////////////////
+                       PolicyEngineData ped =
rmpc.readCurrentPolicyEngineData();
+                       String text = rmpc.getAssertion().getStrValue();
+                       ped.setMessageTypesToDrop(text);
+                       // ////////////////////
+
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/RetransmissionItervalProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/RetransmissionItervalProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/RetransmissionItervalProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/RetransmissionItervalProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,55 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+public class RetransmissionItervalProcessor {
+       private boolean initializedRetransmissionInterval = false;
+
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeRetranmissionIterval(RMPolicyToken spt)
+                       throws NoSuchMethodException {
+               logger
+                              
.debug("RetransmissionIntervalProcessor:initializeRetransmissionInterval");
+               ;
+
+       }
+
+       public Object doRetransmissionInterval(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedRetransmissionInterval) {
+                               try {
+                                       initializeRetranmissionIterval(rmpt);
+                                      
initializedRetransmissionInterval = true;
+                               } catch (NoSuchMethodException e) {
+                                       logger.error("Exception in
initializeRetransmissionInterval", e);
+                                       return new Boolean(false);
+                               }
+                       }
+
+               case RMProcessorContext.COMMIT:
+
+                       // //////////////////
+                       PolicyEngineData ped =
rmpc.readCurrentPolicyEngineData();
+                       String text = rmpc.getAssertion().getStrValue();
+                       ped.setRetransmissionInterval(Long.parseLong(text));
+                       // /////////////////
+
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+}

Added: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/StorageManagersProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/StorageManagersProcessor.java?rev=371847&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/StorageManagersProcessor.java
(added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/processors/StorageManagersProcessor.java
Mon Jan 23 22:58:06 2006
@@ -0,0 +1,87 @@
+package org.apache.sandesha2.policy.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.policy.PolicyEngineData;
+import org.apache.sandesha2.policy.RMPolicy;
+import org.apache.sandesha2.policy.RMPolicyToken;
+import org.apache.sandesha2.policy.RMProcessorContext;
+
+public class StorageManagersProcessor {
+       private boolean initializedStorageManager = false;
+
+       private Log logger = LogFactory.getLog(this.getClass().getName());
+
+       public void initializeStorageManager(RMPolicyToken rmpt)
+                       throws NoSuchMethodException {
+              
logger.debug("StorageManagersProcessor:initializeStorageManager");
+
+               RMPolicyToken tmpRpt = RMPolicy.inmemoryStorageManager.copy();
+               tmpRpt.setProcessTokenMethod(this);
+               rmpt.setChildToken(tmpRpt);
+
+               tmpRpt = RMPolicy.permenentStorageManager.copy();
+               tmpRpt.setProcessTokenMethod(this);
+               rmpt.setChildToken(tmpRpt);
+
+       }
+
+       public Object doStorageManagers(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               RMPolicyToken rmpt = rmpc.readCurrentSecurityToken();
+               switch (rmpc.getAction()) {
+
+               case RMProcessorContext.START:
+                       if (!initializedStorageManager) {
+                               try {
+                                       initializeStorageManager(rmpt);
+                                       initializedStorageManager = true;
+                               } catch (NoSuchMethodException e) {
+                                       logger.error(
+                                                       "Exception
occured in initializeStorageManager", e);
+                                       return new Boolean(false);
+                               }
+                       }
+                       logger.debug(rmpt.getTokenName());
+
+               case RMProcessorContext.COMMIT:
+                       break;
+               case RMProcessorContext.ABORT:
+                       break;
+               }
+               return new Boolean(true);
+       }
+
+       public Object doInmemoryStorageManager(RMProcessorContext rmpc) {
+               logger.debug("Processing "
+                               +
rmpc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[rmpc.getAction()]);
+
+               PolicyEngineData ped = rmpc.readCurrentPolicyEngineData();
+               String cls = rmpc.getAssertion().getStrValue();
+
+               if (cls != null && !cls.trim().equals("")) {
+                       ped.setInmemoryStorageManager(cls.trim());
+               }
+
+               return new Boolean(true);
+       }
+
+       public Object doPermanentStorageManager(RMProcessorContext spc) {
+               logger.debug("Processing "
+                               +
spc.readCurrentSecurityToken().getTokenName() + ": "
+                               +
RMProcessorContext.ACTION_NAMES[spc.getAction()]);
+
+               PolicyEngineData ped = spc.readCurrentPolicyEngineData();
+               String cls = spc.getAssertion().getStrValue();
+
+               if (cls != null && !cls.trim().equals("")) {
+                       ped.setPermanentStorageManager(cls.trim());
+               }
+
+               return new Boolean(true);
+       }
+}

Modified: 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=371847&r1=371846&r2=371847&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java
Mon Jan 23 22:58:06 2006
@@ -29,10 +29,16 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.sandesha2.Sandesha2Constants;
 import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.policy.PolicyEngineData;
 import org.apache.sandesha2.policy.RMPolicyBean;
+import org.apache.sandesha2.policy.RMPolicyProcessor;
+import org.apache.sandesha2.policy.RMProcessorContext;
+import org.apache.ws.policy.Policy;
+

 /**
- * Loads properties from sandesha2.properties file (from
Sandesha2Constants if this is not available).
+ * Loads properties from sandesha2.properties file (from Sandesha2Constants if
+ * this is not available).
 *
 * @author Chamikara Jayalath <chamikaramj@gmail.com>
 */
@@ -40,156 +46,185 @@
 public class PropertyManager {

       public static PropertyManager instance = null;
+
       private final byte PROPERTY_FILE = 1;
+
       private final byte MODULE_DESC = 2;
-
+
       private byte LOAD_SOURCE = MODULE_DESC;
-
+
       Log log = LogFactory.getLog(getClass());
-
+
       private SandeshaPropertyBean propertyBean = null;
-
-       private PropertyManager () {
-               propertyBean = new SandeshaPropertyBean ();
-               loadlPropertiesFromDefaultValues ();
-       }
-
-       public void loadlPropertiesFromDefaultValues () {
-              
propertyBean.setAcknowledgementInterval(Sandesha2Constants.Properties.DefaultValues.AcknowledgementInterval);
-              
propertyBean.setExponentialBackoff(Sandesha2Constants.Properties.DefaultValues.ExponentialBackoff);
-              
propertyBean.setInactiveTimeoutInterval(Sandesha2Constants.Properties.DefaultValues.InactivityTimeout
-                                          
,Sandesha2Constants.Properties.DefaultValues.InactivityTimeoutMeasure);
-              
propertyBean.setInOrder(Sandesha2Constants.Properties.DefaultValues.InvokeInOrder);
+
+       private PropertyManager() {
+               propertyBean = new SandeshaPropertyBean();
+               loadlPropertiesFromDefaultValues();
+       }
+
+       public void loadlPropertiesFromDefaultValues() {
+               propertyBean
+                              
.setAcknowledgementInterval(Sandesha2Constants.Properties.DefaultValues.AcknowledgementInterval);
+               propertyBean
+                              
.setExponentialBackoff(Sandesha2Constants.Properties.DefaultValues.ExponentialBackoff);
+               propertyBean
+                               .setInactiveTimeoutInterval(
+                                              
Sandesha2Constants.Properties.DefaultValues.InactivityTimeout,
+                                              
Sandesha2Constants.Properties.DefaultValues.InactivityTimeoutMeasure);
+               propertyBean
+                              
.setInOrder(Sandesha2Constants.Properties.DefaultValues.InvokeInOrder);
               propertyBean.setMsgTypesToDrop(null);
-              
propertyBean.setRetransmissionInterval(Sandesha2Constants.Properties.DefaultValues.RetransmissionInterval);
-              
propertyBean.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
+               propertyBean
+                              
.setRetransmissionInterval(Sandesha2Constants.Properties.DefaultValues.RetransmissionInterval);
+               propertyBean
+                              
.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
       }
-
-       public void loadPropertiesFromPropertyFile (InputStream in) {
+
+       public void loadPropertiesFromPropertyFile(InputStream in) {
               try {
-                       if (in==null)
-                               in =
Thread.currentThread().getContextClassLoader().getResourceAsStream(Sandesha2Constants.PROPERTY_FILE);
-
-                       Properties properties = new Properties ();
-                       if (in!=null) {
+                       if (in == null)
+                               in =
Thread.currentThread().getContextClassLoader()
+                                              
.getResourceAsStream(Sandesha2Constants.PROPERTY_FILE);
+
+                       Properties properties = new Properties();
+                       if (in != null) {
                               properties.load(in);
                       }
-
-                       String expoBackoffStr =
properties.getProperty(Sandesha2Constants.Properties.ExponentialBackoff);
+
+                       String expoBackoffStr = properties
+                                      
.getProperty(Sandesha2Constants.Properties.ExponentialBackoff);
                       loadExponentialBackoff(expoBackoffStr);
-
-                       String retransmissionIntStr =
properties.getProperty(Sandesha2Constants.Properties.RetransmissionInterval);
+
+                       String retransmissionIntStr = properties
+                                      
.getProperty(Sandesha2Constants.Properties.RetransmissionInterval);
                       loadRetransmissionInterval(retransmissionIntStr);
-
-                       String acknowledgementIntStr =
properties.getProperty(Sandesha2Constants.Properties.AcknowledgementInterval);
+
+                       String acknowledgementIntStr = properties
+                                      
.getProperty(Sandesha2Constants.Properties.AcknowledgementInterval);
                       loadAcknowledgementInterval(acknowledgementIntStr);
-
-
-                       String inactivityTimeoutStr =
properties.getProperty(Sandesha2Constants.Properties.InactivityTimeout);
-                       String inactivityTimeoutMeasure =
properties.getProperty(Sandesha2Constants.Properties.InactivityTimeoutMeasure);
-                      
loadInactivityTimeout(inactivityTimeoutStr,inactivityTimeoutMeasure);
-
-                       String storageMgrClassStr =
properties.getProperty(Sandesha2Constants.Properties.StorageManager);
+
+                       String inactivityTimeoutStr = properties
+                                      
.getProperty(Sandesha2Constants.Properties.InactivityTimeout);
+                       String inactivityTimeoutMeasure = properties
+                                      
.getProperty(Sandesha2Constants.Properties.InactivityTimeoutMeasure);
+                       loadInactivityTimeout(inactivityTimeoutStr,
+                                       inactivityTimeoutMeasure);
+
+                       String storageMgrClassStr = properties
+                                      
.getProperty(Sandesha2Constants.Properties.StorageManager);
                       loadStoragemanagerClass(storageMgrClassStr);
-
-                       String inOrderInvocation =
properties.getProperty(Sandesha2Constants.Properties.InOrderInvocation);
-                       loadInOrderInvocation (inOrderInvocation);
-
-                       String messageTypesToDrop =
properties.getProperty(Sandesha2Constants.Properties.MessageTypesToDrop);
-                       loadMessageTypesToDrop (messageTypesToDrop);
-
-
-                       //loadPropertiesToBean (properties);
+
+                       String inOrderInvocation = properties
+                                      
.getProperty(Sandesha2Constants.Properties.InOrderInvocation);
+                       loadInOrderInvocation(inOrderInvocation);
+
+                       String messageTypesToDrop = properties
+                                      
.getProperty(Sandesha2Constants.Properties.MessageTypesToDrop);
+                       loadMessageTypesToDrop(messageTypesToDrop);
+
+                       // loadPropertiesToBean (properties);
               } catch (IOException e) {
-                       log.info ("A valid property file was not
found. Using default values...");
+                       log
+                                       .info("A valid property file
was not found. Using default values...");
               }
       }
-
-       public void loadPropertiesFromModuleDesc (ModuleDescription desc) {
-
-               Parameter expoBackoffParam = desc.getParameter
(Sandesha2Constants.Properties.ExponentialBackoff);
-               String expoBackoffStr = (String) expoBackoffParam.getValue();
-               loadExponentialBackoff(expoBackoffStr);
-
-               Parameter retransmissionIntParam = desc.getParameter
(Sandesha2Constants.Properties.RetransmissionInterval);
-               String retransmissionIntStr = (String)
retransmissionIntParam.getValue();
-               loadRetransmissionInterval(retransmissionIntStr);
-
-               Parameter acknowledgementIntParam =
desc.getParameter(Sandesha2Constants.Properties.AcknowledgementInterval);
-               String acknowledgementIntStr = (String)
acknowledgementIntParam.getValue();
-               loadAcknowledgementInterval(acknowledgementIntStr);
-
-               Parameter inactivityTimeoutParam =
desc.getParameter(Sandesha2Constants.Properties.InactivityTimeout);
-               String inactivityTimeoutStr = (String)
inactivityTimeoutParam.getValue();
-               Parameter inactivityTimeoutMeasureParam =
desc.getParameter(Sandesha2Constants.Properties.InactivityTimeoutMeasure);
-               String inactivityTimeoutMeasure = (String)
inactivityTimeoutMeasureParam.getValue();
-              
loadInactivityTimeout(inactivityTimeoutStr,inactivityTimeoutMeasure);
-
-               Parameter storageMgrClassParam =
desc.getParameter(Sandesha2Constants.Properties.StorageManager);
-               String storageMgrClassStr = (String)
storageMgrClassParam.getValue();
-               loadStoragemanagerClass(storageMgrClassStr);
-
-               Parameter inOrderInvocationParam =
desc.getParameter(Sandesha2Constants.Properties.InOrderInvocation);
-               String inOrderInvocation = (String)
inOrderInvocationParam.getValue();
-               loadInOrderInvocation (inOrderInvocation);
-
-               Parameter messageTypesToDropParam =
desc.getParameter(Sandesha2Constants.Properties.MessageTypesToDrop);
-               String messageTypesToDrop = (String)
messageTypesToDropParam.getValue();
-               loadMessageTypesToDrop (messageTypesToDrop);
-       }
-
-       public static PropertyManager getInstance () {
-               if (instance==null) {
-                       instance = new PropertyManager ();
+
+       public void loadPropertiesFromModuleDesc(ModuleDescription desc)
+                       throws SandeshaException {
+               Policy policy = desc.getPolicyInclude().getEffectivePolicy();
+
+               if (policy == null) {
+                       throw new SandeshaException(
+                                       "No configuration policy is
found in module.xml");
+
+               }
+
+               RMPolicyProcessor processor = new RMPolicyProcessor();
+
+               try {
+                       processor.setup();
+               } catch (NoSuchMethodException e) {
+                       throw new SandeshaException(e.getMessage());
               }

+               processor.processPolicy(policy);
+
+               RMProcessorContext ctx = processor.getContext();
+               PolicyEngineData data = ctx.readCurrentPolicyEngineData();
+
+               propertyBean.setAcknowledgementInterval(data
+                               .getAcknowledgementInterval());
+               propertyBean.setExponentialBackoff(data.isExponentialBackoff());
+               propertyBean.setInactiveTimeoutInterval((int) data
+                               .getInactivityTimeout(),
data.getInactivityTimeoutMeassure());
+               propertyBean.setInOrder(data.isInvokeInOrder());
+
+               // CHECKME
+               ArrayList msgTypesToDrop = new ArrayList();
+               msgTypesToDrop.add(data.getMessageTypesToDrop());
+               propertyBean.setMsgTypesToDrop(msgTypesToDrop);
+
+               propertyBean
+                              
.setRetransmissionInterval(data.getRetransmissionInterval());
+
+               // CHECKME
+              
propertyBean.setStorageManagerClass(data.getInmemoryStorageManager());
+       }
+
+       public static PropertyManager getInstance() {
+               if (instance == null) {
+                       instance = new PropertyManager();
+               }
+
               return instance;
       }
-
-       public void reloadFromPropertyFile (InputStream stream) {
+
+       public void reloadFromPropertyFile(InputStream stream) {
               loadPropertiesFromPropertyFile(stream);
-       }
-
+       }
+
       /**
        * Loads wsp:exponentianbackoff.
        *
        * @param properties
        */
-       private void loadExponentialBackoff (String expoBackoffStr) {
-
+       private void loadExponentialBackoff(String expoBackoffStr) {
+
               boolean loaded = false;
-
-               if (expoBackoffStr!=null) {
+
+               if (expoBackoffStr != null) {
                       expoBackoffStr = expoBackoffStr.trim();
                       if (expoBackoffStr.equals("true")) {
                               propertyBean.setExponentialBackoff(true);
                               loaded = true;
-                       }else if (expoBackoffStr.equals("false")){
+                       } else if (expoBackoffStr.equals("false")) {
                               propertyBean.setExponentialBackoff(false);
                               loaded = true;
                       }
               }
-
+
               if (!loaded)
-                      
propertyBean.setExponentialBackoff(Sandesha2Constants.Properties.DefaultValues.ExponentialBackoff);
+                       propertyBean
+                                      
.setExponentialBackoff(Sandesha2Constants.Properties.DefaultValues.ExponentialBackoff);
       }
-
-
+
       /**
        * Loads wsp:retransmissionInterval.
        *
        * @param properties
        */
-       private void loadRetransmissionInterval (String retransmissionIntStr) {
-
+       private void loadRetransmissionInterval(String retransmissionIntStr) {
+
               boolean loaded = false;
-
-               if (retransmissionIntStr!=null) {
+
+               if (retransmissionIntStr != null) {
                       try {
                               retransmissionIntStr =
retransmissionIntStr.trim();
-                               int retransmissionInterval =
Integer.parseInt(retransmissionIntStr);
-                               if (retransmissionInterval>0) {
-                                      
propertyBean.setRetransmissionInterval(retransmissionInterval);
+                               int retransmissionInterval = Integer
+                                               .parseInt(retransmissionIntStr);
+                               if (retransmissionInterval > 0) {
+                                       propertyBean
+                                                      
.setRetransmissionInterval(retransmissionInterval);
                                       loaded = true;
                               }
                       } catch (NumberFormatException e) {
@@ -197,25 +232,27 @@
                               loaded = false;
                       }
               }
-
+
               if (!loaded)
-                      
propertyBean.setRetransmissionInterval(Sandesha2Constants.Properties.DefaultValues.RetransmissionInterval);
+                       propertyBean
+                                      
.setRetransmissionInterval(Sandesha2Constants.Properties.DefaultValues.RetransmissionInterval);
       }
-
+
       /**
        * Loads wsp:acknowldgementInterval.
        *
        * @param properties
        */
-       private void loadAcknowledgementInterval (String
acknowledgementIntStr) {
-
+       private void loadAcknowledgementInterval(String acknowledgementIntStr) {
+
               boolean loaded = false;
-
-               if (acknowledgementIntStr!=null) {
+
+               if (acknowledgementIntStr != null) {
                       try {
                               acknowledgementIntStr =
acknowledgementIntStr.trim();
-                               int acknowledgementInt =
Integer.parseInt(acknowledgementIntStr);
-                               if (acknowledgementInt>0) {
+                               int acknowledgementInt = Integer
+                                              
.parseInt(acknowledgementIntStr);
+                               if (acknowledgementInt > 0) {
                                      
propertyBean.setAcknowledgementInterval(acknowledgementInt);
                                       loaded = true;
                               }
@@ -224,28 +261,32 @@
                               loaded = false;
                       }
               }
-
+
               if (!loaded)
-                      
propertyBean.setAcknowledgementInterval(Sandesha2Constants.Properties.DefaultValues.AcknowledgementInterval);
+                       propertyBean
+                                      
.setAcknowledgementInterval(Sandesha2Constants.Properties.DefaultValues.AcknowledgementInterval);
       }
-
+
       /**
        * Loads wsp:inactivityInterval.
        *
        * @param properties
        */
-       private void loadInactivityTimeout (String
inactivityTimeoutStr, String inactivityTimeoutMeasure) {
-
+       private void loadInactivityTimeout(String inactivityTimeoutStr,
+                       String inactivityTimeoutMeasure) {
+
               boolean loaded = false;
-
-               if (inactivityTimeoutStr!=null &&
inactivityTimeoutMeasure!=null) {
+
+               if (inactivityTimeoutStr != null &&
inactivityTimeoutMeasure != null) {
                       try {
                               inactivityTimeoutStr =
inactivityTimeoutStr.trim();
                               inactivityTimeoutMeasure =
inactivityTimeoutMeasure.trim();
-
-                               int inactivityTimeoutVal =
Integer.parseInt(inactivityTimeoutStr);
-                               if (inactivityTimeoutVal>0) {
-                                      
propertyBean.setInactiveTimeoutInterval(inactivityTimeoutVal,inactivityTimeoutMeasure);
+
+                               int inactivityTimeoutVal = Integer
+                                               .parseInt(inactivityTimeoutStr);
+                               if (inactivityTimeoutVal > 0) {
+                                       propertyBean.setInactiveTimeoutInterval(
+                                                      
inactivityTimeoutVal, inactivityTimeoutMeasure);
                                       loaded = true;
                               }
                       } catch (NumberFormatException e) {
@@ -253,116 +294,123 @@
                               loaded = false;
                       }
               }
-
+
               if (!loaded)
-                      
propertyBean.setInactiveTimeoutInterval(Sandesha2Constants.Properties.DefaultValues.InactivityTimeout,Sandesha2Constants.Properties.DefaultValues.InactivityTimeoutMeasure);
+                       propertyBean
+                                       .setInactiveTimeoutInterval(
+                                                      
Sandesha2Constants.Properties.DefaultValues.InactivityTimeout,
+                                                      
Sandesha2Constants.Properties.DefaultValues.InactivityTimeoutMeasure);
       }
-
+
       /**
        * Loads the StorageManager class name.
        *
        * @param properties
        */
-       private void loadStoragemanagerClass (String storageMgrClassStr) {
+       private void loadStoragemanagerClass(String storageMgrClassStr) {

               boolean loaded = false;
-
-               if (storageMgrClassStr!=null) {
+
+               if (storageMgrClassStr != null) {
                       storageMgrClassStr = storageMgrClassStr.trim();
                       propertyBean.setStorageManagerClass(storageMgrClassStr);
                       loaded = true;
               }
-
+
               if (!loaded)
-                      
propertyBean.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
+                       propertyBean
+                                      
.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
       }
-
-       private void loadInOrderInvocation (String inOrderInvocation) {
+
+       private void loadInOrderInvocation(String inOrderInvocation) {

               boolean loaded = false;
-
-               if (inOrderInvocation!=null) {
+
+               if (inOrderInvocation != null) {
                       inOrderInvocation = inOrderInvocation.trim();
                       if (inOrderInvocation.equalsIgnoreCase("true")) {
                               propertyBean.setInOrder(true);
                               loaded = true;
-                       }else if (inOrderInvocation.equalsIgnoreCase("false")) {
+                       } else if
(inOrderInvocation.equalsIgnoreCase("false")) {
                               propertyBean.setInOrder(false);
                               loaded = true;
                       }
               }
-
+
               if (!loaded)
-                      
propertyBean.setInOrder(Sandesha2Constants.Properties.DefaultValues.InvokeInOrder);
-
+                       propertyBean
+                                      
.setInOrder(Sandesha2Constants.Properties.DefaultValues.InvokeInOrder);
+
       }
-
-       private void loadMessageTypesToDrop (String messageTypesToDrop) {

-               boolean loaded=false;
-
+       private void loadMessageTypesToDrop(String messageTypesToDrop) {
+
+               boolean loaded = false;
+
               try {
-                       if (messageTypesToDrop!=null &&
!Sandesha2Constants.VALUE_NONE.equals(messageTypesToDrop)) {
+                       if (messageTypesToDrop != null
+                                       && !Sandesha2Constants.VALUE_NONE
+                                                      
.equals(messageTypesToDrop)) {
                               messageTypesToDrop = messageTypesToDrop.trim();
                               messageTypesToDrop = "[" +
messageTypesToDrop + "]";
-                               ArrayList messageTypesLst = 
SandeshaUtil.getArrayListFromString(messageTypesToDrop);
-
+                               ArrayList messageTypesLst = SandeshaUtil
+                                              
.getArrayListFromString(messageTypesToDrop);
+
                               Iterator itr = messageTypesLst.iterator();
                               while (itr.hasNext()) {
                                       String typeStr = (String) itr.next();
-                                       Integer typeNo = new Integer (typeStr);
+                                       Integer typeNo = new Integer(typeStr);
                                       propertyBean.addMsgTypeToDrop(typeNo);
                               }
                       }
-
+
               } catch (SandeshaException e) {
                       log.error(e.getMessage());
               } catch (NumberFormatException e) {
-                       String message = "Property '" +
Sandesha2Constants.Properties.MessageTypesToDrop + "' contains an
invalid value.";
+                       String message = "Property '"
+                                       +
Sandesha2Constants.Properties.MessageTypesToDrop
+                                       + "' contains an invalid value.";
                       log.error(message);
                       log.error(e.getMessage());
               }
-
-
+
       }
-
-
-
-       public boolean isExponentialBackoff () {
-
+
+       public boolean isExponentialBackoff() {
+
               return propertyBean.isExponentialBackoff();
       }
-
-       public long getRetransmissionInterval () {
+
+       public long getRetransmissionInterval() {
               return propertyBean.getRetransmissionInterval();
       }
-
-       public long getAcknowledgementInterval () {
+
+       public long getAcknowledgementInterval() {
               return propertyBean.getAcknowledgementInaterval();
       }
-
-       public long getInactivityTimeout () {
+
+       public long getInactivityTimeout() {
               return propertyBean.getInactiveTimeoutInterval();
       }
-
-       public String getStorageManagerClass () {
+
+       public String getStorageManagerClass() {
               return propertyBean.getStorageManagerClass();
       }
-
-       public RMPolicyBean getRMPolicyBean () {
+
+       public RMPolicyBean getRMPolicyBean() {
               return propertyBean.getPolicyBean();
       }
-
-       public boolean isInOrderInvocation () {
+
+       public boolean isInOrderInvocation() {
               return propertyBean.isInOrder();
       }
-
-       public ArrayList getMessagesNotToSend () {
+
+       public ArrayList getMessagesNotToSend() {
               return propertyBean.getMsgTypesToDrop();
       }
-
-       public SandeshaPropertyBean getPropertyBean () {
+
+       public SandeshaPropertyBean getPropertyBean() {
               return propertyBean;
       }
-
+
 }

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


Mime
View raw message