src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/ExtendedModelVisitor.java

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/ExtendedModelVisitor.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,138 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.internal.ws.processor.model;
    1.30 +
    1.31 +import java.util.Iterator;
    1.32 +
    1.33 +/**
    1.34 + *
    1.35 + * A model visitor incorporating all the logic required to walk through the model.
    1.36 + *
    1.37 + * @author WS Development Team
    1.38 + */
    1.39 +public class ExtendedModelVisitor {
    1.40 +
    1.41 +    public ExtendedModelVisitor() {}
    1.42 +
    1.43 +    public void visit(Model model) throws Exception {
    1.44 +        preVisit(model);
    1.45 +        for (Service service : model.getServices()) {
    1.46 +            preVisit(service);
    1.47 +            for (Port port : service.getPorts()) {
    1.48 +                preVisit(port);
    1.49 +                if (shouldVisit(port)) {
    1.50 +                    for (Operation operation : port.getOperations()) {
    1.51 +                        preVisit(operation);
    1.52 +                        Request request = operation.getRequest();
    1.53 +                        if (request != null) {
    1.54 +                            preVisit(request);
    1.55 +                            for (Iterator iter4 = request.getHeaderBlocks();
    1.56 +                                iter4.hasNext();) {
    1.57 +
    1.58 +                                Block block = (Block) iter4.next();
    1.59 +                                visitHeaderBlock(block);
    1.60 +                            }
    1.61 +                            for (Iterator iter4 = request.getBodyBlocks();
    1.62 +                                iter4.hasNext();) {
    1.63 +
    1.64 +                                Block block = (Block) iter4.next();
    1.65 +                                visitBodyBlock(block);
    1.66 +                            }
    1.67 +                            for (Iterator iter4 = request.getParameters();
    1.68 +                                iter4.hasNext();) {
    1.69 +
    1.70 +                                Parameter parameter = (Parameter) iter4.next();
    1.71 +                                visit(parameter);
    1.72 +                            }
    1.73 +                            postVisit(request);
    1.74 +                        }
    1.75 +
    1.76 +                        Response response = operation.getResponse();
    1.77 +                        if (response != null) {
    1.78 +                            preVisit(response);
    1.79 +                            for (Iterator iter4 = response.getHeaderBlocks();
    1.80 +                                iter4.hasNext();) {
    1.81 +
    1.82 +                                Block block = (Block) iter4.next();
    1.83 +                                visitHeaderBlock(block);
    1.84 +                            }
    1.85 +                            for (Iterator iter4 = response.getBodyBlocks();
    1.86 +                                iter4.hasNext();) {
    1.87 +
    1.88 +                                Block block = (Block) iter4.next();
    1.89 +                                visitBodyBlock(block);
    1.90 +                            }
    1.91 +                            for (Iterator iter4 = response.getParameters();
    1.92 +                                iter4.hasNext();) {
    1.93 +
    1.94 +                                Parameter parameter = (Parameter) iter4.next();
    1.95 +                                visit(parameter);
    1.96 +                            }
    1.97 +                            postVisit(response);
    1.98 +                        }
    1.99 +
   1.100 +                        for (Iterator iter4 = operation.getFaults();
   1.101 +                            iter4.hasNext();) {
   1.102 +
   1.103 +                            Fault fault = (Fault) iter4.next();
   1.104 +                            preVisit(fault);
   1.105 +                            visitFaultBlock(fault.getBlock());
   1.106 +                            postVisit(fault);
   1.107 +                        }
   1.108 +                        postVisit(operation);
   1.109 +                    }
   1.110 +                }
   1.111 +                postVisit(port);
   1.112 +            }
   1.113 +            postVisit(service);
   1.114 +        }
   1.115 +        postVisit(model);
   1.116 +    }
   1.117 +
   1.118 +    protected boolean shouldVisit(Port port) {
   1.119 +        return true;
   1.120 +    }
   1.121 +
   1.122 +    // these methods are intended for subclasses
   1.123 +    protected void preVisit(Model model) throws Exception {}
   1.124 +    protected void postVisit(Model model) throws Exception {}
   1.125 +    protected void preVisit(Service service) throws Exception {}
   1.126 +    protected void postVisit(Service service) throws Exception {}
   1.127 +    protected void preVisit(Port port) throws Exception {}
   1.128 +    protected void postVisit(Port port) throws Exception {}
   1.129 +    protected void preVisit(Operation operation) throws Exception {}
   1.130 +    protected void postVisit(Operation operation) throws Exception {}
   1.131 +    protected void preVisit(Request request) throws Exception {}
   1.132 +    protected void postVisit(Request request) throws Exception {}
   1.133 +    protected void preVisit(Response response) throws Exception {}
   1.134 +    protected void postVisit(Response response) throws Exception {}
   1.135 +    protected void preVisit(Fault fault) throws Exception {}
   1.136 +    protected void postVisit(Fault fault) throws Exception {}
   1.137 +    protected void visitBodyBlock(Block block) throws Exception {}
   1.138 +    protected void visitHeaderBlock(Block block) throws Exception {}
   1.139 +    protected void visitFaultBlock(Block block) throws Exception {}
   1.140 +    protected void visit(Parameter parameter) throws Exception {}
   1.141 +}

mercurial