Source Code Cross Referenced for TestHandler.java in  » ESB » celtix-1.0 » org » objectweb » celtix » systest » handlers » 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.systest.handlers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.systest.handlers;
002:
003:        import java.util.Map;
004:        import java.util.StringTokenizer;
005:
006:        import javax.xml.bind.JAXBContext;
007:        import javax.xml.bind.JAXBException;
008:        import javax.xml.namespace.QName;
009:        import javax.xml.ws.LogicalMessage;
010:        import javax.xml.ws.ProtocolException;
011:        import javax.xml.ws.handler.LogicalHandler;
012:        import javax.xml.ws.handler.LogicalMessageContext;
013:        import javax.xml.ws.handler.MessageContext;
014:
015:        import org.objectweb.handler_test.types.PingResponse;
016:        import org.objectweb.handler_test.types.PingWithArgs;
017:        import org.objectweb.hello_world_soap_http.types.GreetMe;
018:
019:        public class TestHandler<T extends LogicalMessageContext> extends
020:                TestHandlerBase implements  LogicalHandler<T> {
021:
022:            private final JAXBContext jaxbCtx;
023:
024:            public TestHandler() {
025:                this (true);
026:            }
027:
028:            public TestHandler(boolean serverSide) {
029:                super (serverSide);
030:
031:                try {
032:                    jaxbCtx = JAXBContext.newInstance(GreetMe.class
033:                            .getPackage().getName());
034:                } catch (JAXBException e) {
035:                    throw new RuntimeException(e);
036:                }
037:
038:            }
039:
040:            public String getHandlerId() {
041:                return "handler" + getId();
042:            }
043:
044:            public boolean handleMessage(T ctx) {
045:                methodCalled("handleMessage");
046:                printHandlerInfo("handleMessage", isOutbound(ctx));
047:
048:                boolean outbound = (Boolean) ctx
049:                        .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
050:                boolean ret = handleMessageRet;
051:
052:                if (!isServerSideHandler()) {
053:                    return true;
054:                }
055:
056:                QName operationName = (QName) ctx
057:                        .get(MessageContext.WSDL_OPERATION);
058:                assert operationName != null : "unable to get operation name from "
059:                        + ctx;
060:
061:                if ("ping".equals(operationName.getLocalPart())) {
062:                    ret = handlePingMessage(outbound, ctx);
063:                } else if ("pingWithArgs".equals(operationName.getLocalPart())) {
064:                    ret = handlePingWithArgsMessage(outbound, ctx);
065:                }
066:                return ret;
067:            }
068:
069:            private boolean handlePingWithArgsMessage(boolean outbound, T ctx) {
070:
071:                LogicalMessage msg = ctx.getMessage();
072:                Object payload = msg.getPayload(jaxbCtx);
073:                addHandlerId(ctx.getMessage(), ctx, outbound);
074:
075:                boolean ret = true;
076:                if (payload instanceof  PingWithArgs) {
077:                    String arg = ((PingWithArgs) payload).getHandlersCommand();
078:
079:                    StringTokenizer strtok = new StringTokenizer(arg, " ");
080:                    String hid = strtok.nextToken();
081:                    String direction = strtok.nextToken();
082:                    String command = strtok.nextToken();
083:
084:                    if (outbound) {
085:                        return ret;
086:                    }
087:
088:                    if (getHandlerId().equals(hid)
089:                            && "inbound".equals(direction)) {
090:
091:                        if ("stop".equals(command)) {
092:                            PingResponse resp = new PingResponse();
093:                            getHandlerInfoList(ctx).add(getHandlerId());
094:                            resp.getHandlersInfo().addAll(
095:                                    getHandlerInfoList(ctx));
096:                            msg.setPayload(resp, jaxbCtx);
097:                            ret = false;
098:                        } else if ("throw".equals(command)) {
099:                            throwException(strtok.nextToken());
100:                        }
101:                    }
102:                }
103:                return ret;
104:            }
105:
106:            private void throwException(String exType) {
107:                if (exType.contains("ProtocolException")) {
108:                    throw new ProtocolException("from server handler");
109:                }
110:            }
111:
112:            private boolean handlePingMessage(boolean outbound, T ctx) {
113:
114:                LogicalMessage msg = ctx.getMessage();
115:                addHandlerId(msg, ctx, outbound);
116:                return handleMessageRet;
117:            }
118:
119:            private void addHandlerId(LogicalMessage msg, T ctx,
120:                    boolean outbound) {
121:
122:                Object obj = msg.getPayload(jaxbCtx);
123:                if (obj instanceof  PingResponse) {
124:                    PingResponse origResp = (PingResponse) obj;
125:                    PingResponse newResp = new PingResponse();
126:                    newResp.getHandlersInfo()
127:                            .addAll(origResp.getHandlersInfo());
128:                    newResp.getHandlersInfo().add(getHandlerId());
129:                    msg.setPayload(newResp, jaxbCtx);
130:                } else if (!outbound && obj == null) {
131:                    getHandlerInfoList(ctx).add(getHandlerId());
132:                }
133:            }
134:
135:            public boolean handleFault(T ctx) {
136:                methodCalled("handleFault");
137:                printHandlerInfo("handleFault", isOutbound(ctx));
138:                //boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
139:                return true;
140:            }
141:
142:            public void close(MessageContext arg0) {
143:                methodCalled("close");
144:            }
145:
146:            public void init(Map arg0) {
147:                methodCalled("init");
148:            }
149:
150:            public void destroy() {
151:                methodCalled("destroy");
152:            }
153:
154:            public String toString() {
155:                return getHandlerId();
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.