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 2006/04/28 14:49:34 UTC
svn commit: r397884 [4/8] - in /incubator/synapse/trunk/scratch/synapse2: ./
bin/ modules/ modules/core/ modules/core/conf/ modules/core/src/
modules/core/src/org/ modules/core/src/org/apache/
modules/core/src/org/apache/synapse/ modules/core/src/org/a...
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperImpl.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperImpl.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperImpl.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/ResourceHelperImpl.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,80 @@
+package org.apache.synapse.resources;
+
+import org.apache.synapse.api.ResourceUpdateAware;
+import org.apache.synapse.SynapseException;
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashMap;
+
+/*
+ * 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.
+ */
+
+public class ResourceHelperImpl implements ResourceHelper {
+
+ private Log log = LogFactory.getLog(getClass());
+ protected HashMap resourceHandlers = new HashMap();
+
+
+ public OMElement get(String uri) { // get a resource
+ if (!(uri.equals("") || uri == null)) {
+ Object obj = resourceHandlers.get(uri);
+ if (obj != null) {
+ if (obj instanceof ResourceHandler) {
+ ResourceHandler rh = (ResourceHandler) obj;
+
+ return rh.get(uri);
+ } else {
+ throw new SynapseException("Unsupported uri");
+ }
+ } else {
+ throw new SynapseException("Map doesnt contain the requested ResourceHandler "+uri);
+
+ }
+ } else {
+ throw new SynapseException("Unsupported ResourceHandler ");
+ }
+
+
+ }
+
+ public OMElement get(String uri,
+ ResourceUpdateAware mediator) { // get a resource and be notified of changes
+
+ throw new SynapseException("Not implemented");
+ }
+
+ public void registerResourceHandler(ResourceHandler rh, String urlRoot) {
+ log.debug("registering resource handler for "+urlRoot);
+ //runtime null pointer setting if neeeded, otherwise it has already been checked.
+ if (rh != null && (urlRoot != null)) {
+ if (resourceHandlers.containsKey(urlRoot)) {
+ throw new SynapseException("Uri-root already exists");
+ } else {
+ resourceHandlers.put(urlRoot, rh);
+ }
+
+ }
+ }
+
+ // register a handler for a given set of URLs (which share the same root)
+ public void notifyUpdate(String uriRoot) {
+ throw new SynapseException("Not Implemented");
+ }
+
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/http/SimpleGETResourceHandler.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/http/SimpleGETResourceHandler.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/http/SimpleGETResourceHandler.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/http/SimpleGETResourceHandler.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,99 @@
+package org.apache.synapse.resources.http;
+
+import org.apache.synapse.resources.ResourceHandler;
+import org.apache.synapse.SynapseException;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import java.util.HashMap;
+import java.io.IOException;
+import java.io.InputStream;
+/*
+ * 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.
+ */
+
+public class SimpleGETResourceHandler implements ResourceHandler {
+
+ protected HashMap propertyMap = new HashMap();
+
+ public OMElement get(String uri) {
+ OMElement response = null;
+ HttpClient httpClient = new HttpClient();
+ /*
+ Following code technically gives the mediators to do a simple Http GET and aquire
+ some resources. Any mediator can use this method to quire its resources.
+ */
+ GetMethod httpGet = new GetMethod(uri);
+ try {
+
+ httpClient.executeMethod(httpGet);
+ if (httpGet.getStatusCode() == HttpStatus.SC_OK) {
+ response = processResponse(httpGet.getResponseBodyAsStream());
+ }
+ } catch (IOException e) {
+ throw new SynapseException(e);
+ } finally {
+ httpGet.releaseConnection();
+ }
+ if (response == null)
+ throw new SynapseException("There are no valid resonse resources");
+ return response;
+ }
+
+ public void setProperty(String name, String value) {
+ propertyMap.put(name, value);
+ }
+
+ public String getProperty(String name) {
+ return (String) propertyMap.get(name);
+ }
+
+ public String[] getPropertyNames() {
+
+ return ((String[]) propertyMap.keySet()
+ .toArray(new String[propertyMap.size()]));
+ }
+
+ public boolean isUpdated(String uriRoot){ // used to poll if resource has changed (Pull model)
+
+ //todo: implement this method.
+ return false;
+ }
+
+ private static OMElement processResponse(InputStream inputStream) {
+ if (inputStream == null) {
+ throw new SynapseException(
+ "Input Stream cannot be null for Resource request");
+ }
+ try {
+ XMLStreamReader parser = XMLInputFactory.newInstance()
+ .createXMLStreamReader(inputStream);
+ StAXOMBuilder builder =
+ new StAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);
+ OMElement resourceElement = builder.getDocumentElement();
+ resourceElement.build(); //make sure we are in safe side
+ return resourceElement;
+ } catch (XMLStreamException e) {
+ throw new SynapseException(e);
+ }
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,44 @@
+package org.apache.synapse.resources.xml;
+
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.Mediator;
+/*
+ * 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.
+ */
+
+public class PropertyMediator implements Mediator {
+
+ protected String name;
+ protected String value;
+ public boolean mediate(SynapseMessage sm) {
+ // this is not a inline mediator. Its soule purpose is to provide properties from Synapse.xml
+ return true;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ public String getValue() {
+ return value;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/PropertyMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,57 @@
+package org.apache.synapse.resources.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.xml.MediatorFactory;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+import javax.xml.namespace.QName;
+/*
+ * 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.
+ */
+
+public class PropertyMediatorFactory implements MediatorFactory {
+
+ private static final String PROPERTY = "property";
+
+ private static final QName PROPERTY_Q =
+ new QName(Constants.SYNAPSE_NAMESPACE,
+ PROPERTY);
+
+ private static final QName PROPERTY_NAME_ATT_Q = new QName("name");
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ PropertyMediator pm = new PropertyMediator();
+
+ OMAttribute name = el.getAttribute(PROPERTY_NAME_ATT_Q);
+ if (name == null) {
+ throw new SynapseException(PROPERTY + " must have "
+ + PROPERTY_NAME_ATT_Q + " attribute: " + el.toString());
+ }
+
+ String value = el.getText();
+ pm.setName(name.getAttributeValue());
+ pm.setValue(value);
+
+ return pm;
+ }
+
+ public QName getTagQName() {
+ return PROPERTY_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,46 @@
+package org.apache.synapse.resources.xml;
+
+import org.apache.synapse.mediators.base.AbstractListMediator;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+/*
+ * 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.
+ */
+
+public class ResourceMediator extends AbstractListMediator {
+ protected String type;
+ protected String uriRoot;
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ // this is not a inline mediator, It's soule purpose of existence is to populate the ResourceHandler
+ return true;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType(){
+ return type;
+ }
+
+ public void setURIRoot(String uriRoot) {
+ this.uriRoot = uriRoot;
+ }
+ public String getURIRoot() {
+ return uriRoot;
+ }
+
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/resources/xml/ResourceMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,115 @@
+package org.apache.synapse.resources.xml;
+
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.xml.MediatorFactory;
+import org.apache.synapse.xml.MediatorFactoryFinder;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+/*
+ * 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.
+ */
+
+public class ResourceMediatorFactory implements MediatorFactory {
+
+ private Log log = LogFactory.getLog(getClass());
+
+ private static final String RESOURCE = "resource";
+
+ private static final QName RESOURCE_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ RESOURCE);
+
+ private static final QName RESOURCE_TYPE_ATT_Q = new QName("type");
+
+ private static final QName RESOURCE_URI_ROOT_ATT_Q = new QName("uri-root");
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+
+ ResourceMediator rp = new ResourceMediator();
+
+ this.addPropertiesMediatorsAndURIRoot(se,el,rp);
+
+ OMAttribute type = el.getAttribute(RESOURCE_TYPE_ATT_Q);
+ if (type == null) {
+ throw new SynapseException(RESOURCE + " must have "
+ + RESOURCE_TYPE_ATT_Q + " attribute: " + el.toString());
+ }
+
+ OMAttribute uriRoot = el.getAttribute(RESOURCE_URI_ROOT_ATT_Q);
+ if (uriRoot == null) {
+ throw new SynapseException(RESOURCE + " must have "
+ + RESOURCE_URI_ROOT_ATT_Q + " attribute: " + el.toString());
+ }
+ rp.setType(type.getAttributeValue());
+
+ rp.setURIRoot(uriRoot.getAttributeValue());
+
+ return rp;
+ }
+
+ public QName getTagQName() {
+ return RESOURCE_Q;
+ }
+
+ // this methods will give access to SynapseEnvironment's resouces registration
+
+
+ public void addPropertiesMediatorsAndURIRoot(SynapseEnvironment se, OMElement el,
+ ResourceMediator m) {
+ this.setURIRoot(se,el,m);
+
+ Iterator it = el.getChildElements();
+ List mediators = new LinkedList();
+ while (it.hasNext()) {
+ OMElement child = (OMElement) it.next();
+ Mediator mediator=
+ MediatorFactoryFinder.getMediator(se, child);
+
+ if (mediator != null) {
+ if (mediator instanceof PropertyMediator)
+ mediators.add(mediator);
+ else
+ throw new SynapseException(
+ "List contains an invalid Mediator" +
+ mediator.getClass().getName());
+ } else
+ log.info("Unknown child of all" + child.getLocalName());
+ }
+ m.setList(mediators);
+
+ }
+
+ public void setURIRoot(SynapseEnvironment se, OMElement el, ResourceMediator m) {
+
+ OMAttribute uriRoot = el.getAttribute(RESOURCE_URI_ROOT_ATT_Q);
+ if (uriRoot != null) {
+ // uri-root has already set
+ // se.addResourceMediator(uriRoot.getAttributeValue(), m);
+ m.setURIRoot(uriRoot.getAttributeValue());
+ }
+ log.debug("compile "+el.getLocalName()+" with uri-root '"+uriRoot.getAttributeValue() +"' on "+m.getClass());
+
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractListMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractListMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractListMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractListMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.ListMediator;
+import org.apache.synapse.api.Mediator;
+import org.apache.axiom.om.OMElement;
+
+/**
+ *
+ *
+ * <p> This is the abstract parent of any tag which is a "Node" - so <stage>, <in><out> and <never> all fit this model
+ * <p>It recursively creates a list of processors from the children.
+ *
+ */
+public abstract class AbstractListMediatorFactory extends AbstractMediatorFactory {
+
+ Log log = LogFactory.getLog(getClass());
+
+ public void addChildrenAndSetName(SynapseEnvironment se, OMElement el, ListMediator m)
+ {
+ super.setNameOnMediator(se, el, m);
+
+ Iterator it = el.getChildElements();
+ List mediators = new LinkedList();
+ while (it.hasNext()) {
+ OMElement child = (OMElement) it.next();
+ Mediator med = MediatorFactoryFinder.getMediator(se, child);
+ if (med != null)
+ mediators.add(med);
+ else
+ log.info("Unknown child of all" + child.getLocalName());
+ }
+ m.setList(mediators);
+
+ }
+
+
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AbstractMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+/**
+ *
+ *
+ * <p> This is the abstract superclass of any tag that isn't a "node". I.e. mediators or builtin
+ * mediators like log
+ *
+ */
+public abstract class AbstractMediatorFactory implements MediatorFactory {
+
+ private Log log = LogFactory.getLog(getClass());
+
+ public void setNameOnMediator(SynapseEnvironment se, OMElement el, Mediator m) {
+
+ OMAttribute nm = el.getAttribute(new QName("name"));
+ String name =null;
+ if (nm != null) {
+ name = nm.getAttributeValue().trim();
+ //m.setName(name);
+ se.addMediator(name, m);
+ }
+ log.debug("compile "+el.getLocalName()+" with name '"+name+"' on "+m.getClass());
+
+ }
+
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingInMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingInMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingInMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingInMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.axis2.AddressingInMediator;
+import org.apache.axiom.om.OMElement;
+
+/**
+ *
+ *
+ * <xmp><synapse:addressing/></xmp>
+ * <p>
+ * This tag turns on the addressing module
+ *
+ */
+public class AddressingInMediatorFactory extends AbstractMediatorFactory {
+ private static final QName ADD_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "engage-addressing-in");
+
+
+ public QName getTagQName() {
+ return ADD_Q;
+ }
+
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ AddressingInMediator ap = new AddressingInMediator();
+ super.setNameOnMediator(se,el,ap);
+ return ap;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingOutMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingOutMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingOutMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/AddressingOutMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,41 @@
+package org.apache.synapse.xml;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+
+import org.apache.synapse.mediators.builtin.axis2.AddressingOutMediator;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+/*
+ * 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.
+ */
+
+public class AddressingOutMediatorFactory extends AbstractMediatorFactory {
+
+ private static final QName ADD_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "engage-addressing-out");
+
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ AddressingOutMediator aom = new AddressingOutMediator();
+ super.setNameOnMediator(se,el,aom);
+ return aom;
+ }
+
+ public QName getTagQName() {
+ return ADD_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ClassMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ClassMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ClassMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ClassMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.types.ClassMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+/**
+ *
+ * <xmp><synapse:classmediator name="nm" class="org.fremantle.mediator"</synapse:classmediator></xmp>
+ * TODO add ability to configure properties with Strings/OMElements based on children.
+ */
+public class ClassMediatorFactory extends AbstractMediatorFactory {
+ private static final QName CLM_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "classmediator");
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ ClassMediator cmp = new ClassMediator();
+ super.setNameOnMediator(se, el, cmp);
+
+ OMAttribute clsName = el.getAttribute(new QName("class"));
+ if (clsName == null)
+ throw new SynapseException("missing class attribute on element"
+ + el.toString());
+ try {
+ Class clazz = se.getClassLoader().loadClass(clsName.getAttributeValue());
+ cmp.setClazz(clazz);
+ } catch (ClassNotFoundException e) {
+ throw new SynapseException("class loading error", e);
+ }
+ return cmp;
+
+ }
+
+
+ public QName getTagQName() {
+ return CLM_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/Constants.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/Constants.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/Constants.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+/**
+ * <p/>
+ * Constants used in the XML processing
+ */
+public interface Constants {
+ String SYNAPSE_NAMESPACE = "http://ws.apache.org/ns/synapse";
+ String SYNAPSE = "synapse";
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefaultMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefaultMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefaultMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefaultMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,40 @@
+package org.apache.synapse.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.DefaultMediator;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+/*
+ * 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.
+ */
+
+public class DefaultMediatorFactory
+ extends AbstractListMediatorFactory
+ {
+
+ private static final QName DEFAULT_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "default");
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ DefaultMediator dm = new DefaultMediator();
+ super.addChildrenAndSetName(se,el,dm);
+ return dm;
+ }
+
+ public QName getTagQName() {
+ return DEFAULT_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefineMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefineMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefineMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DefineMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.DefineMediator;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+
+public class DefineMediatorFactory extends AbstractListMediatorFactory {
+ private static final QName DEFINE_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "define");
+
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ DefineMediator defineMediator = new DefineMediator();
+ super.addChildrenAndSetName(se,el,defineMediator);
+ return defineMediator;
+ }
+
+ public QName getTagQName() {
+ return DEFINE_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DropMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DropMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DropMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/DropMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.DropMediator;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+
+public class DropMediatorFactory extends AbstractMediatorFactory {
+
+ private static final QName DROP_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "drop");
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ return new DropMediator();
+ }
+
+ public QName getTagQName() {
+ return DROP_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ExactlyOneMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ExactlyOneMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ExactlyOneMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ExactlyOneMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,38 @@
+package org.apache.synapse.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.ExactlyOneMediator;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.axiom.om.OMElement;
+import javax.xml.namespace.QName;
+
+/**
+ * This will create <exactlyone>
+ * <regex/>[0..n]
+ * <xpath/>[0..n]
+ * <default/> ?
+ * </exactlyone>
+ *
+ *
+ */
+public class ExactlyOneMediatorFactory extends AbstractListMediatorFactory {
+
+ private static final String EXACTLYONE = "exactlyone";
+
+ private static final QName SWITCH_Q = new QName(org.apache.synapse.xml.Constants.SYNAPSE_NAMESPACE,
+ EXACTLYONE);
+
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ ExactlyOneMediator exactlyOne = new ExactlyOneMediator();
+ super.addChildrenAndSetName(se,el,exactlyOne);
+ // now validate all children are ConditionProcessors
+
+
+ return exactlyOne;
+ }
+
+ public QName getTagQName() {
+ return SWITCH_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/FaultMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/FaultMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/FaultMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/FaultMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.axis2.FaultMediator;
+import org.apache.axiom.om.OMElement;
+
+/**
+ *
+ * <p>
+ * <xmp><synapse:fault name="optional"/> </xmp>
+ * TODO add the ability to configure the fault codes, etc
+ *
+ */
+public class FaultMediatorFactory extends AbstractMediatorFactory {
+ private static final QName HEADER_Q = new QName(
+ Constants.SYNAPSE_NAMESPACE, "fault");
+
+ private static final QName FAULTCODE = new QName(
+ Constants.SYNAPSE_NAMESPACE, "faultCode");
+ private static final QName REASON = new QName(
+ Constants.SYNAPSE_NAMESPACE, "reason");
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ FaultMediator fp = new FaultMediator();
+
+ OMElement code = el.getFirstChildWithName(FAULTCODE);
+ if (code != null) {
+ fp.setFaultCode(code.getTextAsQName());
+ }
+ OMElement reason = el.getFirstChildWithName(REASON);
+ if (reason != null) {
+ fp.setReason(reason.getText());
+ }
+ super.setNameOnMediator(se, el, fp);
+ return fp;
+ }
+
+ public QName getTagQName() {
+ return HEADER_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/HeaderMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/HeaderMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/HeaderMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/HeaderMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.HeaderMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+/**
+ *
+ * <p>
+ * <xmp><synapse:header name="optional" type="to|from|faultto|replyto|action"
+ * value="newvalue"/> </xmp>
+ *
+ *
+ */
+public class HeaderMediatorFactory extends AbstractMediatorFactory {
+ private static final QName HEADER_Q = new QName(
+ Constants.SYNAPSE_NAMESPACE, "header");
+
+
+ private static final QName TYPE_ATT_Q = new QName("type"),
+ VALUE_ATT_Q = new QName("value");
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ HeaderMediator hm = new HeaderMediator();
+ super.setNameOnMediator(se, el, hm);
+ OMAttribute val = el.getAttribute(VALUE_ATT_Q);
+ OMAttribute type = el.getAttribute(TYPE_ATT_Q);
+ if (val == null || type == null) {
+ throw new SynapseException("<header> must have both " + VALUE_ATT_Q
+ + " and " + TYPE_ATT_Q + " attributes: " + el.toString());
+ }
+ hm.setHeaderType(type.getAttributeValue());
+ hm.setValue( val.getAttributeValue());
+ return hm;
+ }
+
+ public QName getTagQName() {
+ return HEADER_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/InMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/InMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/InMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/InMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.InMediator;
+import org.apache.axiom.om.OMElement;
+
+
+/**
+ *
+ *
+ * <p>
+ * <xmp><in name="optional">.... </in></xmp>
+ * Uses children if processing an request (i.e. if !response).
+ *
+ */
+public class InMediatorFactory extends
+ AbstractListMediatorFactory {
+ private static final QName IN_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "in");
+
+ public QName getTagQName() {
+ return IN_Q;
+ }
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ InMediator im = new InMediator();
+ super.addChildrenAndSetName(se, el, im);
+ return im;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/LogMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/LogMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/LogMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/LogMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.LogMediator;
+import org.apache.axiom.om.OMElement;
+
+/**
+ *
+ *
+ * <p>
+ * Logs messages using Commons-logging.
+ *
+ * <xmp><log name="optional"/></xmp>
+ * TODO add support for simple one-line log entry (doesn't cause body parsing)
+ *
+ */
+public class LogMediatorFactory extends AbstractMediatorFactory {
+ private static final QName LOG_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "log");
+
+
+ public QName getTagQName() {
+ return LOG_Q;
+ }
+
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ LogMediator lm = new LogMediator();
+ super.setNameOnMediator(se,el,lm);
+ return lm;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.axiom.om.OMElement;
+
+public interface MediatorFactory {
+ public Mediator createMediator(SynapseEnvironment se, OMElement el);
+ public QName getTagQName();
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactoryFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactoryFinder.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactoryFinder.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/MediatorFactoryFinder.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,136 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.synapse.xml;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.mediators.builtin.xslt.XSLTMediatorFactory;
+import org.apache.synapse.resources.xml.PropertyMediatorFactory;
+import org.apache.synapse.resources.xml.ResourceMediatorFactory;
+import org.apache.synapse.api.Mediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+
+import sun.misc.Service;
+
+/**
+ *
+ *
+ * This class is based on J2SE Service Provider model
+ * http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service%20Provider
+ */
+
+public class MediatorFactoryFinder {
+
+ private static Map lookup = null;
+
+ private static Log log = LogFactory
+ .getLog(MediatorFactoryFinder.class);
+
+ private static Class[] mediatorFactories = {
+ SynapseMediatorFactory.class,
+ StageMediatorFactory.class, RegexMediatorFactory.class,
+ XPathMediatorFactory.class,
+ HeaderMediatorFactory.class,
+ ClassMediatorFactory.class,
+ ServiceMediatorFactory.class,
+ LogMediatorFactory.class, SendMediatorFactory.class,
+ FaultMediatorFactory.class,
+ AddressingInMediatorFactory.class,
+ AddressingOutMediatorFactory.class,
+ InMediatorFactory.class, OutMediatorFactory.class,
+ NeverMediatorFactory.class, RefMediatorFactory.class,
+ XSLTMediatorFactory.class,DefineMediatorFactory.class,
+ SendNowMediatorFactory.class,SendMediatorFactory.class,
+ DropMediatorFactory.class,
+ RefDefineMediatorFactory.class, ExactlyOneMediatorFactory.class,
+ DefaultMediatorFactory.class,
+ PropertyMediatorFactory.class, ResourceMediatorFactory.class,
+ };
+
+ private static void initialise() {
+
+ if (lookup != null)
+ return;
+ lookup = new HashMap();
+
+ for (int i = 0; i < mediatorFactories.length; i++) {
+ Class c = mediatorFactories[i];
+ try {
+ lookup.put(((MediatorFactory) c.newInstance())
+ .getTagQName(), c);
+ } catch (Exception e) {
+ throw new SynapseException("problem instantiating "+c.getName(), e);
+ }
+ }
+ log.debug("registering extensions");
+ log.debug(System.getProperty("java.class.path"));
+ // now try additional processors
+ Iterator it = Service.providers(MediatorFactory.class);
+ while (it.hasNext()) {
+ MediatorFactory mf = (MediatorFactory) it.next();
+ QName tag = mf.getTagQName();
+ lookup.put(tag, mf.getClass());
+ log.debug("added MediatorFactory " + mf.getClass() + " to handle " + tag);
+ }
+ }
+
+ /**
+ * @param qn
+ * @return the class which implements the Processor for the given QName
+ */
+ public static Class find(QName qn) {
+ initialise();
+ return (Class) lookup.get(qn);
+ }
+
+ /**
+ * This method returns a Processor given an OMElement. This will be used
+ * recursively by the elements which contain processor elements themselves
+ * (e.g. rules)
+ *
+ * @param synapseEnv
+ * @param element
+ * @return Processor
+ */
+ public static Mediator getMediator(SynapseEnvironment synapseEnv, OMElement element) {
+ OMNamespace n = element.getNamespace();
+
+ Class cls = find(new QName(n.getName(), element
+ .getLocalName()));
+ try {
+ MediatorFactory mf = (MediatorFactory) cls.newInstance();
+ Mediator m = mf.createMediator(synapseEnv, element);
+ return m;
+ } catch (InstantiationException e) {
+ throw new SynapseException(e);
+ } catch (IllegalAccessException e) {
+ throw new SynapseException(e);
+ }
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/NeverMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/NeverMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/NeverMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/NeverMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.NeverMediator;
+import org.apache.axiom.om.OMElement;
+
+
+/**
+ * <xmp><synapse:never name="optional"><more stuff in here></synapse:never></xmp>
+ * Stuff in here never gets processed
+ * You might think that a bit useless, but it lets you put things you want to refer to from elsewhere
+ */
+public class NeverMediatorFactory extends
+ AbstractListMediatorFactory {
+ private static final QName NEVER_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "never");
+
+ public QName getTagQName() {
+ return NEVER_Q;
+ }
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ NeverMediator nm = new NeverMediator();
+ super.addChildrenAndSetName(se, el, nm);
+ return nm;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/OutMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/OutMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/OutMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/OutMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.OutMediator;
+import org.apache.axiom.om.OMElement;
+
+
+public class OutMediatorFactory extends
+ AbstractListMediatorFactory {
+ private static final QName OUT_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "out");
+
+ public QName getTagQName() {
+ return OUT_Q;
+ }
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ OutMediator outMediator= new OutMediator();
+ super.addChildrenAndSetName(se, el, outMediator);
+ return outMediator;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.axiom.om.OMElement;
+
+/**
+ * @deprecated
+ *
+ */
+public interface ProcessorConfigurator {
+ public Processor createProcessor(SynapseEnvironment se, OMElement el);
+ public QName getTagQName();
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefDefineMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefDefineMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefDefineMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefDefineMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.RefDefineMediator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+import javax.xml.namespace.QName;
+
+/*
+ */
+public class RefDefineMediatorFactory extends AbstractMediatorFactory {
+ private static final QName REF_DEFINE_Q = new QName(
+ Constants.SYNAPSE_NAMESPACE, "refdefine");
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ RefDefineMediator rdm = new RefDefineMediator();
+ super.setNameOnMediator(se, el, rdm);
+ OMAttribute attr = el.getAttribute(new QName("ref"));
+ if (attr == null)
+ throw new SynapseException("<ref> must have attribute ref");
+ rdm.setRefDefine(attr.getAttributeValue());
+ return rdm;
+ }
+
+ public QName getTagQName() {
+ return REF_DEFINE_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RefMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.RefMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+
+public class RefMediatorFactory extends
+ AbstractMediatorFactory {
+ private static final QName REF_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "ref");
+
+ public QName getTagQName() {
+ return REF_Q;
+ }
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ RefMediator rm = new RefMediator();
+ super.setNameOnMediator(se, el, rm);
+ OMAttribute attr = el.getAttribute(new QName("ref"));
+ if (attr==null) throw new SynapseException("<ref> must have attribute ref");
+ rm.setRef(attr.getAttributeValue());
+ return rm;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RegexMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RegexMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RegexMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/RegexMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.synapse.xml;
+
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.RegexMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+/**
+ *
+ *
+ */
+public class RegexMediatorFactory extends
+ AbstractListMediatorFactory {
+ private static final String REGEX = "regex";
+
+ private static final QName REGEX_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ REGEX);
+
+ private static final QName REGEX_PATTERN_ATT_Q = new QName("pattern");
+
+ private static final QName REGEX_PROPERTY_ATT_Q = new QName("property");
+
+ private static final QName REGEX_HEADER_ATT_Q = new QName("message-address");
+
+
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ RegexMediator rm = new RegexMediator();
+ super.addChildrenAndSetName(se, el, rm);
+
+ OMAttribute patt = el.getAttribute(REGEX_PATTERN_ATT_Q);
+ if (patt == null) {
+ throw new SynapseException(REGEX + " must have "
+ + REGEX_PATTERN_ATT_Q + " attribute: " + el.toString());
+ }
+
+ OMAttribute prop = el.getAttribute(REGEX_PROPERTY_ATT_Q);
+ OMAttribute head = el.getAttribute(REGEX_HEADER_ATT_Q);
+ if (prop == null && head == null) {
+ throw new SynapseException(REGEX + " must have either "
+ + REGEX_PROPERTY_ATT_Q + " or " + REGEX_HEADER_ATT_Q
+ + " attributes: " + el.toString());
+ }
+ rm.setPattern(patt.getAttributeValue());
+ if (prop != null) {
+ rm.setPropertyName(prop.getAttributeValue());
+ } else {
+ String header = head.getAttributeValue();
+ rm.setHeaderType(header);
+ }
+ return rm;
+ }
+
+ public QName getTagQName() {
+ return REGEX_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SecurityMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SecurityMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SecurityMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SecurityMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,38 @@
+package org.apache.synapse.xml;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.axis2.SecurityMediator;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+/*
+* 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.
+*
+*/
+
+public class SecurityMediatorFactory extends AbstractMediatorFactory {
+ private static final QName SEC_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "engage-security");
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ SecurityMediator sm = new SecurityMediator();
+ super.setNameOnMediator(se,el,sm);
+ return sm;
+ }
+
+ public QName getTagQName() {
+ return SEC_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.SendMediator;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.axiom.om.OMElement;
+
+public class SendMediatorFactory extends AbstractMediatorFactory {
+
+
+ private static final QName SEND_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "send");
+
+
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ SendMediator sm = new SendMediator();
+ super.setNameOnMediator(se, el,sm);
+ return sm;
+
+ }
+
+ public QName getTagQName() {
+
+ return SEND_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendNowMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendNowMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendNowMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SendNowMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.builtin.SendNowMediator;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+/**
+ */
+public class SendNowMediatorFactory extends AbstractMediatorFactory {
+ private static final QName SEND_NOW_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "sendnow");
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ SendNowMediator sm = new SendNowMediator();
+ super.setNameOnMediator(se,el,sm);
+ return sm;
+ }
+
+ public QName getTagQName() {
+ return SEND_NOW_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ServiceMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ServiceMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ServiceMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/ServiceMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.types.axis2.ServiceMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+public class ServiceMediatorFactory extends AbstractMediatorFactory {
+ private static final QName tagName = new QName(Constants.SYNAPSE_NAMESPACE,
+ "servicemediator");
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ ServiceMediator sm = new ServiceMediator();
+ super.setNameOnMediator(se,el,sm);
+
+ OMAttribute attr = el.getAttribute(new QName("service"));
+ if (attr == null)
+ throw new SynapseException(
+ "<servicemediator> must have 'service' attribute");
+ sm.setServiceName(attr.getAttributeValue());
+ return sm;
+ }
+
+ public QName getTagQName() {
+
+ return tagName;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/StageMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/StageMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/StageMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/StageMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.StageMediator;
+import org.apache.axiom.om.OMElement;
+
+/**
+ *
+ *<xmp><synapse:stage name="optional"> do everything in here </synapse:stage></xmp>
+ */
+public class StageMediatorFactory extends
+ AbstractListMediatorFactory{
+ private static final QName STAGE_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "stage");
+
+ public QName getTagQName() {
+ return STAGE_Q;
+ }
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ StageMediator sm = new StageMediator();
+ super.addChildrenAndSetName(se, el, sm);
+ return sm;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SynapseMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SynapseMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SynapseMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/SynapseMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.SynapseMediator;
+import org.apache.axiom.om.OMElement;
+
+public class SynapseMediatorFactory extends
+ AbstractListMediatorFactory {
+
+ private final static QName tagname = new QName(Constants.SYNAPSE_NAMESPACE,
+ "synapse");
+
+ public QName getTagQName() {
+ return tagname;
+ }
+
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ SynapseMediator sm = new SynapseMediator();
+ super.addChildrenAndSetName(se, el, sm);
+ return sm;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/XPathMediatorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/XPathMediatorFactory.java?rev=397884&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/XPathMediatorFactory.java (added)
+++ incubator/synapse/trunk/scratch/synapse2/modules/core/src/org/apache/synapse/xml/XPathMediatorFactory.java Fri Apr 28 05:49:17 2006
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+package org.apache.synapse.xml;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.filters.XPathMediator;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMNamespace;
+
+/**
+ *
+ *
+ * <p>
+ * This class executes a test and then processes all subsequent rules/mediations
+ * if the test is true
+ *
+ */
+public class XPathMediatorFactory extends
+ AbstractListMediatorFactory {
+ private static final String XPATH = "xpath";
+
+ private static final QName XPATH_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "xpath");
+
+ private static final QName XPATH_EXPRESSION_ATT_Q = new QName("expr");
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.synapse.spi.Processor#compile(org.apache.synapse.api.SynapseEnvironment,
+ * org.apache.axis2.om.OMElement)
+ */
+ public Mediator createMediator(SynapseEnvironment se, OMElement el) {
+ XPathMediator xm = new XPathMediator();
+
+ super.addChildrenAndSetName(se, el, xm);
+
+ OMAttribute expr = el.getAttribute(XPATH_EXPRESSION_ATT_Q);
+ if (expr == null) {
+ throw new SynapseException(XPATH + " must have "
+ + XPATH_EXPRESSION_ATT_Q + " attribute: " + el.toString());
+ }
+
+ xm.setXPathExpr(expr.getAttributeValue());
+ Iterator it = el.getAllDeclaredNamespaces();
+ while (it.hasNext()) {
+ OMNamespace n = (OMNamespace) it.next();
+ xm.addXPathNamespace(n.getPrefix(), n.getName());
+ }
+
+ return xm;
+ }
+
+ public QName getTagQName() {
+
+ return XPATH_Q;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org