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.service;
019:
020: import org.apache.cxf.service.model.FaultInfo;
021: import org.apache.cxf.service.model.InterfaceInfo;
022: import org.apache.cxf.service.model.MessageInfo;
023: import org.apache.cxf.service.model.MessagePartInfo;
024: import org.apache.cxf.service.model.OperationInfo;
025: import org.apache.cxf.service.model.ServiceInfo;
026: import org.apache.cxf.service.model.UnwrappedOperationInfo;
027:
028: /**
029: * Implements the Visitor pattern for the Service model.
030: *
031: */
032: public class ServiceModelVisitor {
033: protected ServiceInfo serviceInfo;
034:
035: public ServiceModelVisitor(ServiceInfo serviceInfo) {
036: super ();
037: this .serviceInfo = serviceInfo;
038: }
039:
040: public void walk() {
041: begin(serviceInfo);
042: begin(serviceInfo.getInterface());
043:
044: for (OperationInfo o : serviceInfo.getInterface()
045: .getOperations()) {
046: begin(o);
047:
048: visitOperation(o);
049:
050: end(o);
051: }
052:
053: end(serviceInfo);
054: }
055:
056: private void visitOperation(OperationInfo o) {
057: MessageInfo in = o.getInput();
058: if (in != null) {
059: begin(in);
060:
061: for (MessagePartInfo part : in.getMessageParts()) {
062: begin(part);
063: end(part);
064: }
065:
066: end(in);
067: }
068:
069: MessageInfo out = o.getOutput();
070: if (out != null) {
071: begin(out);
072:
073: for (MessagePartInfo part : out.getMessageParts()) {
074: begin(part);
075: end(part);
076: }
077:
078: end(out);
079: }
080:
081: for (FaultInfo f : o.getFaults()) {
082: begin(f);
083:
084: for (MessagePartInfo part : f.getMessageParts()) {
085: begin(part);
086: end(part);
087: }
088:
089: end(f);
090: }
091:
092: if (o.isUnwrappedCapable()) {
093: OperationInfo uop = o.getUnwrappedOperation();
094: begin(uop);
095: visitOperation(o.getUnwrappedOperation());
096: end(uop);
097: }
098: }
099:
100: public void begin(ServiceInfo service) {
101: }
102:
103: public void begin(InterfaceInfo intf) {
104: }
105:
106: public void begin(OperationInfo op) {
107: }
108:
109: public void begin(UnwrappedOperationInfo op) {
110: }
111:
112: public void begin(MessageInfo msg) {
113: }
114:
115: public void begin(MessagePartInfo part) {
116: }
117:
118: public void begin(FaultInfo fault) {
119: }
120:
121: public void end(ServiceInfo service) {
122: }
123:
124: public void end(InterfaceInfo intf) {
125: }
126:
127: public void end(OperationInfo op) {
128: }
129:
130: public void end(UnwrappedOperationInfo op) {
131: }
132:
133: public void end(MessageInfo msg) {
134: }
135:
136: public void end(MessagePartInfo part) {
137: }
138:
139: public void end(FaultInfo fault) {
140: }
141: }
|