1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
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 | package net.sourceforge.hiveremoting.caucho; |
16 | |
17 | import java.io.InputStream; |
18 | import java.io.OutputStream; |
19 | |
20 | import org.apache.commons.httpclient.HttpConnectionManager; |
21 | import org.apache.commons.logging.Log; |
22 | |
23 | import com.caucho.burlap.client.BurlapRuntimeException; |
24 | import com.caucho.burlap.io.BurlapInput; |
25 | import com.caucho.burlap.io.BurlapOutput; |
26 | import com.caucho.hessian.io.SerializerFactory; |
27 | |
28 | /** |
29 | * Dynamic proxy for Caucho Burlap protocol on client side. |
30 | * |
31 | * @author Jean-Francois Poilpret |
32 | */ |
33 | public class BurlapProxy extends AbstractCauchoProxy |
34 | { |
35 | public BurlapProxy( CauchoProxyContribution contrib, |
36 | SerializerFactory factory, |
37 | HttpConnectionManager cnxManager, |
38 | Log logger) |
39 | { |
40 | super(contrib, factory, cnxManager, logger); |
41 | } |
42 | |
43 | //CSOFF: IllegalThrowsCheck |
44 | @Override protected Object getReturnValue(InputStream is, Class type) |
45 | throws Throwable |
46 | { |
47 | BurlapInput in = new BurlapInput(is); |
48 | // Set special Serializer Factory |
49 | in.setSerializerFactory(_factory); |
50 | //####in.setRemoteResolver(getRemoteResolver()); |
51 | return in.readReply(type); |
52 | } |
53 | //CSON: IllegalThrowsCheck |
54 | |
55 | //CSOFF: IllegalThrowsCheck |
56 | @Override protected void callMethod(OutputStream os, String method, Object[] args) |
57 | throws Throwable |
58 | { |
59 | BurlapOutput out = new BurlapOutput(os); |
60 | // Set special Serializer Factory |
61 | out.setSerializerFactory(_factory); |
62 | out.call(method, args); |
63 | } |
64 | //CSON: IllegalThrowsCheck |
65 | |
66 | @Override protected RuntimeException createException(String message) |
67 | { |
68 | return new BurlapRuntimeException(message); |
69 | } |
70 | |
71 | @Override protected RuntimeException createException(Throwable cause) |
72 | { |
73 | return new BurlapRuntimeException(cause); |
74 | } |
75 | } |