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 AbstractActiveMQTopicDestination extends AbstractJmsTopicDestination {
030    
031        ///////////////////////////////////////////////////////////////////////////
032        // Instance fields.
033       
034        private String brokerUrl = null;
035        private boolean createBroker = true;
036        private boolean waitForStart = false;
037        private boolean durable = false;
038        private String fileStoreRoot = null;
039    
040            
041            public String getBrokerUrl() {
042                    return brokerUrl;
043            }
044    
045            public void setBrokerUrl(String brokerUrl) {
046                    this.brokerUrl = brokerUrl;
047            }
048    
049            public boolean isCreateBroker() {
050                    return createBroker;
051            }
052    
053            public void setCreateBroker(boolean createBroker) {
054                    this.createBroker = createBroker;
055            }
056    
057            public boolean isWaitForStart() {
058                    return waitForStart;
059            }
060    
061            public void setWaitForStart(boolean waitForStart) {
062                    this.waitForStart = waitForStart;
063            }
064    
065            public boolean isDurable() {
066                    return durable;
067            }
068    
069            public void setDurable(boolean durable) {
070                    this.durable = durable;
071            }
072    
073            public String getFileStoreRoot() {
074                    return fileStoreRoot;
075            }
076    
077            public void setFileStoreRoot(String fileStoreRoot) {
078                    this.fileStoreRoot = fileStoreRoot;
079            }
080    
081            
082            @Override
083            protected Adapter buildAdapter() {
084                    return new Adapter("activemq-adapter", "org.granite.gravity.adapters.ActiveMQServiceAdapter", new XMap());
085            }
086            
087            @Override
088            protected Destination buildDestination(Adapter adapter) {
089                    Destination destination = super.buildDestination(adapter);
090                    destination.getProperties().put("server", null);
091            destination.getProperties().put("server/broker-url", brokerUrl);
092            destination.getProperties().put("server/create-broker", String.valueOf(createBroker));
093            if (createBroker) {
094                    destination.getProperties().put("server/wait-for-start", String.valueOf(waitForStart));
095                    destination.getProperties().put("server/durable", String.valueOf(durable));
096                    if (durable)
097                            destination.getProperties().put("server/file-store-root", fileStoreRoot);
098            }
099            return destination;
100            }
101    }