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: * @(#)TypesImpl.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:
033: import org.w3.ns.wsdl.TypesType;
034:
035: /**
036: * Implementation of WSDL 2.0 type definitions component.
037: *
038: * @author Sun Microsystems, Inc.
039: */
040: final class TypesImpl extends Types {
041: /** Container for this Types component */
042: private DescriptionImpl mContainer;
043:
044: /**
045: * Construct a Types component implementation object from the given XML bean.
046: *
047: * @param bean The types XML bean to use to construct this component.
048: * @param container The container for this Types component.
049: */
050: private TypesImpl(TypesType bean, DescriptionImpl container) {
051: super (bean);
052:
053: this .mContainer = container;
054: }
055:
056: /** Map of WSDL-defined attribute QNames. Keyed by QName.toString value */
057: private static java.util.Map sWsdlAttributeQNames = null;
058:
059: /**
060: * Worker class method for {@link #getWsdlAttributeNameMap()}.
061: *
062: * @return Map of WSDL-defined attribute QNames for this component,
063: * indexed by QName.toString()
064: */
065: static synchronized java.util.Map getAttributeNameMap() {
066: if (sWsdlAttributeQNames == null) {
067: sWsdlAttributeQNames = XmlBeansUtil
068: .getAttributesMap(TypesType.type);
069: }
070:
071: return sWsdlAttributeQNames;
072: }
073:
074: /**
075: * Get map of WSDL-defined attribute QNames for this component, indexed by
076: * canonical QName string (see {@link javax.xml.namespace.QName#toString()}.
077: *
078: * @return Map of WSDL-defined attribute QNames for this component,
079: * indexed by QName.toString()
080: */
081: public java.util.Map getWsdlAttributeNameMap() {
082: return getAttributeNameMap();
083: }
084:
085: /**
086: * Get the container for this component.
087: *
088: * @return The component for this component
089: */
090: protected DescriptionImpl getContainer() {
091: return this .mContainer;
092: }
093:
094: /**
095: * A factory class for creating / finding components for given XML beans.
096: * <p>
097: * This factory guarantees that there will only be one component for each
098: * XML bean instance.
099: */
100: static class Factory {
101: /**
102: * Find the WSDL types component associated with the given XML
103: * bean, creating a new component if necessary.
104: * <p>
105: * We use a simple pattern to avoid serializing execution of this
106: * entire method. This is motivated by the observation that this method
107: * is more commonly executed in the case where the component exists than
108: * the case where a component needs to be created.
109: *
110: * @param bean The XML bean to find the component for.
111: * @param defs The container for the component.
112: * @return The WSDL types component for the given <code>bean</code>
113: * (null if the <code>bean</code> is null).
114: */
115: static TypesImpl getInstance(TypesType bean,
116: DescriptionImpl defs) {
117: TypesImpl result;
118:
119: if (bean != null) {
120: Map map = defs.getTypesMap();
121:
122: result = (TypesImpl) map.get(bean);
123:
124: if (result == null) {
125: synchronized (map) {
126: result = (TypesImpl) map.get(bean);
127:
128: if (result == null) {
129: result = new TypesImpl(bean, defs);
130: map.put(bean, result);
131: }
132: }
133: }
134: } else {
135: result = null;
136: }
137:
138: return result;
139: }
140: }
141: }
142:
143: // End-of-file: TypesImpl.java
|