Author: asankaa
Date: Wed Dec 10 18:10:49 2008
New Revision: 26653
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=26653
Log:
adding the EventPublisher Mediator
Added:
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorFactory.java
- copied, changed from r26315,
/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorSerializer.java
- copied, changed from r26315,
/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java
Copied:
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorFactory.java
(from r26315,
/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java)
URL:
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorFactory.java?rev=26653&r1=26315&r2=26653&view=diff
==============================================================================
---
/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorFactory.java
(original)
+++
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorFactory.java
Wed Dec 10 18:10:49 2008
@@ -17,97 +17,45 @@
* under the License.
*/
-package org.apache.synapse.config.xml;
+package org.apache.synapse.config.xml.eventing;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.synapse.Mediator;
+import org.apache.synapse.config.xml.AbstractMediatorFactory;
+import org.apache.synapse.config.xml.XMLConfigConstants;
+import org.apache.synapse.config.xml.SynapseXPathFactory;
+import org.apache.synapse.config.xml.MediatorPropertyFactory;
import org.apache.synapse.mediators.transform.XSLTMediator;
+import org.apache.synapse.mediators.eventing.EventPublisherMediator;
import org.jaxen.JaxenException;
import javax.xml.namespace.QName;
import java.util.Iterator;
/**
- * Factory for [EMAIL PROTECTED] XSLTMediator} instances.
- * <p>
- * Configuration syntax:
- * <pre>
- * <xslt key="property-key" [source="xpath"] [target="string"]>
- * <property name="string" (value="literal" | expression="xpath")/>*
- * <feature name="string" value="true| false" />*
- * </transform>
- * </pre>
+ * Factory for [EMAIL PROTECTED]
org.apache.synapse.mediators.eventing.EventPublisherMediator} instances.
+ * <sequence>
+ * <eventSourcePublisher eventSourceName="name"/>
+ * </sequence>
*/
-public class XSLTMediatorFactory extends AbstractMediatorFactory {
+public class EventPublisherMediatorFactory extends AbstractMediatorFactory {
- private static final QName TAG_NAME = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "xslt");
+ private static final QName TAG_NAME = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "eventSourcePublisher");
+ private static final QName PROP_NAME = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "eventSourceName");
public QName getTagQName() {
return TAG_NAME;
}
public Mediator createMediator(OMElement elem) {
-
- XSLTMediator transformMediator = new XSLTMediator();
-
- OMAttribute attXslt = elem.getAttribute(ATT_KEY);
- OMAttribute attSource = elem.getAttribute(ATT_SOURCE);
- OMAttribute attTarget = elem.getAttribute(ATT_TARGET);
-
- if (attXslt != null) {
- transformMediator.setXsltKey(attXslt.getAttributeValue());
+ EventPublisherMediator eventPublisherMediator = new
EventPublisherMediator();
+ OMAttribute attEventSource = elem.getAttribute(PROP_NAME);
+ if (attEventSource != null) {
+
eventPublisherMediator.setEventSourceName(attEventSource.getAttributeValue());
} else {
- handleException("The 'key' attribute is required for the XSLT
mediator");
- }
-
- if (attSource != null) {
- try {
-
transformMediator.setSourceXPathString(attSource.getAttributeValue());
-
transformMediator.setSource(SynapseXPathFactory.getSynapseXPath(elem,
ATT_SOURCE));
-
- } catch (JaxenException e) {
- handleException("Invalid XPath specified for the source
attribute : " +
- attSource.getAttributeValue());
- }
+ handleException("The 'eventSourceName' attribute is required for
the EventPublisher mediator");
}
-
- if (attTarget != null) {
-
transformMediator.setTargetPropertyName(attTarget.getAttributeValue());
- }
-
- // after successfully creating the mediator
- // set its common attributes such as tracing etc
- processTraceState(transformMediator, elem);
- // set the features
- Iterator iter = elem.getChildrenWithName(FEATURE_Q);
- while (iter.hasNext()) {
- OMElement featureElem = (OMElement) iter.next();
- OMAttribute attName = featureElem.getAttribute(ATT_NAME);
- OMAttribute attValue = featureElem.getAttribute(ATT_VALUE);
- if (attName != null && attValue != null) {
- String name = attName.getAttributeValue();
- String value = attValue.getAttributeValue();
- if (name != null && value != null) {
- if ("true".equals(value.trim())) {
- transformMediator.addFeature(name.trim(),
- true);
- } else if ("false".equals(value.trim())) {
- transformMediator.addFeature(name.trim(),
- false);
- } else {
- handleException("The feature must have value true or
false");
- }
- } else {
- handleException("The valid values for both of the name and
value are need");
- }
- } else {
- handleException("Both of the name and value attribute are
required for a feature");
- }
- }
- transformMediator.addAllProperties(
- MediatorPropertyFactory.getMediatorProperties(elem));
-
- return transformMediator;
+ return eventPublisherMediator;
}
-}
+}
\ No newline at end of file
Copied:
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorSerializer.java
(from r26315,
/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java)
URL:
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorSerializer.java?rev=26653&r1=26315&r2=26653&view=diff
==============================================================================
---
/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/XSLTMediatorSerializer.java
(original)
+++
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/config/xml/eventing/EventPublisherMediatorSerializer.java
Wed Dec 10 18:10:49 2008
@@ -17,73 +17,49 @@
* under the License.
*/
-package org.apache.synapse.config.xml;
+package org.apache.synapse.config.xml.eventing;
import org.apache.axiom.om.OMElement;
import org.apache.synapse.Mediator;
import org.apache.synapse.mediators.transform.XSLTMediator;
import org.apache.synapse.mediators.MediatorProperty;
+import org.apache.synapse.mediators.eventing.EventPublisherMediator;
import org.apache.synapse.config.xml.AbstractMediatorSerializer;
+import org.apache.synapse.config.xml.SynapseXPathSerializer;
import java.util.List;
/**
- * Serializer for [EMAIL PROTECTED] XSLTMediator} instances.
- *
- * @see XSLTMediatorFactory
+ * Serializer for [EMAIL PROTECTED]
org.apache.synapse.mediators.eventing.EventPublisherMediator} instances.
+ *
+ *
*/
-public class XSLTMediatorSerializer extends AbstractMediatorSerializer {
+public class EventPublisherMediatorSerializer extends
AbstractMediatorSerializer {
public OMElement serializeMediator(OMElement parent, Mediator m) {
- if (!(m instanceof XSLTMediator)) {
+ if (!(m instanceof EventPublisherMediator)) {
handleException("Unsupported mediator passed in for serialization
: " + m.getType());
}
- XSLTMediator mediator = (XSLTMediator) m;
- OMElement xslt = fac.createOMElement("xslt", synNS);
+ EventPublisherMediator mediator = (EventPublisherMediator) m;
+ OMElement elmEventPublisher = fac.createOMElement("eventPublisher",
synNS);
- if (mediator.getXsltKey() != null) {
- xslt.addAttribute(fac.createOMAttribute(
- "key", nullNS, mediator.getXsltKey()));
+ if (mediator.getEventSourceName() != null) {
+ elmEventPublisher.addAttribute(fac.createOMAttribute(
+ "eventSourceName", nullNS, mediator.getEventSourceName()));
} else {
- handleException("Invalid XSLT mediator. XSLT registry key is
required");
+ handleException("Invalid EventPublisher mediator. Event Source
Name required");
}
- saveTracingState(xslt,mediator);
+ saveTracingState(elmEventPublisher,mediator);
- if (mediator.getSource() != null &&
-
!XSLTMediator.DEFAULT_XPATH.equals(mediator.getSource().toString())) {
-
- SynapseXPathSerializer.serializeXPath(mediator.getSource(), xslt,
"source");
- }
- if (mediator.getTargetPropertyName() != null) {
- xslt.addAttribute(fac.createOMAttribute(
- "target", nullNS, mediator.getTargetPropertyName()));
- }
- serializeProperties(xslt, mediator.getProperties());
- List<MediatorProperty> features = mediator.getFeatures();
- if (!features.isEmpty()) {
- for (MediatorProperty mp : features) {
- OMElement prop = fac.createOMElement("feature", synNS, xslt);
- if (mp.getName() != null) {
- prop.addAttribute(fac.createOMAttribute("name", nullNS,
mp.getName()));
- } else {
- handleException("The Feature name is missing");
- }
- if (mp.getValue() != null) {
- prop.addAttribute(fac.createOMAttribute("value", nullNS,
mp.getValue()));
- } else {
- handleException("The Feature value is missing");
- }
- }
- }
if (parent != null) {
- parent.addChild(xslt);
+ parent.addChild(elmEventPublisher);
}
- return xslt;
+ return elmEventPublisher;
}
public String getMediatorClassName() {
- return XSLTMediator.class.getName();
+ return EventPublisherMediator.class.getName();
}
-}
+}
\ No newline at end of file
Added:
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java
URL:
http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java?pathrev=26653
==============================================================================
--- (empty file)
+++
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/mediators/eventing/EventPublisherMediator.java
Wed Dec 10 18:10:49 2008
@@ -0,0 +1,36 @@
+package org.apache.synapse.mediators.eventing;
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you 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.
+*/
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.MessageContext;
+
+public class EventPublisherMediator extends AbstractMediator {
+ private String eventSourceName=null;
+ public boolean mediate(MessageContext synCtx) {
+ return false; //To change body of implemented methods use File |
Settings | File Templates.
+ }
+
+ public String getEventSourceName() {
+ return eventSourceName;
+ }
+
+ public void setEventSourceName(String eventSourceName) {
+ this.eventSourceName = eventSourceName;
+ }
+}
_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev