You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ml...@apache.org on 2007/03/20 15:37:24 UTC

svn commit: r520410 - in /webservices/sandesha/trunk/java: src/org/apache/sandesha2/ src/org/apache/sandesha2/util/ test/src/org/apache/sandesha2/storage/

Author: mlovett
Date: Tue Mar 20 07:37:23 2007
New Revision: 520410

URL: http://svn.apache.org/viewvc?view=rev&rev=520410
Log:
Move fixed RM state off the context objects and onto the axis configuration

Modified:
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SandeshaUtil.java
    webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java
    webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java
    webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java
    webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java?view=diff&rev=520410&r1=520409&r2=520410
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/SandeshaModule.java Tue Mar 20 07:37:23 2007
@@ -24,6 +24,7 @@
 import org.apache.axis2.description.AxisDescription;
 import org.apache.axis2.description.AxisModule;
 import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.modules.Module;
 import org.apache.axis2.modules.ModulePolicyExtension;
 import org.apache.axis2.modules.PolicyExtension;
@@ -55,8 +56,11 @@
 			AxisModule module) throws AxisFault {
 		if(log.isDebugEnabled()) log.debug("Entry: SandeshaModule::init, " + configContext);
 
-		//storing the Sandesha module as a property.
-		configContext.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,module.getModuleClassLoader());
+		AxisConfiguration config = configContext.getAxisConfiguration();
+
+		//storing the Sandesha module as a parameter.
+		Parameter parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,module.getModuleClassLoader());
+		config.addParameter(parameter);
 
 		//init the i18n messages
 		SandeshaMessageHelper.innit();
@@ -81,14 +85,15 @@
 			}
 		}
 		
-		Parameter parameter = new Parameter ();
-		parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
-		parameter.setValue(propertyBean);
-		configContext.getAxisConfiguration().addParameter(parameter);;
-		
-		configContext.setProperty(Sandesha2Constants.INMEMORY_STORAGE_MANAGER,null);   // this must be resetted by the module settings.
-		configContext.setProperty(Sandesha2Constants.PERMANENT_STORAGE_MANAGER,null);
+		parameter = new Parameter (Sandesha2Constants.SANDESHA_PROPERTY_BEAN, propertyBean);
+		config.addParameter(parameter);
 		
+		// Reset both storage managers
+		parameter = config.getParameter(Sandesha2Constants.INMEMORY_STORAGE_MANAGER);
+		if(parameter != null) config.removeParameter(parameter);
+		parameter = config.getParameter(Sandesha2Constants.PERMANENT_STORAGE_MANAGER);
+		if(parameter != null) config.removeParameter(parameter);
+
 		try {
 			StorageManager inMemorytorageManager = SandeshaUtil.getInMemoryStorageManager(configContext);
 			inMemorytorageManager.initStorage(module);
@@ -109,7 +114,9 @@
 			log.debug(message,e);
 		}
 		
