Source Code Cross Referenced for XMLPartBase.java in  » Web-Services-AXIS2 » jax-ws » org » apache » axis2 » jaxws » message » impl » 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 » jax ws » org.apache.axis2.jaxws.message.impl 
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:        package org.apache.axis2.jaxws.message.impl;
020:
021:        import org.apache.axiom.om.OMElement;
022:        import org.apache.axiom.soap.SOAP11Constants;
023:        import org.apache.axiom.soap.SOAP12Constants;
024:        import org.apache.axis2.jaxws.ExceptionFactory;
025:        import org.apache.axis2.jaxws.i18n.Messages;
026:        import org.apache.axis2.jaxws.message.Block;
027:        import org.apache.axis2.jaxws.message.Message;
028:        import org.apache.axis2.jaxws.message.Protocol;
029:        import org.apache.axis2.jaxws.message.XMLFault;
030:        import org.apache.axis2.jaxws.message.XMLPart;
031:        import org.apache.axis2.jaxws.message.factory.BlockFactory;
032:        import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
033:        import org.apache.axis2.jaxws.utility.JavaUtils;
034:        import org.apache.commons.logging.Log;
035:        import org.apache.commons.logging.LogFactory;
036:
037:        import javax.jws.soap.SOAPBinding.Style;
038:        import javax.xml.namespace.QName;
039:        import javax.xml.soap.Name;
040:        import javax.xml.soap.Node;
041:        import javax.xml.soap.SOAPElement;
042:        import javax.xml.soap.SOAPEnvelope;
043:        import javax.xml.soap.SOAPException;
044:        import javax.xml.stream.XMLStreamException;
045:        import javax.xml.stream.XMLStreamReader;
046:        import javax.xml.stream.XMLStreamWriter;
047:        import javax.xml.ws.WebServiceException;
048:        import java.util.Iterator;
049:
050:        /**
051:         * XMLPartBase class for an XMLPart An XMLPart is an abstraction of the xml portion of the message.
052:         * The actual representation can be in one of three different forms: * An OM tree * A SAAJ
053:         * SOAPEnvelope * An XMLSpine (an optimized representation of the message) The representation is
054:         * stored in the private variable (content)
055:         * <p/>
056:         * The representation changes as the Message flows through the JAX-WS framework.  For example, here
057:         * is a typical flow on the inbound case: a) Message is built from OM
058:         * (representation: OM) b) Message flows into SOAP Handler chain              (representation:
059:         * OM->SOAPEnvelope) c) Message flows out of the SOAP Handler chain d) Message flows into the
060:         * logical dispatch processing (representation: SOAPEnvelope->XMLSpine)
061:         * <p/>
062:         * The key to performance is the implementation of the transformations between OM, SAAJ SOAPEnvelope
063:         * and XMLSpine.   This base class defines all of the methods that are required on an XMLPart, the
064:         * actual transformations are provided by the derived class.  This division of work allows the
065:         * derived class to concentrate on the optimization of the transformations.  For example, the
066:         * derived class may implement XMLSpine -> OM using OMObjectWrapperElement constructs...thus avoid
067:         * expensive parsing.
068:         * <p/>
069:         * Here are the methods that the derived XMLPart should implement. OMElement
070:         * _convertSE2OM(SOAPEnvelope se) OMElement _convertSpine2OM(XMLSpine spine) SOAPEnvelope
071:         * _convertOM2SE(OMElement om) SOAPEnvelope _convertSpine2SE(XMLSpine spine) XMLSpine
072:         * _convertOM2Spine(OMElement om) XMLSpine _convertSE2Spine(SOAPEnvelope se) XMLSpine
073:         * _createSpine(Protocol protocol)
074:         * <p/>
075:         * NOTE: For XML/HTTP (REST), a SOAP 1.1. Envelope is built and the rest payload is placed in the
076:         * body.  This purposely mimics the Axis2 implementation.
077:         *
078:         * @see org.apache.axis2.jaxws.message.XMLPart
079:         * @see XMLPartImpl
080:         */
081:        public abstract class XMLPartBase implements  XMLPart {
082:
083:            private static Log log = LogFactory.getLog(XMLPartBase.class);
084:
085:            Protocol protocol = Protocol.unknown; // Protocol defaults to unknown
086:            Style style = Style.DOCUMENT; // Style defaults to document
087:            int indirection = 0; // Default indirection for Document
088:
089:            // The actual xml representation is always one of the following
090:            //   OM if the content is an OM tree
091:            //   SOAPENVELOPE if the content is a SOAPEnvelope
092:            //   SPINE if the content is a OM "spine" + Blocks
093:            Object content = null;
094:            int contentType = UNKNOWN;
095:
096:            static final int UNKNOWN = 0;
097:            static final int OM = 1;
098:            static final int SOAPENVELOPE = 2;
099:            static final int SPINE = 3;
100:
101:            boolean consumed = false;
102:
103:            Message parent;
104:
105:            /**
106:             * XMLPart should be constructed via the XMLPartFactory. This constructor constructs an empty
107:             * XMLPart with the specified protocol
108:             *
109:             * @param protocol
110:             * @throws WebServiceException
111:             */
112:            XMLPartBase(Protocol protocol) throws WebServiceException {
113:                super ();
114:                if (protocol.equals(Protocol.unknown)) {
115:                    throw ExceptionFactory.makeWebServiceException(Messages
116:                            .getMessage("ProtocolIsNotKnown"));
117:                }
118:                content = _createSpine(protocol, getStyle(), getIndirection(),
119:                        null);
120:                this .protocol = ((XMLSpine) content).getProtocol();
121:                contentType = SPINE;
122:            }
123:
124:            /**
125:             * XMLPart should be constructed via the XMLPartFactory. This constructor creates an XMLPart from
126:             * the specified root.
127:             *
128:             * @param root
129:             * @param protocol (if null, the soap protocol is inferred from the namespace)
130:             * @throws WebServiceException
131:             */
132:            XMLPartBase(OMElement root, Protocol protocol)
133:                    throws WebServiceException {
134:                content = root;
135:                contentType = OM;
136:                QName qName = root.getQName();
137:                if (protocol == null) {
138:                    if (qName.getNamespaceURI().equals(
139:                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
140:                        this .protocol = Protocol.soap11;
141:                    } else if (qName.getNamespaceURI().equals(
142:                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
143:                        this .protocol = Protocol.soap12;
144:                    }
145:                } else if (protocol == Protocol.rest) {
146:                    this .protocol = Protocol.rest;
147:                    // Axis2 stores XML/HTTP messages inside a soap11 envelope.  We will mimic this behavior
148:                    if (qName.getNamespaceURI().equals(
149:                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
150:                        // Okay
151:                    } else if (qName.getNamespaceURI().equals(
152:                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
153:                        throw ExceptionFactory
154:                                .makeWebServiceException("UNEXPECTED"); // TODO NLS
155:                    } else {
156:                        content = _createSpine(Protocol.rest, Style.DOCUMENT,
157:                                0, root);
158:                        contentType = SPINE;
159:                    }
160:                } else {
161:                    this .protocol = protocol;
162:                }
163:            }
164:
165:            /**
166:             * XMLPart should be constructed via the XMLPartFactory. This constructor creates an XMLPart from
167:             * the specified root.
168:             *
169:             * @param root
170:             * @throws WebServiceException
171:             */
172:            XMLPartBase(SOAPEnvelope root) throws WebServiceException {
173:                content = root;
174:                contentType = SOAPENVELOPE;
175:                String ns = root.getNamespaceURI();
176:                if (ns.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
177:                    protocol = Protocol.soap11;
178:                } else if (ns
179:                        .equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
180:                    protocol = Protocol.soap12;
181:                } else {
182:                    throw ExceptionFactory.makeWebServiceException(Messages
183:                            .getMessage("RESTIsNotSupported"));
184:                }
185:            }
186:
187:            private void setContent(Object content, int contentType) {
188:                this .content = content;
189:                this .contentType = contentType;
190:            }
191:
192:            private OMElement getContentAsOMElement()
193:                    throws WebServiceException {
194:
195:                OMElement om = null;
196:                switch (contentType) {
197:                case (OM):
198:                    om = (OMElement) content;
199:                    break;
200:                case (SPINE):
201:                    om = _convertSpine2OM((XMLSpine) content);
202:                    break;
203:                case (SOAPENVELOPE):
204:                    om = _convertSE2OM((SOAPEnvelope) content);
205:                    break;
206:                default:
207:                    throw ExceptionFactory.makeWebServiceException(Messages
208:                            .getMessage("XMLPartImplErr2"));
209:                }
210:                setContent(om, OM);
211:                return om;
212:            }
213:
214:            private SOAPEnvelope getContentAsSOAPEnvelope()
215:                    throws WebServiceException {
216:                SOAPEnvelope se = null;
217:                switch (contentType) {
218:                case (SOAPENVELOPE):
219:                    se = (SOAPEnvelope) content;
220:                    break;
221:                case (SPINE):
222:                    se = _convertSpine2SE((XMLSpine) content);
223:                    break;
224:                case (OM):
225:                    se = _convertOM2SE((OMElement) content);
226:                    break;
227:                default:
228:                    throw ExceptionFactory.makeWebServiceException(Messages
229:                            .getMessage("XMLPartImplErr2"));
230:                }
231:                setContent(se, SOAPENVELOPE);
232:                return se;
233:            }
234:
235:            private XMLSpine getContentAsXMLSpine() throws WebServiceException {
236:                XMLSpine spine = null;
237:                switch (contentType) {
238:                case (SPINE):
239:                    spine = (XMLSpine) content;
240:                    break;
241:                case (SOAPENVELOPE):
242:                    spine = _convertSE2Spine((SOAPEnvelope) content);
243:                    break;
244:                case (OM):
245:                    spine = _convertOM2Spine((OMElement) content);
246:                    break;
247:                default:
248:                    throw ExceptionFactory.makeWebServiceException(Messages
249:                            .getMessage("XMLPartImplErr2"));
250:                }
251:                spine.setParent(getParent());
252:                setContent(spine, SPINE);
253:                return spine;
254:            }
255:
256:            /* (non-Javadoc)
257:             * @see org.apache.axis2.jaxws.message.XMLPart#getAsOMElement()
258:             */
259:            public OMElement getAsOMElement() throws WebServiceException {
260:                return getContentAsOMElement();
261:            }
262:
263:            /* (non-Javadoc)
264:             * @see org.apache.axis2.jaxws.message.XMLPart#getAsSOAPEnvelope()
265:             */
266:            public SOAPEnvelope getAsSOAPEnvelope() throws WebServiceException {
267:                return getContentAsSOAPEnvelope();
268:            }
269:
270:            /* (non-Javadoc)
271:             * @see org.apache.axis2.jaxws.message.XMLPart#getProtocol()
272:             */
273:            public Protocol getProtocol() {
274:                return protocol;
275:            }
276:
277:            /* (non-Javadoc)
278:             * @see org.apache.axis2.jaxws.message.XMLPart#getStyle()
279:             */
280:            public Style getStyle() {
281:                return style;
282:            }
283:
284:            /* (non-Javadoc)
285:             * @see org.apache.axis2.jaxws.message.XMLPart#getIndirection()
286:             */
287:            public int getIndirection() {
288:                return indirection;
289:            }
290:
291:            /* (non-Javadoc)
292:             * @see org.apache.axis2.jaxws.message.XMLPart#setStyle(javax.jws.soap.SOAPBinding.Style)
293:             */
294:            public void setStyle(Style style) throws WebServiceException {
295:                if (this .style != style) {
296:                    if (contentType == SPINE) {
297:                        // Must switch to something other than XMLSpine
298:                        getContentAsOMElement();
299:                    }
300:                }
301:                this .style = style;
302:                if (style == Style.RPC) {
303:                    setIndirection(1);
304:                } else {
305:                    setIndirection(0);
306:                }
307:            }
308:
309:            public void setIndirection(int indirection) {
310:                if (this .indirection != indirection) {
311:                    if (contentType == SPINE) {
312:                        // Must switch to something other than XMLSpine
313:                        getContentAsOMElement();
314:                    }
315:                }
316:                this .indirection = indirection;
317:            }
318:
319:            public QName getOperationElement() throws WebServiceException {
320:                try {
321:                    if (style != Style.RPC) {
322:                        return null;
323:                    }
324:                    switch (contentType) {
325:                    case OM:
326:                        return ((org.apache.axiom.soap.SOAPEnvelope) content)
327:                                .getBody().getFirstElement().getQName();
328:                    case SPINE:
329:                        return ((XMLSpine) content).getOperationElement();
330:                    case SOAPENVELOPE:
331:                        Iterator it = ((SOAPEnvelope) content).getBody()
332:                                .getChildElements();
333:                        while (it.hasNext()) {
334:                            Node node = (Node) it.next();
335:                            if (node instanceof  SOAPElement) {
336:                                Name name = ((SOAPElement) node)
337:                                        .getElementName();
338:                                return new QName(name.getURI(), name
339:                                        .getLocalName(), name.getPrefix());
340:                            }
341:                        }
342:                    }
343:                    return null;
344:                } catch (SOAPException se) {
345:                    throw ExceptionFactory.makeWebServiceException(se);
346:                }
347:            }
348:
349:            public void setOperationElement(QName operationQName)
350:                    throws WebServiceException {
351:                if (indirection == 1) {
352:                    this .getContentAsXMLSpine().setOperationElement(
353:                            operationQName);
354:                }
355:            }
356:
357:            /* (non-Javadoc)
358:             * @see org.apache.axis2.jaxws.message.XMLPart#getXMLPartContentType()
359:             */
360:            public String getXMLPartContentType() {
361:                switch (contentType) {
362:                case OM:
363:                    return "OM";
364:                case SOAPENVELOPE:
365:                    return "SOAPENVELOPE";
366:                case SPINE:
367:                    return "SPINE";
368:                default:
369:                    return "UNKNOWN";
370:                }
371:            }
372:
373:            /* (non-Javadoc)
374:             * @see org.apache.axis2.jaxws.message.XMLPart#getXMLStreamReader(boolean)
375:             */
376:            public XMLStreamReader getXMLStreamReader(boolean consume)
377:                    throws WebServiceException {
378:                if (consumed) {
379:                    throw ExceptionFactory.makeWebServiceException(Messages
380:                            .getMessage("XMLPartImplErr1"));
381:                }
382:                XMLStreamReader reader = null;
383:                if (contentType == SPINE) {
384:                    reader = getContentAsXMLSpine().getXMLStreamReader(consume);
385:                } else {
386:                    OMElement omElement = getContentAsOMElement();
387:                    if (consume) {
388:                        reader = omElement.getXMLStreamReaderWithoutCaching();
389:                    } else {
390:                        reader = omElement.getXMLStreamReader();
391:                    }
392:                }
393:                setConsumed(consume);
394:                return reader;
395:            }
396:
397:            /* (non-Javadoc)
398:             * @see org.apache.axis2.jaxws.message.XMLPart#getXMLFault()
399:             */
400:            public XMLFault getXMLFault() throws WebServiceException {
401:
402:                XMLFault xmlFault = null;
403:
404:                if (isFault()) {
405:                    // An XMLFault represents the detail elements as Blocks, so 
406:                    // it makes sense to convert the representation to a Spine since
407:                    // that is what we do in other situations where we need a Block.
408:                    // Of course there is some additional optimization that could be done.
409:                    // If we can determine that there are no detail elements, then we could
410:                    // build the fault from an OM or SOAPEnvelope.  
411:                    XMLSpine spine = getContentAsXMLSpine();
412:                    xmlFault = spine.getXMLFault();
413:
414:                    // For each block in the xmlfault, set the message
415:                    Block[] blocks = xmlFault.getDetailBlocks();
416:                    if (blocks != null) {
417:                        for (int i = 0; i < blocks.length; i++) {
418:                            blocks[i].setParent(getParent());
419:                        }
420:                    }
421:                }
422:                return xmlFault;
423:            }
424:
425:            /* (non-Javadoc)
426:             * @see org.apache.axis2.jaxws.message.XMLPart#setXMLFault(org.apache.axis2.jaxws.message.XMLFault)
427:             */
428:            public void setXMLFault(XMLFault xmlFault)
429:                    throws WebServiceException {
430:                // For each block in the xmlfault, set the message
431:                Block[] blocks = xmlFault.getDetailBlocks();
432:                if (blocks != null) {
433:                    for (int i = 0; i < blocks.length; i++) {
434:                        blocks[i].setParent(getParent());
435:                    }
436:                }
437:                // Since the XMLFault contains detail Blocks it makes sence to convert
438:                // to an XMLSpine first (since that is what we do in the other calls that set Blocks).
439:                // Of course if the XMLFault did not have detail Blocks we might be able to 
440:                // do this without a transformation of the data.  
441:                XMLSpine spine = getContentAsXMLSpine();
442:                spine.setXMLFault(xmlFault);
443:            }
444:
445:            /* (non-Javadoc)
446:             * @see org.apache.axis2.jaxws.message.XMLPart#isFault()
447:             */
448:            public boolean isFault() throws WebServiceException {
449:                if (consumed) {
450:                    throw ExceptionFactory.makeWebServiceException(Messages
451:                            .getMessage("XMLPartImplErr1"));
452:                }
453:
454:                try {
455:                    switch (contentType) {
456:                    case OM:
457:                        return XMLFaultUtils
458:                                .isFault((org.apache.axiom.soap.SOAPEnvelope) getContentAsOMElement());
459:                    case SOAPENVELOPE:
460:                        return XMLFaultUtils
461:                                .isFault(getContentAsSOAPEnvelope());
462:                    case SPINE:
463:                        return getContentAsXMLSpine().isFault();
464:                    }
465:                } catch (SOAPException se) {
466:                    throw ExceptionFactory.makeWebServiceException(se);
467:                }
468:                return false;
469:            }
470:
471:            /* (non-Javadoc)
472:             * @see org.apache.axis2.jaxws.message.XMLPart#isConsumed()
473:             */
474:            public boolean isConsumed() {
475:                return consumed;
476:            }
477:
478:            /* (non-Javadoc)
479:             * @see org.apache.axis2.jaxws.message.XMLPart#outputTo(javax.xml.stream.XMLStreamWriter, boolean)
480:             */
481:            public void outputTo(XMLStreamWriter writer, boolean consume)
482:                    throws XMLStreamException, WebServiceException {
483:                if (consumed) {
484:                    throw ExceptionFactory.makeWebServiceException(Messages
485:                            .getMessage("XMLPartImplErr1"));
486:                }
487:                if (contentType == SPINE) {
488:                    getContentAsXMLSpine().outputTo(writer, consume);
489:                } else {
490:                    OMElement omElement = getContentAsOMElement();
491:                    if (consume) {
492:                        omElement.serializeAndConsume(writer);
493:                    } else {
494:                        omElement.serialize(writer);
495:                    }
496:                }
497:                setConsumed(consume);
498:                return;
499:
500:            }
501:
502:            /* (non-Javadoc)
503:             * @see org.apache.axis2.jaxws.message.XMLPart#traceString(java.lang.String)
504:             */
505:            public String traceString(String indent) {
506:                // TODO
507:                return null;
508:            }
509:
510:            /* (non-Javadoc)
511:             * @see org.apache.axis2.jaxws.message.XMLPart#getBodyBlock(int, java.lang.Object, org.apache.axis2.jaxws.message.factory.BlockFactory)
512:             */
513:            public Block getBodyBlock(int index, Object context,
514:                    BlockFactory blockFactory) throws WebServiceException {
515:                Block block = getContentAsXMLSpine().getBodyBlock(index,
516:                        context, blockFactory);
517:                if (block != null) {
518:                    block.setParent(getParent());
519:                }
520:                return block;
521:            }
522:
523:            /* (non-Javadoc)
524:             * @see org.apache.axis2.jaxws.message.XMLPart#getBodyBlock(java.lang.Object, org.apache.axis2.jaxws.message.factory.BlockFactory)
525:             */
526:            public Block getBodyBlock(Object context, BlockFactory blockFactory)
527:                    throws WebServiceException {
528:                Block block = getContentAsXMLSpine().getBodyBlock(context,
529:                        blockFactory);
530:                if (block != null) {
531:                    block.setParent(getParent());
532:                }
533:                return block;
534:            }
535:
536:            /* (non-Javadoc)
537:             * @see org.apache.axis2.jaxws.message.XMLPart#getHeaderBlock(java.lang.String, java.lang.String, java.lang.Object, org.apache.axis2.jaxws.message.factory.BlockFactory)
538:             */
539:            public Block getHeaderBlock(String namespace, String localPart,
540:                    Object context, BlockFactory blockFactory)
541:                    throws WebServiceException {
542:                Block block = getContentAsXMLSpine().getHeaderBlock(namespace,
543:                        localPart, context, blockFactory);
544:                if (block != null) {
545:                    block.setParent(getParent());
546:                }
547:                return block;
548:            }
549:
550:            /* (non-Javadoc)
551:             * @see org.apache.axis2.jaxws.message.XMLPart#getNumBodyBlocks()
552:             */
553:            public int getNumBodyBlocks() throws WebServiceException {
554:                return getContentAsXMLSpine().getNumBodyBlocks();
555:            }
556:
557:            /* (non-Javadoc)
558:             * @see org.apache.axis2.jaxws.message.XMLPart#getNumHeaderBlocks()
559:             */
560:            public int getNumHeaderBlocks() throws WebServiceException {
561:                return getContentAsXMLSpine().getNumHeaderBlocks();
562:            }
563:
564:            /* (non-Javadoc)
565:             * @see org.apache.axis2.jaxws.message.XMLPart#removeBodyBlock(int)
566:             */
567:            public void removeBodyBlock(int index) throws WebServiceException {
568:                getContentAsXMLSpine().removeBodyBlock(index);
569:            }
570:
571:            /* (non-Javadoc)
572:             * @see org.apache.axis2.jaxws.message.XMLPart#removeHeaderBlock(java.lang.String, java.lang.String)
573:             */
574:            public void removeHeaderBlock(String namespace, String localPart)
575:                    throws WebServiceException {
576:                getContentAsXMLSpine().removeHeaderBlock(namespace, localPart);
577:            }
578:
579:            /* (non-Javadoc)
580:             * @see org.apache.axis2.jaxws.message.XMLPart#setBodyBlock(int, org.apache.axis2.jaxws.message.Block)
581:             */
582:            public void setBodyBlock(int index, Block block)
583:                    throws WebServiceException {
584:                block.setParent(getParent());
585:                getContentAsXMLSpine().setBodyBlock(index, block);
586:            }
587:
588:            /* (non-Javadoc)
589:             * @see org.apache.axis2.jaxws.message.XMLPart#setBodyBlock(int, org.apache.axis2.jaxws.message.Block)
590:             */
591:            public void setBodyBlock(Block block) throws WebServiceException {
592:                block.setParent(getParent());
593:                getContentAsXMLSpine().setBodyBlock(block);
594:            }
595:
596:            /* (non-Javadoc)
597:             * @see org.apache.axis2.jaxws.message.XMLPart#setHeaderBlock(java.lang.String, java.lang.String, org.apache.axis2.jaxws.message.Block)
598:             */
599:            public void setHeaderBlock(String namespace, String localPart,
600:                    Block block) throws WebServiceException {
601:                block.setParent(getParent());
602:                getContentAsXMLSpine().setHeaderBlock(namespace, localPart,
603:                        block);
604:            }
605:
606:            /*
607:             * (non-Javadoc)
608:             * @see org.apache.axis2.jaxws.message.XMLPart#getParent()
609:             */
610:            public Message getParent() {
611:                return parent;
612:            }
613:
614:            /*
615:             * Set the backpointer to this XMLPart's parent Message
616:             */
617:            public void setParent(Message p) {
618:                parent = p;
619:            }
620:
621:            /**
622:             * Convert SOAPEnvelope into an OM tree
623:             *
624:             * @param se SOAPEnvelope
625:             * @return OM
626:             * @throws WebServiceException
627:             */
628:            protected abstract OMElement _convertSE2OM(SOAPEnvelope se)
629:                    throws WebServiceException;
630:
631:            /**
632:             * Convert XMLSpine into an OM tree
633:             *
634:             * @param spine XMLSpine
635:             * @return OM
636:             * @throws WebServiceException
637:             */
638:            protected abstract OMElement _convertSpine2OM(XMLSpine spine)
639:                    throws WebServiceException;
640:
641:            /**
642:             * Convert OM tree into a SOAPEnvelope
643:             *
644:             * @param om
645:             * @return SOAPEnvelope
646:             * @throws WebServiceException
647:             */
648:            protected abstract SOAPEnvelope _convertOM2SE(OMElement om)
649:                    throws WebServiceException;
650:
651:            /**
652:             * Convert XMLSpine into a SOAPEnvelope
653:             *
654:             * @param spine
655:             * @return SOAPEnvelope
656:             * @throws WebServiceException
657:             */
658:            protected abstract SOAPEnvelope _convertSpine2SE(XMLSpine spine)
659:                    throws WebServiceException;
660:
661:            /**
662:             * Convert OM into XMLSpine
663:             *
664:             * @param om
665:             * @return
666:             * @throws WebServiceException
667:             */
668:            protected abstract XMLSpine _convertOM2Spine(OMElement om)
669:                    throws WebServiceException;
670:
671:            /**
672:             * Convert SOAPEnvelope into XMLSPine
673:             *
674:             * @param SOAPEnvelope
675:             * @return XMLSpine
676:             * @throws WebServiceException
677:             */
678:            protected abstract XMLSpine _convertSE2Spine(SOAPEnvelope se)
679:                    throws WebServiceException;
680:
681:            /**
682:             * Create an empty, default spine for the specificed protocol
683:             *
684:             * @param protocol
685:             * @return
686:             * @throws WebServiceException
687:             */
688:            protected static XMLSpine _createSpine(Protocol protocol,
689:                    Style style, int indirection, OMElement payload)
690:                    throws WebServiceException {
691:                // Default implementation is to simply construct the spine.
692:                // Derived classes may wish to construct a different kind of XMLSpine
693:                return new XMLSpineImpl(protocol, style, indirection, payload);
694:            }
695:
696:            private void setConsumed(boolean consume) {
697:                if (consume) {
698:                    this .consumed = true;
699:                    if (log.isDebugEnabled()) {
700:                        log.debug("Debug Monitoring When Block is Consumed");
701:                        log.debug(JavaUtils.stackToString());
702:                    }
703:                } else {
704:                    consumed = false;
705:                }
706:            }
707:
708:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.