synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r356079 - in /incubator/synapse/trunk/java/src: org/apache/synapse/ org/apache/synapse/api/ org/apache/synapse/axis2/ org/apache/synapse/processors/ org/apache/synapse/processors/mediatortypes/ samples/userguide/
Date Mon, 12 Dec 2005 01:09:30 GMT
Author: pzf
Date: Sun Dec 11 17:09:27 2005
New Revision: 356079

URL: http://svn.apache.org/viewcvs?rev=356079&view=rev
Log:
giving services the right classloader

Modified:
    incubator/synapse/trunk/java/src/org/apache/synapse/Constants.java
    incubator/synapse/trunk/java/src/org/apache/synapse/api/EnvironmentAware.java
    incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
    incubator/synapse/trunk/java/src/org/apache/synapse/processors/Axis2MediatorProcessor.java
    incubator/synapse/trunk/java/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java
    incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java

Modified: incubator/synapse/trunk/java/src/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/Constants.java?rev=356079&r1=356078&r2=356079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/org/apache/synapse/Constants.java (original)
+++ incubator/synapse/trunk/java/src/org/apache/synapse/Constants.java Sun Dec 11 17:09:27
2005
@@ -15,6 +15,8 @@
  */
 package org.apache.synapse;
 
+import javax.xml.namespace.QName;
+
 
 
 /**
@@ -28,9 +30,10 @@
 
 	String CLASSMEDIATOR = "classmediator";
 
-	String MEDIATE_OPERATION_NAME = "mediate";
+	QName MEDIATE_OPERATION_NAME = new QName("mediate");
 
 	String MEDIATOR_RESPONSE_PROPERTY = "synapse.mediator.response";
+	String MEDIATOR_SYNAPSE_ENV_PROPERTY = "synapse.mediator.environment";
 
 	String ISRESPONSE_PROPERTY = "synapse.isresponse";
 

Modified: incubator/synapse/trunk/java/src/org/apache/synapse/api/EnvironmentAware.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/api/EnvironmentAware.java?rev=356079&r1=356078&r2=356079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/org/apache/synapse/api/EnvironmentAware.java (original)
+++ incubator/synapse/trunk/java/src/org/apache/synapse/api/EnvironmentAware.java Sun Dec
11 17:09:27 2005
@@ -25,5 +25,6 @@
  */
 public interface EnvironmentAware {
 	public void setSynapseEnvironment(SynapseEnvironment se);
+	public void setClassLoader(ClassLoader cl);
 
 }

