blob: 75fb005d6b569c17389a2d77f9e9fb487c721d66 (
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
61
62
63
64
65
|
/**
* 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.server.protocol.admin;
import org.eclipse.net4j.jms.JMSAdminProtocolConstants;
import org.eclipse.net4j.jms.server.IDestination;
import org.eclipse.net4j.jms.server.IServer;
import org.eclipse.net4j.jms.server.IDestination.Type;
import org.eclipse.net4j.signal.IndicationWithResponse;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
/**
* @author Eike Stepper
*/
public class JMSCreateDestinationIndication extends IndicationWithResponse
{
private boolean ok;
public JMSCreateDestinationIndication(JMSAdminServerProtocol protocol)
{
super(protocol, JMSAdminProtocolConstants.SIGNAL_CREATE_DESTINATION);
}
@Override
protected void indicating(ExtendedDataInputStream in) throws Exception
{
byte type = in.readByte();
String name = in.readString();
JMSAdminServerProtocol protocol = (JMSAdminServerProtocol)getProtocol();
IServer server = protocol.getServer();
IDestination destination = server.createDestination(name, getDestinationType(type));
if (destination != null)
{
ok = true;
}
}
@Override
protected void responding(ExtendedDataOutputStream out) throws Exception
{
out.writeBoolean(ok);
}
private Type getDestinationType(byte type)
{
switch (type)
{
case JMSAdminProtocolConstants.DESTINATION_TYPE_QUEUE:
return IDestination.Type.QUEUE;
case JMSAdminProtocolConstants.DESTINATION_TYPE_TOPIC:
return IDestination.Type.TOPIC;
}
throw new IllegalArgumentException("type: " + type); //$NON-NLS-1$
}
}
|