001 /** 002 * 003 * Copyright 2005 LogicBlaze, Inc. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 019 package org.logicblaze.lingo.jms; 020 021 import org.springframework.aop.framework.ProxyFactoryBean; 022 import org.springframework.aop.framework.ProxyFactory; 023 import org.springframework.beans.factory.FactoryBean; 024 025 import javax.jms.JMSException; 026 027 /** 028 * Factory bean for JMS proxies. Behaves like the proxied service when 029 * used as bean reference, exposing the specified service interface. 030 * <p/> 031 * <p>The service URL must be an JMS URL exposing a JMS service. 032 * For details, see JmsClientInterceptor docs. 033 * 034 * @author James Strachan 035 * @see JmsClientInterceptor 036 * @see JmsServiceExporter 037 */ 038 public class JmsProxyFactoryBean extends JmsClientInterceptor implements FactoryBean { 039 040 private Object serviceProxy; 041 042 public void afterPropertiesSet() throws JMSException { 043 super.afterPropertiesSet(); 044 Class serviceInterface = getServiceInterface(); 045 this.serviceProxy = ProxyFactory.getProxy(serviceInterface, this); 046 } 047 048 public Object getObject() { 049 return this.serviceProxy; 050 } 051 052 public Class getObjectType() { 053 return (this.serviceProxy != null) ? this.serviceProxy.getClass() : getServiceInterface(); 054 } 055 056 public boolean isSingleton() { 057 return true; 058 } 059 060 }