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; 018 019import java.io.IOException; 020import java.util.concurrent.Callable; 021import java.util.concurrent.Future; 022import java.util.concurrent.FutureTask; 023import org.apache.activemq.broker.ConnectionContext; 024import org.apache.activemq.command.ActiveMQDestination; 025import org.apache.activemq.command.Message; 026import org.apache.activemq.command.MessageAck; 027import org.apache.activemq.command.MessageId; 028import org.apache.activemq.usage.MemoryUsage; 029 030abstract public class AbstractMessageStore implements MessageStore { 031 public static final FutureTask<Object> FUTURE; 032 protected final ActiveMQDestination destination; 033 protected boolean prioritizedMessages; 034 035 public AbstractMessageStore(ActiveMQDestination destination) { 036 this.destination = destination; 037 } 038 039 public void dispose(ConnectionContext context) { 040 } 041 042 public void start() throws Exception { 043 } 044 045 public void stop() throws Exception { 046 } 047 048 public ActiveMQDestination getDestination() { 049 return destination; 050 } 051 052 public void setMemoryUsage(MemoryUsage memoryUsage) { 053 } 054 055 public void setBatch(MessageId messageId) throws IOException, Exception { 056 } 057 058 /** 059 * flag to indicate if the store is empty 060 * 061 * @return true if the message count is 0 062 * @throws Exception 063 */ 064 public boolean isEmpty() throws Exception { 065 return getMessageCount() == 0; 066 } 067 068 public void setPrioritizedMessages(boolean prioritizedMessages) { 069 this.prioritizedMessages = prioritizedMessages; 070 } 071 072 public boolean isPrioritizedMessages() { 073 return this.prioritizedMessages; 074 } 075 076 public Future<Object> asyncAddQueueMessage(final ConnectionContext context, final Message message) throws IOException { 077 addMessage(context, message); 078 return FUTURE; 079 } 080 081 082 public Future<Object> asyncAddTopicMessage(final ConnectionContext context, final Message message) throws IOException { 083 addMessage(context, message); 084 return FUTURE; 085 } 086 087 public void removeAsyncMessage(ConnectionContext context, MessageAck ack) throws IOException { 088 removeMessage(context, ack); 089 } 090 091 static class CallableImplementation implements Callable<Object> { 092 public Object call() throws Exception { 093 return null; 094 } 095 } 096 097 static { 098 FUTURE = new FutureTask<Object>(new CallableImplementation()); 099 FUTURE.run(); 100 } 101}