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: */
019:
020: package org.apache.axis2.description;
021:
022: import org.apache.axis2.phaseresolver.PhaseException;
023:
024: import java.io.Serializable;
025:
026: /**
027: * Class PhaseRule
028: */
029: public class PhaseRule implements Serializable {
030:
031: /**
032: * Field after
033: */
034: private String after;
035:
036: /**
037: * Field before
038: */
039: private String before;
040:
041: /**
042: * Field phaseFirst
043: */
044: private boolean phaseFirst;
045:
046: /**
047: * Field phaseLast
048: */
049: private boolean phaseLast;
050:
051: /**
052: * Field phaseName
053: */
054: private String phaseName;
055:
056: /**
057: * Constructor PhaseRule.
058: */
059: public PhaseRule() {
060: }
061:
062: public PhaseRule(String phaseName) {
063: this .phaseName = phaseName;
064: }
065:
066: /**
067: * Method getAfter.
068: *
069: * @return Returns String.
070: */
071: public String getAfter() {
072: return after;
073: }
074:
075: /**
076: * Method getBefore.
077: *
078: * @return Returns String.
079: */
080: public String getBefore() {
081: return before;
082: }
083:
084: /**
085: * Method getPhaseName.
086: *
087: * @return Returns String.
088: */
089: public String getPhaseName() {
090: return phaseName;
091: }
092:
093: /**
094: * Method isPhaseFirst.
095: *
096: * @return Returns boolean.
097: */
098: public boolean isPhaseFirst() {
099: return phaseFirst;
100: }
101:
102: /**
103: * Method isPhaseLast.
104: *
105: * @return Returns boolean.
106: */
107: public boolean isPhaseLast() {
108: return phaseLast;
109: }
110:
111: /**
112: * Set the "after" name for this rule.
113: *
114: * @param after the name of the "after" handler
115: */
116: public void setAfter(String after) {
117: if ("".equals(after))
118: after = null;
119: this .after = after;
120: }
121:
122: /**
123: * Set the "before" name for this rule.
124: *
125: * @param before the name of the "before" handler
126: */
127: public void setBefore(String before) {
128: if ("".equals(before))
129: before = null;
130: this .before = before;
131: }
132:
133: /**
134: * Method setPhaseFirst.
135: *
136: * @param phaseFirst true if this rule defines the first Handler in a Phase
137: */
138: public void setPhaseFirst(boolean phaseFirst) {
139: this .phaseFirst = phaseFirst;
140: }
141:
142: /**
143: * Method setPhaseLast.
144: *
145: * @param phaseLast true if this rule defines the last Handler in a Phase
146: */
147: public void setPhaseLast(boolean phaseLast) {
148: this .phaseLast = phaseLast;
149: }
150:
151: /**
152: * Method setPhaseName.
153: *
154: * @param phaseName the name of the Phase
155: */
156: public void setPhaseName(String phaseName) {
157: this .phaseName = phaseName;
158: }
159:
160: /**
161: * Validate "sane" rules - cannot have both phaseFirst/phaseLast and before/after
162: *
163: * @throws PhaseException if phaseFirst/phaseLast is set along with before/after
164: */
165: public void validate() throws PhaseException {
166: if (before != null || after != null) {
167: if (phaseFirst) {
168: throw new PhaseException(
169: "Invalid PhaseRule (phaseFirst is set along with before/after)");
170: }
171: if (phaseLast) {
172: throw new PhaseException(
173: "Invalid PhaseRule (phaseLast is set along with before/after)");
174: }
175: }
176: }
177: }
|