Source Code Cross Referenced for PhaseResolver.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » phaseresolver » 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 AXIS2 » kernal » org.apache.axis2.phaseresolver 
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:         */
019:
020:        package org.apache.axis2.phaseresolver;
021:
022:        import org.apache.axis2.description.*;
023:        import org.apache.axis2.engine.AxisConfiguration;
024:        import org.apache.axis2.engine.Phase;
025:        import org.apache.axis2.wsdl.WSDLConstants;
026:
027:        import java.util.ArrayList;
028:        import java.util.Iterator;
029:        import java.util.List;
030:
031:        /**
032:         * Class PhaseResolver
033:         */
034:        public class PhaseResolver {
035:
036:            private static final int IN_FLOW = 1;
037:            private static final int OUT_FAULT_FLOW = 5;
038:
039:            /**
040:             * Field axisConfig
041:             */
042:            private AxisConfiguration axisConfig;
043:
044:            /**
045:             * Field phaseHolder
046:             */
047:            private PhaseHolder phaseHolder;
048:
049:            /**
050:             * default constructor , to obuild chains for GlobalDescription
051:             *
052:             * @param axisconfig
053:             */
054:            public PhaseResolver(AxisConfiguration axisconfig) {
055:                this .axisConfig = axisconfig;
056:            }
057:
058:            private void engageModuleToFlow(Flow flow, List handlerChain)
059:                    throws PhaseException {
060:                phaseHolder = new PhaseHolder(handlerChain);
061:                if (flow != null) {
062:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
063:                        HandlerDescription metadata = flow.getHandler(j);
064:                        phaseHolder.addHandler(metadata);
065:                    }
066:                }
067:            }
068:
069:            private void engageModuleToOperation(AxisOperation axisOperation,
070:                    AxisModule axisModule, int flowType) throws PhaseException {
071:                List phases = new ArrayList();
072:                Flow flow = null;
073:                switch (flowType) {
074:                case PhaseMetadata.IN_FLOW: {
075:                    phases.addAll(axisConfig.getInFlowPhases());
076:                    phases.addAll(axisOperation.getRemainingPhasesInFlow());
077:                    flow = axisModule.getInFlow();
078:                    break;
079:                }
080:                case PhaseMetadata.OUT_FLOW: {
081:                    phases.addAll(axisOperation.getPhasesOutFlow());
082:                    phases.addAll(axisConfig.getOutFlowPhases());
083:                    flow = axisModule.getOutFlow();
084:                    break;
085:                }
086:                case PhaseMetadata.FAULT_OUT_FLOW: {
087:                    phases.addAll(axisOperation.getPhasesOutFaultFlow());
088:                    phases.addAll(axisConfig.getOutFaultFlowPhases());
089:                    flow = axisModule.getFaultOutFlow();
090:                    break;
091:                }
092:                case PhaseMetadata.FAULT_IN_FLOW: {
093:                    phases.addAll(axisOperation.getPhasesInFaultFlow());
094:                    phases.addAll(axisConfig.getInFaultFlowPhases());
095:                    flow = axisModule.getFaultInFlow();
096:                    break;
097:                }
098:                }
099:                engageModuleToFlow(flow, phases);
100:            }
101:
102:            public void engageModuleToOperation(AxisOperation axisOperation,
103:                    AxisModule module) throws PhaseException {
104:                for (int type = IN_FLOW; type < OUT_FAULT_FLOW; type++) {
105:                    engageModuleToOperation(axisOperation, module, type);
106:                }
107:            }
108:
109:            /**
110:             * To remove handlers from global chians this method can be used , first it take inflow
111:             * of the module and then take handler one by one and then remove those handlers from
112:             * global inchain ,
113:             * the same procedure will be carry out for all the other flows as well.
114:             *
115:             * @param module
116:             */
117:            public void disengageModuleFromGlobalChains(AxisModule module) {
118:                //INFLOW
119:                Flow flow = module.getInFlow();
120:                if (flow != null) {
121:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
122:                        HandlerDescription handler = flow.getHandler(j);
123:                        removeHandlerfromaPhase(handler, axisConfig
124:                                .getInFlowPhases());
125:                    }
126:                }
127:                //OUTFLOW
128:                flow = module.getOutFlow();
129:                if (flow != null) {
130:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
131:                        HandlerDescription handler = flow.getHandler(j);
132:                        removeHandlerfromaPhase(handler, axisConfig
133:                                .getOutFlowPhases());
134:                    }
135:                }
136:                //INFAULTFLOW
137:                flow = module.getFaultInFlow();
138:                if (flow != null) {
139:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
140:                        HandlerDescription handler = flow.getHandler(j);
141:                        removeHandlerfromaPhase(handler, axisConfig
142:                                .getInFaultFlowPhases());
143:                    }
144:                }
145:                //OUTFAULTFLOW
146:                flow = module.getFaultOutFlow();
147:                if (flow != null) {
148:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
149:                        HandlerDescription handler = flow.getHandler(j);
150:                        removeHandlerfromaPhase(handler, axisConfig
151:                                .getOutFaultFlowPhases());
152:                    }
153:                }
154:            }
155:
156:            /**
157:             * To remove handlers from operations chians this method can be used , first it take inflow
158:             * of the module and then take handler one by one and then remove those handlers from
159:             * global inchain ,
160:             * the same procedure will be carry out for all the other flows as well.
161:             *
162:             * @param module
163:             */
164:            public void disengageModuleFromOperationChain(AxisModule module,
165:                    AxisOperation operation) {
166:                //INFLOW
167:                Flow flow = module.getInFlow();
168:                if (flow != null) {
169:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
170:                        HandlerDescription handler = flow.getHandler(j);
171:                        removeHandlerfromaPhase(handler, operation
172:                                .getRemainingPhasesInFlow());
173:                    }
174:                }
175:                //OUTFLOW
176:                flow = module.getOutFlow();
177:                if (flow != null) {
178:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
179:                        HandlerDescription handler = flow.getHandler(j);
180:                        removeHandlerfromaPhase(handler, operation
181:                                .getPhasesOutFlow());
182:                    }
183:                }
184:                //INFAULTFLOW
185:                flow = module.getFaultInFlow();
186:                if (flow != null) {
187:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
188:                        HandlerDescription handler = flow.getHandler(j);
189:                        removeHandlerfromaPhase(handler, operation
190:                                .getPhasesInFaultFlow());
191:                    }
192:                }
193:                //OUTFAULTFLOW
194:                flow = module.getFaultOutFlow();
195:                if (flow != null) {
196:                    for (int j = 0; j < flow.getHandlerCount(); j++) {
197:                        HandlerDescription handler = flow.getHandler(j);
198:                        removeHandlerfromaPhase(handler, operation
199:                                .getPhasesOutFaultFlow());
200:                    }
201:                }
202:            }
203:
204:            /**
205:             * To remove a single handler from a given list of phases
206:             *
207:             * @param handler
208:             * @param phaseList
209:             */
210:            private void removeHandlerfromaPhase(HandlerDescription handler,
211:                    ArrayList phaseList) {
212:                String phaseName = handler.getRules().getPhaseName();
213:                Iterator phaseItr = phaseList.iterator();
214:                while (phaseItr.hasNext()) {
215:                    Phase phase = (Phase) phaseItr.next();
216:                    if (phase.getPhaseName().equals(phaseName)) {
217:                        phase.removeHandler(handler);
218:                        break;
219:                    }
220:                }
221:            }
222:
223:            public void engageModuleToMessage(AxisMessage axisMessage,
224:                    AxisModule axisModule) throws PhaseException {
225:                String direction = axisMessage.getDirection();
226:                AxisOperation axisOperation = axisMessage.getAxisOperation();
227:                if (WSDLConstants.MESSAGE_LABEL_OUT_VALUE
228:                        .equalsIgnoreCase(direction)) {
229:                    engageModuleToOperation(axisOperation, axisModule,
230:                            PhaseMetadata.OUT_FLOW);
231:                } else if (WSDLConstants.MESSAGE_LABEL_IN_VALUE
232:                        .equalsIgnoreCase(direction)) {
233:                    engageModuleToOperation(axisOperation, axisModule,
234:                            PhaseMetadata.IN_FLOW);
235:                } else if (WSDLConstants.MESSAGE_LABEL_FAULT_VALUE
236:                        .equals(direction)) {
237:                    //TODO : Need to handle fault correctly
238:                }
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.