01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.phase;
19:
20: import java.util.Set;
21:
22: import javax.xml.stream.XMLStreamReader;
23:
24: import org.apache.cxf.common.util.SortedArraySet;
25: import org.apache.cxf.message.Message;
26:
27: public abstract class AbstractPhaseInterceptor<T extends Message>
28: implements PhaseInterceptor<T> {
29: private final String id;
30: private final String phase;
31: private final Set<String> before = new SortedArraySet<String>();
32: private final Set<String> after = new SortedArraySet<String>();
33:
34: public AbstractPhaseInterceptor(String phase) {
35: this (null, phase);
36: }
37:
38: public AbstractPhaseInterceptor(String i, String p) {
39: super ();
40: id = i == null ? getClass().getName() : i;
41: phase = p;
42: }
43:
44: public void addBefore(String i) {
45: before.add(i);
46: }
47:
48: public void addAfter(String i) {
49: after.add(i);
50: }
51:
52: public final Set<String> getAfter() {
53: return after;
54: }
55:
56: public final Set<String> getBefore() {
57: return before;
58: }
59:
60: public final String getId() {
61: return id;
62: }
63:
64: public final String getPhase() {
65: return phase;
66: }
67:
68: public void handleFault(T message) {
69: }
70:
71: public boolean isGET(T message) {
72: String method = (String) message
73: .get(Message.HTTP_REQUEST_METHOD);
74: return "GET".equals(method)
75: && message.getContent(XMLStreamReader.class) == null;
76: }
77: }
|