01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.cxfbc.interceptors;
18:
19: import org.apache.cxf.interceptor.AttachmentOutInterceptor;
20: import org.apache.cxf.interceptor.Fault;
21: import org.apache.cxf.message.Message;
22: import org.apache.cxf.phase.AbstractPhaseInterceptor;
23: import org.apache.cxf.phase.Phase;
24:
25: public class MtomCheckInterceptor extends
26: AbstractPhaseInterceptor<Message> {
27:
28: private boolean mtomEnabled;
29:
30: public MtomCheckInterceptor(boolean mtom) {
31: super (Phase.PRE_STREAM);
32: addBefore(AttachmentOutInterceptor.class.getName());
33: this .mtomEnabled = mtom;
34: }
35:
36: public void handleMessage(Message message) throws Fault {
37: if (message.getAttachments() != null
38: && message.getAttachments().size() > 0) {
39: message.put(org.apache.cxf.message.Message.MTOM_ENABLED,
40: mtomEnabled);
41: message.put("write.attachments", mtomEnabled);
42: }
43: }
44:
45: }
|