Skip to main content
summaryrefslogtreecommitdiffstats
blob: 01157de47bf37f2c4b38628ac893b38e2ddf4564 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/***************************************************************************
 * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *    Eike Stepper - initial API and implementation
 **************************************************************************/
package org.eclipse.net4j.jms.internal.admin;

import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.jms.JMSAdminProtocolConstants;
import org.eclipse.net4j.jms.admin.IJMSAdmin;
import org.eclipse.net4j.jms.internal.admin.bundle.OM;
import org.eclipse.net4j.jms.internal.admin.protocol.JMSAdminProtocol;
import org.eclipse.net4j.jms.internal.admin.protocol.JMSCreateDestinationRequest;

/**
 * @author Eike Stepper
 */
public class JMSAdmin implements IJMSAdmin
{
  private JMSAdminProtocol protocol;

  public JMSAdmin(IConnector connector)
  {
    protocol = new JMSAdminProtocol(connector);
  }

  public void close()
  {
    protocol.close();
    protocol = null;
  }

  public boolean createQueue(String name)
  {
    return createDestination(name, JMSAdminProtocolConstants.DESTINATION_TYPE_QUEUE);
  }

  public boolean createTopic(String name)
  {
    return createDestination(name, JMSAdminProtocolConstants.DESTINATION_TYPE_TOPIC);
  }

  private boolean createDestination(String name, byte type)
  {
    try
    {
      return new JMSCreateDestinationRequest(protocol, type, name).send();
    }
    catch (Exception ex)
    {
      OM.LOG.error(ex);
      return false;
    }
  }
}

Back to the top