01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
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: package edu.iu.uis.eden.messaging.serviceconnectors;
18:
19: import javax.jms.Connection;
20: import javax.jms.ConnectionFactory;
21: import javax.jms.Destination;
22: import javax.jms.Queue;
23: import javax.jms.Session;
24:
25: import org.kuali.bus.security.jms.AuthenticationJmsProxyFactoryBean;
26: import org.logicblaze.lingo.SimpleMetadataStrategy;
27: import org.logicblaze.lingo.jms.JmsProxyFactoryBean;
28:
29: import edu.iu.uis.eden.messaging.JmsServiceDefinition;
30: import edu.iu.uis.eden.messaging.RemotedServiceHolder;
31: import edu.iu.uis.eden.messaging.ServiceInfo;
32:
33: /**
34: *
35: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
36: * @version $Revision: 1.2.24.1 $ $Date: 2007/10/17 20:32:04 $
37: * @since 0.9
38: */
39: public class JmsConnector extends AbstractServiceConnector {
40:
41: public JmsConnector(final ServiceInfo serviceInfo) {
42: super (serviceInfo);
43: }
44:
45: public RemotedServiceHolder getServiceHolder() throws Exception {
46: final JmsServiceDefinition serviceDef = (JmsServiceDefinition) getServiceInfo()
47: .getServiceDefinition();
48: final JmsProxyFactoryBean factoryBean = getCredentialsSource() != null ? new AuthenticationJmsProxyFactoryBean(
49: getCredentialsSource(), getServiceInfo())
50: : new JmsProxyFactoryBean();
51:
52: factoryBean.setServiceInterface(Class.forName(serviceDef
53: .getServiceInterface()));
54: factoryBean.setConnectionFactory(serviceDef
55: .getConnectionFactory());
56: factoryBean.setDestination(getDestination(serviceDef
57: .getConnectionFactory(), serviceDef
58: .getServiceInterface()));
59: factoryBean
60: .setMetadataStrategy(new SimpleMetadataStrategy(true));
61: factoryBean.afterPropertiesSet();
62: return new RemotedServiceHolder(getServiceProxyWithFailureMode(
63: factoryBean.getObject(), getServiceInfo()),
64: getServiceInfo());
65: }
66:
67: protected Destination getDestination(
68: final ConnectionFactory connectionFactory,
69: final String queueName) throws Exception {
70: final Connection connection = connectionFactory
71: .createConnection();
72: final Session session = connection.createSession(true,
73: Session.AUTO_ACKNOWLEDGE);
74: final Queue queue = session.createQueue(queueName);
75: return queue;
76: }
77: }
|