KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > sandesha > server > DelegateInvokeHandler


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

17
18 package org.apache.sandesha.server;
19
20 import org.apache.axis.Handler;
21 import org.apache.axis.MessageContext;
22 import org.apache.axis.providers.java.RPCProvider;
23 import org.apache.sandesha.Constants;
24
25 import java.util.Collections JavaDoc;
26 import java.util.Map JavaDoc;
27
28 /**
29  * Use the configured handler or <code>org.apache.axis.providers.java.RPCProvider</code>
30  * <p/>
31  * if none was explicitly set to execute the web service invoke.
32  *
33  * @author Patrick Collins
34  */

35
36 public class DelegateInvokeHandler implements InvokeHandler {
37     private Map JavaDoc params = Collections.EMPTY_MAP;
38
39     public boolean handleInvoke(MessageContext aMessageContext) throws Exception JavaDoc {
40         Handler handler = (Handler) Class.forName(getActualInvoker()).newInstance();
41         handler.invoke(aMessageContext);
42         return aMessageContext.getOperation().getMethod().getReturnType() == Void.TYPE;
43     }
44
45     protected String JavaDoc getActualInvoker() {
46         String JavaDoc invoker = (String JavaDoc) getParms().get(Constants.INVOKER);
47         if (invoker == null || invoker.length() == 0) {
48             invoker = RPCProvider.class.getName();
49         }
50         return invoker;
51     }
52
53     protected Map JavaDoc getParms() {
54         return params;
55     }
56
57     public void addParams(Map JavaDoc aParams) {
58         if (aParams != null) {
59             params = aParams;
60         }
61     }
62 }
63
64
Popular Tags