Source Code Cross Referenced for DescriptionImpl.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) 


0001:        /*
0002:         * BEGIN_HEADER - DO NOT EDIT
0003:         *
0004:         * The contents of this file are subject to the terms
0005:         * of the Common Development and Distribution License
0006:         * (the "License").  You may not use this file except
0007:         * in compliance with the License.
0008:         *
0009:         * You can obtain a copy of the license at
0010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0011:         * See the License for the specific language governing
0012:         * permissions and limitations under the License.
0013:         *
0014:         * When distributing Covered Code, include this CDDL
0015:         * HEADER in each file and include the License file at
0016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0017:         * If applicable add the following below this CDDL HEADER,
0018:         * with the fields enclosed by brackets "[]" replaced with
0019:         * your own identifying information: Portions Copyright
0020:         * [year] [name of copyright owner]
0021:         */
0022:
0023:        /*
0024:         * @(#)DescriptionImpl.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:        package com.sun.jbi.wsdl2.impl;
0030:
0031:        import java.io.StringWriter;
0032:
0033:        import java.lang.ref.WeakReference;
0034:
0035:        import java.util.Collections;
0036:        import java.util.HashMap;
0037:        import java.util.Map;
0038:        import java.util.WeakHashMap;
0039:
0040:        import javax.xml.namespace.QName;
0041:
0042:        import org.apache.xmlbeans.XmlOptions;
0043:
0044:        import org.w3.ns.wsdl.BindingType;
0045:        import org.w3.ns.wsdl.DescriptionDocument;
0046:        import org.w3.ns.wsdl.DescriptionType;
0047:        import org.w3.ns.wsdl.ImportType;
0048:        import org.w3.ns.wsdl.IncludeType;
0049:        import org.w3.ns.wsdl.InterfaceType;
0050:        import org.w3.ns.wsdl.ServiceType;
0051:
0052:        /**
0053:         * Implementation of WSDL 2.0 Description container.
0054:         * 
0055:         * @author Sun Microsystems, Inc.
0056:         */
0057:        final class DescriptionImpl extends Description {
0058:            /** The base URI for the document this wsdl:definitions component came from */
0059:            private String mDocumentBaseUri;
0060:
0061:            /** The document bean for this wsdl:definitions component */
0062:            private DescriptionDocument mDocBean;
0063:
0064:            /**
0065:             * Construct a definitions component implementation object from the given
0066:             * XML beans.
0067:             * 
0068:             * @param docBean         The Description XML bean to use to construct this
0069:             *                        component.
0070:             * @param documentBaseUri The base URI for the document this definitions
0071:             *                        component is based on.
0072:             */
0073:            private DescriptionImpl(DescriptionDocument docBean,
0074:                    String documentBaseUri) {
0075:                super (docBean.getDescription());
0076:                this .mDocumentBaseUri = documentBaseUri;
0077:                this .mDocBean = docBean;
0078:            }
0079:
0080:            /**
0081:             * Get the document bean for this component.
0082:             * 
0083:             * @return The document bean for this component.
0084:             */
0085:            DescriptionDocument getDocBean() {
0086:                return this .mDocBean;
0087:            }
0088:
0089:            /**
0090:             * Get the base document URI for this definitions component.
0091:             * 
0092:             * @return The base URI for the document this definitions component is associated
0093:             *         with.
0094:             */
0095:            public String getDocumentBaseUri() {
0096:                return this .mDocumentBaseUri;
0097:            }
0098:
0099:            /**
0100:             * Set the base document URI for this wsdl:definitions component.
0101:             * 
0102:             * @param theDocumentBaseUri The base document URI for this component
0103:             */
0104:            public void setDocumentBaseUri(String theDocumentBaseUri) {
0105:                if (theDocumentBaseUri != null) {
0106:                    this .mDocumentBaseUri = theDocumentBaseUri;
0107:
0108:                    // $TBD -- invalidate all import / include definitions loaded, if they
0109:                    //         use relative location URIs?
0110:                }
0111:            }
0112:
0113:            /** Map of WSDL-defined attribute QNames. Keyed by QName.toString value */
0114:            private static java.util.Map sWsdlAttributeQNames = null;
0115:
0116:            /** 
0117:             * Worker class-method for {@link #getWsdlAttributeNameMap()}.
0118:             * 
0119:             * @return Map of WSDL-defined attribute QNames for this component, 
0120:             *         indexed by QName.toString()
0121:             */
0122:            static synchronized java.util.Map getAttributeNameMap() {
0123:                if (sWsdlAttributeQNames == null) {
0124:                    sWsdlAttributeQNames = XmlBeansUtil
0125:                            .getAttributesMap(DescriptionType.type);
0126:                }
0127:
0128:                return sWsdlAttributeQNames;
0129:            }
0130:
0131:            /**
0132:             * Get map of WSDL-defined attribute QNames for this component, indexed by 
0133:             * canonical QName string (see {@link javax.xml.namespace.QName#toString()}.
0134:             *
0135:             * @return Map of WSDL-defined attribute QNames for this component, 
0136:             *         indexed by QName.toString()
0137:             */
0138:            public java.util.Map getWsdlAttributeNameMap() {
0139:                return getAttributeNameMap();
0140:            }
0141:
0142:            /**
0143:             * Get namespace for components in this container.
0144:             *
0145:             * @return Namespace for components in this container.
0146:             */
0147:            public String getTargetNamespace() {
0148:                return getBean().getTargetNamespace();
0149:            }
0150:
0151:            /**
0152:             * Set namespace for components in this container.
0153:             *
0154:             * @param theTargetNamespace Namespace for components in this container.
0155:             */
0156:            public void setTargetNamespace(String theTargetNamespace) {
0157:                getBean().setTargetNamespace(theTargetNamespace);
0158:            }
0159:
0160:            /**
0161:             * Get the number of Types items in types.
0162:             *
0163:             * @return The number of Types items in types
0164:             */
0165:            public int getTypesLength() {
0166:                return getBean().sizeOfTypesArray();
0167:            }
0168:
0169:            /**
0170:             * Get types (in schema or whatever) by indexed position.
0171:             *
0172:             * @param index Indexed position value 0..length-1
0173:             * @return Types (in schema or whatever) at given <code>index</code>
0174:             * position.
0175:             */
0176:            public com.sun.jbi.wsdl2.Types getType(int index) {
0177:                return TypesImpl.Factory.getInstance(getBean().getTypesArray(
0178:                        index), this );
0179:            }
0180:
0181:            /**
0182:             * Set types (in schema or whatever) by indexed position.
0183:             *
0184:             * @param index Indexed position value (0..length-1) of the item to set
0185:             * @param  theType Item to add at position <code>index</code>.
0186:             */
0187:            public void setType(int index, com.sun.jbi.wsdl2.Types theType) {
0188:                getBean().setTypesArray(
0189:                        index,
0190:                        theType != null ? ((TypesImpl) theType).getBean()
0191:                                : null);
0192:            }
0193:
0194:            /**
0195:             * Append an item to types (in schema or whatever).
0196:             *
0197:             * @param theType Item to append to types
0198:             */
0199:            public void appendType(com.sun.jbi.wsdl2.Types theType) {
0200:                synchronized (getBean().monitor()) {
0201:                    getBean().setTypesArray(
0202:                            getTypesLength(),
0203:                            theType != null ? ((TypesImpl) theType).getBean()
0204:                                    : null);
0205:                }
0206:            }
0207:
0208:            /**
0209:             * Remove types (in schema or whatever) by index position.
0210:             *
0211:             * @param index The index position of the type to remove
0212:             * @return The Types removed, if any.
0213:             */
0214:            public com.sun.jbi.wsdl2.Types removeType(int index) {
0215:                com.sun.jbi.wsdl2.Types result;
0216:
0217:                synchronized (getBean().monitor()) {
0218:                    result = getType(index);
0219:                    getBean().removeTypes(index);
0220:                }
0221:
0222:                return result;
0223:            }
0224:
0225:            /**
0226:             * Get the number of Import items in imports.
0227:             *
0228:             * @return The number of Import items in imports
0229:             */
0230:            public int getImportsLength() {
0231:                return getBean().sizeOfImportArray();
0232:            }
0233:
0234:            /**
0235:             * Get definitions imported into this container by indexed position.
0236:             *
0237:             * @param index Indexed position value 0..length-1
0238:             * @return Description imported into this container. at given <code>index</code> 
0239:             *         position.
0240:             */
0241:            public com.sun.jbi.wsdl2.Import getImport(int index) {
0242:                ImportType theImport = getBean().getImportArray(index);
0243:
0244:                return ImportImpl.Factory.getInstance(theImport, this );
0245:            }
0246:
0247:            /**
0248:             * Set definitions imported into this container, by indexed position.
0249:             *
0250:             * @param index Indexed position value (0..length-1) of the item to set
0251:             * @param  theImport Item to add at position <code>index</code>.
0252:             */
0253:            public void setImport(int index, com.sun.jbi.wsdl2.Import theImport) {
0254:                getBean().setImportArray(
0255:                        index,
0256:                        theImport != null ? ((Import) theImport).getBean()
0257:                                : null);
0258:            }
0259:
0260:            /**
0261:             * Append an item to definitions imported into this container.
0262:             *
0263:             * @param theImport Item to append to imports
0264:             */
0265:            public void appendImport(com.sun.jbi.wsdl2.Import theImport) {
0266:                final int nImports = this .getImportsLength();
0267:
0268:                setImport(nImports, theImport);
0269:            }
0270:
0271:            /**
0272:             * Remove definitions imported into this container, by index position.
0273:             *
0274:             * @param index The index position of the import to remove
0275:             * @return The Import removed, if any.
0276:             */
0277:            public com.sun.jbi.wsdl2.Import removeImport(int index) {
0278:                com.sun.jbi.wsdl2.Import result = this .getImport(index);
0279:
0280:                getBean().removeImport(index);
0281:
0282:                return result;
0283:            }
0284:
0285:            /**
0286:             * Get the number of Include items in includes.
0287:             *
0288:             * @return The number of Include items in includes
0289:             */
0290:            public int getIncludesLength() {
0291:                return getBean().sizeOfIncludeArray();
0292:            }
0293:
0294:            /**
0295:             * Get definitions included in this container, by indexed position.
0296:             *
0297:             * @param index Indexed position value 0..length-1
0298:             * @return Description included in this container. at given <code>index</code> 
0299:             *         position.
0300:             */
0301:            public com.sun.jbi.wsdl2.Include getInclude(int index) {
0302:                IncludeType type = getBean().getIncludeArray(index);
0303:
0304:                return IncludeImpl.Factory.getInstance(type, this );
0305:            }
0306:
0307:            /**
0308:             * Set definitions included in this container, by indexed position.
0309:             *
0310:             * @param index Indexed position value (0..length-1) of the item to set
0311:             * @param  theInclude Item to add at position <code>index</code>.
0312:             */
0313:            public void setInclude(int index,
0314:                    com.sun.jbi.wsdl2.Include theInclude) {
0315:                getBean().setIncludeArray(
0316:                        index,
0317:                        theInclude != null ? ((IncludeImpl) theInclude)
0318:                                .getBean() : null);
0319:            }
0320:
0321:            /**
0322:             * Append an item to definitions included in this container.
0323:             *
0324:             * @param theInclude Item to append to includes
0325:             */
0326:            public void appendInclude(com.sun.jbi.wsdl2.Include theInclude) {
0327:                final int length = getIncludesLength();
0328:
0329:                setInclude(length, theInclude);
0330:            }
0331:
0332:            /**
0333:             * Remove definitions included in this container, by index position.
0334:             *
0335:             * @param index The index position of the include to remove
0336:             * @return The Include removed, if any.
0337:             */
0338:            public com.sun.jbi.wsdl2.Include removeInclude(int index) {
0339:                com.sun.jbi.wsdl2.Include result = getInclude(index);
0340:
0341:                getBean().removeInclude(index);
0342:
0343:                return result;
0344:            }
0345:
0346:            /**
0347:             * Get the number of Interface items in interfaces.
0348:             *
0349:             * @return The number of Interface items in interfaces
0350:             */
0351:            public int getInterfacesLength() {
0352:                return getBean().sizeOfInterfaceArray();
0353:            }
0354:
0355:            /**
0356:             * Get interfaces for this component, by indexed position.
0357:             *
0358:             * @param index Indexed position value 0..length-1
0359:             * @return Interfaces for this component. at given <code>index</code> position.
0360:             */
0361:            public com.sun.jbi.wsdl2.Interface getInterface(int index) {
0362:                return InterfaceImpl.Factory.getInstance(getBean()
0363:                        .getInterfaceArray(index), this );
0364:            }
0365:
0366:            /**
0367:             * Set interfaces for this component, by indexed position.
0368:             *
0369:             * @param index Indexed position value (0..length-1) of the item to set
0370:             * @param  theInterface Item to add at position <code>index</code>.
0371:             */
0372:            public void setInterface(int index,
0373:                    com.sun.jbi.wsdl2.Interface theInterface) {
0374:                getBean().setInterfaceArray(
0375:                        index,
0376:                        theInterface != null ? ((Interface) theInterface)
0377:                                .getBean() : null);
0378:            }
0379:
0380:            /**
0381:             * Append an item to interfaces for this component.
0382:             *
0383:             * @param theInterface Item to append to interfaces
0384:             */
0385:            public void appendInterface(com.sun.jbi.wsdl2.Interface theInterface) {
0386:                final int length = getInterfacesLength();
0387:
0388:                setInterface(length, theInterface);
0389:            }
0390:
0391:            /**
0392:             * Remove interfaces for this component, by index position.
0393:             *
0394:             * @param index The index position of the interface to remove
0395:             * @return The Interface removed, if any.
0396:             */
0397:            public com.sun.jbi.wsdl2.Interface removeInterface(int index) {
0398:                com.sun.jbi.wsdl2.Interface result = getInterface(index);
0399:
0400:                getBean().removeInterface(index);
0401:
0402:                return result;
0403:            }
0404:
0405:            /**
0406:             * Get the number of Binding items in bindings.
0407:             *
0408:             * @return The number of Binding items in bindings
0409:             */
0410:            public int getBindingsLength() {
0411:                return getBean().sizeOfBindingArray();
0412:            }
0413:
0414:            /**
0415:             * Get bindings for this component, by indexed position.
0416:             *
0417:             * @param index Indexed position value 0..length-1
0418:             * @return Bindings for this component. at given <code>index</code> position.
0419:             */
0420:            public com.sun.jbi.wsdl2.Binding getBinding(int index) {
0421:                return BindingImpl.Factory.getInstance(getBean()
0422:                        .getBindingArray(index), this );
0423:            }
0424:
0425:            /**
0426:             * Set bindings for this component, by indexed position.
0427:             *
0428:             * @param index Indexed position value (0..length-1) of the item to set
0429:             * @param  theBinding Item to add at position <code>index</code>.
0430:             */
0431:            public void setBinding(int index,
0432:                    com.sun.jbi.wsdl2.Binding theBinding) {
0433:                getBean().setBindingArray(
0434:                        index,
0435:                        theBinding != null ? ((BindingImpl) theBinding)
0436:                                .getBean() : null);
0437:            }
0438:
0439:            /**
0440:             * Append an item to bindings for this component..
0441:             *
0442:             * @param theBinding Item to append to bindings
0443:             */
0444:            public void appendBinding(com.sun.jbi.wsdl2.Binding theBinding) {
0445:                final int length = getBindingsLength();
0446:
0447:                setBinding(length, theBinding);
0448:            }
0449:
0450:            /**
0451:             * Remove bindings for this component, by index position.
0452:             *
0453:             * @param index The index position of the binding to remove
0454:             * @return The Binding removed, if any.
0455:             */
0456:            public com.sun.jbi.wsdl2.Binding removeBinding(int index) {
0457:                com.sun.jbi.wsdl2.Binding result = getBinding(index);
0458:
0459:                getBean().removeBinding(index);
0460:
0461:                return result;
0462:            }
0463:
0464:            /**
0465:             * Get the number of Service items in services.
0466:             *
0467:             * @return The number of Service items in services
0468:             */
0469:            public int getServicesLength() {
0470:                return getBean().sizeOfServiceArray();
0471:            }
0472:
0473:            /**
0474:             * Get services for this component, by indexed position.
0475:             *
0476:             * @param index Indexed position value 0..length-1
0477:             * @return Services for this component. at given <code>index</code> position.
0478:             */
0479:            public com.sun.jbi.wsdl2.Service getService(int index) {
0480:                return ServiceImpl.Factory.getInstance(getBean()
0481:                        .getServiceArray(index), this );
0482:            }
0483:
0484:            /**
0485:             * Set services for this component, by indexed position.
0486:             *
0487:             * @param index Indexed position value (0..length-1) of the item to set
0488:             * @param  theService Item to add at position <code>index</code>.
0489:             */
0490:            public void setService(int index,
0491:                    com.sun.jbi.wsdl2.Service theService) {
0492:                getBean().setServiceArray(
0493:                        index,
0494:                        theService != null ? ((ServiceImpl) theService)
0495:                                .getBean() : null);
0496:            }
0497:
0498:            /**
0499:             * Append an item to services for this component..
0500:             *
0501:             * @param theService Item to append to services
0502:             */
0503:            public void appendService(com.sun.jbi.wsdl2.Service theService) {
0504:                final int length = getServicesLength();
0505:
0506:                setService(length, theService);
0507:            }
0508:
0509:            /**
0510:             * Remove services for this component, by index position.
0511:             *
0512:             * @param index The index position of the service to remove
0513:             * @return The Service removed, if any.
0514:             */
0515:            public com.sun.jbi.wsdl2.Service removeService(int index) {
0516:                com.sun.jbi.wsdl2.Service result = getService(index);
0517:
0518:                getBean().removeService(index);
0519:
0520:                return result;
0521:            }
0522:
0523:            /**
0524:             * Find named binding in this definition or the imported/included bindings.
0525:             * <p>
0526:             * This implementation assumes that the import/include structure does not
0527:             * introduce a circular search path.
0528:             * 
0529:             * @param name Name of binding to find.
0530:             * @return Named Binding; null if none found.
0531:             */
0532:            public com.sun.jbi.wsdl2.Binding findBinding(QName name) {
0533:                com.sun.jbi.wsdl2.Binding result = null;
0534:
0535:                if (name != null) {
0536:                    String namespace = name.getNamespaceURI();
0537:
0538:                    if (getTargetNamespace().equals(namespace)) {
0539:                        result = findLocalBinding(name.getLocalPart());
0540:                    }
0541:
0542:                    if (result == null && namespace == null) {
0543:                        result = findIncludedBinding(name);
0544:                    }
0545:
0546:                    if (result == null && namespace == null) {
0547:                        result = findImportedBinding(name);
0548:                    }
0549:                }
0550:
0551:                return result;
0552:            }
0553:
0554:            /**
0555:             * Find binding with given local name in the bindings from this definition
0556:             * only.
0557:             * 
0558:             * @param localName Local name of the binding to search for.
0559:             * @return Binding found matching the local name given; null if not found.
0560:             */
0561:            protected com.sun.jbi.wsdl2.Binding findLocalBinding(
0562:                    String localName) {
0563:                com.sun.jbi.wsdl2.Binding result = null;
0564:                BindingType[] bindings = getBean().getBindingArray();
0565:
0566:                for (int idx = 0; idx < bindings.length; idx++) {
0567:                    BindingType type = bindings[idx];
0568:
0569:                    if (type != null && localName.equals(type.getName())) {
0570:                        result = BindingImpl.Factory.getInstance(type, this );
0571:                    }
0572:                }
0573:
0574:                return result;
0575:            }
0576:
0577:            /**
0578:             * Find binding with given qualified name in the bindings included in 
0579:             * this defintions component.
0580:             * 
0581:             * @param name Qualified name of binding to look for
0582:             * @return Binding with given qualified name; null if not found
0583:             */
0584:            protected com.sun.jbi.wsdl2.Binding findIncludedBinding(QName name) {
0585:                com.sun.jbi.wsdl2.Binding result = null;
0586:                IncludeType[] imports = getBean().getIncludeArray();
0587:                final int nIncludes = imports != null ? imports.length : 0;
0588:                String tns = name.getNamespaceURI();
0589:
0590:                for (int idx = 0; result == null && idx < nIncludes; idx++) {
0591:                    IncludeType include = imports[idx];
0592:                    IncludeImpl includeImpl = IncludeImpl.Factory.getInstance(
0593:                            include, this );
0594:
0595:                    if (includeImpl != null) {
0596:                        DescriptionImpl defs = (DescriptionImpl) includeImpl
0597:                                .getDescription();
0598:
0599:                        result = defs != null ? defs.findBinding(name) : null;
0600:                    }
0601:                }
0602:
0603:                return result;
0604:            }
0605:
0606:            /**
0607:             * Find binding with given qualified name in the bindings imported in 
0608:             * this definitions component.
0609:             * 
0610:             * @param name Qualified name of binding to look for
0611:             * @return Binding with given qualified name; null if not found
0612:             */
0613:            protected com.sun.jbi.wsdl2.Binding findImportedBinding(QName name) {
0614:                com.sun.jbi.wsdl2.Binding result = null;
0615:                ImportType[] imports = getBean().getImportArray();
0616:                final int nImports = imports != null ? imports.length : 0;
0617:                String tns = name.getNamespaceURI();
0618:
0619:                for (int idx = 0; result == null && idx < nImports; idx++) {
0620:                    ImportType imp = imports[idx];
0621:                    ImportImpl impImpl = ImportImpl.Factory.getInstance(imp,
0622:                            this );
0623:
0624:                    if (impImpl != null && tns.equals(imp.getNamespace())) {
0625:                        DescriptionImpl defs = (DescriptionImpl) impImpl
0626:                                .getDescription();
0627:
0628:                        result = defs != null ? defs.findBinding(name) : null;
0629:                    }
0630:                }
0631:
0632:                return result;
0633:            }
0634:
0635:            /**
0636:             * Find named interface in this definition or the imported/included interfaces.
0637:             *
0638:             * @param name Name of interface to find.
0639:             * @return Named Interface; null if none found.
0640:             */
0641:            public com.sun.jbi.wsdl2.Interface findInterface(QName name) {
0642:                com.sun.jbi.wsdl2.Interface result = null;
0643:
0644:                if (name != null) {
0645:                    String namespace = name.getNamespaceURI();
0646:
0647:                    if (getTargetNamespace().equals(namespace)) {
0648:                        result = findLocalInterface(name.getLocalPart());
0649:                    }
0650:
0651:                    if (result == null && namespace != null) {
0652:                        result = findIncludedInterface(name);
0653:                    }
0654:
0655:                    if (result == null && namespace != null) {
0656:                        result = findImportedInterface(name);
0657:                    }
0658:                }
0659:
0660:                return result;
0661:            }
0662:
0663:            /**
0664:             * Find interface with given local name in the interfaces from this definition
0665:             * only.
0666:             * 
0667:             * @param localName Local name of the interface to search for.
0668:             * @return Interface found matching the local name given; null if not found.
0669:             */
0670:            protected com.sun.jbi.wsdl2.Interface findLocalInterface(
0671:                    String localName) {
0672:                com.sun.jbi.wsdl2.Interface result = null;
0673:                InterfaceType[] interfaces = getBean().getInterfaceArray();
0674:
0675:                for (int idx = 0; idx < interfaces.length; idx++) {
0676:                    InterfaceType type = interfaces[idx];
0677:
0678:                    if (type != null && localName.equals(type.getName())) {
0679:                        result = InterfaceImpl.Factory.getInstance(type, this );
0680:                    }
0681:                }
0682:
0683:                return result;
0684:            }
0685:
0686:            /**
0687:             * Find interface with given qualified name in the interfaces included in 
0688:             * this defintions component.
0689:             * 
0690:             * @param name Qualified name of interface to look for
0691:             * @return Interface with given qualified name; null if not found
0692:             */
0693:            protected com.sun.jbi.wsdl2.Interface findIncludedInterface(
0694:                    QName name) {
0695:                com.sun.jbi.wsdl2.Interface result = null;
0696:                IncludeType[] imports = getBean().getIncludeArray();
0697:                final int nIncludes = imports != null ? imports.length : 0;
0698:                String tns = name.getNamespaceURI();
0699:
0700:                for (int idx = 0; result == null && idx < nIncludes; idx++) {
0701:                    IncludeType include = imports[idx];
0702:                    IncludeImpl includeImpl = IncludeImpl.Factory.getInstance(
0703:                            include, this );
0704:
0705:                    if (includeImpl != null) {
0706:                        DescriptionImpl defs = (DescriptionImpl) includeImpl
0707:                                .getDescription();
0708:
0709:                        result = defs != null ? defs.findInterface(name) : null;
0710:                    }
0711:                }
0712:
0713:                return result;
0714:            }
0715:
0716:            /**
0717:             * Find interface with given qualified name in the interfaces imported in 
0718:             * this definitions component.
0719:             * 
0720:             * @param name Qualified name of interface to look for
0721:             * @return Interface with given qualified name; null if not found
0722:             */
0723:            protected com.sun.jbi.wsdl2.Interface findImportedInterface(
0724:                    QName name) {
0725:                com.sun.jbi.wsdl2.Interface result = null;
0726:                ImportType[] imports = getBean().getImportArray();
0727:                final int nImports = imports != null ? imports.length : 0;
0728:                String tns = name.getNamespaceURI();
0729:
0730:                for (int idx = 0; result == null && idx < nImports; idx++) {
0731:                    ImportType imp = imports[idx];
0732:                    ImportImpl impImpl = ImportImpl.Factory.getInstance(imp,
0733:                            this );
0734:
0735:                    if (impImpl != null && tns.equals(imp.getNamespace())) {
0736:                        DescriptionImpl defs = (DescriptionImpl) impImpl
0737:                                .getDescription();
0738:
0739:                        result = defs != null ? defs.findInterface(name) : null;
0740:                    }
0741:                }
0742:
0743:                return result;
0744:            }
0745:
0746:            /**
0747:             * Find named service in this definition or the imported/included services.
0748:             *
0749:             * @param name Name of service to find.
0750:             * @return Named Service; null if none found.
0751:             */
0752:            public com.sun.jbi.wsdl2.Service findService(QName name) {
0753:                com.sun.jbi.wsdl2.Service result = null;
0754:
0755:                if (name != null) {
0756:                    String namespace = name.getNamespaceURI();
0757:
0758:                    if (getTargetNamespace().equals(namespace)) {
0759:                        result = findLocalService(name.getLocalPart());
0760:                    }
0761:
0762:                    if (result == null && namespace != null) {
0763:                        result = findIncludedService(name);
0764:                    }
0765:
0766:                    if (result == null && namespace != null) {
0767:                        result = findImportedService(name);
0768:                    }
0769:                }
0770:
0771:                return result;
0772:            }
0773:
0774:            /**
0775:             * Find interface with given local name in the interfaces from this definition
0776:             * only.
0777:             * 
0778:             * @param localName Local name of the interface to search for.
0779:             * @return Service found matching the local name given; null if not found.
0780:             */
0781:            protected com.sun.jbi.wsdl2.Service findLocalService(
0782:                    String localName) {
0783:                com.sun.jbi.wsdl2.Service result = null;
0784:                ServiceType[] interfaces = getBean().getServiceArray();
0785:
0786:                for (int idx = 0; idx < interfaces.length; idx++) {
0787:                    ServiceType type = interfaces[idx];
0788:
0789:                    if (type != null && localName.equals(type.getName())) {
0790:                        result = ServiceImpl.Factory.getInstance(type, this );
0791:                    }
0792:                }
0793:
0794:                return result;
0795:            }
0796:
0797:            /**
0798:             * Find interface with given qualified name in the interfaces included in 
0799:             * this defintions component.
0800:             * 
0801:             * @param name Qualified name of interface to look for
0802:             * @return Service with given qualified name; null if not found
0803:             */
0804:            protected com.sun.jbi.wsdl2.Service findIncludedService(QName name) {
0805:                com.sun.jbi.wsdl2.Service result = null;
0806:                IncludeType[] imports = getBean().getIncludeArray();
0807:                final int nIncludes = imports != null ? imports.length : 0;
0808:                String tns = name.getNamespaceURI();
0809:
0810:                for (int idx = 0; result == null && idx < nIncludes; idx++) {
0811:                    IncludeType include = imports[idx];
0812:                    IncludeImpl includeImpl = IncludeImpl.Factory.getInstance(
0813:                            include, this );
0814:
0815:                    if (includeImpl != null) {
0816:                        DescriptionImpl defs = (DescriptionImpl) includeImpl
0817:                                .getDescription();
0818:
0819:                        result = defs != null ? defs.findService(name) : null;
0820:                    }
0821:                }
0822:
0823:                return result;
0824:            }
0825:
0826:            /**
0827:             * Find an interface with given qualified name in the interfaces imported in 
0828:             * this definitions component.
0829:             * 
0830:             * @param name Qualified name of interface to look for
0831:             * @return Service with given qualified name; null if not found
0832:             */
0833:            protected com.sun.jbi.wsdl2.Service findImportedService(QName name) {
0834:                com.sun.jbi.wsdl2.Service result = null;
0835:                ImportType[] imports = getBean().getImportArray();
0836:                final int nImports = imports != null ? imports.length : 0;
0837:                String tns = name.getNamespaceURI();
0838:
0839:                for (int idx = 0; result == null && idx < nImports; idx++) {
0840:                    ImportType imp = imports[idx];
0841:                    ImportImpl impImpl = ImportImpl.Factory.getInstance(imp,
0842:                            this );
0843:
0844:                    if (impImpl != null && tns.equals(imp.getNamespace())) {
0845:                        DescriptionImpl defs = (DescriptionImpl) impImpl
0846:                                .getDescription();
0847:
0848:                        result = defs != null ? defs.findService(name) : null;
0849:                    }
0850:                }
0851:
0852:                return result;
0853:            }
0854:
0855:            /**
0856:             * Create a new binding component, appended to this definition's binding list.
0857:             *
0858:             * @param name Name of binding to create.
0859:             * @return Newly created binding, appended to the bindings list.
0860:             */
0861:            public com.sun.jbi.wsdl2.Binding addNewBinding(String name) {
0862:                BindingType bindingBean = getBean().addNewBinding();
0863:
0864:                bindingBean.setName(name);
0865:
0866:                return BindingImpl.Factory.getInstance(bindingBean, this );
0867:            }
0868:
0869:            /**
0870:             * Create a new import component, appended to this definition's import list.
0871:             *
0872:             * @return Newly created import, appended to the imports list.
0873:             */
0874:            public com.sun.jbi.wsdl2.Import addNewImport() {
0875:                return ImportImpl.Factory.getInstance(getBean().addNewImport(),
0876:                        this );
0877:            }
0878:
0879:            /**
0880:             * Create a new include, appended to this definition's include list.
0881:             *
0882:             * @return Newly created include, appended to the includes list.
0883:             */
0884:            public com.sun.jbi.wsdl2.Include addNewInclude() {
0885:                return IncludeImpl.Factory.getInstance(getBean()
0886:                        .addNewInclude(), this );
0887:            }
0888:
0889:            /**
0890:             * Create a new interface component, appended to this definition's interface list.
0891:             *
0892:             * @param name Name of interface to create.
0893:             * @return Newly created interface, appended to interfaces list.
0894:             */
0895:            public com.sun.jbi.wsdl2.Interface addNewInterface(String name) {
0896:                InterfaceType ifaceBean = getBean().addNewInterface();
0897:
0898:                ifaceBean.setName(name);
0899:
0900:                return InterfaceImpl.Factory.getInstance(ifaceBean, this );
0901:            }
0902:
0903:            /**
0904:             * Create a new service component, appended to this definition's service list.
0905:             *
0906:             * @param name Name of service to create.
0907:             * @return Newly created service, appended to the services list.
0908:             */
0909:            public com.sun.jbi.wsdl2.Service addNewService(String name) {
0910:                ServiceType serviceBean = getBean().addNewService();
0911:
0912:                serviceBean.setName(name);
0913:
0914:                return ServiceImpl.Factory.getInstance(serviceBean, this );
0915:            }
0916:
0917:            /**
0918:             * Create a new types component, replacing the existing types component of 
0919:             * this definition, if necessary.
0920:             *
0921:             * @return Newly created Types component.
0922:             */
0923:            public com.sun.jbi.wsdl2.Types newTypes() {
0924:                return TypesImpl.Factory.getInstance(getBean().addNewTypes(),
0925:                        this );
0926:            }
0927:
0928:            /*
0929:             * The following maps are used to map XML Bean instances (of various types)
0930:             * to component objects. These maps are used by the component factories.
0931:             */
0932:            /** Map of known BindingType beans to Binding components */
0933:            private final Map mBindingMap = new HashMap();
0934:
0935:            /**
0936:             * Get the BindingType to BindingImpl object map for this definitions
0937:             * component.
0938:             * 
0939:             * @return The binding map for this definition.
0940:             */
0941:            public Map getBindingMap() {
0942:                return this .mBindingMap;
0943:            }
0944:
0945:            /** Map of known BindingFaultType beans to BindingFault components */
0946:            private final Map mBindingFaultMap = new HashMap();
0947:
0948:            /**
0949:             * Get the BindingFaultType to BindingFaultImpl object map for this 
0950:             * definitions component.
0951:             * 
0952:             * @return The binding fault map for this definition.
0953:             */
0954:            public Map getBindingFaultMap() {
0955:                return this .mBindingFaultMap;
0956:            }
0957:
0958:            /** 
0959:             * Map of known BindingFaultType beans to BindingFaultReference 
0960:             * components 
0961:             */
0962:            private final Map mBindingFaultReferenceMap = new HashMap();
0963:
0964:            /**
0965:             * Get the BindingFaultType to BindingFaultReferenceImpl map 
0966:             * for this definitions component.
0967:             * 
0968:             * @return The Binding Fault Reference map for this definition.
0969:             */
0970:            public Map getBindingFaultReferenceMap() {
0971:                return this .mBindingFaultReferenceMap;
0972:            }
0973:
0974:            /**
0975:             * Map of known BindingOperationFaultType beans to BindingOperationFault
0976:             * components
0977:             */
0978:            private final Map mBindingOperationFaultMap = new HashMap();
0979:
0980:            /**
0981:             * Get the BindingOperationFault to BindingOperationFaultImpl map
0982:             * for this definitions component.
0983:             *
0984:             * @return The Binding Operation Fault map for this definition.
0985:             */
0986:            public Map getBindingOperationFaultMap() {
0987:                return this .mBindingOperationFaultMap;
0988:            }
0989:
0990:            /** 
0991:             * Map of known BindingOperationMessageType beans to 
0992:             * BindingMessageReferenceImpl components.
0993:             */
0994:            private final Map mBindingMessageReferenceMap = new HashMap();
0995:
0996:            /**
0997:             * Get the BindingOperationMessageType to BindingMessageReferenceImpl
0998:             * map for this definitions component.
0999:             * 
1000:             * @return The Binding Operation Message Type map for this definition.
1001:             */
1002:            public Map getBindingMessageReferenceMap() {
1003:                return this .mBindingMessageReferenceMap;
1004:            }
1005:
1006:            /** 
1007:             * Map of known BindingOperationType beans to BindingOperationImpl 
1008:             * components 
1009:             */
1010:            private final Map mBindingOperationMap = new HashMap();
1011:
1012:            /**
1013:             * Get the BindingOperationType to BindingOperationImpl map for this
1014:             * definitions component.
1015:             * 
1016:             * @return The Binding Operation map for this component.
1017:             */
1018:            public Map getBindingOperationMap() {
1019:                return this .mBindingOperationMap;
1020:            }
1021:
1022:            /** Map of known DocumentationType beans to DocumentImpl components */
1023:            private final Map mDocumentMap = new HashMap();
1024:
1025:            /**
1026:             * Get the DocumentationType to DocumentImpl map for this definitions
1027:             * component.
1028:             * 
1029:             * @return The Document map for this component.
1030:             */
1031:            public Map getDocumentMap() {
1032:                return this .mDocumentMap;
1033:            }
1034:
1035:            /** Map of known EndpointType beans to EndpointImpl components */
1036:            private final Map mEndpointMap = new HashMap();
1037:
1038:            /**
1039:             * Get the EndpointType to EndpointImpl map for this definitions
1040:             * component.
1041:             * 
1042:             * @return The Endpoint map for this component.
1043:             */
1044:            public Map getEndpointMap() {
1045:                return this .mEndpointMap;
1046:            }
1047:
1048:            /** Map of known ImportType beans to ImportImpl components */
1049:            private final Map mImportMap = new HashMap();
1050:
1051:            /**
1052:             * Get the ImportType to ImportImpl map for this definitions
1053:             * component.
1054:             * 
1055:             * @return The Import map for this component.
1056:             */
1057:            public Map getImportMap() {
1058:                return this .mImportMap;
1059:            }
1060:
1061:            /** Map of known IncludeType beans to IncludeImpl components */
1062:            private final Map mIncludeMap = new HashMap();
1063:
1064:            /**
1065:             * Get the IncludeType to IncludeImpl map for this definitions
1066:             * component.
1067:             * 
1068:             * @return The Include map for this component.
1069:             */
1070:            public Map getIncludeMap() {
1071:                return this .mIncludeMap;
1072:            }
1073:
1074:            /** Map of known InterfaceType beans to InterfaceImpl components */
1075:            private final Map mInterfaceMap = new HashMap();
1076:
1077:            /**
1078:             * Get the InterfaceType to InterfaceImpl map for this component.
1079:             * 
1080:             * @return The Interface map for this component.
1081:             */
1082:            public Map getInterfaceMap() {
1083:                return this .mInterfaceMap;
1084:            }
1085:
1086:            /** Map of known InterfaceFaultType beans to InterfaceFault components */
1087:            private final Map mInterfaceFaultMap = new HashMap();
1088:
1089:            /**
1090:             * Get the InterfaceFaultType to InterfaceFaultImpl object map for this 
1091:             * definitions component.
1092:             * 
1093:             * @return The interface fault map for this definition.
1094:             */
1095:            public Map getInterfaceFaultMap() {
1096:                return this .mInterfaceFaultMap;
1097:            }
1098:
1099:            /** 
1100:             * Map of known InterfaceOperationType beans to InterfaceOperationImpl 
1101:             * components 
1102:             * 
1103:             */
1104:            private final Map mInterfaceOperationMap = new HashMap();
1105:
1106:            /**
1107:             * Get the InterfaceOperationType to InterfaceOperationImpl map for
1108:             * this component.
1109:             * 
1110:             * @return The Interface Operation map for this component.
1111:             */
1112:            public Map getInterfaceOperationMap() {
1113:                return this .mInterfaceOperationMap;
1114:            }
1115:
1116:            /** 
1117:             * Map of known MessageRefFaultType beans to MessageFaultReferenceImpl 
1118:             * components 
1119:             */
1120:            private final Map mMessageFaultReferenceMap = new HashMap();
1121:
1122:            /**
1123:             * Get the MessageRefFaultType to MessageFaultReferenceImpl map for
1124:             * this component.
1125:             * 
1126:             * @return The Message Fault Reference map for this compoent.
1127:             */
1128:            public Map getMessageFaultReferenceMap() {
1129:                return this .mMessageFaultReferenceMap;
1130:            }
1131:
1132:            /** Map of known MessageRefType beans to MessageReferenceImpl components */
1133:            private final Map mMessageReferenceMap = new HashMap();
1134:
1135:            /**
1136:             * Get the MessageRefType to MessageReferenceImpl map for this
1137:             * component.
1138:             * 
1139:             * @return The Message Reference map for this component.
1140:             */
1141:            public Map getMessageReferenceMap() {
1142:                return this .mMessageReferenceMap;
1143:            }
1144:
1145:            /** Map of known ServiceType beans to ServiceImpl components */
1146:            private final Map mServiceMap = new HashMap();
1147:
1148:            /**
1149:             * Get the ServiceType to ServiceImpl map for this component.
1150:             * 
1151:             * @return The Service map for this component.
1152:             */
1153:            public Map getServiceMap() {
1154:                return this .mServiceMap;
1155:            }
1156:
1157:            /** Map of known TypesType beans to TypesImpl components */
1158:
1159:            private final Map mTypesMap = new HashMap();
1160:
1161:            /**
1162:             * Get the TypesType to TypesImpl map for this component.
1163:             * 
1164:             * @return The Types map for this component.
1165:             */
1166:            public Map getTypesMap() {
1167:                return this .mTypesMap;
1168:            }
1169:
1170:            /**
1171:             * Get the container for this component.
1172:             * 
1173:             * @return The component for this component
1174:             */
1175:            protected DescriptionImpl getContainer() {
1176:                return this ;
1177:            }
1178:
1179:            /**
1180:             * Return this WSDL definition as an XML string.
1181:             *
1182:             * @return This definition, serialized as an XML string.
1183:             */
1184:            public String toXmlString() {
1185:                String result;
1186:                StringWriter sw = new StringWriter();
1187:                XmlOptions options = new XmlOptions();
1188:
1189:                options.setSavePrettyPrint();
1190:                options
1191:                        .setSavePrettyPrintIndent(Constants.XML_PRETTY_PRINT_INDENT);
1192:                options.setSaveOuter();
1193:
1194:                try {
1195:                    getBean().save(sw, options);
1196:                    sw.close();
1197:                } catch (java.io.IOException ex) {
1198:                    sw.write("\n<!-- IO error: ");
1199:                    sw.write(ex.getMessage());
1200:                    sw.write("\n     Document truncated. -->\n");
1201:                    // $TODO: log error
1202:                }
1203:
1204:                return sw.getBuffer().toString();
1205:            }
1206:
1207:            /**
1208:             * Return this document as a DOM document.
1209:             *
1210:             * @return This definition, as a DOM document.
1211:             */
1212:            public org.w3c.dom.Document toXmlDocument() {
1213:                return (org.w3c.dom.Document) getDocBean().newDomNode();
1214:            }
1215:
1216:            /**
1217:             * This class serves as the external API for creating (or recalling)
1218:             * DescriptionImpl objects. This allows a simple caching mechanism that
1219:             * permits us to find the DescriptionImpl object associated with a
1220:             * particular XmlBeans WSDL Description object, maintaining a one-to-one
1221:             * relationship between the Impl object and the XML bean instance.
1222:             */
1223:            static class Factory {
1224:                /** 
1225:                 * The association map between all known DefinitionType objects (the key)
1226:                 * and the corresponding DescriptionImpl objects. This is a WeakHashMap
1227:                 * to permit reclamation of the definition by the GC. 
1228:                 */
1229:                private static Map sDescriptionMap = Collections
1230:                        .synchronizedMap(new WeakHashMap());
1231:
1232:                /**
1233:                 * Get (or create if necessary) the instance of DescriptionImpl that is 
1234:                 * associated with the given XML Bean object, <code>type</code>.
1235:                 * <p>
1236:                 * This is thread-safe.<p>
1237:                 * 
1238:                 * @param docBean         The XML Bean object to get the definitions 
1239:                 *                        component of.
1240:                 * @param documentBaseUri The base URI to be associated with the result when
1241:                 *                        handled as a document.
1242:                 * @return The definitions component implementation object for 
1243:                 *         the <code>bean</code> supplied.
1244:                 */
1245:                static DescriptionImpl getInstance(DescriptionDocument docBean,
1246:                        String documentBaseUri) {
1247:                    DescriptionImpl result = null;
1248:
1249:                    if (docBean != null) { //
1250:                        //  Since the values we put in the WeakHashMap have strong 
1251:                        //  references to the key, we must wrap the value in a weak 
1252:                        //  reference to allow the GC to reclaim old definitions out of
1253:                        //  our cache.
1254:                        //
1255:                        synchronized (sDescriptionMap) {
1256:                            WeakReference ref = (WeakReference) sDescriptionMap
1257:                                    .get(docBean);
1258:
1259:                            if (ref != null) {
1260:                                result = (DescriptionImpl) ref.get();
1261:                            }
1262:
1263:                            if (result == null) {
1264:                                result = new DescriptionImpl(docBean,
1265:                                        documentBaseUri);
1266:                                sDescriptionMap.put(docBean, new WeakReference(
1267:                                        result));
1268:                            }
1269:                        }
1270:                    }
1271:
1272:                    return result;
1273:                }
1274:
1275:                /**
1276:                 * Create a new definitions component implementation. This is for the 
1277:                 * programmatic creation of WSDL.
1278:                 * 
1279:                 * @param documentBaseUri The base URI to be associated with the result when
1280:                 *                        handled as a document.
1281:                 * @return A new definitions component implementation object.
1282:                 */
1283:                static DescriptionImpl newInstance(String documentBaseUri) {
1284:                    DescriptionDocument docBean = DescriptionDocument.Factory
1285:                            .newInstance();
1286:                    DescriptionType bean = docBean.addNewDescription();
1287:
1288:                    return getInstance(docBean, documentBaseUri);
1289:                }
1290:            } //  end inner class Factory
1291:        }
1292:
1293:        // End-of-file: DescriptionImpl.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.