001/*
002 * Copyright 2002-2012 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.jaxws;
018
019import javax.xml.ws.BindingProvider;
020
021import org.springframework.aop.framework.ProxyFactory;
022import org.springframework.beans.factory.FactoryBean;
023
024/**
025 * {@link org.springframework.beans.factory.FactoryBean} for a specific port of a
026 * JAX-WS service. Exposes a proxy for the port, to be used for bean references.
027 * Inherits configuration properties from {@link JaxWsPortClientInterceptor}.
028 *
029 * @author Juergen Hoeller
030 * @since 2.5
031 * @see #setServiceInterface
032 * @see LocalJaxWsServiceFactoryBean
033 */
034public class JaxWsPortProxyFactoryBean extends JaxWsPortClientInterceptor
035                implements FactoryBean<Object> {
036
037        private Object serviceProxy;
038
039
040        @Override
041        public void afterPropertiesSet() {
042                super.afterPropertiesSet();
043
044                // Build a proxy that also exposes the JAX-WS BindingProvider interface.
045                ProxyFactory pf = new ProxyFactory();
046                pf.addInterface(getServiceInterface());
047                pf.addInterface(BindingProvider.class);
048                pf.addAdvice(this);
049                this.serviceProxy = pf.getProxy(getBeanClassLoader());
050        }
051
052
053        @Override
054        public Object getObject() {
055                return this.serviceProxy;
056        }
057
058        @Override
059        public Class<?> getObjectType() {
060                return getServiceInterface();
061        }
062
063        @Override
064        public boolean isSingleton() {
065                return true;
066        }
067
068}