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