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