KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > client > ClientHandlerUtil


1 /*
2
3 * Copyright 1999-2004 The Apache Software Foundation.
4
5 *
6
7 * Licensed under the Apache License, Version 2.0 (the "License");
8
9 * you may not use this file except in compliance with the License.
10
11 * You may obtain a copy of the License at
12
13 *
14
15 * http://www.apache.org/licenses/LICENSE-2.0
16
17 *
18
19 * Unless required by applicable law or agreed to in writing, software
20
21 * distributed under the License is distributed on an "AS IS" BASIS,
22
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
25 * See the License for the specific language governing permissions and
26
27 * limitations under the License.
28
29 *
30
31 */

32
33 package org.apache.sandesha.client;
34
35
36 import org.apache.axis.Handler;
37 import org.apache.axis.SimpleChain;
38 import org.apache.axis.components.logger.LogFactory;
39 import org.apache.commons.logging.Log;
40
41 import java.util.Iterator JavaDoc;
42 import java.util.List JavaDoc;
43
44
45 /**
46  * This class is used to get a handler chain from a given
47  * <p/>
48  * array of handler names.
49  *
50  * @author Patrick Collins
51  */

52
53 public class ClientHandlerUtil {
54
55
56     private static final Log log = LogFactory.getLog(ClientHandlerUtil.class.getName());
57
58
59     public static SimpleChain getHandlerChain(List JavaDoc arr) {
60
61         SimpleChain reqHandlers = new SimpleChain();
62
63         Iterator JavaDoc it = arr.iterator();
64
65         boolean hasReqHandlers = false;
66
67         try {
68
69             while (it.hasNext()) {
70
71                 hasReqHandlers = true;
72
73                 String JavaDoc strClass = (String JavaDoc) it.next();
74
75                 Class JavaDoc c = Class.forName(strClass);
76
77                 Handler h = (Handler) c.newInstance();
78
79                 reqHandlers.addHandler(h);
80
81             }
82
83         } catch (Exception JavaDoc e) {
84
85             log.error(e);
86
87             return null;
88
89         }
90
91         if (hasReqHandlers)
92
93             return reqHandlers;
94
95         else
96
97             return null;
98
99     }
100
101
102 }
103
104
Popular Tags