/*
 * Copyright 2002-2006 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.jms.remoting;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.FactoryBean;

/**
 * Factory bean for JMS proxies. Behaves like the proxied service when
 * used as bean reference, exposing the specified service interface.
 *
 * <p>For configuration details, see JmsClientInterceptor docs.
 *
 * @author Juergen Hoeller
 * @since 2.0
 * @see #setConnectionFactory
 * @see #setQueueName
 * @see org.springframework.jms.remoting.JmsInvokerClientInterceptor
 * @see org.springframework.jms.remoting.JmsInvokerServiceExporter
 */
public class JmsInvokerProxyFactoryBean extends JmsInvokerClientInterceptor implements FactoryBean {

	private Class serviceInterface;

	private Object serviceProxy;


	/**
	 * Set the interface that the proxy should implement.
	 */
	public void setServiceInterface(Class serviceInterface) {
		if (serviceInterface == null || !serviceInterface.isInterface()) {
			throw new IllegalArgumentException("serviceInterface must be an interface");
		}
		this.serviceInterface = serviceInterface;
	}

	public void afterPropertiesSet() {
		super.afterPropertiesSet();
		if (this.serviceInterface == null) {
			throw new IllegalArgumentException("serviceInterface is required");
		}
		this.serviceProxy = ProxyFactory.getProxy(this.serviceInterface, this);
	}


	public Object getObject() {
		return this.serviceProxy;
	}

	public Class getObjectType() {
		return (this.serviceProxy != null) ? this.serviceProxy.getClass() : this.serviceInterface;
	}

	public boolean isSingleton() {
		return true;
	}

}

@@ -804,17 +804,27 @@
 proxies.
- 
+%0A * %0A * %3Cp%3E
 Behaves 
@@ -852,19 +852,16 @@
 ice when
-%0A *
  used as
@@ -861,16 +861,18 @@
 used as 
+a 
 bean ref
@@ -878,16 +878,19 @@
 ference,
+%0A *
  exposin
@@ -904,16 +904,51 @@
 pecified
+ %7B@link #setServiceInterface(Class)
  service
@@ -957,16 +957,17 @@
 nterface
+%7D
 .%0A *%0A * 
@@ -1000,19 +1000,40 @@
 ls, see 
-Jms
+the%0A * %7B@link JmsInvoker
 ClientIn
@@ -1045,13 +1045,17 @@
 ptor
- 
+%7D java
 doc
-s
 .%0A *
@@ -1502,25 +1502,282 @@
 oxy 
-should implement.
+must implement.%0A%09 * @param serviceInterface the interface that the proxy must implement%0A%09 * @throws IllegalArgumentException if the supplied %3Ccode%3EserviceInterface%3C/code%3E%0A%09 * is %3Ccode%3Enull%3C/code%3E, or if the supplied %3Ccode%3EserviceInterface%3C/code%3E%0A%09 * is not an interface type
 %0A%09 *

Corrected Javadoc typo ('JmsClientInterceptor' -> 'JmsInvokerClientInterceptor').