KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > xfire > MuleHeadersInHandler


1 /*
2  * $Id: MuleHeadersInHandler.java 3937 2006-11-20 16:04:25Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.soap.xfire;
12
13 import org.codehaus.xfire.MessageContext;
14 import org.codehaus.xfire.handler.AbstractHandler;
15 import org.jdom.Element;
16 import org.jdom.Namespace;
17 import org.mule.config.MuleProperties;
18 import org.mule.providers.soap.MuleSoapHeaders;
19
20 /**
21  * Reads the Mule Soap Header and sets the various header properties on the context.
22  */

23 public class MuleHeadersInHandler extends AbstractHandler
24 {
25     protected final Namespace ns = Namespace.getNamespace(MuleSoapHeaders.MULE_NAMESPACE,
26         MuleSoapHeaders.MULE_10_ACTOR);
27
28     /**
29      * Invoke a handler. If a fault occurs it will be handled via the
30      * <code>handleFault</code> method.
31      *
32      * @param context The message context.
33      */

34     public void invoke(MessageContext context) throws Exception JavaDoc
35     {
36         if (context.getInMessage() != null)
37         {
38             Element header = context.getInMessage().getHeader();
39             if (header == null) return;
40
41             Element muleHeaders = header.getChild(MuleSoapHeaders.MULE_HEADER, ns);
42             if (muleHeaders != null)
43             {
44                 Element child = muleHeaders.getChild(MuleProperties.MULE_CORRELATION_ID_PROPERTY, ns);
45                 if (child != null)
46                 {
47                     context.setProperty(MuleProperties.MULE_CORRELATION_ID_PROPERTY, child.getText());
48                 }
49                 child = muleHeaders.getChild(MuleProperties.MULE_CORRELATION_GROUP_SIZE_PROPERTY, ns);
50                 if (child != null)
51                 {
52                     context.setProperty(MuleProperties.MULE_CORRELATION_GROUP_SIZE_PROPERTY, child.getText());
53                 }
54                 child = muleHeaders.getChild(MuleProperties.MULE_CORRELATION_SEQUENCE_PROPERTY, ns);
55                 if (child != null)
56                 {
57                     context.setProperty(MuleProperties.MULE_CORRELATION_SEQUENCE_PROPERTY, child.getText());
58                 }
59                 child = muleHeaders.getChild(MuleProperties.MULE_REPLY_TO_PROPERTY, ns);
60                 if (child != null)
61                 {
62                     context.setProperty(MuleProperties.MULE_REPLY_TO_PROPERTY, child.getText());
63                 }
64             }
65         }
66     }
67
68 }
69
Popular Tags