View Javadoc

1   /***
2    * Redistribution and use of this software and associated documentation
3    * ("Software"), with or without modification, are permitted provided
4    * that the following conditions are met:
5    *
6    * 1. Redistributions of source code must retain copyright
7    *    statements and notices.  Redistributions must also contain a
8    *    copy of this document.
9    *
10   * 2. Redistributions in binary form must reproduce the
11   *    above copyright notice, this list of conditions and the
12   *    following disclaimer in the documentation and/or other
13   *    materials provided with the distribution.
14   *
15   * 3. The name "Exolab" must not be used to endorse or promote
16   *    products derived from this Software without prior written
17   *    permission of Exoffice Technologies.  For written permission,
18   *    please contact info@exolab.org.
19   *
20   * 4. Products derived from this Software may not be called "Exolab"
21   *    nor may "Exolab" appear in their names without prior written
22   *    permission of Exoffice Technologies. Exolab is a registered
23   *    trademark of Exoffice Technologies.
24   *
25   * 5. Due credit should be given to the Exolab Project
26   *    (http://www.exolab.org/).
27   *
28   * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
32   * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39   * OF THE POSSIBILITY OF SUCH DAMAGE.
40   *
41   * Copyright 2000,2003 (C) Exoffice Technologies Inc. All Rights Reserved.
42   *
43   * $Id: AbstractAdminConnection.java,v 1.1 2004/11/26 01:51:14 tanderson Exp $
44   */
45  package org.exolab.jms.tools.admin;
46  
47  import java.util.Enumeration;
48  
49  
50  /***
51   * The abstract class all AbstractAdminConnection objects must inherit from.
52   * Currently there are only two object types. OfflineConnection, for objects
53   * that directly connect to and use the persistency mechanism, and
54   * OnlineConnection objects that connect to an OpenJMSServer for all
55   * their requests.
56   *
57   * @version     $Revision: 1.1 $ $Date: 2004/11/26 01:51:14 $
58   * @author      <a href="mailto:mourikis@exolab.org">Jim Mourikis</a>
59   * @see         OfflineConnection
60   * @see	        OnlineConnection
61   */
62  public abstract class AbstractAdminConnection {
63  
64      protected static AbstractAdminConnection _instance = null;
65  
66      /***
67       * Returns the one and only instance of the connection object.
68       *
69       * @return AdminConnection The one and only instance.
70       */
71      public static AbstractAdminConnection instance() {
72          return _instance;
73      }
74  
75      /***
76       * Return the number of outstanding messages for a particular destination.
77       *
78       * @param       topic       name of the topic
79       * @param       name        durable consumer name
80       * @return      int         message count
81       */
82      public abstract int getDurableConsumerMessageCount(String topic,
83                                                         String name);
84  
85      /***
86       * Return the number of outstanding messages for a particular queue.
87       *
88       * @param       queue       the queue name
89       * @return      int         message count
90       */
91      public abstract int getQueueMessageCount(String queue);
92  
93      /***
94       * Add a durable consumer for the specified name the passed in name
95       *
96       * @param       topic           name of the destination
97       * @param       name            name of the consumer
98       * @return      boolean         true if successful
99       */
100     public abstract boolean addDurableConsumer(String topic, String name);
101 
102     /***
103      * Remove the consumer with the specified name
104      *
105      * @param       name            name of the consumer
106      * @return      boolean         true if successful
107      */
108     public abstract boolean removeDurableConsumer(String name);
109 
110     /***
111      * Return the collection of durable consumer names for a particular
112      * topic destination.
113      *
114      * @param       topic           the topic name
115      * @return      Vector          collection of strings
116      */
117     public abstract Enumeration getDurableConsumers(String destination);
118 
119     /***
120      * Check if the durable consumer exists.
121      *
122      * @param       name            name of the durable conusmer
123      * @return      boolean         true if it exists and false otherwise
124      */
125     public abstract boolean durableConsumerExists(String name);
126 
127     /***
128      * De-Activate an active persistent consumer.
129      *
130      * @param       name            name of the consumer
131      * @return      boolean         true if successful
132      */
133     public abstract boolean unregisterConsumer(String name);
134 
135     /***
136      * Check to see if the given consumer is currently connected to the
137      * OpenJMSServer. This is only valid when in online mode.
138      *
139      * @param name The name of the onsumer.
140      * @return boolean True if the consumer is connected.
141      *
142      */
143     public abstract boolean isConnected(String name);
144 
145     /***
146      * Return a list of all registered destinations.
147      *
148      * @return      Enumeration     collection of JmsDestination objects
149      */
150     public abstract Enumeration getAllDestinations();
151 
152     /***
153      * Add a specific destination with the specified name
154      *
155      * @param       name        destination name
156      * @param       queue       whether it is queue or a topic
157      * @return      boolean     true if successful
158      */
159     public abstract boolean addDestination(String destination,
160                                            boolean isQueue);
161 
162     /***
163      * Destroy the specified destination and all associated messsages and
164      * consumers. This is a very dangerous operation to execute while there
165      * are clients online
166      *
167      * @param       destination     destination to destroy
168      */
169     public abstract boolean removeDestination(String name);
170 
171     /***
172      * Terminate the JMS Server. If it is running as a standalone application
173      * then exit the application. It is running as an embedded application then
174      * just terminate the thread
175      */
176     public abstract void stopServer();
177 
178     /***
179      * Purge all processed messages from the database.
180      *
181      * @return      int         the number of messages purged.
182      */
183     public abstract int purgeMessages();
184 
185     /***
186      * Close the connection.
187      */
188     public abstract void close();
189 
190     /***
191      * Adds a new User to the DB.
192      *
193      * @param username    the users name
194      * @param password    the users password
195      * @return <code>true</code> if the user is added
196      * otherwise <code>false</code>
197      */
198     public abstract boolean addUser(String username, String password);
199 
200     /***
201      * Change the password for this user
202      *
203      * @param username    the users name
204      * @param password    the users password
205      * @return <code>true</code> if the password is changed
206      * otherwise <code>false</code>
207      */
208     public abstract boolean changePassword(String username, String password);
209 
210     /***
211      * Remove a user from the DB.
212      *
213      * @param username    the users name
214      * @return <code>true</code> if the user is removed
215      * otherwise <code>false</code>
216      */
217     public abstract boolean removeUser(String username);
218 
219     /***
220      * List all users in the DB
221      *
222      * @return Enumeration of users
223      */
224     public abstract Enumeration getAllUsers();
225 }