Source Code Cross Referenced for VersionTransformer.java in  » ESB » celtix-1.0 » org » objectweb » celtix » bus » ws » addressing » soap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » celtix 1.0 » org.objectweb.celtix.bus.ws.addressing.soap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.bus.ws.addressing.soap;
002:
003:        import java.util.Collections;
004:        import java.util.HashSet;
005:        import java.util.Set;
006:        import java.util.logging.Logger;
007:
008:        import javax.xml.bind.JAXBException;
009:        import javax.xml.bind.Marshaller;
010:        import javax.xml.bind.Unmarshaller;
011:        import javax.xml.namespace.QName;
012:        import javax.xml.soap.SOAPHeader;
013:        import javax.xml.soap.SOAPHeaderElement;
014:
015:        import org.objectweb.celtix.bus.ws.addressing.Names;
016:        import org.objectweb.celtix.common.logging.LogUtils;
017:
018:        // importation convention: if the same class name is used for 
019:        // 2005/08 and 2004/08, then the former version is imported
020:        // and the latter is fully qualified when used
021:        import org.objectweb.celtix.ws.addressing.AttributedURIType;
022:        import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
023:        import org.objectweb.celtix.ws.addressing.RelatesToType;
024:        import org.objectweb.celtix.ws.addressing.v200408.AttributedURI;
025:        import org.objectweb.celtix.ws.addressing.v200408.Relationship;
026:
027:        /**
028:         * This class is responsible for transforming between the native 
029:         * WS-Addressing schema version (i.e. 2005/08) and exposed
030:         * version (currently may be 2005/08 or 2004/08).
031:         * <p>
032:         * The native version is that used throughout the stack, were the
033:         * WS-A types are represented via the JAXB generated types for the
034:         * 2005/08 schema.
035:         * <p>
036:         * The exposed version is that used when the WS-A types are 
037:         * externalized, i.e. are encoded in the headers of outgoing 
038:         * messages. For outgoing requests, the exposed version is 
039:         * determined from configuration. For outgoing responses, the
040:         * exposed version is determined by the exposed version of
041:         * the corresponding request.
042:         * <p>
043:         * The motivation for using different native and exposed types
044:         * is usually to facilitate a WS-* standard based on an earlier 
045:         * version of WS-Adressing (for example WS-RM depends on the
046:         * 2004/08 version).
047:         */
048:        public class VersionTransformer extends
049:                org.objectweb.celtix.bus.ws.addressing.VersionTransformer {
050:
051:            public static final Set<QName> HEADERS;
052:            private static final Logger LOG = LogUtils
053:                    .getL7dLogger(VersionTransformer.class);
054:
055:            protected MAPCodec codec;
056:
057:            /**
058:             * Constructor.
059:             * 
060:             * @param mapCodec the MAPCodec to use
061:             */
062:            public VersionTransformer(MAPCodec mapCodec) {
063:                codec = mapCodec;
064:            }
065:
066:            /**
067:             * Encode message in exposed version.
068:             * 
069:             * @param exposeAs specifies the WS-Addressing version to expose
070:             * @param value the value to encode
071:             * @param localName the localName for the header 
072:             * @param clz the class
073:             * @param header the SOAP header
074:             * @param marshaller the JAXB marshaller to use
075:             */
076:            public <T> void encodeAsExposed(String exposeAs, T value,
077:                    String localName, Class<T> clz, SOAPHeader header,
078:                    Marshaller marshaller) throws JAXBException {
079:                if (value != null) {
080:                    if (NATIVE_VERSION.equals(exposeAs)) {
081:                        codec.encodeMAP(value, new QName(exposeAs, localName),
082:                                clz, header, marshaller);
083:                    } else if (Names200408.WSA_NAMESPACE_NAME.equals(exposeAs)) {
084:                        if (AttributedURIType.class.equals(clz)) {
085:                            codec.encodeMAP(convert((AttributedURIType) value),
086:                                    new QName(exposeAs, localName),
087:                                    AttributedURI.class, header, marshaller);
088:                        } else if (EndpointReferenceType.class.equals(clz)) {
089:                            codec.encodeMAP(
090:                                    convert((EndpointReferenceType) value),
091:                                    new QName(exposeAs, localName),
092:                                    Names200408.EPR_TYPE, header, marshaller);
093:
094:                        } else if (RelatesToType.class.equals(clz)) {
095:                            codec.encodeMAP(convert((RelatesToType) value),
096:                                    new QName(exposeAs, localName),
097:                                    Relationship.class, header, marshaller);
098:
099:                        }
100:                    }
101:                }
102:            }
103:
104:            /**
105:             * Decodes a MAP from a exposed version.
106:             *
107:             * @param encodedAs specifies the encoded version
108:             * @param clz the class
109:             * @param headerElement the SOAP header element
110:             * @param marshaller the JAXB marshaller to use
111:             * @return the decoded value
112:             */
113:            @SuppressWarnings("unchecked")
114:            public <T> T decodeAsNative(String encodedAs, Class<T> clz,
115:                    SOAPHeaderElement headerElement, Unmarshaller unmarshaller)
116:                    throws JAXBException {
117:                T ret = null;
118:                LOG.fine("decodeAsNative: encodedAs: " + encodedAs);
119:                LOG.fine("                class: " + clz.getName());
120:
121:                if (NATIVE_VERSION.equals(encodedAs)) {
122:                    ret = codec.decodeMAP(clz, headerElement, unmarshaller);
123:                } else if (Names200408.WSA_NAMESPACE_NAME.equals(encodedAs)) {
124:                    if (AttributedURIType.class.equals(clz)) {
125:                        return (T) convert(codec.decodeMAP(AttributedURI.class,
126:                                headerElement, unmarshaller));
127:                    } else if (EndpointReferenceType.class.equals(clz)) {
128:                        return (T) convert(codec.decodeMAP(
129:                                Names200408.EPR_TYPE, headerElement,
130:                                unmarshaller));
131:                    } else if (RelatesToType.class.equals(clz)) {
132:                        return (T) convert(codec.decodeMAP(Relationship.class,
133:                                headerElement, unmarshaller));
134:                    }
135:                }
136:                return ret;
137:            }
138:
139:            /**
140:             * Augment the set of headers understood by the protocol binding
141:             * with the 2004/08 header QNames.
142:             */
143:            static {
144:                Set<QName> headers = new HashSet<QName>();
145:                headers.addAll(Names.HEADERS);
146:                Names200408.addHeaders(headers);
147:                HEADERS = Collections.unmodifiableSet(headers);
148:            }
149:
150:            /**
151:             * Holder for 2004/08 Names
152:             */
153:            public static final class Names200408
154:                    extends
155:                    org.objectweb.celtix.bus.ws.addressing.VersionTransformer.Names200408 {
156:
157:                protected Names200408() {
158:                }
159:
160:                /**
161:                 * Adds 2004/08 headers to set.
162:                 * 
163:                 * @param headers set of headers
164:                 */
165:                private static void addHeaders(Set<QName> headers) {
166:                    headers.add(new QName(WSA_NAMESPACE_NAME,
167:                            Names.WSA_FROM_NAME));
168:                    headers
169:                            .add(new QName(WSA_NAMESPACE_NAME,
170:                                    Names.WSA_TO_NAME));
171:                    headers.add(new QName(WSA_NAMESPACE_NAME,
172:                            Names.WSA_REPLYTO_NAME));
173:                    headers.add(new QName(WSA_NAMESPACE_NAME,
174:                            Names.WSA_FAULTTO_NAME));
175:                    headers.add(new QName(WSA_NAMESPACE_NAME,
176:                            Names.WSA_ACTION_NAME));
177:                    headers.add(new QName(WSA_NAMESPACE_NAME,
178:                            Names.WSA_MESSAGEID_NAME));
179:                }
180:            }
181:        }
w__w__w_.___j__a___v_a2s_.___c_o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.