String methodName;
String destinationContext;
if (type == Topic.class)
{
destinationContext = "topic";
methodName = "createTopic";
}
else if (type == Queue.class)
{
destinationContext = "queue";
methodName = "createQueue";
}
else
{
// type was not a Topic or Queue, bad user
throw new IllegalArgumentException
("Expected javax.jms.Queue or javax.jms.Topic: " + type);
}
String name = jndiSuffix;
String jndiName = destinationContext + "/" + jndiSuffix;
ObjectName serverPeerName = new ObjectName("jboss.messaging:service=ServerPeer");
KernelAbstraction kernel = KernelAbstractionFactory.getInstance();
// invoke the server to create the destination
Object result = kernel.invoke(serverPeerName,
methodName,
new Object[]{name, jndiName},
new String[]{"java.lang.String", "java.lang.String"});
log.debug("result = " + result);