Modified: incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java?rev=356079&r1=356078&r2=356079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
(original)
+++ incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
Sun Dec 11 17:09:27 2005
@@ -5,7 +5,9 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
 import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseEnvironment;
 import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.EnvironmentAware;
 import org.apache.synapse.api.Mediator;
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
@@ -27,12 +29,14 @@
 public class ServiceMediatorMessageReceiver extends AbstractMessageReceiver {
     public void receive(MessageContext messageContext) throws AxisFault {
         Object obj = makeNewServiceObject(messageContext);
-        /**
-         * Dependency manager is used in inject MessageContext to the mediator object
-         * So some service related properties can be taken from META-INF folder
-         */
-        DependencyManager.configureBusinessLogicProvider(obj,messageContext,null);
+        
         Mediator mediator = (Mediator)obj;
+        
+        if (EnvironmentAware.class.isAssignableFrom(mediator.getClass())) {
+        	SynapseEnvironment se = (SynapseEnvironment)messageContext.getProperty(Constants.MEDIATOR_SYNAPSE_ENV_PROPERTY);
+			((EnvironmentAware) mediator).setSynapseEnvironment(se);
+			((EnvironmentAware) mediator).setClassLoader(messageContext.getAxisService().getClassLoader());
+		}
         SynapseMessage smc = new Axis2SynapseMessage(messageContext);
         boolean returnValue = mediator.mediate(smc);
         messageContext.setProperty(Constants.MEDIATOR_STATUS, new Boolean(returnValue));

Modified: incubator/synapse/trunk/java/src/org/apache/synapse/processors/Axis2MediatorProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/processors/Axis2MediatorProcessor.java?rev=356079&r1=356078&r2=356079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/org/apache/synapse/processors/Axis2MediatorProcessor.java
(original)
+++ incubator/synapse/trunk/java/src/org/apache/synapse/processors/Axis2MediatorProcessor.java
Sun Dec 11 17:09:27 2005
@@ -52,7 +52,7 @@
             if (as == null)
                 throw new SynapseException("cannot locate service "
                         + mediatorName);
-            // todo: qos stuff goes here
+
             AxisOperation ao = as
                     .getOperation(Constants.MEDIATE_OPERATION_NAME);
             OperationContext oc = OperationContextFactory
@@ -70,6 +70,8 @@
             msgContext.setAxisOperation(ao);
             msgContext.setAxisService(as);
 
+            msgContext.setProperty(Constants.MEDIATOR_SYNAPSE_ENV_PROPERTY, se);
+            
             ae.receive(msgContext);
         } catch (AxisFault axisFault) {
             throw new SynapseException(axisFault);

Modified: incubator/synapse/trunk/java/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java?rev=356079&r1=356078&r2=356079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java
(original)
+++ incubator/synapse/trunk/java/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java
Sun Dec 11 17:09:27 2005
@@ -20,6 +20,7 @@
 import org.apache.synapse.SynapseEnvironment;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.EnvironmentAware;
 import org.apache.synapse.api.Mediator;
 import org.apache.synapse.processors.AbstractProcessor;
 
@@ -44,6 +45,9 @@
 			m = (Mediator) getClazz().newInstance();
 		} catch (Exception e) {
 			throw new SynapseException(e);
+		}
+		if (EnvironmentAware.class.isAssignableFrom(m.getClass())) {
+			((EnvironmentAware) m).setSynapseEnvironment(se);
 		}
 		return m.mediate(smc);
 

Modified: incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java?rev=356079&r1=356078&r2=356079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java (original)
+++ incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java Sun Dec
11 17:09:27 2005
@@ -4,7 +4,6 @@
 
 import javax.xml.namespace.QName;
 
-
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Call;
@@ -36,30 +35,28 @@
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HttpTransportProperties;
 
-
 public class ProxyStockQuoteClient {
 
 	/**
 	 * 
-	 *            <p>
-	 *            This is a fairly static test client for Synapse. It makes a
-	 *            StockQuote request to XMethods stockquote service. The EPR it
-	 *            is sent to is for XMethods, but the actual transport URL is
-	 *            designed to go to the Synapse listener.
+	 * <p>
+	 * This is a fairly static test client for Synapse. It makes a StockQuote
+	 * request to XMethods stockquote service. The EPR it is sent to is for
+	 * XMethods, but the actual transport URL is designed to go to the Synapse
+	 * listener.
 	 * 
 	 */
 	public static void main(String[] args) {
 
 		if (args.length > 0 && args[0].substring(0, 1).equals("-")) {
 			System.out
-					.println("This client demonstrates Synapse as a proxy\n" +
-							"Usage: ProxyStockQuoteClient Symbol XmethodsURL ProxyURL");
+					.println("This client demonstrates Synapse as a proxy\n"
+							+ "Usage: ProxyStockQuoteClient Symbol XmethodsURL ProxyURL");
 			System.out
 					.println("\nDefault values: IBM http://64.124.140.30:9090/soap http://localhost:8080");
 			System.out
 					.println("\nThe XMethods URL will be used in the <wsa:To> header");
-			System.out
-					.println("The Proxy URL will be used as an HTTP proxy");
+			System.out.println("The Proxy URL will be used as an HTTP proxy");
 			System.out
 					.println("\nTo demonstrate Synapse virtual URLs, set the xmethods URL to urn:xmethods-delayed-quotes\n"
 							+ "\nTo demonstrate content-based behaviour, set the Symbol to MSFT\n"
@@ -91,65 +88,56 @@
 			symbol.setText(symb);
 
 			// step 2 - set up the call object
-			
+
 			// the wsa:To
 			EndpointReference targetEPR = new EndpointReference(purl);
 
 			Options options = new Options();
-			
+
 			options.setTo(targetEPR);
 
 			URL url = new URL(purl);
-			
+
 			HttpTransportProperties httpProps = new HttpTransportProperties();
 			HttpTransportProperties.ProxyProperties proxyProperties = httpProps.new ProxyProperties();
-			//proxyProperties.setProxyName(url.getHost());
-			//proxyProperties.setProxyPort(url.getPort());
-			
+			// proxyProperties.setProxyName(url.getHost());
+			// proxyProperties.setProxyPort(url.getPort());
+
 			proxyProperties.setProxyName("localhost");
 			proxyProperties.setProxyPort(6060);
 			proxyProperties.setUserName("anonymous");
 			proxyProperties.setPassWord("anonymous");
 			proxyProperties.setDomain("anonymous");
 			options.setProperty(HTTPConstants.PROXY, proxyProperties);
-			
-			
+
 			AxisConfiguration ac = new AxisConfiguration();
 			ConfigurationContext cc = new ConfigurationContext(ac);
 			AxisServiceGroup asg = new AxisServiceGroup(ac);
 			AxisService as = new AxisService(new QName("AnonymousService"));
-			
+
 			asg.addService(as);
-			
+
 			ServiceGroupContext sgc = new ServiceGroupContext(cc, asg);
-			
+
 			ServiceContext sc = sgc.getServiceContext("AnonymousService");
-			//sc.createOperationContext(new QName("getQuote"));
-			
-		 AxisOperation axisOperationTemplate = new OutInAxisOperation(
-	                    new QName("getQuote"));
-
-		 as.addOperation(axisOperationTemplate);
-	     cc.getAxisConfiguration().addService(as);
-	     TransportOutDescription tod = new TransportOutDescription(new QName(Constants.TRANSPORT_HTTP));
-	     tod.setSender(new CommonsHTTPTransportSender());
-	     ac.addTransportOut(tod);
-	     
-	     
-	     
-	            
 
-			
+			AxisOperation axisOperationTemplate = new OutInAxisOperation(
+					new QName("getQuote"));
+
+			as.addOperation(axisOperationTemplate);
+			cc.getAxisConfiguration().addService(as);
+			TransportOutDescription tod = new TransportOutDescription(
+					new QName(Constants.TRANSPORT_HTTP));
+			tod.setSender(new CommonsHTTPTransportSender());
+			ac.addTransportOut(tod);
+
 			Call call;
 			call = new Call(sc);
-			
-			
+
 			call.setClientOptions(options);
-			
-			
-			
+
 			// step 3 - Blocking invocation
-			OMElement result = call.invokeBlocking( "getQuote", getQuote);
+			OMElement result = call.invokeBlocking("getQuote", getQuote);
 
 			// step 4 - parse result
 			QName gQR = new QName("urn:xmethods-delayed-quotes",



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


Mime
View raw message