You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2005/10/18 16:01:56 UTC
svn commit: r326109 - in
/incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse:
./ client/ dispatch/ receivers/ rules/
Author: saminda
Date: Tue Oct 18 07:01:44 2005
New Revision: 326109
URL: http://svn.apache.org/viewcvs?rev=326109&view=rev
Log:
Update the scratch code
Modified:
incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/SynapseConstants.java
incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/client/SampleClient.java
incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/dispatch/SyanpseDispatcher.java
incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/receivers/SynapseMessageReceiver.java
incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleConfiguration.java
incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleEngine.java
Modified: incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/SynapseConstants.java?rev=326109&r1=326108&r2=326109&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/SynapseConstants.java (original)
+++ incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/SynapseConstants.java Tue Oct 18 07:01:44 2005
@@ -20,7 +20,9 @@
}
public interface SynapseRuleEngine {
public static final String GENERAT_RULE_ARRAY_LIST = "generalRules";
+ public static final String GENERAT_RULE_ARRAY_BOOLEAN = "boolean";
public static final String XPATH_RULE_ARRAY_LIST= "xpathRules";
+ public static final String XPATH_RULE_ARRAY_BOOLEAN= "boolean";
public static final String SYNAPSE_RECEIVER = "receiver";
public static final String SYNAPSE_RULE_ENGINE= "synapseRuleEngine";
}
Modified: incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/client/SampleClient.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/client/SampleClient.java?rev=326109&r1=326108&r2=326109&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/client/SampleClient.java (original)
+++ incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/client/SampleClient.java Tue Oct 18 07:01:44 2005
@@ -39,25 +39,13 @@
public static class ClientUtil {
- public OMElement getEchoOMElement() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace(
- "http://example1.org/example1", "example1");
- OMElement method = fac.createOMElement("echo", omNs);
- OMElement value = fac.createOMElement("Text", omNs);
- value.addChild(fac.createText(value, "Axis2 Echo String "));
- method.addChild(value);
-
- return method;
- }
-
public OMElement getPingOMElement() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(
- "http://example1.org/example1", "example1");
+ "http://synapse.org/synapse", "synapse");
OMElement method = fac.createOMElement("ping", omNs);
- OMElement value = fac.createOMElement("Text", omNs);
- value.addChild(fac.createText(value, "Axis2 Ping String "));
+ OMElement value = fac.createOMElement("text", omNs);
+ value.addChild(fac.createText(value, "Synpase Ping String "));
method.addChild(value);
return method;
Modified: incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/dispatch/SyanpseDispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/dispatch/SyanpseDispatcher.java?rev=326109&r1=326108&r2=326109&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/dispatch/SyanpseDispatcher.java (original)
+++ incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/dispatch/SyanpseDispatcher.java Tue Oct 18 07:01:44 2005
@@ -41,28 +41,9 @@
operationName = new QName(opName);
/**
- * Configuration only being done for the General Rule listing
- * need to do it for xpath rule listing too
+ * Synapse Rule Engine, which determine which rules to apply,
+ * general of xpath {Scope of M1}
*/
-// SynapaseRuleBean bean = null;
-//
-// ArrayList generalList = (ArrayList) messageContext.getProperty(
-// SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_LIST);
-// ArrayList xpathList = (ArrayList) messageContext.getProperty(
-// SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_LIST);
-//
-//
-// Integer state = (Integer) messageContext
-// .getProperty(SynapseConstants.SYNAPSE_STATE);
-//
-// if ( generalList.size() > 0) {
-// bean = (SynapaseRuleBean) generalList.get(state.intValue() - 1);
-// serviceName = bean.getMediator();
-// }
-//
-// if ( xpathList.size() > 0 ) {
-//
-// }
serviceName = SynapseRuleEngine.findService(messageContext);
AxisConfiguration registry =
Modified: incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/receivers/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/receivers/SynapseMessageReceiver.java?rev=326109&r1=326108&r2=326109&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/receivers/SynapseMessageReceiver.java (original)
+++ incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/receivers/SynapseMessageReceiver.java Tue Oct 18 07:01:44 2005
@@ -72,6 +72,7 @@
(oldSynapseState.intValue()) + 1);
msgContext.setProperty(SynapseConstants.SYNAPSE_STATE,
newSynapseState);
+ msgContext.setProperty(SynapseConstants.MEDEATOT_STATE,mediatorState);
if (mediatorState.booleanValue()) {
/**
@@ -118,6 +119,20 @@
SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_LIST,
returnMsgCtx.getProperty(
SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_LIST));
+ newContext.setProperty(
+ SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_LIST,
+ returnMsgCtx.getProperty(
+ SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_LIST));
+ newContext.setProperty(
+ SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_BOOLEAN,
+ returnMsgCtx.getProperty(
+ SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_BOOLEAN));
+ newContext.setProperty(
+ SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_BOOLEAN,
+ returnMsgCtx.getProperty(
+ SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_BOOLEAN));
+
+
newContext.setServerSide(true);
newContext.setEnvelope(returnMsgCtx.getEnvelope());
newContext.setServiceContextID(returnMsgCtx.getServiceContextID());
Modified: incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleConfiguration.java?rev=326109&r1=326108&r2=326109&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleConfiguration.java (original)
+++ incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleConfiguration.java Tue Oct 18 07:01:44 2005
@@ -95,9 +95,10 @@
Iterator ruleIte = ruleReader.getRulesIterator();
while (ruleIte.hasNext()) {
- // genertal rule handling with "*"
SynapaseRuleBean bean = (SynapaseRuleBean) ruleIte.next();
-
+ /**
+ * general rule handling
+ */
if (bean.getCondition().equals("*")) {
// this could be more than this.
this.generalRuleList.add(bean);
@@ -109,9 +110,15 @@
//settingup the namespace which needed to be dealt with care
SimpleNamespaceContext nameSpace = new SimpleNamespaceContext();
//add the relevent name spaces
+ //-------------------- as an Example
+ nameSpace.addNamespace("synapse", "http://synapse.org/synapse");
+ //--------------------
xpath.setNamespaceContext(nameSpace);
-
- boolean xpathBool = xpath.booleanValueOf(nameSpace);
+ /**
+ * Xpath validation for the incomming message.
+ */
+ boolean xpathBool = xpath
+ .booleanValueOf(messageContext.getEnvelope());
if (xpathBool) {
this.xpathRuleList.add(bean);
@@ -124,6 +131,12 @@
messageContext.setProperty(
SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_LIST,
xpathRuleList);
+ messageContext.setProperty(
+ SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_BOOLEAN,
+ new Boolean(true));
+ messageContext.setProperty(
+ SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_BOOLEAN,
+ new Boolean(true));
}
}
Modified: incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleEngine.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleEngine.java?rev=326109&r1=326108&r2=326109&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleEngine.java (original)
+++ incubator/synapse/trunk/scratch/saminda/synapse2/src/org/apache/synapse/rules/SynapseRuleEngine.java Tue Oct 18 07:01:44 2005
@@ -13,14 +13,19 @@
* To change this template use File | Settings | File Templates.
*/
public class SynapseRuleEngine {
- public static String findService(MessageContext messageContext) {
+ /**
+ * Synapse Rule Engine, which is able to select between "general" and "xpath"
+ * rules and applying it.
+ * This code has been written giving support to Rule Extensibility.
+ * <p/>
+ * 1. First all the general rules will be apply to all the incoming messages.
+ * 2. Xpaht Rule apply to relevent messages.
+ */
+ public static String findService(MessageContext messageContext) {
SynapaseRuleBean bean = null;
String serviceName = null;
- boolean generalListBoolean = true;
- boolean xpathListBoolean = true;
-
ArrayList generalList = (ArrayList) messageContext.getProperty(
SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_LIST);
@@ -32,9 +37,13 @@
if (generalList.size() > 0) {
if ((state.intValue() <= generalList.size()) &&
- generalListBoolean) {
+ ((Boolean) messageContext.getProperty(
+ SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_BOOLEAN))
+ .booleanValue()) {
if (state.intValue() == generalList.size()) {
- generalListBoolean = false;
+ messageContext.setProperty(
+ SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_BOOLEAN,
+ new Boolean(false));
messageContext.setProperty(SynapseConstants.SYNAPSE_STATE,
new Integer(1));
}
@@ -44,15 +53,21 @@
}
if (xpathList.size() > 0) {
- if (!generalListBoolean) {
- if ((state.intValue() <= generalList.size()) &&
- xpathListBoolean) {
- if (state.intValue() == generalList.size()) {
- xpathListBoolean = false;
+ if (!((Boolean) messageContext.getProperty(
+ SynapseConstants.SynapseRuleEngine.GENERAT_RULE_ARRAY_BOOLEAN))
+ .booleanValue()) {
+ if ((state.intValue() <= xpathList.size()) &&
+ ((Boolean) messageContext.getProperty(
+ SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_BOOLEAN))
+ .booleanValue()) {
+ if (state.intValue() == xpathList.size()) {
+ ((Boolean) messageContext.getProperty(
+ SynapseConstants.SynapseRuleEngine.XPATH_RULE_ARRAY_BOOLEAN))
+ .booleanValue();
messageContext.setProperty(
SynapseConstants.SYNAPSE_STATE, new Integer(1));
}
- bean = (SynapaseRuleBean) generalList
+ bean = (SynapaseRuleBean) xpathList
.get(state.intValue() - 1);
serviceName = bean.getMediator();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org