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.cxf.feature;
018
019 import java.util.ArrayList;
020 import java.util.Collection;
021 import java.util.logging.Logger;
022
023 import org.apache.camel.component.cxf.interceptors.ConfigureDocLitWrapperInterceptor;
024 import org.apache.camel.component.cxf.interceptors.RemoveClassTypeInterceptor;
025 import org.apache.cxf.Bus;
026 import org.apache.cxf.common.logging.LogUtils;
027 import org.apache.cxf.endpoint.Client;
028 import org.apache.cxf.endpoint.Server;
029 import org.apache.cxf.interceptor.ClientFaultConverter;
030
031 /**
032 * This feature just setting up the CXF endpoint interceptor for handling the
033 * Message in PAYLOAD data format
034 */
035 public class PayLoadDataFormatFeature extends AbstractDataFormatFeature {
036 private static final Logger LOG = LogUtils.getL7dLogger(PayLoadDataFormatFeature.class);
037
038 private static final Collection<Class> REMOVING_FAULT_IN_INTERCEPTORS;
039
040
041 static {
042 REMOVING_FAULT_IN_INTERCEPTORS = new ArrayList<Class>();
043 REMOVING_FAULT_IN_INTERCEPTORS.add(ClientFaultConverter.class);
044 }
045
046 @Override
047 public void initialize(Client client, Bus bus) {
048 removeFaultInInterceptorFromClient(client);
049 client.getEndpoint().getBinding().getInInterceptors().add(new ConfigureDocLitWrapperInterceptor(true));
050 client.getEndpoint().getBinding().getInInterceptors().add(new RemoveClassTypeInterceptor());
051 }
052
053 @Override
054 public void initialize(Server server, Bus bus) {
055 server.getEndpoint().getBinding().getInInterceptors().add(new ConfigureDocLitWrapperInterceptor(true));
056 server.getEndpoint().getBinding().getInInterceptors().add(new RemoveClassTypeInterceptor());
057 }
058
059 @Override
060 protected Logger getLogger() {
061 return LOG;
062 }
063
064 private void removeFaultInInterceptorFromClient(Client client) {
065 removeInterceptors(client.getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
066 removeInterceptors(client.getEndpoint().getService().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
067 removeInterceptors(client.getEndpoint().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
068 removeInterceptors(client.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
069 }
070
071
072 }