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.ProxyFactory;
22 import org.springframework.beans.factory.FactoryBean;
23
24 import javax.jms.JMSException;
25
26 /***
27 * Factory bean for JMS proxies. Behaves like the proxied service when
28 * used as bean reference, exposing the specified service interface.
29 * <p/>
30 * <p>The service URL must be an JMS URL exposing a JMS service.
31 * For details, see JmsClientInterceptor docs.
32 *
33 * @author James Strachan
34 * @see JmsClientInterceptor
35 * @see JmsServiceExporter
36 */
37 public class JmsProxyFactoryBean extends JmsClientInterceptor implements FactoryBean {
38
39 private Object serviceProxy;
40
41 public void afterPropertiesSet() throws JMSException {
42 super.afterPropertiesSet();
43 Class serviceInterface = getServiceInterface();
44 this.serviceProxy = ProxyFactory.getProxy(serviceInterface, this);
45 }
46
47 public Object getObject() {
48 return this.serviceProxy;
49 }
50
51 public Class getObjectType() {
52 return (this.serviceProxy != null) ? this.serviceProxy.getClass() : getServiceInterface();
53 }
54
55 public boolean isSingleton() {
56 return true;
57 }
58
59 }