KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > api > jaxws > project > config > HandlerChain


1
2 /*
3  * The contents of this file are subject to the terms of the Common Development
4  * and Distribution License (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 http://www.netbeans.org/cddl.html
8  * or http://www.netbeans.org/cddl.txt.
9  *
10  * When distributing Covered Code, include this CDDL Header Notice in each file
11  * and include the License file at http://www.netbeans.org/cddl.txt.
12  * If applicable, add the following below the CDDL Header, with the fields
13  * enclosed by brackets [] replaced by your own identifying information:
14  * "Portions Copyrighted [year] [name of copyright owner]"
15  *
16  * The Original Software is NetBeans. The Initial Developer of the Original
17  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
18  * Microsystems, Inc. All Rights Reserved.
19  */
/*
20  * HandlerChain.java
21  *
22  * Created on March 19, 2006, 9:02 AM
23  *
24  * To change this template, choose Tools | Template Manager
25  * and open the template in the editor.
26  */

27
28 package org.netbeans.modules.websvc.api.jaxws.project.config;
29
30 /**
31  *
32  * @author rico
33  */

34 public class HandlerChain {
35     private org.netbeans.modules.websvc.jaxwsmodel.handler_config1_0.HandlerChain chain;
36     /** Creates a new instance of HandlerChain */
37     public HandlerChain(org.netbeans.modules.websvc.jaxwsmodel.handler_config1_0.HandlerChain chain) {
38         this.chain=chain;
39     }
40     
41     Object JavaDoc getOriginal() {
42         return chain;
43     }
44     
45     public String JavaDoc getHandlerChainName() {
46         return chain.getHandlerChainName();
47     }
48     
49     public Handler[] getHandlers() {
50         org.netbeans.modules.websvc.jaxwsmodel.handler_config1_0.Handler[] handlers = chain.getHandler();
51         Handler[] newHandlers = new Handler[handlers.length];
52         for (int i=0;i<handlers.length;i++) {
53             newHandlers[i]=new Handler(handlers[i]);
54         }
55         return newHandlers;
56     }
57     
58     public void setHandlerChainName(String JavaDoc value) {
59         chain.setHandlerChainName(value);
60     }
61     
62     public Handler newHandler() {
63         org.netbeans.modules.websvc.jaxwsmodel.handler_config1_0.Handler handler = chain.newHandler();
64         return new Handler(handler);
65     }
66     
67     public void addHandler(String JavaDoc handlerName, String JavaDoc handlerClass) {
68         org.netbeans.modules.websvc.jaxwsmodel.handler_config1_0.Handler handler = chain.newHandler();
69         handler.setHandlerName(handlerName);
70         handler.setHandlerClass(handlerClass);
71         chain.addHandler(handler);
72     }
73     
74     public boolean removeHandler(String JavaDoc handlerNameOrClass) {
75         org.netbeans.modules.websvc.jaxwsmodel.handler_config1_0.Handler[] handlers = chain.getHandler();
76         for (int i=0;i<handlers.length;i++) {
77             if (handlerNameOrClass.equals(handlers[i].getHandlerName()) ||
78                     handlerNameOrClass.equals(handlers[i].getHandlerClass())) {
79                 chain.removeHandler(handlers[i]);
80                 return true;
81             }
82         }
83         return false;
84     }
85     
86     public Handler findHandlerByName(String JavaDoc handlerName) {
87         Handler[] handlers = getHandlers();
88         for (int i=0;i<handlers.length;i++) {
89             if (handlerName.equals(handlers[i].getHandlerName())) return handlers[i];
90         }
91         return null;
92     }
93 }
94
Popular Tags