001    /*
002     * Copyright 2009 Red Hat, Inc.
003     * Red Hat licenses this file to you under the Apache License, version
004     * 2.0 (the "License"); you may not use this file except in compliance
005     * with the License.  You may obtain a copy of the License at
006     *    http://www.apache.org/licenses/LICENSE-2.0
007     * Unless required by applicable law or agreed to in writing, software
008     * distributed under the License is distributed on an "AS IS" BASIS,
009     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
010     * implied.  See the License for the specific language governing
011     * permissions and limitations under the License.
012     */
013    
014    package org.hornetq.api.jms.management;
015    
016    import java.util.Map;
017    
018    import javax.management.MBeanOperationInfo;
019    
020    import org.hornetq.api.core.TransportConfiguration;
021    import org.hornetq.api.core.client.ClientSessionFactory;
022    import org.hornetq.api.core.management.Operation;
023    import org.hornetq.api.core.management.Parameter;
024    import org.hornetq.spi.core.remoting.ConnectorFactory;
025    
026    /**
027     * A JMSSserverControl is used to manage HornetQ JMS server.
028     * 
029     * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
030     * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
031     */
032    public interface JMSServerControl
033    {
034       // Attributes ----------------------------------------------------
035    
036       /**
037        * Returns whether this server is started.
038        */
039       boolean isStarted();
040    
041       /**
042        * Returns this server's version
043        */
044       String getVersion();
045    
046       /**
047        * Returns the names of the JMS topics available on this server.
048        */
049       String[] getTopicNames();
050    
051       /**
052        * Returns the names of the JMS queues available on this server.
053        */
054       String[] getQueueNames();
055    
056       /**
057        * Returns the names of the JMS connection factories available on this server.
058        */
059       String[] getConnectionFactoryNames();
060    
061       // Operations ----------------------------------------------------
062       /**
063           * Creates a durable JMS Queue.
064           *
065           * @return {@code true} if the queue was created, {@code false} else
066           */
067          @Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
068          boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name) throws Exception;
069    
070       /**
071        * Creates a durable JMS Queue with the specified name and JNDI binding.
072        * 
073        * @return {@code true} if the queue was created, {@code false} else
074        */
075       @Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
076       boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
077                           @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use '&comma;' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
078    
079       /**
080          * Creates a durable JMS Queue with the specified name, JNDI binding and selector.
081          *
082          * @return {@code true} if the queue was created, {@code false} else
083          */
084         @Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
085         boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
086                             @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use '&comma;' if u need to use commas in your jndi name)") String jndiBindings,
087                             @Parameter(name = "selector", desc = "the jms selector") String selector) throws Exception;
088    
089         /**
090          * Creates a JMS Queue with the specified name, durability, selector and JNDI binding.
091          *
092          * @return {@code true} if the queue was created, {@code false} else
093          */
094         @Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
095         boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
096                             @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use '&comma;' if u need to use commas in your jndi name)") String jndiBindings,
097                             @Parameter(name = "selector", desc = "the jms selector") String selector,
098                             @Parameter(name = "durable", desc = "durability of the queue") boolean durable) throws Exception;
099    
100    
101       /**
102        * Destroys a JMS Queue with the specified name.
103        * 
104        * @return {@code true} if the queue was destroyed, {@code false} else
105        */
106       @Operation(desc = "Destroy a JMS Queue", impact = MBeanOperationInfo.ACTION)
107       boolean destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name) throws Exception;
108    
109       /**
110        * Creates a JMS Topic.
111        *
112        * @return {@code true} if the topic was created, {@code false} else
113        */
114       @Operation(desc = "Create a JMS Topic", impact = MBeanOperationInfo.ACTION)
115       boolean createTopic(@Parameter(name = "name", desc = "Name of the topic to create") String name) throws Exception;
116    
117       /**
118        * Creates a JMS Topic with the specified name and JNDI binding.
119        * 
120        * @return {@code true} if the topic was created, {@code false} else
121        */
122       @Operation(desc = "Create a JMS Topic", impact = MBeanOperationInfo.ACTION)
123       boolean createTopic(@Parameter(name = "name", desc = "Name of the topic to create") String name,
124                           @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use '&comma;' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
125    
126       /**
127        * Destroys a JMS Topic with the specified name.
128        * 
129        * @return {@code true} if the topic was destroyed, {@code false} else
130        */
131       @Operation(desc = "Destroy a JMS Topic", impact = MBeanOperationInfo.ACTION)
132       boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy") String name) throws Exception;
133    
134       /**
135        * Create a JMS ConnectionFactory with the specified name connected to a single HornetQ server.
136        * <br>
137        * The ConnectionFactory is bound to JNDI for all the specified bindings.
138        */
139       void createConnectionFactory(final String name,
140                                           final String liveTransportClassName,
141                                           final Map<String, Object> liveTransportParams,
142                                           final Object[] jndiBindings) throws Exception;
143       /**
144        * Create a JMS ConnectionFactory with the specified name connected to a static list of live-backup servers.
145        * <br>
146        * The ConnectionFactory is bound to JNDI for all the specified bindings Strings.
147        * <br>
148        * {@code liveConnectorsTransportClassNames} (resp. {@code backupConnectorsTransportClassNames}) are the class names 
149        * of the {@link ConnectorFactory} to connect to the live (resp. backup) servers
150        * and {@code liveConnectorTransportParams} (resp. backupConnectorTransportParams) are Map&lt;String, Object&gt; for the corresponding {@link TransportConfiguration}'s parameters.
151        * 
152        * @see ClientSessionFactory#setStaticConnectors(java.util.List)
153        */
154       void createConnectionFactory(String name,
155                                    Object[] liveConnectorsTransportClassNames,
156                                    Object[] liveConnectorTransportParams,
157                                    Object[] backupConnectorsTransportClassNames,
158                                    Object[] backupConnectorTransportParams,
159                                    Object[] bindings) throws Exception;
160    
161       /**
162        * Create a JMS ConnectionFactory with the specified name connected to a single live-backup pair of servers.
163        * <br>
164        * The ConnectionFactory is bound to JNDI for all the specified bindings Strings.
165        * <br>
166        * {@code backupTransportClassNames} and {@code backupTransportParams} can be {@code null} if there is no backup server.
167        */
168       @Operation(desc = "Create a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
169       void createConnectionFactory(@Parameter(name = "name") String name,
170                                    @Parameter(name = "liveTransportClassNames", desc = "comma-separated list of class names for transport to live servers") String liveTransportClassNames,
171                                    @Parameter(name = "liveTransportParams", desc = "comma-separated list of key=value parameters for the live transports (enclosed between { } for each transport)") String liveTransportParams,
172                                    @Parameter(name = "backupTransportClassNames", desc = "comma-separated list of class names for transport to backup servers") String backupTransportClassNames,
173                                    @Parameter(name = "backupTransportParams", desc = "comma-separated list of key=value parameters for the backup transports (enclosed between { } for each transport)") String backupTransportParams,
174                                    @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use '&comma;' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
175    
176       /**
177        * Create a JMS ConnectionFactory with the specified name using a discovery group to discover HornetQ servers.
178        * <br>
179        * The ConnectionFactory is bound to JNDI for all the specified bindings Strings.
180        * <br>
181        * This factory listens to the specified {@code discoveryAddress} and {@code discoveryPort} to discover which servers it can connect to.
182        */
183       void createConnectionFactory(String name,
184                                    String discoveryAddress,
185                                    int discoveryPort,
186                                    Object[] bindings) throws Exception;
187    
188       /**
189        * Create a JMS ConnectionFactory with the specified name using a discovery group to discover HornetQ servers.
190        * <br>
191        * The ConnectionFactory is bound to JNDI for the specified bindings Strings
192        * <br>
193        * This factory listens to the specified {@code discoveryAddress} and {@code discoveryPort} to discover which servers it can connect to.
194        */
195       @Operation(desc = "Create a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
196       void createConnectionFactory(@Parameter(name = "name") String name,
197                                    @Parameter(name = "discoveryAddress") String discoveryAddress,
198                                    @Parameter(name = "discoveryPort") int discoveryPort,
199                                    @Parameter(name = "jndiBindings") String jndiBindings) throws Exception;
200    
201       /**
202        * Destroy the ConnectionFactory corresponding to the specified name.
203        */
204       @Operation(desc = "Destroy a JMS ConnectionFactory", impact = MBeanOperationInfo.ACTION)
205       void destroyConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to destroy") String name) throws Exception;
206    
207       /**
208        * Lists the addresses of all the clients connected to this address.
209        */
210       @Operation(desc = "List the client addresses", impact = MBeanOperationInfo.INFO)
211       String[] listRemoteAddresses() throws Exception;
212    
213       /**
214        * Lists the addresses of the clients connected to this address which matches the specified IP address.
215        */
216       @Operation(desc = "List the client addresses which match the given IP Address", impact = MBeanOperationInfo.INFO)
217       String[] listRemoteAddresses(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
218    
219       /**
220        * Closes all the connections of clients connected to this server which matches the specified IP address.
221        */
222       @Operation(desc = "Closes all the connections for the given IP Address", impact = MBeanOperationInfo.INFO)
223       boolean closeConnectionsForAddress(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
224    
225       /**
226        * Lists all the IDs of the connections connected to this server.
227        */
228       @Operation(desc = "List all the connection IDs", impact = MBeanOperationInfo.INFO)
229       String[] listConnectionIDs() throws Exception;
230    
231       /**
232        * Lists all the sessions IDs for the specified connection ID.
233        */
234       @Operation(desc = "List the sessions for the given connectionID", impact = MBeanOperationInfo.INFO)
235       String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
236    
237    
238    }