1 /*** 2 * 3 * Copyright 2005 LogicBlaze, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 **/ 18 19 package org.logicblaze.lingo.jms; 20 21 import org.springframework.aop.framework.ProxyFactoryBean; 22 import org.springframework.aop.framework.ProxyFactory; 23 import org.springframework.beans.factory.FactoryBean; 24 25 import javax.jms.JMSException; 26 27 /*** 28 * Factory bean for JMS proxies. Behaves like the proxied service when 29 * used as bean reference, exposing the specified service interface. 30 * <p/> 31 * <p>The service URL must be an JMS URL exposing a JMS service. 32 * For details, see JmsClientInterceptor docs. 33 * 34 * @author James Strachan 35 * @see JmsClientInterceptor 36 * @see JmsServiceExporter 37 */ 38 public class JmsProxyFactoryBean extends JmsClientInterceptor implements FactoryBean { 39 40 private Object serviceProxy; 41 42 public void afterPropertiesSet() throws JMSException { 43 super.afterPropertiesSet(); 44 Class serviceInterface = getServiceInterface(); 45 this.serviceProxy = ProxyFactory.getProxy(serviceInterface, this); 46 } 47 48 public Object getObject() { 49 return this.serviceProxy; 50 } 51 52 public Class getObjectType() { 53 return (this.serviceProxy != null) ? this.serviceProxy.getClass() : getServiceInterface(); 54 } 55 56 public boolean isSingleton() { 57 return true; 58 } 59 60 }