KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > store > PersistenceAdapter


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.store;
19
20 import org.apache.activemq.Service;
21 import org.apache.activemq.broker.ConnectionContext;
22 import org.apache.activemq.command.ActiveMQDestination;
23 import org.apache.activemq.command.ActiveMQQueue;
24 import org.apache.activemq.command.ActiveMQTopic;
25 import org.apache.activemq.memory.UsageManager;
26
27 import java.io.File JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.util.Set JavaDoc;
30
31 /**
32  * Adapter to the actual persistence mechanism used with ActiveMQ
33  *
34  * @version $Revision: 1.3 $
35  */

36 public interface PersistenceAdapter extends Service {
37
38     /**
39      * Returns a set of all the {@link org.apache.activemq.command.ActiveMQDestination}
40      * objects that the persistence store is aware exist.
41      *
42      * @return active destinations
43      */

44     public Set JavaDoc<ActiveMQDestination> getDestinations();
45
46     /**
47      * Factory method to create a new queue message store with the given destination name
48      * @param destination
49      * @return the message store
50      * @throws IOException
51      */

52     public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException JavaDoc;
53
54     /**
55      * Factory method to create a new topic message store with the given destination name
56      * @param destination
57      * @return the topic message store
58      * @throws IOException
59      */

60     public TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException JavaDoc;
61
62     /**
63      * Factory method to create a new persistent prepared transaction store for XA recovery
64      * @return transaction store
65      * @throws IOException
66      */

67     public TransactionStore createTransactionStore() throws IOException JavaDoc;
68
69     /**
70      * This method starts a transaction on the persistent storage - which is nothing to
71      * do with JMS or XA transactions - its purely a mechanism to perform multiple writes
72      * to a persistent store in 1 transaction as a performance optimization.
73      * <p/>
74      * Typically one transaction will require one disk synchronization point and so for
75      * real high performance its usually faster to perform many writes within the same
76      * transaction to minimize latency caused by disk synchronization. This is especially
77      * true when using tools like Berkeley Db or embedded JDBC servers.
78      * @param context
79      * @throws IOException
80      */

81     public void beginTransaction(ConnectionContext context) throws IOException JavaDoc;
82
83
84     /**
85      * Commit a persistence transaction
86      * @param context
87      * @throws IOException
88      *
89      * @see PersistenceAdapter#beginTransaction(ConnectionContext context)
90      */

91     public void commitTransaction(ConnectionContext context) throws IOException JavaDoc;
92
93     /**
94      * Rollback a persistence transaction
95      * @param context
96      * @throws IOException
97      *
98      * @see PersistenceAdapter#beginTransaction(ConnectionContext context)
99      */

100     public void rollbackTransaction(ConnectionContext context) throws IOException JavaDoc;
101     
102     /**
103      *
104      * @return last broker sequence
105      * @throws IOException
106      */

107     public long getLastMessageBrokerSequenceId() throws IOException JavaDoc;
108     
109     /**
110      * Delete's all the messages in the persistent store.
111      *
112      * @throws IOException
113      */

114     public void deleteAllMessages() throws IOException JavaDoc;
115         
116     /**
117      * @param usageManager The UsageManager that is controlling the broker's memory usage.
118      */

119     public void setUsageManager(UsageManager usageManager);
120     
121     /**
122      * Set the name of the broker using the adapter
123      * @param brokerName
124      */

125     public void setBrokerName(String JavaDoc brokerName);
126     
127     /**
128      * Set the directory where any data files should be created
129      * @param dir
130      */

131     public void setDirectory(File JavaDoc dir);
132     
133     /**
134      * checkpoint any
135      * @param sync
136      * @throws IOException
137      *
138      */

139     public void checkpoint(boolean sync) throws IOException JavaDoc;
140 }
141
Popular Tags