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    
021    package org.granite.gravity.config;
022    
023    import org.granite.config.flex.Adapter;
024    import org.granite.config.flex.Destination;
025    import org.granite.util.XMap;
026    import org.jboss.seam.ScopeType;
027    import org.jboss.seam.annotations.Scope;
028    
029    
030    @Scope(ScopeType.APPLICATION)
031    public 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 transactedSessions = false;
041        
042            
043            public String getName() {
044                    return name;
045            }
046    
047            public void setName(String name) {
048                    this.name = name;
049            }
050    
051            public String getConnectionFactory() {
052                    return connectionFactoryJndiName;
053            }
054    
055            public void setConnectionFactory(String connectionFactoryJndiName) {
056                    this.connectionFactoryJndiName = connectionFactoryJndiName;
057            }
058    
059            public String getJndiName() {
060                    return destinationJndiName;
061            }
062    
063            public void setJndiName(String jndiName) {
064                    this.destinationJndiName = jndiName;
065            }
066    
067            public String getDestinationJndiName() {
068                    return destinationJndiName;
069            }
070    
071            public void setDestinationJndiName(String jndiName) {
072                    this.destinationJndiName = jndiName;
073            }
074    
075            public String getAcknowledgeMode() {
076                    return acknowledgeMode;
077            }
078    
079            public void setAcknowledgeMode(String acknowledgeMode) {
080                    this.acknowledgeMode = acknowledgeMode;
081            }
082    
083            public boolean isTransactedSessions() {
084                    return transactedSessions;
085            }
086    
087            public void setTransactedSessions(boolean transactedSessions) {
088                    this.transactedSessions = transactedSessions;
089            }
090    
091            
092            @Override
093            protected Adapter buildAdapter() {
094                    return new Adapter("jms-adapter", "org.granite.gravity.adapters.JMSServiceAdapter", new XMap());
095            }
096            
097            @Override
098            protected Destination buildDestination(Adapter adapter) {
099                    Destination destination = super.buildDestination(adapter);
100                    destination.getProperties().put("jms", null);
101            destination.getProperties().put("jms/destination-type", "Topic");
102            destination.getProperties().put("jms/destination-name", name);
103            destination.getProperties().put("jms/destination-jndi-name", destinationJndiName);
104            destination.getProperties().put("jms/connection-factory", connectionFactoryJndiName);
105            destination.getProperties().put("jms/acknowledge-mode", acknowledgeMode);
106            destination.getProperties().put("jms/transacted-sessions", String.valueOf(transactedSessions));
107            destination.getProperties().put("jms/no-local", String.valueOf(isNoLocal()));
108            return destination;
109            }
110    }