use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class VerifyDestinationHandler method handle.
/**
* Method to handle Destination (create or delete) messages
*/
@Override
public boolean handle(IMQConnection con, Packet msg) throws BrokerException {
int status = Status.OK;
String reason = null;
assert msg.getPacketType() == PacketType.VERIFY_DESTINATION;
Packet pkt = new Packet(con.useDirectBuffers());
pkt.setConsumerID(msg.getConsumerID());
pkt.setPacketType(PacketType.VERIFY_DESTINATION_REPLY);
Hashtable hash = new Hashtable();
Hashtable props = null;
String selectorstr = null;
int type = 0;
try {
props = msg.getProperties();
String destination = (String) props.get("JMQDestination");
Integer inttype = (Integer) props.get("JMQDestType");
// destination & type required
assert destination != null;
type = (inttype == null) ? 0 : inttype.intValue();
selectorstr = (String) props.get("JMQSelector");
if (selectorstr != null) {
Selector.compile(selectorstr);
}
boolean notFound = false;
DestinationSpi d = null;
if (DestinationUID.isWildcard(destination)) {
// retrieve the list of destinations
pkt.setWildcard(true);
// see if there are any destinations that match
DestinationUID duid = DestinationUID.getUID(destination, type);
List[] ll = coreLifecycle.findMatchingIDs(con.getPartitionedStore(), duid);
List l = ll[0];
if (l.isEmpty()) {
notFound = true;
}
} else {
DestinationSpi[] ds = coreLifecycle.getDestination(con.getPartitionedStore(), destination, DestType.isQueue(type));
d = ds[0];
notFound = (d == null);
}
if (notFound) {
// not found
status = Status.NOT_FOUND;
reason = "destination not found";
hash.put("JMQCanCreate", Boolean.valueOf(coreLifecycle.canAutoCreate(DestType.isQueue(type))));
} else {
if (d != null) {
hash.put("JMQDestType", Integer.valueOf(d.getType()));
}
}
} catch (SelectorFormatException ex) {
reason = ex.getMessage();
status = Status.BAD_REQUEST;
logger.log(Logger.WARNING, BrokerResources.W_SELECTOR_PARSE, selectorstr, ex);
} catch (IOException ex) {
logger.logStack(Logger.ERROR, BrokerResources.E_INTERNAL_BROKER_ERROR, "Unable to verify destination - no properties", ex);
reason = ex.getMessage();
status = Status.ERROR;
} catch (ClassNotFoundException ex) {
logger.logStack(Logger.ERROR, BrokerResources.E_INTERNAL_BROKER_ERROR, "Unable to verify destination -bad class", ex);
reason = ex.getMessage();
status = Status.ERROR;
} catch (BrokerException ex) {
reason = ex.getMessage();
status = ex.getStatusCode();
logger.logStack(Logger.DEBUG, BrokerResources.E_INTERNAL_BROKER_ERROR, "Unable to verify destination ", ex);
} catch (SecurityException ex) {
reason = ex.getMessage();
status = Status.FORBIDDEN;
logger.log(Logger.WARNING, ex.toString(), ex);
}
hash.put("JMQStatus", Integer.valueOf(status));
if (reason != null) {
hash.put("JMQReason", reason);
}
if (((IMQBasicConnection) con).getDumpPacket() || ((IMQBasicConnection) con).getDumpOutPacket()) {
hash.put("JMQReqID", msg.getSysMessageID().toString());
}
pkt.setProperties(hash);
con.sendControlMessage(pkt);
return true;
}
use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class DestinationMonitor method getProducerWildcards.
public String[] getProducerWildcards() throws MBeanException {
ArrayList<String> al = new ArrayList<>();
String[] list = null;
int numProducers = getNumProducers().intValue();
Iterator producers;
if (numProducers <= 0) {
return (null);
}
producers = d.getProducers();
while (producers.hasNext()) {
ProducerSpi oneProd = (ProducerSpi) producers.next();
if (oneProd.isWildcard()) {
DestinationUID id = oneProd.getDestinationUID();
al.add(id.getName());
}
}
if (al.size() > 0) {
list = new String[al.size()];
list = al.toArray(list);
}
return (list);
}
use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class DestinationMonitor method getWildcards.
public String[] getWildcards() throws MBeanException {
ArrayList<String> al = new ArrayList<>();
String[] list = null;
int numConsumers = getNumConsumers().intValue(), numProducers = getNumProducers().intValue();
if (numConsumers > 0) {
Iterator consumers = d.getConsumers();
while (consumers.hasNext()) {
Consumer oneCon = (Consumer) consumers.next();
if (oneCon.isWildcard()) {
DestinationUID id = oneCon.getDestinationUID();
al.add(id.getName());
}
}
}
if (numProducers > 0) {
Iterator producers = d.getProducers();
while (producers.hasNext()) {
ProducerSpi oneProd = (ProducerSpi) producers.next();
if (oneProd.isWildcard()) {
DestinationUID id = oneProd.getDestinationUID();
al.add(id.getName());
}
}
}
if (al.size() > 0) {
list = new String[al.size()];
list = al.toArray(list);
}
return (list);
}
use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class DestinationMonitor method getConsumerWildcards.
public String[] getConsumerWildcards() throws MBeanException {
ArrayList<String> al = new ArrayList<>();
String[] list = null;
int numConsumers = getNumConsumers().intValue();
Iterator consumers;
if (numConsumers <= 0) {
return (null);
}
consumers = d.getConsumers();
while (consumers.hasNext()) {
Consumer oneCon = (Consumer) consumers.next();
if (oneCon.isWildcard()) {
DestinationUID id = oneCon.getDestinationUID();
al.add(id.getName());
}
}
if (al.size() > 0) {
list = new String[al.size()];
list = al.toArray(list);
}
return (list);
}
use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class DestinationMonitor method getNumWildcardConsumers.
public Integer getNumWildcardConsumers(String wildcard) throws MBeanException {
int numConsumers = getNumConsumers().intValue();
if (numConsumers <= 0) {
return (Integer.valueOf(0));
}
Iterator consumers = d.getConsumers();
if (consumers == null) {
return (Integer.valueOf(0));
}
int count = 0;
while (consumers.hasNext()) {
Consumer oneCon = (Consumer) consumers.next();
if (oneCon.isWildcard()) {
/*
* If wildcard param is not null, check for matches If it is null, return total count of wildcards
*/
if (wildcard != null) {
DestinationUID id = oneCon.getDestinationUID();
if (id.getName().equals(wildcard)) {
count++;
}
} else {
count++;
}
}
}
return (Integer.valueOf(count));
}
Aggregations