001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.servicemix.soap.core.model;
018
019 import java.util.Collection;
020 import java.util.HashMap;
021 import java.util.Map;
022
023 import javax.xml.namespace.QName;
024
025 import org.apache.servicemix.soap.api.InterceptorChain;
026 import org.apache.servicemix.soap.api.Message;
027 import org.apache.servicemix.soap.api.model.Binding;
028 import org.apache.servicemix.soap.api.model.Operation;
029 import org.apache.servicemix.soap.core.AbstractInterceptorProvider;
030 import org.apache.servicemix.soap.core.MessageImpl;
031 import org.apache.servicemix.soap.core.PhaseInterceptorChain;
032
033 /**
034 * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
035 */
036 public class AbstractBinding<T extends Operation> extends AbstractInterceptorProvider
037 implements Binding<T> {
038
039 private Map<QName, T> operations;
040 private String location;
041
042 public AbstractBinding() {
043 operations = new HashMap<QName, T>();
044 }
045
046 public Message createMessage() {
047 Message in = new MessageImpl();
048 in.put(Binding.class, this);
049 return in;
050 }
051
052 public Message createMessage(Message request) {
053 Message out = new MessageImpl();
054 out.put(Binding.class, this);
055 out.put(Operation.class, request.get(Operation.class));
056 return out;
057 }
058
059 public InterceptorChain getInterceptorChain(Phase phase) {
060 InterceptorChain chain = new PhaseInterceptorChain();
061 chain.add(getInterceptors(phase));
062 return chain;
063 }
064
065 public T getOperation(QName name) {
066 return operations.get(name);
067 }
068
069 public Collection<T> getOperations() {
070 return operations.values();
071 }
072
073 public void addOperation(T operation) {
074 operations.put(operation.getName(), operation);
075 }
076
077 /**
078 * @return the location
079 */
080 public String getLocation() {
081 return location;
082 }
083
084 /**
085 * @param location the location to set
086 */
087 public void setLocation(String location) {
088 this.location = location;
089 }
090
091 }