001 /**
002 * GRANITE DATA SERVICES
003 * Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S.
004 *
005 * This file is part of the Granite Data Services Platform.
006 *
007 * Granite Data Services is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * Granite Data Services is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
015 * General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this library; if not, write to the Free Software
019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
020 * USA, or see <http://www.gnu.org/licenses/>.
021 */
022 package org.granite.gravity.config;
023
024 import org.granite.config.flex.Adapter;
025 import org.granite.config.flex.Destination;
026 import org.granite.util.XMap;
027
028
029 public class AbstractJmsTopicDestination extends AbstractMessagingDestination {
030
031 ///////////////////////////////////////////////////////////////////////////
032 // Instance fields.
033
034 private String name = null;
035 private String connectionFactoryJndiName = null;
036 private String destinationJndiName = null;
037 private String acknowledgeMode = null;
038 private boolean textMessages = false;
039 private boolean transactedSessions = false;
040
041
042 public String getName() {
043 return name;
044 }
045
046 public void setName(String name) {
047 this.name = name;
048 }
049
050 public String getConnectionFactory() {
051 return connectionFactoryJndiName;
052 }
053
054 public void setConnectionFactory(String connectionFactoryJndiName) {
055 this.connectionFactoryJndiName = connectionFactoryJndiName;
056 }
057
058 public String getJndiName() {
059 return destinationJndiName;
060 }
061
062 public void setJndiName(String jndiName) {
063 this.destinationJndiName = jndiName;
064 }
065
066 public String getDestinationJndiName() {
067 return destinationJndiName;
068 }
069
070 public void setDestinationJndiName(String jndiName) {
071 this.destinationJndiName = jndiName;
072 }
073
074 public String getAcknowledgeMode() {
075 return acknowledgeMode;
076 }
077
078 public void setAcknowledgeMode(String acknowledgeMode) {
079 this.acknowledgeMode = acknowledgeMode;
080 }
081
082 public boolean isTextMessages() {
083 return textMessages;
084 }
085
086 public void setTextMessages(boolean textMessages) {
087 this.textMessages = textMessages;
088 }
089
090 public boolean isTransactedSessions() {
091 return transactedSessions;
092 }
093
094 public void setTransactedSessions(boolean transactedSessions) {
095 this.transactedSessions = transactedSessions;
096 }
097
098
099 @Override
100 protected Adapter buildAdapter() {
101 return new Adapter("jms-adapter", "org.granite.gravity.adapters.JMSServiceAdapter", new XMap());
102 }
103
104 @Override
105 protected Destination buildDestination(Adapter adapter) {
106 Destination destination = super.buildDestination(adapter);
107 destination.getProperties().put("jms", null);
108 destination.getProperties().put("jms/destination-type", "Topic");
109 destination.getProperties().put("jms/destination-name", name);
110 destination.getProperties().put("jms/destination-jndi-name", destinationJndiName);
111 destination.getProperties().put("jms/connection-factory", connectionFactoryJndiName);
112 if (textMessages)
113 destination.getProperties().put("jms/message-type", "javax.jms.TextMessage");
114 destination.getProperties().put("jms/acknowledge-mode", acknowledgeMode);
115 destination.getProperties().put("jms/transacted-sessions", String.valueOf(transactedSessions));
116 destination.getProperties().put("jms/no-local", String.valueOf(isNoLocal()));
117 return destination;
118 }
119 }