KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > bussinessproxy > remote > RemoteInvocationHandler


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

15
16 package com.jdon.bussinessproxy.remote;
17
18 import java.lang.reflect.InvocationHandler JavaDoc;
19 import java.lang.reflect.Method JavaDoc;
20
21 import com.jdon.bussinessproxy.TargetMetaDef;
22 import com.jdon.bussinessproxy.remote.auth.Authenticator;
23 import com.jdon.bussinessproxy.remote.http.HttpClient;
24 import com.jdon.util.Debug;
25
26 public class RemoteInvocationHandler implements InvocationHandler JavaDoc {
27
28   private final static String JavaDoc module = RemoteInvocationHandler.class.getName();
29   private final static HttpClient httpClient = HttpClient.getInstance();
30
31   private TargetMetaDef targetMetaDef = null;
32
33   public RemoteInvocationHandler(TargetMetaDef targetMetaDef) {
34     this.targetMetaDef = targetMetaDef;
35   }
36
37   public Object JavaDoc invoke(Object JavaDoc p_proxy, Method JavaDoc method, Object JavaDoc[] args) throws
38       Throwable JavaDoc {
39     Debug.logVerbose("[JdonFramework]method:" + method.getName(), module);
40
41     if (method.getName().equals(Authenticator.AUTH_METHOD_NAME))
42       return httpClient.invokeAuth(args);
43     else
44        return httpClient.invoke(targetMetaDef, method, args);
45   }
46
47
48
49 }
50
Popular Tags