Source Code Cross Referenced for ColocUtil.java in  » Web-Services-apache-cxf-2.0.1 » bindings » org » apache » cxf » binding » coloc » 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 » bindings » org.apache.cxf.binding.coloc 
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.binding.coloc;
019:
020:        import java.util.Collection;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.SortedSet;
024:        import java.util.logging.Level;
025:        import java.util.logging.Logger;
026:
027:        import org.apache.cxf.Bus;
028:        import org.apache.cxf.endpoint.Endpoint;
029:        import org.apache.cxf.interceptor.Interceptor;
030:        import org.apache.cxf.interceptor.InterceptorChain;
031:        import org.apache.cxf.message.Exchange;
032:        import org.apache.cxf.phase.Phase;
033:        import org.apache.cxf.phase.PhaseInterceptorChain;
034:        import org.apache.cxf.service.model.FaultInfo;
035:        import org.apache.cxf.service.model.MessageInfo;
036:        import org.apache.cxf.service.model.MessagePartInfo;
037:        import org.apache.cxf.service.model.OperationInfo;
038:
039:        public final class ColocUtil {
040:            //private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ColocInInterceptor.class);
041:            private static final Logger LOG = Logger.getLogger(ColocUtil.class
042:                    .getName());
043:
044:            private ColocUtil() {
045:                //Completge
046:            }
047:
048:            public static void setPhases(SortedSet<Phase> list, String start,
049:                    String end) {
050:                Phase startPhase = new Phase(start, 1);
051:                Phase endPhase = new Phase(end, 2);
052:                Iterator<Phase> iter = list.iterator();
053:                boolean remove = true;
054:                while (iter.hasNext()) {
055:                    Phase p = iter.next();
056:                    if (remove && p.getName().equals(startPhase.getName())) {
057:                        remove = false;
058:                    } else if (p.getName().equals(endPhase.getName())) {
059:                        remove = true;
060:                    } else if (remove) {
061:                        iter.remove();
062:                    }
063:                }
064:            }
065:
066:            public static InterceptorChain getOutInterceptorChain(Exchange ex,
067:                    SortedSet<Phase> phases) {
068:                Bus bus = ex.get(Bus.class);
069:                PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
070:
071:                Endpoint ep = ex.get(Endpoint.class);
072:                List<Interceptor> il = ep.getOutInterceptors();
073:                if (LOG.isLoggable(Level.FINE)) {
074:                    LOG.fine("Interceptors contributed by endpoint: " + il);
075:                }
076:                chain.add(il);
077:                il = ep.getService().getOutInterceptors();
078:                if (LOG.isLoggable(Level.FINE)) {
079:                    LOG.fine("Interceptors contributed by service: " + il);
080:                }
081:                chain.add(il);
082:                il = bus.getOutInterceptors();
083:                if (LOG.isLoggable(Level.FINE)) {
084:                    LOG.fine("Interceptors contributed by bus: " + il);
085:                }
086:                chain.add(il);
087:
088:                return chain;
089:            }
090:
091:            public static InterceptorChain getInInterceptorChain(Exchange ex,
092:                    SortedSet<Phase> phases) {
093:                Bus bus = ex.get(Bus.class);
094:                PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
095:
096:                Endpoint ep = ex.get(Endpoint.class);
097:                List<Interceptor> il = ep.getInInterceptors();
098:                if (LOG.isLoggable(Level.FINE)) {
099:                    LOG.fine("Interceptors contributed by endpoint: " + il);
100:                }
101:                chain.add(il);
102:                il = ep.getService().getInInterceptors();
103:                if (LOG.isLoggable(Level.FINE)) {
104:                    LOG.fine("Interceptors contributed by service: " + il);
105:                }
106:                chain.add(il);
107:                il = bus.getInInterceptors();
108:                if (LOG.isLoggable(Level.FINE)) {
109:                    LOG.fine("Interceptors contributed by bus: " + il);
110:                }
111:                chain.add(il);
112:                chain.setFaultObserver(new ColocOutFaultObserver(bus));
113:
114:                return chain;
115:            }
116:
117:            public static boolean isSameOperationInfo(OperationInfo oi1,
118:                    OperationInfo oi2) {
119:                return oi1.getName().equals(oi2.getName())
120:                        && isSameMessageInfo(oi1.getInput(), oi2.getInput())
121:                        && isSameMessageInfo(oi1.getOutput(), oi2.getOutput())
122:                        && isSameFaultInfo(oi1.getFaults(), oi2.getFaults());
123:            }
124:
125:            public static boolean isSameMessageInfo(MessageInfo mi1,
126:                    MessageInfo mi2) {
127:                if ((mi1 == null && mi2 != null)
128:                        || (mi1 != null && mi2 == null)) {
129:                    return false;
130:                }
131:
132:                if (mi1 != null && mi2 != null) {
133:                    List<MessagePartInfo> mpil1 = mi1.getMessageParts();
134:                    List<MessagePartInfo> mpil2 = mi2.getMessageParts();
135:                    if (mpil1.size() != mpil2.size()) {
136:                        return false;
137:                    }
138:                    int idx = 0;
139:                    for (MessagePartInfo mpi1 : mpil1) {
140:                        MessagePartInfo mpi2 = mpil2.get(idx);
141:                        if (!mpi1.getTypeClass().equals(mpi2.getTypeClass())) {
142:                            return false;
143:                        }
144:                        ++idx;
145:                    }
146:                }
147:                return true;
148:            }
149:
150:            public static boolean isSameFaultInfo(Collection<FaultInfo> fil1,
151:                    Collection<FaultInfo> fil2) {
152:                if ((fil1 == null && fil2 != null)
153:                        || (fil1 != null && fil2 == null)) {
154:                    return false;
155:                }
156:
157:                if (fil1 != null && fil2 != null) {
158:                    if (fil1.size() != fil2.size()) {
159:                        return false;
160:                    }
161:                    for (FaultInfo fi1 : fil1) {
162:                        Iterator<FaultInfo> iter = fil2.iterator();
163:                        Class<?> fiClass1 = fi1.getProperty(Class.class
164:                                .getName(), Class.class);
165:                        boolean match = false;
166:                        while (iter.hasNext()) {
167:                            FaultInfo fi2 = iter.next();
168:                            Class<?> fiClass2 = fi2.getProperty(Class.class
169:                                    .getName(), Class.class);
170:                            //Sender/Receiver Service Model not same for faults wr.t message names.
171:                            //So Compare Exception Class Instance.
172:                            if (fiClass1.equals(fiClass2)) {
173:                                match = true;
174:                                break;
175:                            }
176:                        }
177:                        if (!match) {
178:                            return false;
179:                        }
180:                    }
181:                }
182:                return true;
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.