-		configContext.setProperty(Sandesha2Constants.SECURITY_MANAGER,null);
+		// Reset the security manager, and then load it
+		parameter = config.getParameter(Sandesha2Constants.SECURITY_MANAGER);
+		if(parameter != null) config.removeParameter(parameter);
 		SecurityManager util = SandeshaUtil.getSecurityManager(configContext);
 		util.initSecurity(module);
 

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SandeshaUtil.java?view=diff&rev=520410&r1=520409&r2=520410
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SandeshaUtil.java Tue Mar 20 07:37:23 2007
@@ -244,30 +244,52 @@
 	
 	public static StorageManager getInMemoryStorageManager(ConfigurationContext context) throws SandeshaException {
 
-		StorageManager inMemoryStorageManager = (StorageManager) context.getProperty(Sandesha2Constants.INMEMORY_STORAGE_MANAGER);
-		if (inMemoryStorageManager != null)
-			return inMemoryStorageManager;
-
-		//Currently module policies (default) are used to find the storage manager. These cant be overriden
-		//TODO change this so that different services can hv different storage managers.
-		String storageManagerClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getInMemoryStorageManagerClass();
-		inMemoryStorageManager = getStorageManagerInstance(storageManagerClassStr,context);
-		context.setProperty(Sandesha2Constants.INMEMORY_STORAGE_MANAGER,inMemoryStorageManager);
+		StorageManager inMemoryStorageManager = null;
+		
+		AxisConfiguration config = context.getAxisConfiguration();
+		Parameter parameter = config.getParameter(Sandesha2Constants.INMEMORY_STORAGE_MANAGER);
+		if(parameter != null) inMemoryStorageManager = (StorageManager) parameter.getValue();
+		if (inMemoryStorageManager != null)	return inMemoryStorageManager;
+
+		try {
+			//Currently module policies (default) are used to find the storage manager. These cant be overriden
+			//TODO change this so that different services can hv different storage managers.
+			String storageManagerClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getInMemoryStorageManagerClass();
+			inMemoryStorageManager = getStorageManagerInstance(storageManagerClassStr,context);
+			parameter = new Parameter(Sandesha2Constants.INMEMORY_STORAGE_MANAGER, inMemoryStorageManager);
+			config.addParameter(parameter);
+		} catch(AxisFault e) {
+			String message = SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.cannotInitInMemoryStorageManager,
+					e.toString());
+			throw new SandeshaException(message, e);
+		}
 		
 		return inMemoryStorageManager;
 	}
 	
 	public static StorageManager getPermanentStorageManager(ConfigurationContext context) throws SandeshaException {
 
-		StorageManager permanentStorageManager = (StorageManager) context.getProperty(Sandesha2Constants.PERMANENT_STORAGE_MANAGER);
-		if (permanentStorageManager != null)
-			return permanentStorageManager;
-
-		//Currently module policies (default) are used to find the storage manager. These cant be overriden
-		//TODO change this so that different services can hv different storage managers.
-		String storageManagerClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getPermanentStorageManagerClass ();
-		permanentStorageManager = getStorageManagerInstance(storageManagerClassStr,context);
-		context.setProperty(Sandesha2Constants.PERMANENT_STORAGE_MANAGER,permanentStorageManager);
+		StorageManager permanentStorageManager = null;
+		
+		AxisConfiguration config = context.getAxisConfiguration();
+		Parameter parameter = config.getParameter(Sandesha2Constants.PERMANENT_STORAGE_MANAGER);
+		if(parameter != null) permanentStorageManager = (StorageManager) parameter.getValue();
+		if (permanentStorageManager != null)	return permanentStorageManager;
+
+		try {
+			//Currently module policies (default) are used to find the storage manager. These cant be overriden
+			//TODO change this so that different services can hv different storage managers.
+			String storageManagerClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getInMemoryStorageManagerClass();
+			permanentStorageManager = getStorageManagerInstance(storageManagerClassStr,context);
+			parameter = new Parameter(Sandesha2Constants.PERMANENT_STORAGE_MANAGER, permanentStorageManager);
+			config.addParameter(parameter);
+		} catch(AxisFault e) {
+			String message = SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.cannotInitPersistentStorageManager,
+					e.toString());
+			throw new SandeshaException(message, e);
+		}
 		
 		return permanentStorageManager;
 	}
