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;
019:
020: import java.util.ArrayList;
021: import java.util.HashMap;
022: import java.util.List;
023: import java.util.Map;
024: import java.util.concurrent.Executor;
025:
026: import javax.xml.namespace.QName;
027:
028: import org.apache.cxf.configuration.Configurable;
029: import org.apache.cxf.databinding.DataBinding;
030: import org.apache.cxf.endpoint.Endpoint;
031: import org.apache.cxf.interceptor.AbstractAttributedInterceptorProvider;
032: import org.apache.cxf.service.invoker.Invoker;
033: import org.apache.cxf.service.model.EndpointInfo;
034: import org.apache.cxf.service.model.ServiceInfo;
035: import org.apache.cxf.workqueue.SynchronousExecutor;
036:
037: public class ServiceImpl extends AbstractAttributedInterceptorProvider
038: implements Service, Configurable {
039: private List<ServiceInfo> serviceInfos;
040: private DataBinding dataBinding;
041: private Executor executor;
042: private Invoker invoker;
043: private Map<QName, Endpoint> endpoints = new HashMap<QName, Endpoint>();
044:
045: public ServiceImpl() {
046: this ((ServiceInfo) null);
047: }
048:
049: public ServiceImpl(ServiceInfo si) {
050: serviceInfos = new ArrayList<ServiceInfo>();
051: if (si != null) {
052: serviceInfos.add(si);
053: }
054: executor = SynchronousExecutor.getInstance();
055: }
056:
057: public ServiceImpl(List<ServiceInfo> si) {
058: serviceInfos = si;
059: executor = SynchronousExecutor.getInstance();
060: }
061:
062: public String getBeanName() {
063: return getName().toString();
064: }
065:
066: public QName getName() {
067: return serviceInfos.get(0).getName();
068: }
069:
070: public List<ServiceInfo> getServiceInfos() {
071: return serviceInfos;
072: }
073:
074: public EndpointInfo getEndpointInfo(QName endpoint) {
075: for (ServiceInfo inf : serviceInfos) {
076: EndpointInfo ef = inf.getEndpoint(endpoint);
077: if (ef != null) {
078: return ef;
079: }
080: }
081: return null;
082: }
083:
084: public Executor getExecutor() {
085: return executor;
086: }
087:
088: public void setExecutor(Executor executor) {
089: this .executor = executor;
090: }
091:
092: public Invoker getInvoker() {
093: return invoker;
094: }
095:
096: public void setInvoker(Invoker invoker) {
097: this .invoker = invoker;
098: }
099:
100: public DataBinding getDataBinding() {
101: return dataBinding;
102: }
103:
104: public void setDataBinding(DataBinding dataBinding) {
105: this .dataBinding = dataBinding;
106: }
107:
108: public Map<QName, Endpoint> getEndpoints() {
109: return endpoints;
110: }
111:
112: public void setEndpoints(Map<QName, Endpoint> endpoints) {
113: this .endpoints = endpoints;
114: }
115:
116: public void setProperties(Map<String, Object> properties) {
117: this.putAll(properties);
118: }
119: }
|