Source Code Cross Referenced for OOBHdrServiceImpl.java in  » Web-Services-apache-cxf-2.0.1 » systests » org » apache » cxf » systest » outofband » header » 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 » Web Services apache cxf 2.0.1 » systests » org.apache.cxf.systest.outofband.header 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.systest.outofband.header;
019:
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import javax.annotation.Resource;
024:        import javax.xml.bind.JAXBContext;
025:        import javax.xml.bind.JAXBElement;
026:        import javax.xml.bind.JAXBException;
027:        import javax.xml.namespace.QName;
028:        import javax.xml.ws.Holder;
029:        import javax.xml.ws.WebServiceContext;
030:        import javax.xml.ws.handler.MessageContext;
031:        import org.w3c.dom.Node;
032:
033:        import org.apache.cxf.headers.Header;
034:        import org.apache.cxf.helpers.CastUtils;
035:        import org.apache.cxf.jaxb.JAXBDataBinding;
036:        import org.apache.cxf.outofband.header.ObjectFactory;
037:        import org.apache.cxf.outofband.header.OutofBandHeader;
038:        import org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType;
039:        import org.apache.hello_world_doc_lit_bare.types.TradePriceData;
040:
041:        @javax.jws.WebService(serviceName="SOAPService",portName="SoapPort",endpointInterface="org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType",targetNamespace="http://apache.org/hello_world_doc_lit_bare",wsdlLocation="testutils/doc_lit_bare.wsdl")
042:        public class OOBHdrServiceImpl implements  PutLastTradedPricePortType {
043:            @Resource
044:            private WebServiceContext context;
045:
046:            public void sayHi(Holder<TradePriceData> inout) {
047:                inout.value.setTickerPrice(4.5f);
048:                inout.value.setTickerSymbol("APACHE");
049:                if (checkContext()) {
050:                    //System.out.println("Received out-of-band header as expected..");
051:                    sendReturnOOBHeader();
052:                }
053:            }
054:
055:            private void sendReturnOOBHeader() {
056:                if (context != null) {
057:                    MessageContext ctx = context.getMessageContext();
058:                    if (ctx != null) {
059:                        try {
060:                            //                  Create out-of-band header object.
061:                            OutofBandHeader ob = new OutofBandHeader();
062:                            ob.setName("testOobReturnHeaderName");
063:                            ob.setValue("testOobReturnHeaderValue");
064:                            ob.setHdrAttribute("testReturnHdrAttribute");
065:                            // Add Out-of-band header object to HeaderHolder.
066:
067:                            JAXBElement<OutofBandHeader> job = new JAXBElement<OutofBandHeader>(
068:                                    new QName(
069:                                            OOBHeaderTest.TEST_HDR_NS,
070:                                            OOBHeaderTest.TEST_HDR_RESPONSE_ELEM),
071:                                    OutofBandHeader.class, null, ob);
072:                            Header hdr = new Header(new QName(
073:                                    OOBHeaderTest.TEST_HDR_NS,
074:                                    OOBHeaderTest.TEST_HDR_RESPONSE_ELEM), job,
075:                                    new JAXBDataBinding(ob.getClass()));
076:                            List<Header> hdrList = CastUtils.cast((List<?>) ctx
077:                                    .get(Header.HEADER_LIST));
078:                            hdrList.add(hdr);
079:                            //Add headerHolder to requestContext.
080:                            //                    ctx.put(Header.HEADER_LIST, hdrList);
081:                            //System.out.println("Completed adding list to context");
082:                        } catch (Exception ex) {
083:                            ex.printStackTrace();
084:                        }
085:                    }
086:                }
087:            }
088:
089:            public void putLastTradedPrice(TradePriceData body) {
090:                //System.out.println("-----TradePriceData TickerPrice : ----- " + body.getTickerPrice());
091:                //System.out.println("-----TradePriceData TickerSymbol : ----- " + body.getTickerSymbol());
092:            }
093:
094:            private boolean checkContext() {
095:                boolean success = false;
096:                MessageContext ctx = context == null ? null : context
097:                        .getMessageContext();
098:                if (ctx.containsKey(Header.HEADER_LIST)) {
099:                    List oobHdr = (List) ctx.get(Header.HEADER_LIST);
100:
101:                    if (oobHdr instanceof  List) {
102:                        Iterator iter = oobHdr.iterator();
103:                        while (iter.hasNext()) {
104:                            Object hdr = iter.next();
105:                            if (hdr instanceof  Header
106:                                    && ((Header) hdr).getObject() instanceof  Node) {
107:                                Header hdr1 = (Header) hdr;
108:                                //System.out.println("Node conains : " + hdr1.getObject().toString());
109:                                try {
110:                                    JAXBElement job = (JAXBElement) JAXBContext
111:                                            .newInstance(ObjectFactory.class)
112:                                            .createUnmarshaller().unmarshal(
113:                                                    (Node) hdr1.getObject());
114:                                    OutofBandHeader ob = (OutofBandHeader) job
115:                                            .getValue();
116:                                    if ("testOobHeader".equals(ob.getName())
117:                                            && "testOobHeaderValue".equals(ob
118:                                                    .getValue())
119:                                            && "testHdrAttribute".equals(ob
120:                                                    .getHdrAttribute())) {
121:                                        success = true;
122:                                    } else {
123:                                        throw new RuntimeException(
124:                                                "test failed");
125:                                    }
126:                                } catch (JAXBException ex) {
127:                                    //
128:                                    ex.printStackTrace();
129:                                }
130:                            }
131:                        }
132:                    } else {
133:                        throw new RuntimeException("Header should not be null"
134:                                + "and should be of type JAXBHeaderHolder");
135:                    }
136:                } else {
137:                    throw new RuntimeException(
138:                            "MessageContext is null or doesnot contain OOBHeaders");
139:                }
140:
141:                return success;
142:            }
143:
144:            public String bareNoParam() {
145:                return "testResponse";
146:            }
147:
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.