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.httpinvoker;
18:
19: import org.springframework.aop.framework.ProxyFactory;
20: import org.springframework.beans.factory.FactoryBean;
21:
22: /**
23: * FactoryBean for HTTP invoker proxies. Exposes the proxied service for
24: * use as a bean reference, using the specified service interface.
25: *
26: * <p>The service URL must be an HTTP URL exposing an HTTP invoker service.
27: * Optionally, a codebase URL can be specified for on-demand dynamic code download
28: * from a remote location. For details, see HttpInvokerClientInterceptor docs.
29: *
30: * <p>Serializes remote invocation objects and deserializes remote invocation
31: * result objects. Uses Java serialization just like RMI, but provides the
32: * same ease of setup as Caucho's HTTP-based Hessian and Burlap protocols.
33: *
34: * <p><b>HTTP invoker is the recommended protocol for Java-to-Java remoting.</b>
35: * It is more powerful and more extensible than Hessian and Burlap, at the
36: * expense of being tied to Java. Nevertheless, it is as easy to set up as
37: * Hessian and Burlap, which is its main advantage compared to RMI.
38: *
39: * @author Juergen Hoeller
40: * @since 1.1
41: * @see #setServiceInterface
42: * @see #setServiceUrl
43: * @see #setCodebaseUrl
44: * @see HttpInvokerClientInterceptor
45: * @see HttpInvokerServiceExporter
46: * @see org.springframework.remoting.rmi.RmiProxyFactoryBean
47: * @see org.springframework.remoting.caucho.HessianProxyFactoryBean
48: * @see org.springframework.remoting.caucho.BurlapProxyFactoryBean
49: */
50: public class HttpInvokerProxyFactoryBean extends
51: HttpInvokerClientInterceptor implements FactoryBean {
52:
53: private Object serviceProxy;
54:
55: public void afterPropertiesSet() {
56: super .afterPropertiesSet();
57: if (getServiceInterface() == null) {
58: throw new IllegalArgumentException(
59: "Property 'serviceInterface' is required");
60: }
61: this .serviceProxy = new ProxyFactory(getServiceInterface(),
62: this ).getProxy(getBeanClassLoader());
63: }
64:
65: public Object getObject() {
66: return this .serviceProxy;
67: }
68:
69: public Class getObjectType() {
70: return getServiceInterface();
71: }
72:
73: public boolean isSingleton() {
74: return true;
75: }
76:
77: }
|