Author: chamikara
Date: Wed May 17 00:13:38 2006
New Revision: 407185

URL: http://svn.apache.org/viewcvs?rev=407185&view=rev
Log:
Loading the modules from the module class loader.
A refactor due to a change in policy

Modified:
    webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
    
webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java

Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java?rev=407185&r1=407184&r2=407185&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java 
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java 
Wed May 17 00:13:38 2006
@@ -498,4 +498,7 @@
        String POST_FAILURE_MESSAGE = "PostFailureMessage";
        
        String REINJECTED_MESSAGE = "ReinjectedMessage";
+       
+       String MODULE_CLASS_LOADER = "Sandesha2ModuleClassLoader";
+       
 }

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=407185&r1=407184&r2=407185&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java 
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java Wed 
May 17 00:13:38 2006
@@ -25,13 +25,14 @@
 import org.apache.axis2.modules.Module;
 import org.apache.axis2.modules.ModulePolicyExtension;
 import org.apache.axis2.modules.PolicyExtension;
+import org.apache.log4j.Logger;
 import org.apache.sandesha2.policy.RMPolicyExtension;
+import org.apache.sandesha2.storage.SandeshaStorageException;
 import org.apache.sandesha2.storage.StorageManager;
 import org.apache.sandesha2.util.PropertyManager;
 import org.apache.sandesha2.util.SandeshaPropertyBean;
 import org.apache.sandesha2.util.SandeshaUtil;
 
-
 /**
  * The Module class of Sandesha2.
  * 
@@ -40,10 +41,15 @@
 
 public class SandeshaModule implements Module, ModulePolicyExtension {
     
+    private Logger log = Logger.getLogger(SandeshaModule.class);
+    
        // initialize the module
        public void init(ConfigurationContext configContext,
                        AxisModule module) throws AxisFault {
 
+               //storing the Sadesha module as a property.
+               
configContext.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,module.getModuleClassLoader());
+               
                // continueUncompletedSequences (storageManager,configCtx);
 
                SandeshaPropertyBean constantPropertyBean = 
PropertyManager.loadPropertiesFromDefaultValues();
@@ -60,11 +66,21 @@
                
configContext.setProperty(Sandesha2Constants.INMEMORY_STORAGE_MANAGER,null);   
// this must be resetted by the module settings.
                
configContext.setProperty(Sandesha2Constants.PERMANENT_STORAGE_MANAGER,null);
                
-               StorageManager inMemorytorageManager = 
SandeshaUtil.getInMemoryStorageManager(configContext);
-               StorageManager permanentStorageManager = 
SandeshaUtil.getPermanentStorageManager(configContext);
+               try {
+                       StorageManager inMemorytorageManager = 
SandeshaUtil.getInMemoryStorageManager(configContext);
+                       inMemorytorageManager.initStorage(module);
+               } catch (SandeshaStorageException e) {
+                       String message = "Cannot initialize the given in-memory 
storage manager.";
+                       log.debug(message,e);
+               }
                
-               inMemorytorageManager.initStorage(module);
-               permanentStorageManager.initStorage(module);
+               try {
+                       StorageManager permanentStorageManager = 
SandeshaUtil.getPermanentStorageManager(configContext);
+                       permanentStorageManager.initStorage(module);
+               } catch (SandeshaStorageException e) {
+                       String message = "Cannot initialize the given 
persistent storage manager.";
+                       log.debug(message,e);
+               }
        }
 
        public void engageNotify(AxisDescription axisDescription) throws 
AxisFault {

Modified: 
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=407185&r1=407184&r2=407185&view=diff
==============================================================================
--- 
webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java
 (original)
+++ 
webservices/sandesha/trunk/src/org/apache/sandesha2/policy/RMPolicyProcessor.java
 Wed May 17 00:13:38 2006
@@ -15,11 +15,11 @@
 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.All;
 import org.apache.ws.policy.Assertion;
+import org.apache.ws.policy.ExactlyOne;
 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;
 
@@ -124,7 +124,7 @@
                        policy = (Policy) policy.normalize();
                }
 
-               XorCompositeAssertion xor = (XorCompositeAssertion) 
policy.getTerms()
+               ExactlyOne xor = (ExactlyOne) policy.getTerms()
                                .get(0);
                List listOfPolicyAlternatives = xor.getTerms();
 
@@ -132,7 +132,7 @@
                int numberOfAlternatives = listOfPolicyAlternatives.size();
 
                for (int i = 0; !success && i < numberOfAlternatives; i++) {
-                       AndCompositeAssertion aPolicyAlternative = 
(AndCompositeAssertion) listOfPolicyAlternatives
+                       All aPolicyAlternative = (All) listOfPolicyAlternatives
                                        .get(i);
 
                        List listOfAssertions = aPolicyAlternative.getTerms();

Modified: 
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: 
http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java?rev=407185&r1=407184&r2=407185&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java 
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java 
Wed May 17 00:13:38 2006
@@ -377,13 +377,19 @@
                
                StorageManager storageManager = null;
                try {
-                       Class c = Class.forName(className);
-                       Class configContextClass = 
Class.forName(context.getClass().getName());
+                   ClassLoader classLoader = (ClassLoader)     
context.getProperty(Sandesha2Constants.MODULE_CLASS_LOADER);
+
+                   if (classLoader==null)
+                       throw new SandeshaException ("Module class loader not 
found");
+                   
+                   Class c = classLoader.loadClass(className);
+                       Class configContextClass = context.getClass();
+                       
                        Constructor constructor = c.getConstructor(new Class[] 
{ configContextClass });
-                       Object obj = constructor.newInstance(new Object[] { 
context });
+                       Object obj = constructor.newInstance(new Object[] 
{context});
 
                        if (obj == null || !(obj instanceof StorageManager))
-                               throw new SandeshaException("StorageManager 
must implement org.apache.sandeshat.storage.StorageManager");
+                               throw new SandeshaException("StorageManager 
must implement org.apache.sandesha2.storage.StorageManager");
 
                        StorageManager mgr = (StorageManager) obj;
                        storageManager = mgr;
@@ -392,7 +398,7 @@
                } catch (Exception e) {
                        String message = "Cannot load the given storage 
manager";
                        log.error(message);
-                       throw new SandeshaException(message);
+                       throw new SandeshaException(message,e);
                }
        }
 



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

Reply via email to