You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by de...@apache.org on 2005/10/31 12:18:58 UTC
svn commit: r329798 - in
/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse: ./
engine/ module/
Author: deepal
Date: Mon Oct 31 03:18:39 2005
New Revision: 329798
URL: http://svn.apache.org/viewcvs?rev=329798&view=rev
Log:
added simple deployment support , at the module init SynpseEngine will be populated using sysnpse.xml , not complete yet :(
Added:
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java
Modified:
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java
incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java
Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java?rev=329798&r1=329797&r2=329798&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java Mon Oct 31 03:18:39 2005
@@ -6,5 +6,11 @@
public static final String MEDIATION_RESULT = "Mediation Result";
public static final String SYNAPSE_ENGINE = "Synapse Engine";
+ String DIRECTION_IN ="incomming" ;
+ String DIRECTION_OUT ="outgoing" ;
+ String DIRECTION ="direction" ;
+ String STAGE_IN ="IN" ;
+ String STAGE_PROCESS ="PROCESS" ;
+ String STAGE_OUT ="OUT" ;
}
Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java?rev=329798&r1=329797&r2=329798&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java Mon Oct 31 03:18:39 2005
@@ -1,7 +1,6 @@
package org.apache.synapse.engine;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.synapse.mediator.Mediator;
import java.util.List;
@@ -10,9 +9,9 @@
public class Rule {
private Mediator[] mediators;
- private ConfigurationContext configContext;
private AxisConfiguration axisConfig;
private List qosModules;
+ private String name;
public Mediator[] getMediators() {
return mediators;
@@ -37,5 +36,13 @@
public void setQosModules(List qosModules) {
this.qosModules = qosModules;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
}
}
Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java?rev=329798&r1=329797&r2=329798&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java Mon Oct 31 03:18:39 2005
@@ -3,7 +3,8 @@
public class RuleEngineFactory {
public RuleSelector getRuleEngine(Rule[] rules){
- return new RuleSelectorImpl(rules);
+ return null;
+// return new RuleSelectorImpl(rules);
}
}
Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java?rev=329798&r1=329797&r2=329798&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java Mon Oct 31 03:18:39 2005
@@ -16,6 +16,8 @@
* In other words, RuleSelector should be created per stage per direction
*/
public void init(OMElement ruleSet);
+
+
Rule [] getRules();
/**
Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java?rev=329798&r1=329797&r2=329798&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java Mon Oct 31 03:18:39 2005
@@ -2,10 +2,17 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMAttribute;
+import javax.xml.namespace.QName;
import java.util.Iterator;
+import java.util.ArrayList;
public class RuleSelectorImpl implements RuleSelector {
+
+ private Rule rules [];
+
+
/**
* This will give a chance for the rules processor to compile or do whatever
* stuff he needs to optimize rules processing.
@@ -14,7 +21,29 @@
* In other words, RuleSelector should be created per stage per direction
*/
public void init(OMElement ruleSet) {
- //To change body of implemented methods use File | Settings | File Templates.
+ ArrayList ruleslist = new ArrayList();
+ Iterator itsruls = ruleSet.getChildrenWithName(new QName("rule"));
+ while (itsruls.hasNext()) {
+ OMElement ruleelement = (OMElement) itsruls.next();
+ OMAttribute attributeName = ruleelement.getAttribute(new QName("name"));
+ if(attributeName != null){
+ String rulename = attributeName.getAttributeValue();
+ Rule rule = new Rule();
+ Iterator mediatoes = ruleelement.getChildrenWithName(new QName("mediator"));
+ while (mediatoes.hasNext()) {
+ OMElement mediatorElement = (OMElement) mediatoes.next();
+ OMAttribute mediatorName = mediatorElement.getAttribute(new QName("name"));
+ //todo: Deepal mediator has to create and add the rule
+ }
+ rule.setName(rulename);
+ ruleslist.add(rule);
+ }
+ }
+ rules = (Rule[])ruleslist.toArray(new Rule[ruleslist.size()]);
+ }
+
+ public Rule [] getRules() {
+ return rules;
}
/**
Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java?rev=329798&r1=329797&r2=329798&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java Mon Oct 31 03:18:39 2005
@@ -13,8 +13,6 @@
private OMElement outgoingProcessingStageRuleSet;
private OMElement outgoingPostStageRuleSet;
- private Class ruleEngineClass;
-
public OMElement getIncomingPreStageRuleSet() {
return incomingPreStageRuleSet;
}
@@ -65,13 +63,5 @@
public void setOutgoingPostStageRuleSet(
OMElement outgoingPostStageRuleSet) {
this.outgoingPostStageRuleSet = outgoingPostStageRuleSet;
- }
-
- public Class getRuleEngineClass() {
- return ruleEngineClass;
- }
-
- public void setRuleEngineClass(Class ruleEngineClass) {
- this.ruleEngineClass = ruleEngineClass;
}
}
Added: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java?rev=329798&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java (added)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java Mon Oct 31 03:18:39 2005
@@ -0,0 +1,106 @@
+package org.apache.synapse.engine;
+
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.SynapseException;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* @author : Deepal Jayasinghe (deepal@apache.org)
+*
+*/
+
+public class SynapseDeployer {
+
+ private File synpseConfig;
+
+ public SynapseDeployer(File synpseConfig) {
+ this.synpseConfig = synpseConfig;
+ }
+
+ public SynapseConfiguration populteConfig() throws SynapseException{
+ SynapseConfiguration synConfig = new SynapseConfiguration();
+ try {
+ InputStream in = new FileInputStream(synpseConfig);
+ XMLStreamReader xmlReader =
+ XMLInputFactory.newInstance().createXMLStreamReader(in);
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac, xmlReader);
+ OMElement element = staxOMBuilder.getDocumentElement();
+ element.build();
+ Iterator disElements = element.getChildrenWithName(new QName(SynapseConstants.DIRECTION_IN));
+ while (disElements.hasNext()) {
+ OMElement omElement = (OMElement) disElements.next();
+ OMAttribute nameatt = omElement.getAttribute(new QName("name"));
+ if(nameatt !=null){
+ if(SynapseConstants.DIRECTION_IN.equals(nameatt.getAttributeValue())){
+ Iterator rulitr = omElement.getChildrenWithName(new QName("ruleSet"));
+ while (rulitr.hasNext()) {
+ OMElement rulset = (OMElement) rulitr.next();
+ OMAttribute stageAtt = rulset.getAttribute(new QName("stage"));
+ if(stageAtt != null){
+ String satge = stageAtt.getAttributeValue();
+ if(SynapseConstants.STAGE_IN.equals(satge)){
+ synConfig.setIncomingPreStageRuleSet(rulset);
+ } else if(SynapseConstants.STAGE_PROCESS.equals(satge)){
+ synConfig.setIncomingProcessingStageRuleSet(rulset);
+ } else if (SynapseConstants.STAGE_OUT.equals(satge)){
+ synConfig.setIncomingPostStageRuleSet(rulset);
+ }
+ }
+ }
+ } else if(SynapseConstants.DIRECTION_OUT.equals(nameatt.getAttributeValue())){
+ Iterator rulitr = omElement.getChildrenWithName(new QName("ruleSet"));
+ while (rulitr.hasNext()) {
+ OMElement rulset = (OMElement) rulitr.next();
+ OMAttribute stageAtt = rulset.getAttribute(new QName("stage"));
+ if(stageAtt != null){
+ String satge = stageAtt.getAttributeValue();
+ if(SynapseConstants.STAGE_IN.equals(satge)){
+ synConfig.setOutgoingPreStageRuleSet(rulset);
+ } else if(SynapseConstants.STAGE_PROCESS.equals(satge)){
+ synConfig.setOutgoingProcessingStageRuleSet(rulset);
+ } else if (SynapseConstants.STAGE_OUT.equals(satge)){
+ synConfig.setOutgoingPostStageRuleSet(rulset);
+ }
+ }
+ }
+ }
+ } else {
+ throw new SynapseException("direction name requird") ;
+ }
+ }
+ } catch (FileNotFoundException e) {
+ throw new SynapseException(e);
+ } catch (XMLStreamException e) {
+ throw new SynapseException(e);
+ }
+ return synConfig;
+ }
+}
Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java?rev=329798&r1=329797&r2=329798&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java (original)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java Mon Oct 31 03:18:39 2005
@@ -1,6 +1,9 @@
package org.apache.synapse.engine;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisConfigurationImpl;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.om.OMAttribute;
import org.apache.axis2.om.OMElement;
@@ -10,6 +13,7 @@
import javax.xml.namespace.QName;
import java.util.Iterator;
+import java.util.List;
public class SynapseEngine {
@@ -22,12 +26,14 @@
private RuleSelector outgoingProcessingStageRuleSelector;
private RuleSelector outgoingPostStageRuleSelector;
+ private AxisConfiguration axisConfig;
+
/**
*
*/
public void init(SynapseConfiguration synapseConfiguration)
throws SynapseException {
-
+ axisConfig = new AxisConfigurationImpl();
incomingPreStageRuleSelector = createRuleSelector(
synapseConfiguration.getIncomingPreStageRuleSet());
incomingProcessingStageRuleSelector = createRuleSelector(
@@ -167,11 +173,15 @@
Rule [] rules = ruleSelector.getRules();
for (int i = 0; i < rules.length; i++) {
Rule rule = rules[i];
- rule.setAxisConfig();
+ AxisService service = new AxisService(new QName(rule.getName()));
+ List qoslist = rule.getQosModules();
+ for (int j = 0; j < qoslist.size(); j++) {
+ String moduleName = (String) qoslist.get(j);
+ //todo engage all the mdoule to the service
+ }
+ axisConfig.addService(service);
+// rule.setAxisConfig();
}
-
-
-
return ruleSelector;
} catch (Exception e) {
throw new SynapseException(e);
Added: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml?rev=329798&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml (added)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml Mon Oct 31 03:18:39 2005
@@ -0,0 +1,20 @@
+<synapse>
+ <direction name="incomming">
+ <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="IN">
+ <rule name="Rule1">
+ <xpath>*</xpath>
+ <mediator name="Log"/>
+ <!--<mediator>Log</mediator>-->
+ <qos>Addressing</qos>
+ </rule>
+ </ruleSet>
+ <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="PROCESS"/>
+ <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="OUT"/>
+ </direction>
+ <direction name="outgoing">
+ <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="IN"/>
+ <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="PROCESS"/>
+ <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="OUT"/>
+ </direction>
+
+</synapse>
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java?rev=329798&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java (added)
+++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java Mon Oct 31 03:18:39 2005
@@ -0,0 +1,57 @@
+package org.apache.synapse.module;
+
+import org.apache.axis2.modules.Module;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ParameterImpl;
+import org.apache.synapse.engine.SynapseConfiguration;
+import org.apache.synapse.engine.SynapseDeployer;
+import org.apache.synapse.engine.SynapseEngine;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseConstants;
+
+import java.io.File;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* @author : Deepal Jayasinghe (deepal@apache.org)
+*
+*/
+
+public class SynapseModule implements Module {
+
+ public void init(AxisConfiguration axisConfiguration) throws AxisFault {
+ try {
+ File syncongiFile = new File("./synapse.xml");
+ SynapseConfiguration config = new SynapseDeployer(syncongiFile
+ ).populteConfig();
+
+ SynapseEngine engine = new SynapseEngine();
+ engine.init(config);
+ Parameter syPara = new ParameterImpl();
+ syPara.setName(SynapseConstants.SYNAPSE_ENGINE);
+ syPara.setValue(engine);
+ axisConfiguration.addParameter(syPara);
+ } catch (SynapseException e) {
+ throw new AxisFault(e);
+ }
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void shutdown(AxisConfiguration axisConfiguration) throws AxisFault {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org
Re: svn commit: r329798 - in
/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse: ./
engine/ module/
Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
Can u post a note explaining the syntax of synapse.xml? Without that a
bit hard to get into it :).
Also .. s/incomming/incoming/g.
Sanjiva.
On Mon, 2005-10-31 at 11:18 +0000, deepal@apache.org wrote:
> Author: deepal
> Date: Mon Oct 31 03:18:39 2005
> New Revision: 329798
>
> URL: http://svn.apache.org/viewcvs?rev=329798&view=rev
> Log:
> added simple deployment support , at the module init SynpseEngine will be populated using sysnpse.xml , not complete yet :(
>
> Added:
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java
> Modified:
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java
> incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java
>
> Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java?rev=329798&r1=329797&r2=329798&view=diff
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java (original)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/SynapseConstants.java Mon Oct 31 03:18:39 2005
> @@ -6,5 +6,11 @@
> public static final String MEDIATION_RESULT = "Mediation Result";
>
> public static final String SYNAPSE_ENGINE = "Synapse Engine";
> + String DIRECTION_IN ="incomming" ;
> + String DIRECTION_OUT ="outgoing" ;
> + String DIRECTION ="direction" ;
> + String STAGE_IN ="IN" ;
> + String STAGE_PROCESS ="PROCESS" ;
> + String STAGE_OUT ="OUT" ;
>
> }
>
> Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java?rev=329798&r1=329797&r2=329798&view=diff
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java (original)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/Rule.java Mon Oct 31 03:18:39 2005
> @@ -1,7 +1,6 @@
> package org.apache.synapse.engine;
>
> import org.apache.axis2.engine.AxisConfiguration;
> -import org.apache.axis2.context.ConfigurationContext;
> import org.apache.synapse.mediator.Mediator;
>
> import java.util.List;
> @@ -10,9 +9,9 @@
> public class Rule {
>
> private Mediator[] mediators;
> - private ConfigurationContext configContext;
> private AxisConfiguration axisConfig;
> private List qosModules;
> + private String name;
>
> public Mediator[] getMediators() {
> return mediators;
> @@ -37,5 +36,13 @@
>
> public void setQosModules(List qosModules) {
> this.qosModules = qosModules;
> + }
> +
> + public String getName() {
> + return name;
> + }
> +
> + public void setName(String name) {
> + this.name = name;
> }
> }
>
> Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java?rev=329798&r1=329797&r2=329798&view=diff
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java (original)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleEngineFactory.java Mon Oct 31 03:18:39 2005
> @@ -3,7 +3,8 @@
> public class RuleEngineFactory {
>
> public RuleSelector getRuleEngine(Rule[] rules){
> - return new RuleSelectorImpl(rules);
> + return null;
> +// return new RuleSelectorImpl(rules);
> }
>
> }
>
> Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java?rev=329798&r1=329797&r2=329798&view=diff
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java (original)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelector.java Mon Oct 31 03:18:39 2005
> @@ -16,6 +16,8 @@
> * In other words, RuleSelector should be created per stage per direction
> */
> public void init(OMElement ruleSet);
> +
> +
> Rule [] getRules();
>
> /**
>
> Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java?rev=329798&r1=329797&r2=329798&view=diff
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java (original)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/RuleSelectorImpl.java Mon Oct 31 03:18:39 2005
> @@ -2,10 +2,17 @@
>
> import org.apache.axis2.context.MessageContext;
> import org.apache.axis2.om.OMElement;
> +import org.apache.axis2.om.OMAttribute;
>
> +import javax.xml.namespace.QName;
> import java.util.Iterator;
> +import java.util.ArrayList;
>
> public class RuleSelectorImpl implements RuleSelector {
> +
> + private Rule rules [];
> +
> +
> /**
> * This will give a chance for the rules processor to compile or do whatever
> * stuff he needs to optimize rules processing.
> @@ -14,7 +21,29 @@
> * In other words, RuleSelector should be created per stage per direction
> */
> public void init(OMElement ruleSet) {
> - //To change body of implemented methods use File | Settings | File Templates.
> + ArrayList ruleslist = new ArrayList();
> + Iterator itsruls = ruleSet.getChildrenWithName(new QName("rule"));
> + while (itsruls.hasNext()) {
> + OMElement ruleelement = (OMElement) itsruls.next();
> + OMAttribute attributeName = ruleelement.getAttribute(new QName("name"));
> + if(attributeName != null){
> + String rulename = attributeName.getAttributeValue();
> + Rule rule = new Rule();
> + Iterator mediatoes = ruleelement.getChildrenWithName(new QName("mediator"));
> + while (mediatoes.hasNext()) {
> + OMElement mediatorElement = (OMElement) mediatoes.next();
> + OMAttribute mediatorName = mediatorElement.getAttribute(new QName("name"));
> + //todo: Deepal mediator has to create and add the rule
> + }
> + rule.setName(rulename);
> + ruleslist.add(rule);
> + }
> + }
> + rules = (Rule[])ruleslist.toArray(new Rule[ruleslist.size()]);
> + }
> +
> + public Rule [] getRules() {
> + return rules;
> }
>
> /**
>
> Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java?rev=329798&r1=329797&r2=329798&view=diff
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java (original)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseConfiguration.java Mon Oct 31 03:18:39 2005
> @@ -13,8 +13,6 @@
> private OMElement outgoingProcessingStageRuleSet;
> private OMElement outgoingPostStageRuleSet;
>
> - private Class ruleEngineClass;
> -
> public OMElement getIncomingPreStageRuleSet() {
> return incomingPreStageRuleSet;
> }
> @@ -65,13 +63,5 @@
> public void setOutgoingPostStageRuleSet(
> OMElement outgoingPostStageRuleSet) {
> this.outgoingPostStageRuleSet = outgoingPostStageRuleSet;
> - }
> -
> - public Class getRuleEngineClass() {
> - return ruleEngineClass;
> - }
> -
> - public void setRuleEngineClass(Class ruleEngineClass) {
> - this.ruleEngineClass = ruleEngineClass;
> }
> }
>
> Added: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java?rev=329798&view=auto
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java (added)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseDeployer.java Mon Oct 31 03:18:39 2005
> @@ -0,0 +1,106 @@
> +package org.apache.synapse.engine;
> +
> +import org.apache.axis2.om.OMFactory;
> +import org.apache.axis2.om.OMAbstractFactory;
> +import org.apache.axis2.om.OMElement;
> +import org.apache.axis2.om.OMAttribute;
> +import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
> +import org.apache.synapse.SynapseConstants;
> +import org.apache.synapse.SynapseException;
> +
> +import javax.xml.stream.XMLInputFactory;
> +import javax.xml.stream.XMLStreamReader;
> +import javax.xml.stream.XMLStreamException;
> +import javax.xml.namespace.QName;
> +import java.io.File;
> +import java.io.InputStream;
> +import java.io.FileInputStream;
> +import java.io.FileNotFoundException;
> +import java.util.Iterator;
> +/*
> +* Copyright 2004,2005 The Apache Software Foundation.
> +*
> +* Licensed under the Apache License, Version 2.0 (the "License");
> +* you may not use this file except in compliance with the License.
> +* You may obtain a copy of the License at
> +*
> +* http://www.apache.org/licenses/LICENSE-2.0
> +*
> +* Unless required by applicable law or agreed to in writing, software
> +* distributed under the License is distributed on an "AS IS" BASIS,
> +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +* See the License for the specific language governing permissions and
> +* limitations under the License.
> +*
> +* @author : Deepal Jayasinghe (deepal@apache.org)
> +*
> +*/
> +
> +public class SynapseDeployer {
> +
> + private File synpseConfig;
> +
> + public SynapseDeployer(File synpseConfig) {
> + this.synpseConfig = synpseConfig;
> + }
> +
> + public SynapseConfiguration populteConfig() throws SynapseException{
> + SynapseConfiguration synConfig = new SynapseConfiguration();
> + try {
> + InputStream in = new FileInputStream(synpseConfig);
> + XMLStreamReader xmlReader =
> + XMLInputFactory.newInstance().createXMLStreamReader(in);
> + OMFactory fac = OMAbstractFactory.getOMFactory();
> + StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac, xmlReader);
> + OMElement element = staxOMBuilder.getDocumentElement();
> + element.build();
> + Iterator disElements = element.getChildrenWithName(new QName(SynapseConstants.DIRECTION_IN));
> + while (disElements.hasNext()) {
> + OMElement omElement = (OMElement) disElements.next();
> + OMAttribute nameatt = omElement.getAttribute(new QName("name"));
> + if(nameatt !=null){
> + if(SynapseConstants.DIRECTION_IN.equals(nameatt.getAttributeValue())){
> + Iterator rulitr = omElement.getChildrenWithName(new QName("ruleSet"));
> + while (rulitr.hasNext()) {
> + OMElement rulset = (OMElement) rulitr.next();
> + OMAttribute stageAtt = rulset.getAttribute(new QName("stage"));
> + if(stageAtt != null){
> + String satge = stageAtt.getAttributeValue();
> + if(SynapseConstants.STAGE_IN.equals(satge)){
> + synConfig.setIncomingPreStageRuleSet(rulset);
> + } else if(SynapseConstants.STAGE_PROCESS.equals(satge)){
> + synConfig.setIncomingProcessingStageRuleSet(rulset);
> + } else if (SynapseConstants.STAGE_OUT.equals(satge)){
> + synConfig.setIncomingPostStageRuleSet(rulset);
> + }
> + }
> + }
> + } else if(SynapseConstants.DIRECTION_OUT.equals(nameatt.getAttributeValue())){
> + Iterator rulitr = omElement.getChildrenWithName(new QName("ruleSet"));
> + while (rulitr.hasNext()) {
> + OMElement rulset = (OMElement) rulitr.next();
> + OMAttribute stageAtt = rulset.getAttribute(new QName("stage"));
> + if(stageAtt != null){
> + String satge = stageAtt.getAttributeValue();
> + if(SynapseConstants.STAGE_IN.equals(satge)){
> + synConfig.setOutgoingPreStageRuleSet(rulset);
> + } else if(SynapseConstants.STAGE_PROCESS.equals(satge)){
> + synConfig.setOutgoingProcessingStageRuleSet(rulset);
> + } else if (SynapseConstants.STAGE_OUT.equals(satge)){
> + synConfig.setOutgoingPostStageRuleSet(rulset);
> + }
> + }
> + }
> + }
> + } else {
> + throw new SynapseException("direction name requird") ;
> + }
> + }
> + } catch (FileNotFoundException e) {
> + throw new SynapseException(e);
> + } catch (XMLStreamException e) {
> + throw new SynapseException(e);
> + }
> + return synConfig;
> + }
> +}
>
> Modified: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java?rev=329798&r1=329797&r2=329798&view=diff
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java (original)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/SynapseEngine.java Mon Oct 31 03:18:39 2005
> @@ -1,6 +1,9 @@
> package org.apache.synapse.engine;
>
> import org.apache.axis2.AxisFault;
> +import org.apache.axis2.description.AxisService;
> +import org.apache.axis2.engine.AxisConfiguration;
> +import org.apache.axis2.engine.AxisConfigurationImpl;
> import org.apache.axis2.context.MessageContext;
> import org.apache.axis2.om.OMAttribute;
> import org.apache.axis2.om.OMElement;
> @@ -10,6 +13,7 @@
>
> import javax.xml.namespace.QName;
> import java.util.Iterator;
> +import java.util.List;
>
>
> public class SynapseEngine {
> @@ -22,12 +26,14 @@
> private RuleSelector outgoingProcessingStageRuleSelector;
> private RuleSelector outgoingPostStageRuleSelector;
>
> + private AxisConfiguration axisConfig;
> +
> /**
> *
> */
> public void init(SynapseConfiguration synapseConfiguration)
> throws SynapseException {
> -
> + axisConfig = new AxisConfigurationImpl();
> incomingPreStageRuleSelector = createRuleSelector(
> synapseConfiguration.getIncomingPreStageRuleSet());
> incomingProcessingStageRuleSelector = createRuleSelector(
> @@ -167,11 +173,15 @@
> Rule [] rules = ruleSelector.getRules();
> for (int i = 0; i < rules.length; i++) {
> Rule rule = rules[i];
> - rule.setAxisConfig();
> + AxisService service = new AxisService(new QName(rule.getName()));
> + List qoslist = rule.getQosModules();
> + for (int j = 0; j < qoslist.size(); j++) {
> + String moduleName = (String) qoslist.get(j);
> + //todo engage all the mdoule to the service
> + }
> + axisConfig.addService(service);
> +// rule.setAxisConfig();
> }
> -
> -
> -
> return ruleSelector;
> } catch (Exception e) {
> throw new SynapseException(e);
>
> Added: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml?rev=329798&view=auto
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml (added)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/engine/synapse.xml Mon Oct 31 03:18:39 2005
> @@ -0,0 +1,20 @@
> +<synapse>
> + <direction name="incomming">
> + <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="IN">
> + <rule name="Rule1">
> + <xpath>*</xpath>
> + <mediator name="Log"/>
> + <!--<mediator>Log</mediator>-->
> + <qos>Addressing</qos>
> + </rule>
> + </ruleSet>
> + <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="PROCESS"/>
> + <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="OUT"/>
> + </direction>
> + <direction name="outgoing">
> + <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="IN"/>
> + <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="PROCESS"/>
> + <ruleSet class="org.apache.synapse.engine.RuleSelectorImpl" stage="OUT"/>
> + </direction>
> +
> +</synapse>
> \ No newline at end of file
>
> Added: incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java
> URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java?rev=329798&view=auto
> ==============================================================================
> --- incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java (added)
> +++ incubator/synapse/trunk/scratch/prototype1/src/org/apache/synapse/module/SynapseModule.java Mon Oct 31 03:18:39 2005
> @@ -0,0 +1,57 @@
> +package org.apache.synapse.module;
> +
> +import org.apache.axis2.modules.Module;
> +import org.apache.axis2.engine.AxisConfiguration;
> +import org.apache.axis2.AxisFault;
> +import org.apache.axis2.description.Parameter;
> +import org.apache.axis2.description.ParameterImpl;
> +import org.apache.synapse.engine.SynapseConfiguration;
> +import org.apache.synapse.engine.SynapseDeployer;
> +import org.apache.synapse.engine.SynapseEngine;
> +import org.apache.synapse.SynapseException;
> +import org.apache.synapse.SynapseConstants;
> +
> +import java.io.File;
> +/*
> +* Copyright 2004,2005 The Apache Software Foundation.
> +*
> +* Licensed under the Apache License, Version 2.0 (the "License");
> +* you may not use this file except in compliance with the License.
> +* You may obtain a copy of the License at
> +*
> +* http://www.apache.org/licenses/LICENSE-2.0
> +*
> +* Unless required by applicable law or agreed to in writing, software
> +* distributed under the License is distributed on an "AS IS" BASIS,
> +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +* See the License for the specific language governing permissions and
> +* limitations under the License.
> +*
> +* @author : Deepal Jayasinghe (deepal@apache.org)
> +*
> +*/
> +
> +public class SynapseModule implements Module {
> +
> + public void init(AxisConfiguration axisConfiguration) throws AxisFault {
> + try {
> + File syncongiFile = new File("./synapse.xml");
> + SynapseConfiguration config = new SynapseDeployer(syncongiFile
> + ).populteConfig();
> +
> + SynapseEngine engine = new SynapseEngine();
> + engine.init(config);
> + Parameter syPara = new ParameterImpl();
> + syPara.setName(SynapseConstants.SYNAPSE_ENGINE);
> + syPara.setValue(engine);
> + axisConfiguration.addParameter(syPara);
> + } catch (SynapseException e) {
> + throw new AxisFault(e);
> + }
> + //To change body of implemented methods use File | Settings | File Templates.
> + }
> +
> + public void shutdown(AxisConfiguration axisConfiguration) throws AxisFault {
> + //To change body of implemented methods use File | Settings | File Templates.
> + }
> +}
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org