001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.store.kahadb;
018
019import org.apache.activemq.command.ActiveMQDestination;
020import org.apache.activemq.filter.DestinationMapEntry;
021import org.apache.activemq.store.PersistenceAdapter;
022import org.apache.activemq.usage.StoreUsage;
023
024/**
025 * @org.apache.xbean.XBean element="filteredKahaDB"
026 *
027 */
028public class FilteredKahaDBPersistenceAdapter extends DestinationMapEntry {
029    private PersistenceAdapter persistenceAdapter;
030    private boolean perDestination;
031    private StoreUsage usage;
032
033    public FilteredKahaDBPersistenceAdapter() {
034        super();
035    }
036
037    public FilteredKahaDBPersistenceAdapter(FilteredKahaDBPersistenceAdapter template, ActiveMQDestination destination, PersistenceAdapter adapter) {
038        setDestination(destination);
039        persistenceAdapter  = adapter;
040        if (template.getUsage() != null) {
041            usage = template.getUsage().copy();
042        }
043    }
044
045    public PersistenceAdapter getPersistenceAdapter() {
046        return persistenceAdapter;
047    }
048
049    public void setPersistenceAdapter(PersistenceAdapter persistenceAdapter) {
050        this.persistenceAdapter = persistenceAdapter;
051    }
052
053    public boolean isPerDestination() {
054        return perDestination;
055    }
056
057    public void setPerDestination(boolean perDestination) {
058        this.perDestination = perDestination;
059    }
060
061    @Override
062    public String toString() {
063        return "FilteredKahaDBPersistenceAdapter [" + destination + "]";
064    }
065
066    @Override
067    public int compareTo(Object that) {
068        if (that instanceof FilteredKahaDBPersistenceAdapter) {
069            return this.destination.compareTo(((FilteredKahaDBPersistenceAdapter) that).destination);
070        }
071        return super.compareTo(that);
072    }
073
074    public void setUsage(StoreUsage usage) {
075        this.usage = usage;
076    }
077
078    public StoreUsage getUsage() {
079        return usage;
080    }
081}