[esb-java-dev] svn commit r23698 - in branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup: . tasks
indika at wso2.com
indika at wso2.com
Tue Nov 11 05:05:37 PST 2008
Author: indika
Date: Tue Nov 11 05:05:37 2008
New Revision: 23698
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=23698
Log:
Missing files when get code from synapse trunck
Modified:
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/Task.java
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/tasks/MessageInjector.java
Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/Task.java
URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/Task.java?rev=23698&r1=23697&r2=23698&view=diff
==============================================================================
--- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/Task.java (original)
+++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/Task.java Tue Nov 11 05:05:37 2008
@@ -22,10 +22,5 @@
/**
* Defines the Task for a SimpleQuartzStartup.
*/
-public interface Task {
-
- /**
- * Execute method will be invoked by the SimpleQuartzStartup.
- */
- public void execute();
+public interface Task extends org.apache.synapse.task.Task {
}
Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/tasks/MessageInjector.java
URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/tasks/MessageInjector.java?rev=23698&r1=23697&r2=23698&view=diff
==============================================================================
--- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/tasks/MessageInjector.java (original)
+++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/startup/tasks/MessageInjector.java Tue Nov 11 05:05:37 2008
@@ -19,12 +19,15 @@
package org.apache.synapse.startup.tasks;
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.ManagedLifecycle;
import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
import org.apache.synapse.core.SynapseEnvironment;
import org.apache.synapse.startup.Task;
import org.apache.synapse.util.PayloadHelper;
@@ -49,6 +52,14 @@
*/
private String to = null;
+ /**
+ * Could be one of either "soap11" | "soap12" | "pox" | "get"
+ */
+ private String format = null;
+
+ /**
+ * SOAPAction of the message to be set, in case of the format is soap11
+ */
private String soapAction = null;
/**
@@ -56,37 +67,53 @@
*/
private SynapseEnvironment synapseEnvironment;
+ public static String SOAP11_FORMAT = "soap11";
+ public static String SOAP12_FORMAT = "soap12";
+ public static String POX_FORMAT = "pox";
+ public static String GET_FORMAT = "get";
+
/**
* Initializes the Injector
*
- * @param se
- * SynapseEnvironment of synapse
+ * @param se SynapseEnvironment of synapse
*/
public void init(SynapseEnvironment se) {
- synapseEnvironment = se;
- }
+ synapseEnvironment = se;
+ }
/**
* Set the message to be injected
*
- * @param elem
- * OMElement describing the message
+ * @param elem OMElement describing the message
*/
public void setMessage(OMElement elem) {
- log.debug("set message " + elem.toString());
- message = elem;
- }
+ log.debug("set message " + elem.toString());
+ message = elem;
+ }
/**
* Set the to address of the message to be injected
*
- * @param url
- * String containing the to address
+ * @param url String containing the to address
*/
public void setTo(String url) {
- to = url;
- }
+ to = url;
+ }
+
+ /**
+ * Sets the format of the message
+ *
+ * @param format could be one of either "soap11" | "soap12" | "pox" | "get"
+ */
+ public void setFormat(String format) {
+ this.format = format;
+ }
+ /**
+ * Sets the SOAPAction and valid only when the format is given as soap11
+ *
+ * @param soapAction SOAPAction header value to be set
+ */
public void setSoapAction(String soapAction) {
this.soapAction = soapAction;
}
@@ -96,35 +123,54 @@
* in to the SynapseEnvironment
*/
public void execute() {
- log.debug("execute");
- if (synapseEnvironment == null) {
- log.error("Synapse Environment not set");
- return;
- }
- if (message == null) {
- log.error("message not set");
- return;
-
- }
- if (to == null) {
- log.error("to address not set");
- return;
+ log.debug("execute");
+ if (synapseEnvironment == null) {
+ log.error("Synapse Environment not set");
+ return;
+ }
+ if (message == null) {
+ log.error("message not set");
+ return;
- }
+ }
+ if (to == null) {
+ log.error("to address not set");
+ return;
+
+ }
MessageContext mc = synapseEnvironment.createMessageContext();
mc.setTo(new EndpointReference(to));
- PayloadHelper.setXMLPayload(mc, message.cloneOMElement());
+ if (format == null) {
+ PayloadHelper.setXMLPayload(mc, message.cloneOMElement());
+ } else {
+ try {
+ if (SOAP11_FORMAT.equalsIgnoreCase(format)) {
+ mc.setEnvelope(OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope());
+ } else if (SOAP12_FORMAT.equalsIgnoreCase(format)) {
+ mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope());
+ } else if (POX_FORMAT.equalsIgnoreCase(format)) {
+ mc.setDoingPOX(true);
+ } else if (GET_FORMAT.equalsIgnoreCase(format)) {
+ mc.setDoingGET(true);
+ }
+ PayloadHelper.setXMLPayload(mc, message.cloneOMElement());
+ } catch (AxisFault axisFault) {
+ String msg = "Error in setting the message payload : " + message;
+ log.error(msg, axisFault);
+ throw new SynapseException(msg, axisFault);
+ }
+ }
if (soapAction != null) {
mc.setSoapAction(soapAction);
}
synapseEnvironment.injectMessage(mc);
- }
+ }
/**
* Destroys the Injector
*/
public void destroy() {
- }
+ }
}
More information about the Esb-java-dev
mailing list