001/*
002 * Copyright 2002-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.remoting.caucho;
018
019import org.springframework.aop.framework.ProxyFactory;
020import org.springframework.beans.factory.FactoryBean;
021import org.springframework.lang.Nullable;
022
023/**
024 * {@link FactoryBean} for Hessian proxies. Exposes the proxied service
025 * for use as a bean reference, using the specified service interface.
026 *
027 * <p>Hessian is a slim, binary RPC protocol.
028 * For information on Hessian, see the
029 * <a href="http://hessian.caucho.com">Hessian website</a>
030 * <b>Note: As of Spring 4.0, this proxy factory requires Hessian 4.0 or above.</b>
031 *
032 * <p>The service URL must be an HTTP URL exposing a Hessian service.
033 * For details, see the {@link HessianClientInterceptor} javadoc.
034 *
035 * @author Juergen Hoeller
036 * @since 13.05.2003
037 * @see #setServiceInterface
038 * @see #setServiceUrl
039 * @see HessianClientInterceptor
040 * @see HessianServiceExporter
041 * @see org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean
042 * @see org.springframework.remoting.rmi.RmiProxyFactoryBean
043 */
044public class HessianProxyFactoryBean extends HessianClientInterceptor implements FactoryBean<Object> {
045
046        @Nullable
047        private Object serviceProxy;
048
049
050        @Override
051        public void afterPropertiesSet() {
052                super.afterPropertiesSet();
053                this.serviceProxy = new ProxyFactory(getServiceInterface(), this).getProxy(getBeanClassLoader());
054        }
055
056
057        @Override
058        @Nullable
059        public Object getObject() {
060                return this.serviceProxy;
061        }
062
063        @Override
064        public Class<?> getObjectType() {
065                return getServiceInterface();
066        }
067
068        @Override
069        public boolean isSingleton() {
070                return true;
071        }
072
073}