@@ -276,7 +298,10 @@
 		
 		StorageManager storageManager = null;
 		try {
-		    ClassLoader classLoader = (ClassLoader)	context.getProperty(Sandesha2Constants.MODULE_CLASS_LOADER);
+			ClassLoader classLoader = null;
+			AxisConfiguration config = context.getAxisConfiguration();
+			Parameter classLoaderParam = config.getParameter(Sandesha2Constants.MODULE_CLASS_LOADER);
+			if(classLoaderParam != null) classLoader = (ClassLoader) classLoaderParam.getValue(); 
 
 		    if (classLoader==null)
 		    	throw new SandeshaException (SandeshaMessageHelper.getMessage(
@@ -688,20 +713,31 @@
 	
 
 	public static SecurityManager getSecurityManager(ConfigurationContext context) throws SandeshaException {
-		SecurityManager util = (SecurityManager) context.getProperty(Sandesha2Constants.SECURITY_MANAGER);
+		SecurityManager util = null;
+		AxisConfiguration config = context.getAxisConfiguration();
+		Parameter p = config.getParameter(Sandesha2Constants.SECURITY_MANAGER);
+		if(p != null) util = (SecurityManager) p.getValue();
 		if (util != null) return util;
 
-		//Currently module policies are used to find the security impl. These cant be overriden
-		String securityManagerClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getSecurityManagerClass();
-		util = getSecurityManagerInstance(securityManagerClassStr,context);
-		context.setProperty(Sandesha2Constants.SECURITY_MANAGER,util);
-		
+		try {
+			//Currently module policies are used to find the security impl. These cant be overriden
+			String securityManagerClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getSecurityManagerClass();
+			util = getSecurityManagerInstance(securityManagerClassStr,context);
+			p = new Parameter(Sandesha2Constants.SECURITY_MANAGER,util);
+			config.addParameter(p);
+		} catch(AxisFault e) {
+			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotInitSecurityManager, e.toString());
+			throw new SandeshaException(message,e);
+		}
 		return util;
 	}
 
 	private static SecurityManager getSecurityManagerInstance (String className,ConfigurationContext context) throws SandeshaException {
 		try {
-		  ClassLoader classLoader = (ClassLoader)	context.getProperty(Sandesha2Constants.MODULE_CLASS_LOADER);
+			ClassLoader classLoader = null;
+			AxisConfiguration config = context.getAxisConfiguration();
+			Parameter classLoaderParam = config.getParameter(Sandesha2Constants.MODULE_CLASS_LOADER);
+			if(classLoaderParam != null) classLoader = (ClassLoader) classLoaderParam.getValue(); 
 
 		  if (classLoader==null)
 	    	throw new SandeshaException (SandeshaMessageHelper.getMessage(SandeshaMessageKeys.classLoaderNotFound));

Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java?view=diff&rev=520410&r1=520409&r2=520410
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java (original)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/InvokerBeanMgrTest.java Tue Mar 20 07:37:23 2007
@@ -49,7 +49,8 @@
         ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
         
         ClassLoader classLoader = getClass().getClassLoader();
-        configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+        parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+        axisConfig.addParameter(parameter);
         
         StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
         transaction = storageManager.getTransaction();

Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java?view=diff&rev=520410&r1=520409&r2=520410
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java (original)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMDBeanMgrTest.java Tue Mar 20 07:37:23 2007
@@ -49,8 +49,8 @@
         ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
         
         ClassLoader classLoader = getClass().getClassLoader();
-        configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
-        
+        parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+        axisConfig.addParameter(parameter);
         
         StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
         transaction = storageManager.getTransaction();

Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java?view=diff&rev=520410&r1=520409&r2=520410
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java (original)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/RMSBeanMgrTest.java Tue Mar 20 07:37:23 2007
@@ -50,7 +50,8 @@
         ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
 
         ClassLoader classLoader = getClass().getClassLoader();
-        configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+        parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+        axisConfig.addParameter(parameter);
         
         StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
         transaction = storageManager.getTransaction();

Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java?view=diff&rev=520410&r1=520409&r2=520410
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java (original)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/storage/SenderBeanMgrTest.java Tue Mar 20 07:37:23 2007
@@ -51,7 +51,8 @@
         ConfigurationContext configCtx = new ConfigurationContext(axisConfig);
         
         ClassLoader classLoader = getClass().getClassLoader();
-        configCtx.setProperty(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+        parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,classLoader);
+        axisConfig.addParameter(parameter);
         
         StorageManager storageManager = SandeshaUtil.getInMemoryStorageManager(configCtx);
         transaction = storageManager.getTransaction();



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