KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > remoting > httpinvoker > HttpInvokerProxyFactoryBean


1 /*
2  * Copyright 2002-2007 the original author or authors.
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 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 HttpInvokerClientInterceptor
51         implements FactoryBean {
52
53     private Object JavaDoc serviceProxy;
54
55
56     public void afterPropertiesSet() {
57         super.afterPropertiesSet();
58         if (getServiceInterface() == null) {
59             throw new IllegalArgumentException JavaDoc("Property 'serviceInterface' is required");
60         }
61         this.serviceProxy = new ProxyFactory(getServiceInterface(), this).getProxy(getBeanClassLoader());
62     }
63
64
65     public Object JavaDoc getObject() {
66         return this.serviceProxy;
67     }
68
69     public Class JavaDoc getObjectType() {
70         return getServiceInterface();
71     }
72
73     public boolean isSingleton() {
74         return true;
75     }
76
77 }
78
Popular Tags