001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with 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,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.phase;
019:
020: import java.util.SortedSet;
021:
022: import org.apache.cxf.common.util.SortedArraySet;
023: import org.apache.cxf.extension.BusExtension;
024:
025: public class PhaseManagerImpl implements PhaseManager, BusExtension {
026:
027: private SortedSet<Phase> inPhases;
028: private SortedSet<Phase> outPhases;
029:
030: public PhaseManagerImpl() {
031: createInPhases();
032: createOutPhases();
033: }
034:
035: public PhaseManagerImpl(SortedSet<Phase> in, SortedSet<Phase> out) {
036: inPhases = in;
037: outPhases = out;
038: }
039:
040: public Class<?> getRegistrationType() {
041: return PhaseManager.class;
042: }
043:
044: public SortedSet<Phase> getInPhases() {
045: return inPhases;
046: }
047:
048: public SortedSet<Phase> getOutPhases() {
049: return outPhases;
050: }
051:
052: final void createInPhases() {
053: int i = 0;
054:
055: inPhases = new SortedArraySet<Phase>();
056: inPhases.add(new Phase(Phase.RECEIVE, ++i * 1000));
057: inPhases.add(new Phase(Phase.PRE_STREAM, ++i * 1000));
058: inPhases.add(new Phase(Phase.USER_STREAM, ++i * 1000));
059: inPhases.add(new Phase(Phase.POST_STREAM, ++i * 1000));
060: inPhases.add(new Phase(Phase.READ, ++i * 1000));
061: inPhases.add(new Phase(Phase.PRE_PROTOCOL, ++i * 1000));
062: inPhases.add(new Phase(Phase.USER_PROTOCOL, ++i * 1000));
063: inPhases.add(new Phase(Phase.POST_PROTOCOL, ++i * 1000));
064: inPhases.add(new Phase(Phase.UNMARSHAL, ++i * 1000));
065: inPhases.add(new Phase(Phase.PRE_LOGICAL, ++i * 1000));
066: inPhases.add(new Phase(Phase.USER_LOGICAL, ++i * 1000));
067: inPhases.add(new Phase(Phase.POST_LOGICAL, ++i * 1000));
068: inPhases.add(new Phase(Phase.PRE_INVOKE, ++i * 1000));
069: inPhases.add(new Phase(Phase.INVOKE, ++i * 1000));
070: inPhases.add(new Phase(Phase.POST_INVOKE, ++i * 1000));
071: }
072:
073: final void createOutPhases() {
074:
075: outPhases = new SortedArraySet<Phase>();
076: int i = 0;
077:
078: outPhases.add(new Phase(Phase.SETUP, ++i * 1000));
079: outPhases.add(new Phase(Phase.PRE_LOGICAL, ++i * 1000));
080: outPhases.add(new Phase(Phase.USER_LOGICAL, ++i * 1000));
081: outPhases.add(new Phase(Phase.POST_LOGICAL, ++i * 1000));
082: outPhases.add(new Phase(Phase.PREPARE_SEND, ++i * 1000));
083:
084: outPhases.add(new Phase(Phase.PRE_STREAM, ++i * 1000));
085:
086: outPhases.add(new Phase(Phase.PRE_PROTOCOL, ++i * 1000));
087:
088: outPhases.add(new Phase(Phase.WRITE, ++i * 1000));
089: outPhases.add(new Phase(Phase.PRE_MARSHAL, ++i * 1000));
090: outPhases.add(new Phase(Phase.MARSHAL, ++i * 1000));
091: outPhases.add(new Phase(Phase.POST_MARSHAL, ++i * 1000));
092:
093: outPhases.add(new Phase(Phase.USER_PROTOCOL, ++i * 1000));
094: outPhases.add(new Phase(Phase.POST_PROTOCOL, ++i * 1000));
095:
096: outPhases.add(new Phase(Phase.USER_STREAM, ++i * 1000));
097: outPhases.add(new Phase(Phase.POST_STREAM, ++i * 1000));
098:
099: outPhases.add(new Phase(Phase.SEND, ++i * 1000));
100:
101: //Make sure ending interceptors are put in positions symmetric
102: // to their starting interceptors
103: outPhases.add(new Phase(Phase.SEND_ENDING, ++i * 1000));
104:
105: outPhases.add(new Phase(Phase.POST_STREAM_ENDING, ++i * 1000));
106: outPhases.add(new Phase(Phase.USER_STREAM_ENDING, ++i * 1000));
107:
108: outPhases
109: .add(new Phase(Phase.POST_PROTOCOL_ENDING, ++i * 1000));
110: outPhases
111: .add(new Phase(Phase.USER_PROTOCOL_ENDING, ++i * 1000));
112:
113: outPhases.add(new Phase(Phase.MARSHAL_ENDING, ++i * 1000));
114: outPhases.add(new Phase(Phase.WRITE_ENDING, ++i * 1000));
115:
116: outPhases.add(new Phase(Phase.PRE_PROTOCOL_ENDING, ++i * 1000));
117:
118: outPhases.add(new Phase(Phase.PRE_STREAM_ENDING, ++i * 1000));
119:
120: outPhases.add(new Phase(Phase.PREPARE_SEND_ENDING, ++i * 1000));
121: outPhases.add(new Phase(Phase.POST_LOGICAL_ENDING, ++i * 1000));
122: outPhases.add(new Phase(Phase.USER_LOGICAL_ENDING, ++i * 1000));
123: outPhases.add(new Phase(Phase.PRE_LOGICAL_ENDING, ++i * 1000));
124: outPhases.add(new Phase(Phase.SETUP_ENDING, ++i * 1000));
125:
126: }
127:
128: }
|