001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * 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, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.camel.component.cxf; 019 020 import org.apache.camel.Consumer; 021 import org.apache.camel.Processor; 022 import org.apache.camel.Producer; 023 import org.apache.camel.impl.DefaultEndpoint; 024 import org.apache.cxf.BusException; 025 import org.apache.cxf.message.Message; 026 import org.apache.cxf.service.model.EndpointInfo; 027 import org.apache.cxf.transport.local.LocalTransportFactory; 028 029 /** 030 * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Endpoint</a> 031 * 032 * @version $Revision: 550734 $ 033 */ 034 public class CxfEndpoint extends DefaultEndpoint<CxfExchange> { 035 private CxfBinding binding; 036 private final CxfComponent component; 037 private final EndpointInfo endpointInfo; 038 private boolean inOut = true; 039 040 public CxfEndpoint(String uri, CxfComponent component, EndpointInfo endpointInfo) { 041 super(uri, component); 042 this.component = component; 043 this.endpointInfo = endpointInfo; 044 } 045 046 public Producer<CxfExchange> createProducer() throws Exception { 047 return new CxfProducer(this, getLocalTransportFactory()); 048 } 049 050 public Consumer<CxfExchange> createConsumer(Processor processor) throws Exception { 051 return new CxfConsumer(this, processor, getLocalTransportFactory()); 052 } 053 054 public CxfExchange createExchange() { 055 return new CxfExchange(getContext(), getBinding()); 056 } 057 058 public CxfExchange createExchange(Message inMessage) { 059 return new CxfExchange(getContext(), getBinding(), inMessage); 060 } 061 062 public CxfBinding getBinding() { 063 if (binding == null) { 064 binding = new CxfBinding(); 065 } 066 return binding; 067 } 068 069 public void setBinding(CxfBinding binding) { 070 this.binding = binding; 071 } 072 073 public boolean isInOut() { 074 return inOut; 075 } 076 077 public void setInOut(boolean inOut) { 078 this.inOut = inOut; 079 } 080 081 public LocalTransportFactory getLocalTransportFactory() throws BusException { 082 return component.getLocalTransportFactory(); 083 } 084 085 public EndpointInfo getEndpointInfo() { 086 return endpointInfo; 087 } 088 089 public CxfComponent getComponent() { 090 return component; 091 } 092 093 public boolean isSingleton() { 094 return true; 095 } 096 097 }