ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mckie...@apache.org
Subject svn commit: r573243 - in /webservices/sandesha/trunk/java/modules: core/src/main/java/org/apache/sandesha2/ core/src/main/java/org/apache/sandesha2/i18n/ core/src/main/java/org/apache/sandesha2/policy/ core/src/main/java/org/apache/sandesha2/policy/bui...
Date Thu, 06 Sep 2007 12:34:08 GMT
Author: mckierna
Date: Thu Sep  6 05:34:04 2007
New Revision: 573243

URL: http://svn.apache.org/viewvc?rev=573243&view=rev
Log:
SANDESHA2-120 : plugin to decorate replyTo EPRs

Modified:
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/PropertyManager.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
    webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
    webservices/sandesha/trunk/java/modules/mar/module.xml

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
Thu Sep  6 05:34:04 2007
@@ -420,6 +420,8 @@
 		
 		public static final String RetransmissionCount = "RetransmissionCount";
 
+		public static final String EPRDecorator = "EPRDecorator";
+		
 		public static final String SecurityManager = "SecurityManager";
 
 		public static final String ContextManager = "ContextManager";
@@ -460,6 +462,8 @@
 			
 			public static final int MaximumRetransmissionCount = 10;
 			
+			public static final String EPRDecorator = "org.apache.sandesha2.addressing.EPRDecoratorImpl";
+			
 			public static final String SecurityManager = "org.apache.sandesha2.security.dummy.DummySecurityManager";
 
 			public static final String ContextManager = "org.apache.sandesha2.context.DummyContextManager";
@@ -544,6 +548,8 @@
 	
 	static final String SECURITY_MANAGER = "Sandesha2SecurityManager";
 	
+	static final String EPR_DECORATOR = "Sandesha2EPRDecorator";	
+	
 	static final String CONTEXT_MANAGER = "Sandesha2ContextManager";
 	
 	static final String RETRANSMITTABLE_PHASES = "RMRetransmittablePhases";
@@ -608,6 +614,7 @@
         public static final String ELEM_MSG_TYPES_TO_DROP = "MessageTypesToDrop";
         public static final String ELEM_STORAGE_MGR = "StorageManagers";
         public static final String ELEM_SEC_MGR = "SecurityManager";
+        public static final String ELEM_EPR_DECORATOR = "EPRDecorator";
         public static final String ELEM_CONTEXT_MGR = "ContextManager";
         public static final String ELEM_INMEMORY_STORAGE_MGR = "InMemoryStorageManager";
         public static final String ELEM_PERMANENT_STORAGE_MGR = "PermanentStorageManager";
@@ -632,6 +639,7 @@
         public static final QName Q_ELEM_MSG_TYPES_TO_DROP = new QName(URI_RM_POLICY_NS,
ELEM_MSG_TYPES_TO_DROP, ATTR_WSRM);
         public static final QName Q_ELEM_STORAGE_MGR =new QName(URI_RM_POLICY_NS, ELEM_STORAGE_MGR,
ATTR_WSRM);
         public static final QName Q_ELEM_SEC_MGR = new QName(URI_RM_POLICY_NS, ELEM_SEC_MGR,
ATTR_WSRM);
+        public static final QName Q_ELEM_EPR_DECORATOR = new QName(URI_RM_POLICY_NS, ELEM_EPR_DECORATOR,
ATTR_WSRM);
         public static final QName Q_ELEM_CONTEXT_MGR = new QName(URI_RM_POLICY_NS, ELEM_CONTEXT_MGR,
ATTR_WSRM);
         public static final QName Q_ELEM_INMEMORY_STORAGE_MGR =new QName(URI_RM_POLICY_NS,
ELEM_INMEMORY_STORAGE_MGR, ATTR_WSRM);
         public static final QName Q_ELEM_PERMANENT_STORAGE_MGR =new QName(URI_RM_POLICY_NS,
ELEM_PERMANENT_STORAGE_MGR, ATTR_WSRM);

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
Thu Sep  6 05:34:04 2007
@@ -27,7 +27,9 @@
 	public static final String cannotGetStorageManager="cannotGetStorageManager";
 	public static final String storageManagerMustImplement="storageManagerMustImplement";
 	public static final String cannotInitSecurityManager="cannotInitSecurityManager";
+	public static final String cannotInitEPRDecorator="cannotInitEPRDecorator";
 	public static final String securityManagerMustImplement="securityManagerMustImplement";
+	public static final String eprDecoratorMustImplement="eprDecoratorMustImplement";
 	public static final String cannotInitContextManager="cannotInitContextManager";
 	public static final String contextManagerMustImplement="contextManagerMustImplement";
 	public static final String cannotFindModulePolicies="cannotFindModulePolicies";

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java
Thu Sep  6 05:34:04 2007
@@ -52,6 +52,8 @@
     private String permanentStorageManagerClass = null;
 
     private String securityManagerClass = null;
+
+    private String eprDecoratorClass = null;
     
     private String contextManagerClass = null;
 
