KickJava   Java API By Example, From Geeks To Geeks.

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


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.Collections JavaDoc;
22 import java.util.Map JavaDoc;
23 import java.util.Set JavaDoc;
24
25 import org.apache.activemq.broker.region.Destination;
26 import org.apache.activemq.broker.region.Subscription;
27 import org.apache.activemq.broker.region.policy.PendingDurableSubscriberMessageStoragePolicy;
28 import org.apache.activemq.command.ActiveMQDestination;
29 import org.apache.activemq.command.BrokerId;
30 import org.apache.activemq.command.BrokerInfo;
31 import org.apache.activemq.command.ConnectionInfo;
32 import org.apache.activemq.command.ConsumerInfo;
33 import org.apache.activemq.command.DestinationInfo;
34 import org.apache.activemq.command.Message;
35 import org.apache.activemq.command.MessageAck;
36 import org.apache.activemq.command.MessageDispatch;
37 import org.apache.activemq.command.MessageDispatchNotification;
38 import org.apache.activemq.command.MessagePull;
39 import org.apache.activemq.command.ProducerInfo;
40 import org.apache.activemq.command.RemoveSubscriptionInfo;
41 import org.apache.activemq.command.Response;
42 import org.apache.activemq.command.SessionInfo;
43 import org.apache.activemq.command.TransactionId;
44 import org.apache.activemq.kaha.Store;
45
46 /**
47  * Implementation of the broker where all it's methods throw an
48  * BrokerStoppedException.
49  *
50  * @version $Revision$
51  */

52 public class ErrorBroker implements Broker {
53
54     private final String JavaDoc message;
55
56     public ErrorBroker(String JavaDoc message) {
57         this.message = message;
58     }
59
60     public Map JavaDoc getDestinationMap() {
61         return Collections.EMPTY_MAP;
62     }
63
64     public Set JavaDoc getDestinations(ActiveMQDestination destination) {
65         return Collections.EMPTY_SET;
66     }
67
68     public Broker getAdaptor(Class JavaDoc type) {
69         if (type.isInstance(this)) {
70             return this;
71         }
72         return null;
73     }
74
75     public BrokerId getBrokerId() {
76         throw new BrokerStoppedException(this.message);
77     }
78
79     public String JavaDoc getBrokerName() {
80         throw new BrokerStoppedException(this.message);
81     }
82
83     public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception JavaDoc {
84         throw new BrokerStoppedException(this.message);
85     }
86
87     public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable JavaDoc error) throws Exception JavaDoc {
88         throw new BrokerStoppedException(this.message);
89     }
90
91     public void addSession(ConnectionContext context, SessionInfo info) throws Exception JavaDoc {
92         throw new BrokerStoppedException(this.message);
93     }
94
95     public void removeSession(ConnectionContext context, SessionInfo info) throws Exception JavaDoc {
96         throw new BrokerStoppedException(this.message);
97     }
98
99     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception JavaDoc {
100         throw new BrokerStoppedException(this.message);
101     }
102
103     public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception JavaDoc {
104         throw new BrokerStoppedException(this.message);
105     }
106
107     public Connection[] getClients() throws Exception JavaDoc {
108         throw new BrokerStoppedException(this.message);
109     }
110
111     public ActiveMQDestination[] getDestinations() throws Exception JavaDoc {
112         throw new BrokerStoppedException(this.message);
113     }
114
115     public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception JavaDoc {
116         throw new BrokerStoppedException(this.message);
117     }
118
119     public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc {
120         throw new BrokerStoppedException(this.message);
121     }
122
123     public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc {
124         throw new BrokerStoppedException(this.message);
125     }
126
127     public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc {
128         throw new BrokerStoppedException(this.message);
129     }
130
131     public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception JavaDoc {
132         throw new BrokerStoppedException(this.message);
133     }
134
135     public void forgetTransaction(ConnectionContext context, TransactionId transactionId) throws Exception JavaDoc {
136         throw new BrokerStoppedException(this.message);
137     }
138
139     public Destination addDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception JavaDoc {
140         throw new BrokerStoppedException(this.message);
141     }
142
143     public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception JavaDoc {
144         throw new BrokerStoppedException(this.message);
145     }
146
147     public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception JavaDoc {
148         throw new BrokerStoppedException(this.message);
149     }
150
151     public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception JavaDoc {
152         throw new BrokerStoppedException(this.message);
153     }
154
155     public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception JavaDoc {
156         throw new BrokerStoppedException(this.message);
157     }
158
159     public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception JavaDoc {
160         throw new BrokerStoppedException(this.message);
161     }
162
163     public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception JavaDoc {
164         throw new BrokerStoppedException(this.message);
165     }
166
167     public void gc() {
168         throw new BrokerStoppedException(this.message);
169     }
170
171     public void start() throws Exception JavaDoc {
172         throw new BrokerStoppedException(this.message);
173     }
174
175     public void stop() throws Exception JavaDoc {
176         throw new BrokerStoppedException(this.message);
177     }
178
179     public void addBroker(Connection connection, BrokerInfo info) {
180         throw new BrokerStoppedException(this.message);
181
182     }
183
184     public void removeBroker(Connection connection, BrokerInfo info) {
185         throw new BrokerStoppedException(this.message);
186     }
187
188     public BrokerInfo[] getPeerBrokerInfos() {
189         throw new BrokerStoppedException(this.message);
190     }
191
192     public void processDispatch(MessageDispatch messageDispatch) {
193         throw new BrokerStoppedException(this.message);
194     }
195
196     public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception JavaDoc {
197         throw new BrokerStoppedException(this.message);
198     }
199
200     public boolean isSlaveBroker() {
201         throw new BrokerStoppedException(this.message);
202     }
203
204     public boolean isStopped() {
205         return true;
206     }
207
208     public Set JavaDoc getDurableDestinations() {
209         throw new BrokerStoppedException(this.message);
210     }
211
212     public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception JavaDoc {
213         throw new BrokerStoppedException(this.message);
214     }
215
216     public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception JavaDoc {
217         throw new BrokerStoppedException(this.message);
218     }
219
220     public boolean isFaultTolerantConfiguration() {
221         throw new BrokerStoppedException(this.message);
222     }
223
224     public ConnectionContext getAdminConnectionContext() {
225         throw new BrokerStoppedException(this.message);
226     }
227
228     public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
229         throw new BrokerStoppedException(this.message);
230     }
231
232     public Response messagePull(ConnectionContext context, MessagePull pull) {
233         throw new BrokerStoppedException(this.message);
234     }
235         
236     public Store getTempDataStore() {
237         throw new BrokerStoppedException(this.message);
238     }
239     
240     public URI JavaDoc getVmConnectorURI(){
241         throw new BrokerStoppedException(this.message);
242     }
243
244 }
245
Popular Tags