KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > WebServiceHandlerChain


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment;
25
26 import java.util.LinkedList JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.List JavaDoc;
29
30 /**
31  * Represents a single handler-chains in a webservice in webservices.xml
32  */

33 public class WebServiceHandlerChain extends Descriptor {
34
35     // List of handlers associated with this endpoint.
36
// Handler order is important and must be preserved.
37
private LinkedList JavaDoc<WebServiceHandler> handlers;
38
39     private String JavaDoc protocolBinding = null;
40     private String JavaDoc serviceNamePattern = null;
41     private String JavaDoc portNamePattern = null;
42     
43     // copy constructor
44
public WebServiceHandlerChain(WebServiceHandlerChain other) {
45     super(other);
46         this.protocolBinding = other.protocolBinding;
47         this.serviceNamePattern = other.serviceNamePattern;
48         this.portNamePattern = other.portNamePattern;
49     if (other.handlers != null) {
50             handlers = new LinkedList JavaDoc();
51         for (Iterator JavaDoc i = other.handlers.iterator(); i.hasNext();) {
52         WebServiceHandler wsh = (WebServiceHandler)i.next();
53         handlers.addLast(new WebServiceHandler(wsh));
54         }
55     } else {
56         handlers = null;
57     }
58     }
59
60     public WebServiceHandlerChain() {
61         handlers = new LinkedList JavaDoc();
62     }
63
64     public void setProtocolBindings(String JavaDoc bindingId) {
65         protocolBinding = bindingId;
66         super.changed();
67     }
68     
69     public String JavaDoc getProtocolBindings() {
70         return protocolBinding;
71     }
72     
73     public void setServiceNamePattern(String JavaDoc pattern) {
74         serviceNamePattern = pattern;
75         super.changed();
76     }
77     
78     public String JavaDoc getServiceNamePattern() {
79         return serviceNamePattern;
80     }
81     
82     public void setPortNamePattern(String JavaDoc pattern) {
83         portNamePattern = pattern;
84         super.changed();
85     }
86     
87     public String JavaDoc getPortNamePattern() {
88         return portNamePattern;
89     }
90     
91     /**
92      *@return true if this endpoint has at least one handler in its
93      * handler chain.
94      */

95     public boolean hasHandlers() {
96         return ( handlers.size() > 0 );
97     }
98
99     /**
100      * Append handler to end of handler chain for this endpoint.
101      */

102     public void addHandler(WebServiceHandler handler) {
103         handlers.addLast(handler);
104         super.changed();
105     }
106
107     public void removeHandler(WebServiceHandler handler) {
108         handlers.remove(handler);
109         super.changed();
110     }
111
112     public void removeHandlerByName(String JavaDoc handlerName) {
113         for(Iterator JavaDoc iter = handlers.iterator(); iter.hasNext();) {
114             WebServiceHandler next = (WebServiceHandler) iter.next();
115             if( next.getHandlerName().equals(handlerName) ) {
116                 iter.remove();
117                 super.changed();
118                 break;
119             }
120         }
121     }
122
123     /**
124      * Get ordered list of WebServiceHandler handlers for this endpoint.
125      */

126     public List JavaDoc<WebServiceHandler> getHandlers() {
127         return handlers;
128     }
129 }
130
Popular Tags