@@ -214,6 +216,14 @@
         this.securityManagerClass = className;
     }
     
+    public String getEPRDecoratorClass(){
+    	return eprDecoratorClass;
+    }
+    
+    public void setEPRDecoratorClass(String className) {
+      this.eprDecoratorClass = className;
+    }
+    
     public String getContextManagerClass() {
     	return contextManagerClass;
     }
@@ -343,6 +353,11 @@
 			// <wsrm:SecurityManager />
 			writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_SEC_MGR.getLocalPart(),
namespaceURI);
 			writer.writeCharacters(getSecurityManagerClass());
+			writer.writeEndElement();
+			
+			//<wsrm:EPRDecorator />
+			writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_EPR_DECORATOR.getLocalPart(),
namespaceURI);
+			writer.writeCharacters(getEPRDecoratorClass());
 			writer.writeEndElement();
 			
 			//<wsrm:ContextManager />

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java
Thu Sep  6 05:34:04 2007
@@ -124,9 +124,11 @@
             }  else if (Sandesha2Constants.Assertions.ELEM_SEC_MGR
                     .equals(name)) {
                 propertyBean.setSecurityManagerClass (element.getText().trim());
-            }  else if (Sandesha2Constants.Assertions.ELEM_STORAGE_MGR
+            }
+            else if (Sandesha2Constants.Assertions.ELEM_EPR_DECORATOR.equals(name)) {
+            	propertyBean.setEPRDecoratorClass(element.getText().trim());
+            } else if (Sandesha2Constants.Assertions.ELEM_STORAGE_MGR
                     .equals(name)) {
-            	
                 if (element!=null) {
                     //finding out storage managers.
                 	

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/PropertyManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/PropertyManager.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/PropertyManager.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/PropertyManager.java
Thu Sep  6 05:34:04 2007
@@ -65,6 +65,7 @@
 		loadMessageTypesToDrop(msgTypesToDrop, propertyBean);
 
 		propertyBean.setSecurityManagerClass(Sandesha2Constants.Properties.DefaultValues.SecurityManager);
+		propertyBean.setEPRDecoratorClass(Sandesha2Constants.Properties.DefaultValues.EPRDecorator);
 		propertyBean.setContextManagerClass(Sandesha2Constants.Properties.DefaultValues.ContextManager);
 		propertyBean.setEnableMakeConnection(Sandesha2Constants.Properties.DefaultValues.EnableMakeConnection);
 		propertyBean.setEnableRMAnonURI(Sandesha2Constants.Properties.DefaultValues.EnableRMAnonURI);
@@ -133,6 +134,9 @@
 			    .getProperty(Sandesha2Constants.Properties.SecurityManager);
 			loadSecurityManagerClass(securityManagerClassStr,propertyBean);
 			
+			String eprDecoratorParam = properties.getProperty(Sandesha2Constants.Properties.EPRDecorator);
+			loadEPRDecoratorClass(eprDecoratorParam,propertyBean);
+			
 			String contextManagerClassStr = properties.getProperty(Sandesha2Constants.Properties.ContextManager);
 			loadContextManagerClass(contextManagerClassStr,propertyBean);
 
@@ -206,6 +210,10 @@
 		Parameter securityManagerClassParam = desc.getParameter(Sandesha2Constants.Properties.SecurityManager);
 		String securityManagerClassStr = (String) securityManagerClassParam.getValue();
 		loadSecurityManagerClass(securityManagerClassStr,propertyBean);
+		
+		Parameter eprDecoratorClassParam = desc.getParameter(Sandesha2Constants.Properties.EPRDecorator);
+		String eprDecoratorClassString = (String) eprDecoratorClassParam.getValue();
+		loadEPRDecoratorClass(eprDecoratorClassString,propertyBean);
 
 		return propertyBean;
 	}
@@ -492,6 +500,18 @@
 
 	}
 
