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: */package org.apache.cxf.service.model;
019:
020: import java.util.Collection;
021: import java.util.Collections;
022: import java.util.Map;
023: import java.util.concurrent.ConcurrentHashMap;
024:
025: import javax.xml.namespace.QName;
026:
027: /**
028: *
029: */
030: public class BindingOperationInfo extends AbstractPropertiesHolder {
031:
032: protected OperationInfo opInfo;
033:
034: BindingInfo bindingInfo;
035:
036: BindingMessageInfo inputMessage;
037: BindingMessageInfo outputMessage;
038: Map<QName, BindingFaultInfo> faults;
039:
040: BindingOperationInfo opHolder;
041:
042: public BindingOperationInfo() {
043: }
044:
045: BindingOperationInfo(BindingInfo bi, OperationInfo opinfo) {
046: bindingInfo = bi;
047: opInfo = opinfo;
048:
049: if (opInfo.getInput() != null) {
050: inputMessage = new BindingMessageInfo(opInfo.getInput(),
051: this );
052: } else {
053: inputMessage = null;
054: }
055: if (opInfo.getOutput() != null) {
056: outputMessage = new BindingMessageInfo(opInfo.getOutput(),
057: this );
058: } else {
059: outputMessage = null;
060: }
061:
062: Collection<FaultInfo> of = opinfo.getFaults();
063: if (!of.isEmpty()) {
064: faults = new ConcurrentHashMap<QName, BindingFaultInfo>(of
065: .size());
066: for (FaultInfo fault : of) {
067: faults.put(fault.getFaultName(), new BindingFaultInfo(
068: fault, this ));
069: }
070: }
071:
072: if (opinfo.isUnwrappedCapable()) {
073: opHolder = new BindingOperationInfo(bi, opinfo
074: .getUnwrappedOperation(), this );
075: }
076: }
077:
078: BindingOperationInfo(BindingInfo bi, OperationInfo opinfo,
079: BindingOperationInfo wrapped) {
080: this (bi, opinfo);
081: opHolder = wrapped;
082: }
083:
084: public void updateUnwrappedOperation() {
085: if (opInfo.isUnwrappedCapable() && opHolder == null) {
086: opHolder = new BindingOperationInfo(bindingInfo, opInfo
087: .getUnwrappedOperation(), this );
088: }
089: }
090:
091: public BindingInfo getBinding() {
092: return bindingInfo;
093: }
094:
095: public QName getName() {
096: return opInfo.getName();
097: }
098:
099: public OperationInfo getOperationInfo() {
100: return opInfo;
101: }
102:
103: public BindingMessageInfo getInput() {
104: return inputMessage;
105: }
106:
107: public BindingMessageInfo getOutput() {
108: return outputMessage;
109: }
110:
111: public BindingFaultInfo getFault(QName name) {
112: if (faults != null) {
113: return faults.get(name);
114: }
115: return null;
116: }
117:
118: public Collection<BindingFaultInfo> getFaults() {
119: if (faults == null) {
120: return Collections.emptyList();
121: }
122: return Collections.unmodifiableCollection(faults.values());
123: }
124:
125: public boolean isUnwrappedCapable() {
126: return opInfo.isUnwrappedCapable();
127: }
128:
129: public BindingOperationInfo getUnwrappedOperation() {
130: return opHolder;
131: }
132:
133: public void setUnwrappedOperation(BindingOperationInfo op) {
134: opHolder = op;
135: }
136:
137: public boolean isUnwrapped() {
138: return opInfo.isUnwrapped();
139: }
140:
141: public BindingOperationInfo getWrappedOperation() {
142: return opHolder;
143: }
144:
145: @Override
146: public String toString() {
147: return new StringBuilder().append("[BindingOperationInfo: ")
148: .append(getName()).append("]").toString();
149: }
150:
151: }
|