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: * @(#)BindingOperationImpl.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 javax.xml.namespace.QName;
034:
035: import org.w3.ns.wsdl.BindingOperationMessageType;
036: import org.w3.ns.wsdl.BindingOperationType;
037:
038: /**
039: * Implementation of WSDL 2.0 Binding Operation Component.
040: *
041: * @author Sun Microsystems, Inc.
042: */
043: final class BindingOperationImpl extends BindingOperation {
044: /** Container for this component */
045: private DescriptionImpl mContainer;
046:
047: /**
048: * Get the container for this component.
049: *
050: * @return The component for this component
051: */
052: protected DescriptionImpl getContainer() {
053: return this .mContainer;
054: }
055:
056: /**
057: * Construct a binding operation component implementation object from the
058: * given XML bean.
059: * @param type The binding operation XML bean to use to construct this
060: * component.
061: * @param defs Container for this component.
062: */
063: private BindingOperationImpl(BindingOperationType type,
064: DescriptionImpl defs) {
065: super (type);
066: this .mContainer = defs;
067: }
068:
069: /** Map of WSDL-defined attribute QNames. Keyed by QName.toString value */
070: private static java.util.Map sWsdlAttributeQNames = null;
071:
072: /**
073: * Worker class method for {@link #getWsdlAttributeNameMap()}.
074: *
075: * @return Map of WSDL-defined attribute QNames for this component,
076: * indexed by QName.toString()
077: */
078: static synchronized java.util.Map getAttributeNameMap() {
079: if (sWsdlAttributeQNames == null) {
080: sWsdlAttributeQNames = XmlBeansUtil
081: .getAttributesMap(BindingOperationType.type);
082: }
083:
084: return sWsdlAttributeQNames;
085: }
086:
087: /**
088: * Get map of WSDL-defined attribute QNames for this component, indexed by
089: * canonical QName string (see {@link javax.xml.namespace.QName#toString()}.
090: *
091: * @return Map of WSDL-defined attribute QNames for this component,
092: * indexed by QName.toString()
093: */
094: public java.util.Map getWsdlAttributeNameMap() {
095: return getAttributeNameMap();
096: }
097:
098: /**
099: * Get the qualified name of the Interface Operation being bound.
100: *
101: * @return Qualified name of the Interface Operation being bound
102: */
103: public QName getInterfaceOperation() {
104: return getBean().getRef();
105: }
106:
107: /**
108: * Set operation being bound.
109: *
110: * @param theInterfaceOperation Qualified name of the Interface Operation
111: * being bound
112: */
113: public void setInterfaceOperation(QName theInterfaceOperation) {
114: getBean().setRef(theInterfaceOperation);
115: }
116:
117: /**
118: * Get the number of BindingMessageReference items in inputs.
119: *
120: * @return The number of BindingMessageReference items in inputs
121: */
122: public int getInputsLength() {
123: return getBean().sizeOfInputArray();
124: }
125:
126: /**
127: * Get input binding message references by indexed position.
128: *
129: * @param index Indexed position value 0..length-1
130: * @return Input binding message references at given <code>index</code> position.
131: */
132: public com.sun.jbi.wsdl2.BindingMessageReference getInput(int index) {
133: return BindingMessageReferenceImpl.Factory.getInstance(
134: getBean().getInputArray(index), mContainer);
135: }
136:
137: /**
138: * Set input binding message references by indexed position.
139: *
140: * @param index Indexed position value (0..length-1) of the item to set
141: * @param theInput Item to add at position <code>index</code>.
142: */
143: public void setInput(int index,
144: com.sun.jbi.wsdl2.BindingMessageReference theInput) {
145: getBean()
146: .setInputArray(
147: index,
148: theInput != null ? ((BindingMessageReferenceImpl) theInput)
149: .getBean()
150: : null);
151: }
152:
153: /**
154: * Append an item to input binding message references.
155: *
156: * @param theInput Item to append to inputs
157: */
158: public void appendInput(
159: com.sun.jbi.wsdl2.BindingMessageReference theInput) {
160: final int length = getInputsLength();
161:
162: setInput(length, theInput);
163: }
164:
165: /**
166: * Remove input binding message references by index position.
167: *
168: * @param index The index position of the input to remove
169: * @return The BindingMessageReference removed, if any.
170: */
171: public com.sun.jbi.wsdl2.BindingMessageReference removeInput(
172: int index) {
173: com.sun.jbi.wsdl2.BindingMessageReference result = getInput(index);
174:
175: getBean().removeInput(index);
176:
177: return result;
178: }
179:
180: /**
181: * Get the number of BindingMessageReference items in outputs.
182: *
183: * @return The number of BindingMessageReference items in outputs
184: */
185: public int getOutputsLength() {
186: return getBean().sizeOfOutputArray();
187: }
188:
189: /**
190: * Get output binding message references by indexed position.
191: *
192: * @param index Indexed position value 0..length-1
193: * @return Output binding message references at given <code>index</code> position.
194: */
195: public com.sun.jbi.wsdl2.BindingMessageReference getOutput(int index) {
196: return BindingMessageReferenceImpl.Factory.getInstance(
197: getBean().getOutputArray(index), this .mContainer);
198: }
199:
200: /**
201: * Set output binding message references by indexed position.
202: *
203: * @param index Indexed position value (0..length-1) of the item to set
204: * @param theOutput Item to add at position <code>index</code>.
205: */
206: public void setOutput(int index,
207: com.sun.jbi.wsdl2.BindingMessageReference theOutput) {
208: getBean()
209: .setOutputArray(
210: index,
211: theOutput != null ? ((BindingMessageReferenceImpl) theOutput)
212: .getBean()
213: : null);
214: }
215:
216: /**
217: * Append an item to output binding message references.
218: *
219: * @param theOutput Item to append to outputs
220: */
221: public void appendOutput(
222: com.sun.jbi.wsdl2.BindingMessageReference theOutput) {
223: final int length = getOutputsLength();
224:
225: setOutput(length, theOutput);
226: }
227:
228: /**
229: * Remove output binding message references by index position.
230: *
231: * @param index The index position of the output to remove
232: * @return The BindingMessageReference removed, if any.
233: */
234: public com.sun.jbi.wsdl2.BindingMessageReference removeOutput(
235: int index) {
236: com.sun.jbi.wsdl2.BindingMessageReference result = getOutput(index);
237:
238: getBean().removeOutput(index);
239:
240: return result;
241: }
242:
243: /**
244: * Get the target namespace of this operation
245: *
246: * @return Target namespace of this operation
247: */
248: public String getTargetNamespace() {
249: return this .mContainer.getTargetNamespace();
250: }
251:
252: /**
253: * Create a new message reference for this operation, appending it to this
254: * operation's input list.
255: *
256: * @param messageLabel NC role name of the message for which binding details
257: * are provided
258: * @return The newly created input message reference, appended to this
259: * operation.
260: */
261: public com.sun.jbi.wsdl2.BindingMessageReference addNewInput(
262: String messageLabel) {
263: BindingOperationMessageType msgBean;
264:
265: synchronized (getBean().monitor()) {
266: msgBean = getBean().addNewInput();
267:
268: msgBean.setMessageLabel(messageLabel);
269: }
270:
271: return BindingMessageReferenceImpl.Factory.getInstance(msgBean,
272: mContainer);
273: }
274:
275: /**
276: * Create a new message reference for this operation, appending it this
277: * operation's output list.
278: *
279: * @param messageLabel NC role name of the message for which binding details
280: * are provided.
281: * @return The newly created output message reference, appended to this
282: * operation.
283: */
284: public com.sun.jbi.wsdl2.BindingMessageReference addNewOutput(
285: String messageLabel) {
286: BindingOperationMessageType msgBean;
287:
288: synchronized (getBean().monitor()) {
289: msgBean = getBean().addNewOutput();
290:
291: msgBean.setMessageLabel(messageLabel);
292: }
293:
294: return BindingMessageReferenceImpl.Factory.getInstance(msgBean,
295: mContainer);
296: }
297:
298: /**
299: * A factory class for creating / finding components for given XML beans.
300: * <p>
301: * This factory guarantees that there will only be one component for each
302: * XML bean instance.
303: */
304: static class Factory {
305: /**
306: * Find the binding operation component associated with the given XML
307: * bean, creating a new component if necessary.
308: * <p>
309: * This is thread-safe.<p>
310: *
311: * @param bean The XML bean to find the component for.
312: * @param defs The container for the component.
313: * @return The binding operation component for the given bean.
314: */
315: static BindingOperationImpl getInstance(
316: BindingOperationType bean, DescriptionImpl defs) {
317: BindingOperationImpl result;
318:
319: if (bean != null) {
320: Map map = defs.getBindingOperationMap();
321:
322: synchronized (map) {
323: result = (BindingOperationImpl) map.get(bean);
324:
325: if (result == null) {
326: result = new BindingOperationImpl(bean, defs);
327: map.put(bean, result);
328: }
329: }
330: } else {
331: result = null;
332: }
333:
334: return result;
335: }
336: }
337:
338: }
339:
340: // End-of-file: BindingOperationImpl.java
|