+	/**
+	 * Loads the EPR decorator class name.
+	 * 
+	 * @param properties
+	 */
+	private static void loadEPRDecoratorClass(String eprDecoratorClassStr, SandeshaPolicyBean
propertyBean) {
+		if (eprDecoratorClassStr != null) {
+			eprDecoratorClassStr = eprDecoratorClassStr.trim();
+			propertyBean.setEPRDecoratorClass(eprDecoratorClassStr);
+		}
+	}
+	
 	/**
 	 * Loads the SecurityManager class name.
 	 * 

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
Thu Sep  6 05:34:04 2007
@@ -208,6 +208,7 @@
 
 		if(replyTo != null) {
 			EndpointReference replyToEPR = new EndpointReference(replyTo);
+			replyToEPR = SandeshaUtil.getEPRDecorator(createSeqRMMsg.getConfigurationContext()).decorateEndpointReference(replyToEPR);
 			createSeqRMMsg.setReplyTo(replyToEPR);
 		}
 

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
Thu Sep  6 05:34:04 2007
@@ -17,18 +17,14 @@
 
 package org.apache.sandesha2.util;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
 
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axiom.om.OMElement;
@@ -66,6 +62,7 @@
 import org.apache.sandesha2.RMMsgContext;
 import org.apache.sandesha2.Sandesha2Constants;
 import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.addressing.EPRDecorator;
 import org.apache.sandesha2.client.SandeshaClientConstants;
 import org.apache.sandesha2.context.ContextManager;
 import org.apache.sandesha2.i18n.SandeshaMessageHelper;
@@ -758,6 +755,52 @@
 		return util;
 	}
 
+	public static EPRDecorator getEPRDecorator(ConfigurationContext context) throws SandeshaException
{
+		EPRDecorator decorator = null;
+		AxisConfiguration config = context.getAxisConfiguration();
+		Parameter p = config.getParameter(Sandesha2Constants.EPR_DECORATOR);
+		if(p != null) decorator = (EPRDecorator) p.getValue();
+		if (decorator != null) return decorator;
+
+		try {
+			//Currently module policies are used to find the decorator impl. These cant be overriden
+			String decoratorClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getEPRDecoratorClass();
+			decorator = getEPRDecoratorInstance(decoratorClassStr,context);
+			p = new Parameter(Sandesha2Constants.EPR_DECORATOR,decorator);
+			config.addParameter(p);
+		} catch(AxisFault e) {
+			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotInitEPRDecorator,
e.toString());
+			throw new SandeshaException(message,e);
+		}
+		return decorator;
+}
+	
+	private static EPRDecorator getEPRDecoratorInstance (String className,ConfigurationContext
context) throws SandeshaException {
+		try {
+			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));
+		    
+		  Class c = classLoader.loadClass(className);
+			Class configContextClass = context.getClass();
+			
+			Constructor constructor = c.getConstructor(new Class[] { configContextClass });
+			Object obj = constructor.newInstance(new Object[] {context});
+					if (!(obj instanceof EPRDecorator)) {
+				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.eprDecoratorMustImplement,
className);
+				throw new SandeshaException(message);
+			}
+			return (EPRDecorator) obj;
+			
+		} catch (Exception e) {
+			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotInitEPRDecorator,
e.toString());
+			throw new SandeshaException(message,e);
+		}
+	}
+	
 	private static SecurityManager getSecurityManagerInstance (String className,ConfigurationContext
context) throws SandeshaException {
 		try {
 			ClassLoader classLoader = null;

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
Thu Sep  6 05:34:04 2007
@@ -231,6 +231,15 @@
 				}
 			}
 			
+			//try to redecorate the EPR if necessary
+			if (log.isDebugEnabled())
+				log.debug("Redecorate EPR : " + msgCtx.getEnvelope().getHeader());
+			EndpointReference replyToEPR = msgCtx.getReplyTo();
+			if(replyToEPR!=null){
+				replyToEPR = SandeshaUtil.getEPRDecorator(msgCtx.getConfigurationContext()).decorateEndpointReference(replyToEPR);
+				msgCtx.setReplyTo(replyToEPR); 
+			}
+			
 			// have to commit the transaction before sending. This may
 			// get changed when WS-AT is available.
 			if(transaction != null) {

Modified: webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
Thu Sep  6 05:34:04 2007
@@ -28,6 +28,8 @@
 storageManagerMustImplement=StorageManager {0} must implement the org.apache.sandesha2.storage.StorageManager
interface.
 cannotInitSecurityManager=Cannot initialize the given security manager due to exception {0}.
 securityManagerMustImplement=SecurityManager {0} must implement the org.apache.sandesha2.storage.StorageManager
interface.
+cannotInitEPRDecorator=Cannot initialize the given epr decorator due to exception {0}.
+eprDecoratorMustImplement=EPRDecorator {0} must implement the org.apache.sandesha2.addressing.EPRDecorator
interface.
 cannotInitContextManager=Cannot initialize the given context manager due to exception {0}.
 contextManagerMustImplement=ContextManager {0} must implement the org.apache.sandesha2.context.ContextManager
interface.
 cannotFindModulePolicies=No policies were found in the module.xml at the module initiation
time.

Modified: webservices/sandesha/trunk/java/modules/mar/module.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/mar/module.xml?rev=573243&r1=573242&r2=573243&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/mar/module.xml (original)
+++ webservices/sandesha/trunk/java/modules/mar/module.xml Thu Sep  6 05:34:04 2007
@@ -135,6 +135,7 @@
 	      <!-- This will not be overriden by service level policies -->
 				<sandesha2:SecurityManager>org.apache.sandesha2.security.dummy.DummySecurityManager</sandesha2:SecurityManager>
 				<sandesha2:ContextManager>org.apache.sandesha2.context.DummyContextManager</sandesha2:ContextManager>
+				<sandesha2:EPRDecorator>org.apache.sandesha2.addressing.EPRDecoratorImpl</sandesha2:EPRDecorator>
 				
 				<sandesha2:MakeConnection>
 				  <sandesha2:Enabled>true</sandesha2:Enabled>



---------------------------------------------------------------------
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