Search in sources :

Example 1 with UpdateMessage

use of org.apache.synapse.mediators.annotations.UpdateMessage in project wso2-synapse by wso2.

the class AnnotatedCommandMediator method introspectClass.

/**
 * Introspect the command class annotations
 */
protected void introspectClass(Class<?> commandClass) {
    beforeFields = new HashMap<Field, SynapseXPath>();
    afterFields = new HashMap<Field, SynapseXPath>();
    beforeMethods = new HashMap<Method, SynapseXPath>();
    afterMethods = new HashMap<Method, SynapseXPath>();
    for (Field f : commandClass.getDeclaredFields()) {
        ReadFromMessage readFromMessage = f.getAnnotation(ReadFromMessage.class);
        if (readFromMessage != null) {
            SynapseXPath axiomXpath = createSynapseXPATH(readFromMessage.value(), f.getAnnotation(Namespaces.class));
            beforeFields.put(f, axiomXpath);
        }
        UpdateMessage updateMessage = f.getAnnotation(UpdateMessage.class);
        if (updateMessage != null) {
            SynapseXPath axiomXpath = createSynapseXPATH(updateMessage.value(), f.getAnnotation(Namespaces.class));
            afterFields.put(f, axiomXpath);
        }
        ReadAndUpdate readAndUpdate = f.getAnnotation(ReadAndUpdate.class);
        if (readAndUpdate != null) {
            SynapseXPath axiomXpath = createSynapseXPATH(readAndUpdate.value(), f.getAnnotation(Namespaces.class));
            beforeFields.put(f, axiomXpath);
            afterFields.put(f, axiomXpath);
        }
    }
    for (Method m : commandClass.getDeclaredMethods()) {
        ReadFromMessage readFromMessage = m.getAnnotation(ReadFromMessage.class);
        if (readFromMessage != null) {
            SynapseXPath axiomXpath = createSynapseXPATH(readFromMessage.value(), m.getAnnotation(Namespaces.class));
            beforeMethods.put(m, axiomXpath);
        }
        UpdateMessage updateMessage = m.getAnnotation(UpdateMessage.class);
        if (updateMessage != null) {
            SynapseXPath axiomXpath = createSynapseXPATH(updateMessage.value(), m.getAnnotation(Namespaces.class));
            afterMethods.put(m, axiomXpath);
        }
    }
}
Also used : Field(java.lang.reflect.Field) SynapseXPath(org.apache.synapse.util.xpath.SynapseXPath) Namespaces(org.apache.synapse.mediators.annotations.Namespaces) UpdateMessage(org.apache.synapse.mediators.annotations.UpdateMessage) ReadAndUpdate(org.apache.synapse.mediators.annotations.ReadAndUpdate) ReadFromMessage(org.apache.synapse.mediators.annotations.ReadFromMessage) Method(java.lang.reflect.Method)

Aggregations

Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Namespaces (org.apache.synapse.mediators.annotations.Namespaces)1 ReadAndUpdate (org.apache.synapse.mediators.annotations.ReadAndUpdate)1 ReadFromMessage (org.apache.synapse.mediators.annotations.ReadFromMessage)1 UpdateMessage (org.apache.synapse.mediators.annotations.UpdateMessage)1 SynapseXPath (org.apache.synapse.util.xpath.SynapseXPath)1