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.camel.component.jetty;
018
019 import java.net.URI;
020 import java.net.URISyntaxException;
021 import java.util.List;
022
023 import org.apache.camel.Consumer;
024 import org.apache.camel.Processor;
025 import org.apache.camel.Producer;
026 import org.apache.camel.component.http.HttpConsumer;
027 import org.apache.camel.component.http.HttpEndpoint;
028 import org.eclipse.jetty.client.HttpClient;
029 import org.eclipse.jetty.server.Handler;
030
031 /**
032 * @version $Revision: 19763 $
033 */
034 public class JettyHttpEndpoint extends HttpEndpoint {
035
036 private boolean sessionSupport;
037 private List<Handler> handlers;
038 private HttpClient client;
039 private JettyHttpBinding jettyBinding;
040 private boolean enableJmx;
041
042 public JettyHttpEndpoint(JettyHttpComponent component, String uri, URI httpURL) throws URISyntaxException {
043 super(uri, component, httpURL);
044 }
045
046 @Override
047 public JettyHttpComponent getComponent() {
048 return (JettyHttpComponent) super.getComponent();
049 }
050
051 @Override
052 public Producer createProducer() throws Exception {
053 JettyHttpProducer answer = new JettyHttpProducer(this, getClient());
054 answer.setBinding(getJettyBinding());
055 return answer;
056 }
057
058 @Override
059 public Consumer createConsumer(Processor processor) throws Exception {
060 return new HttpConsumer(this, processor);
061 }
062
063 public void setSessionSupport(boolean support) {
064 sessionSupport = support;
065 }
066
067 public boolean isSessionSupport() {
068 return sessionSupport;
069 }
070
071 public List<Handler> getHandlers() {
072 return handlers;
073 }
074
075 public void setHandlers(List<Handler> handlers) {
076 this.handlers = handlers;
077 }
078
079 public HttpClient getClient() {
080 if (client == null) {
081 return getComponent().getHttpClient();
082 }
083 return client;
084 }
085
086 public void setClient(HttpClient client) {
087 this.client = client;
088 }
089
090 public synchronized JettyHttpBinding getJettyBinding() {
091 if (jettyBinding == null) {
092 jettyBinding = new DefaultJettyHttpBinding();
093 jettyBinding.setHeaderFilterStrategy(getHeaderFilterStrategy());
094 jettyBinding.setThrowExceptionOnFailure(isThrowExceptionOnFailure());
095 }
096 return jettyBinding;
097 }
098
099 public void setJettyBinding(JettyHttpBinding jettyBinding) {
100 this.jettyBinding = jettyBinding;
101 }
102
103 public boolean isEnableJmx() {
104 return this.enableJmx;
105 }
106
107 public void setEnableJmx(boolean enableJmx) {
108 this.enableJmx = enableJmx;
109 }
110 }