Source Code Cross Referenced for DocumentImpl.java in  » ESB » open-esb » com » sun » jbi » wsdl2 » 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 » ESB » open esb » com.sun.jbi.wsdl2.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)DocumentImpl.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.wsdl2.impl;
030:
031:        import java.util.Map;
032:        import java.util.List;
033:        import java.util.ArrayList;
034:
035:        import org.apache.xmlbeans.XmlException;
036:        import org.apache.xmlbeans.XmlOptions;
037:
038:        import org.w3.ns.wsdl.DocumentationType;
039:
040:        import org.w3c.dom.DocumentFragment;
041:        import org.w3c.dom.Element;
042:
043:        /**
044:         * Implementation of Documentation for a WSDL, component.
045:         * 
046:         * @author Sun Microsystems, Inc.
047:         */
048:        final class DocumentImpl extends Document {
049:            /** Documentation Xml bean. */
050:            private DocumentationType mBean;
051:
052:            /** The component which is documented by this component. */
053:            private ExtensibleDocumentedComponent mParent;
054:
055:            /** Container for this component */
056:            private DescriptionImpl mContainer;
057:
058:            /**
059:             * Fetch the Xml bean for this component.
060:             * 
061:             * @return The XML Bean for this documentation component.
062:             */
063:            DocumentationType getBean() {
064:                return this .mBean;
065:            }
066:
067:            /**
068:             * Construct a Document component from the given XmlBean.
069:             * 
070:             * @param bean   The XmlBean for this document component.
071:             * @param parent The parent for which this component serves as 
072:             *               documentation.
073:             * @param defs   The container for this component.
074:             */
075:            private DocumentImpl(DocumentationType bean,
076:                    ExtensibleDocumentedComponent parent, DescriptionImpl defs) {
077:                this .mBean = bean;
078:                this .mParent = parent;
079:                this .mContainer = defs;
080:            }
081:
082:            /**
083:             * Get DOM document fragment containing documentation.
084:             *
085:             * @return DOM document fragment containing documentation
086:             */
087:            public DocumentFragment getDocumentation() {
088:                XmlOptions opts = new XmlOptions().setSaveOuter()
089:                        .setSaveAggresiveNamespaces();
090:                DocumentFragment result = (DocumentFragment) getBean()
091:                        .newDomNode(opts);
092:
093:                return result;
094:            }
095:
096:            /**
097:             * Set DOM element containing documentation.
098:             *
099:             * @param theDocumentFragment DOM element containing documentation
100:             */
101:            public void setDocumentation(DocumentFragment theDocumentFragment) {
102:                if (theDocumentFragment != null) {
103:                    DocumentationType newBean = null;
104:
105:                    try {
106:                        newBean = DocumentationType.Factory
107:                                .parse(theDocumentFragment);
108:                    } catch (XmlException ex) {
109:                        ; //  Keep checkstyle happy.
110:
111:                        //  Retry after wrapping the fragment in a documentation element
112:                        //  (below).
113:                    }
114:
115:                    if (newBean == null) {
116:                        //  Try wrapping in a wsdl documentation element.
117:                        org.w3c.dom.Document doc = theDocumentFragment
118:                                .getOwnerDocument();
119:                        Element elm = doc.createElementNS(
120:                                Constants.WSDL_NAMESPACE_NAME, "documentation");
121:                        elm.appendChild(theDocumentFragment);
122:
123:                        try {
124:                            newBean = DocumentationType.Factory.parse(elm);
125:                        } catch (XmlException ex) {
126:                            System.err
127:                                    .println("Error parsing documentation fragment");
128:                            System.err.println(ex.getMessage());
129:                            System.err.println(ex.getError().toString());
130:                            ex.printStackTrace(System.err);
131:                        }
132:
133:                    }
134:
135:                    if (newBean != null) {
136:                        DocumentationType oldBean = getBean();
137:                        Map map = mContainer.getDocumentMap();
138:
139:                        synchronized (map) {
140:                            map.put(newBean, map.remove(oldBean));
141:
142:                            DocumentationType[] docTypeArray = mParent
143:                                    .getExBean().getDocumentationArray();
144:                            ArrayList theList = new ArrayList();
145:                            if (docTypeArray != null) {
146:                                for (int i = 0; i < docTypeArray.length; ++i) {
147:                                    theList.add(i, docTypeArray[i]);
148:                                }
149:                            }
150:
151:                            int theIndex = theList.indexOf(oldBean);
152:                            if (theIndex != -1)
153:                                theList.set(theIndex, newBean);
154:                            else
155:                                theList.add(newBean);
156:
157:                            mParent.getExBean().setDocumentationArray(
158:                                    (DocumentationType[]) theList.toArray());
159:                        }
160:                    }
161:                }
162:                return; // $$TODO -- need to verify insertion point of theDocumentFragment 
163:            }
164:
165:            /**
166:             * A factory class for creating / finding components for given XML beans.
167:             * <p>
168:             * This factory guarantees that there will only be one component for each
169:             * XML bean instance.
170:             */
171:            static class Factory {
172:                /**
173:                 * Find the WSDL documentation component associated with the given XML
174:                 * bean, creating a new component if necessary.
175:                 * <p>
176:                 * This is thread-safe.<p>
177:                 * 
178:                 * @param bean   The XML bean to find the component for.
179:                 * @param parent The parent for which this component serves as 
180:                 *               documentation.
181:                 * @param defs   The container for the component.
182:                 * @return The WSDL documentation component for the given <code>bean</code>
183:                 *         (null if the <code>bean</code> is null).
184:                 */
185:                static DocumentImpl getInstance(DocumentationType bean,
186:                        ExtensibleDocumentedComponent parent,
187:                        DescriptionImpl defs) {
188:                    DocumentImpl result;
189:
190:                    if (bean != null) {
191:                        Map map = defs.getDocumentMap();
192:
193:                        synchronized (map) {
194:                            result = (DocumentImpl) map.get(bean);
195:
196:                            if (result == null) {
197:                                result = new DocumentImpl(bean, parent, defs);
198:                                map.put(bean, result);
199:                            }
200:                        }
201:                    } else {
202:                        result = null;
203:                    }
204:
205:                    return result;
206:                }
207:            }
208:        }
209:
210:        // End-of-file: DocumentImpl.java
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.