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: import java.util.logging.Logger;
025:
026: import javax.xml.namespace.QName;
027:
028: import org.apache.cxf.common.i18n.Message;
029: import org.apache.cxf.common.logging.LogUtils;
030:
031: public class InterfaceInfo extends AbstractDescriptionElement {
032: private static final Logger LOG = LogUtils
033: .getL7dLogger(InterfaceInfo.class);
034:
035: QName name;
036: ServiceInfo service;
037:
038: Map<QName, OperationInfo> operations = new ConcurrentHashMap<QName, OperationInfo>(
039: 4);
040:
041: public InterfaceInfo(ServiceInfo info, QName q) {
042: name = q;
043: service = info;
044: info.setInterface(this );
045: }
046:
047: public ServiceInfo getService() {
048: return service;
049: }
050:
051: public void setName(QName n) {
052: name = n;
053: }
054:
055: public QName getName() {
056: return name;
057: }
058:
059: /**
060: * Adds an operation to this service.
061: *
062: * @param oname the qualified name of the operation.
063: * @return the operation.
064: */
065: public OperationInfo addOperation(QName oname) {
066: if (oname == null) {
067: throw new NullPointerException(new Message(
068: "OPERATION.NAME.NOT.NULL", LOG).toString());
069: }
070: if (operations.containsKey(oname)) {
071: throw new IllegalArgumentException(new Message(
072: "DUPLICATED.OPERATION.NAME", LOG,
073: new Object[] { oname }).toString());
074: }
075:
076: OperationInfo operation = new OperationInfo(this , oname);
077: addOperation(operation);
078: return operation;
079: }
080:
081: /**
082: * Adds an operation to this service.
083: *
084: * @param operation the operation.
085: */
086: void addOperation(OperationInfo operation) {
087: operations.put(operation.getName(), operation);
088: }
089:
090: /**
091: * Returns the operation info with the given name, if found.
092: *
093: * @param oname the name.
094: * @return the operation; or <code>null</code> if not found.
095: */
096: public OperationInfo getOperation(QName oname) {
097: return operations.get(oname);
098: }
099:
100: /**
101: * Returns all operations for this service.
102: *
103: * @return all operations.
104: */
105: public Collection<OperationInfo> getOperations() {
106: return Collections.unmodifiableCollection(operations.values());
107: }
108:
109: }
|