01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.springframework.remoting.caucho;
18:
19: import org.springframework.aop.framework.ProxyFactory;
20: import org.springframework.beans.factory.BeanClassLoaderAware;
21: import org.springframework.beans.factory.FactoryBean;
22: import org.springframework.util.ClassUtils;
23:
24: /**
25: * FactoryBean for Hessian proxies. Exposes the proxied service for
26: * use as a bean reference, using the specified service interface.
27: *
28: * <p>Hessian is a slim, binary RPC protocol.
29: * For information on Hessian, see the
30: * <a href="http://www.caucho.com/hessian">Hessian website</a>
31: *
32: * <p>The service URL must be an HTTP URL exposing a Hessian service.
33: * For details, see the {@link HessianClientInterceptor} javadoc.
34: *
35: * @author Juergen Hoeller
36: * @since 13.05.2003
37: * @see #setServiceInterface
38: * @see #setServiceUrl
39: * @see HessianClientInterceptor
40: * @see HessianServiceExporter
41: * @see org.springframework.remoting.caucho.BurlapProxyFactoryBean
42: * @see org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean
43: * @see org.springframework.remoting.rmi.RmiProxyFactoryBean
44: */
45: public class HessianProxyFactoryBean extends HessianClientInterceptor
46: implements FactoryBean, BeanClassLoaderAware {
47:
48: private ClassLoader beanClassLoader = ClassUtils
49: .getDefaultClassLoader();
50:
51: private Object serviceProxy;
52:
53: public void setBeanClassLoader(ClassLoader classLoader) {
54: this .beanClassLoader = classLoader;
55: }
56:
57: public void afterPropertiesSet() {
58: super .afterPropertiesSet();
59: this .serviceProxy = new ProxyFactory(getServiceInterface(),
60: this ).getProxy(this .beanClassLoader);
61: }
62:
63: public Object getObject() {
64: return this .serviceProxy;
65: }
66:
67: public Class getObjectType() {
68: return getServiceInterface();
69: }
70:
71: public boolean isSingleton() {
72: return true;
73: }
74:
75: }
|