KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > Broker


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.broker;
19
20 import java.net.URI JavaDoc;
21 import java.util.Set JavaDoc;
22 import org.apache.activemq.Service;
23 import org.apache.activemq.broker.region.Destination;
24 import org.apache.activemq.broker.region.Region;
25 import org.apache.activemq.broker.region.policy.PendingDurableSubscriberMessageStoragePolicy;
26 import org.apache.activemq.command.ActiveMQDestination;
27 import org.apache.activemq.command.BrokerId;
28 import org.apache.activemq.command.BrokerInfo;
29 import org.apache.activemq.command.ConnectionInfo;
30 import org.apache.activemq.command.DestinationInfo;
31 import org.apache.activemq.command.MessageDispatch;
32 import org.apache.activemq.command.MessageDispatchNotification;
33 import org.apache.activemq.command.MessagePull;
34 import org.apache.activemq.command.ProducerInfo;
35 import org.apache.activemq.command.Response;
36 import org.apache.activemq.command.SessionInfo;
37 import org.apache.activemq.command.TransactionId;
38 import org.apache.activemq.kaha.Store;
39
40 /**
41  * The Message Broker which routes messages,
42  * maintains subscriptions and connections, acknowledges messages and handles
43  * transactions.
44  *
45  * @version $Revision: 1.8 $
46  */

47 public interface Broker extends Region, Service {
48     
49     /**
50      * Get a Broker from the Broker Stack that is a particular class
51      * @param type
52      * @return
53      */

54     public Broker getAdaptor(Class JavaDoc type);
55
56     /**
57      * Get the id of the broker
58      */

59     public BrokerId getBrokerId();
60
61     /**
62      * Get the name of the broker
63      */

64     public String JavaDoc getBrokerName();
65     
66     /**
67      * A remote Broker connects
68      */

69     public void addBroker(Connection connection, BrokerInfo info);
70     
71     /**
72      * Remove a BrokerInfo
73      * @param connection
74      * @param info
75      */

76     public void removeBroker(Connection connection,BrokerInfo info);
77     
78
79     /**
80      * A client is establishing a connection with the broker.
81      * @throws Exception TODO
82      */

83     public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception JavaDoc;
84     
85     /**
86      * A client is disconnecting from the broker.
87      * @param context the environment the operation is being executed under.
88      * @param info
89      * @param error null if the client requested the disconnect or the error that caused the client to disconnect.
90      * @throws Exception TODO
91      */

92     public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable JavaDoc error) throws Exception JavaDoc;
93
94     /**
95      * Adds a session.
96      * @param context
97      * @param info
98      * @throws Exception TODO
99      */

100     public void addSession(ConnectionContext context, SessionInfo info) throws Exception JavaDoc;
101
102     /**
103      * Removes a session.
104      * @param context
105      * @param info
106      * @throws Exception TODO
107      */

108     public void removeSession(ConnectionContext context, SessionInfo info) throws Exception JavaDoc;
109
110     /**
111      * Adds a producer.
112      * @param context the enviorment the operation is being executed under.
113      * @throws Exception TODO
114      */

115     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception JavaDoc;
116
117     /**
118      * Removes a producer.
119      * @param context the enviorment the operation is being executed under.
120      * @throws Exception TODO
121      */

122     public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception JavaDoc;
123       
124     /**
125      * @return all clients added to the Broker.
126      * @throws Exception TODO
127      */

128     public Connection[] getClients() throws Exception JavaDoc;
129
130     /**
131      * @return all destinations added to the Broker.
132      * @throws Exception TODO
133      */

134     public ActiveMQDestination[] getDestinations() throws Exception JavaDoc;
135     
136     /**
137      * Gets a list of all the prepared xa transactions.
138      * @throws Exception TODO
139      */

140     public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception JavaDoc;
141
142     /**
143      * Starts a transaction.
144      * @param context
145      * @param xid
146      * @throws Exception TODO
147      */

148     public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc;
149
150     /**
151      * Prepares a transaction. Only valid for xa transactions.
152      * @param context
153      * @param xid
154      * @return
155      * @throws Exception TODO
156      */

157     public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc;
158
159     /**
160      * Rollsback a transaction.
161      * @param context
162      * @param xid
163      * @throws Exception TODO
164      */

165
166     public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc;
167
168     /**
169      * Commits a transaction.
170      * @param context
171      * @param xid
172      * @param onePhase
173      * @throws Exception TODO
174      */

175     public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception JavaDoc;
176
177     /**
178      * Forgets a transaction.
179      */

180     public void forgetTransaction(ConnectionContext context, TransactionId transactionId) throws Exception JavaDoc;
181     
182     /**
183      * Get the BrokerInfo's of any connected Brokers
184      * @return array of peer BrokerInfos
185      */

186     BrokerInfo[] getPeerBrokerInfos();
187     
188     
189     /**
190      * Notify the Broker that a dispatch has happened
191      * @param messageDispatch
192      */

193     public void processDispatch(MessageDispatch messageDispatch);
194     
195     /**
196      * @return true if the broker is running as a slave
197      */

198     public boolean isSlaveBroker();
199     
200     /**
201      * @return true if the broker has stopped
202      */

203     public boolean isStopped();
204     
205     /**
206      * @return a Set of all durable destinations
207      */

208     public Set JavaDoc getDurableDestinations();
209     
210     /**
211      * Add and process a DestinationInfo object
212      * @param context
213      * @param info
214      * @throws Exception
215      */

216     public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception JavaDoc;
217     
218     
219     /**
220      * Remove and process a DestinationInfo object
221      * @param context
222      * @param info
223      * @throws Exception
224      */

225     public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception JavaDoc;
226
227     
228     /**
229      * @return true if fault tolerant
230      */

231     public boolean isFaultTolerantConfiguration();
232
233     /**
234      * @return the connection context used to make administration operations on startup or via JMX MBeans
235      */

236     public abstract ConnectionContext getAdminConnectionContext();
237
238     /**
239      * Sets the default administration connection context used when configuring the broker on startup or via JMX
240      * @param adminConnectionContext
241      */

242     public abstract void setAdminConnectionContext(ConnectionContext adminConnectionContext);
243       
244     /**
245      * @return the temp data store
246      */

247     public Store getTempDataStore();
248     
249     /**
250      * @return the URI that can be used to connect to the local Broker
251      */

252     public URI JavaDoc getVmConnectorURI();
253 }
254
Popular Tags