This closes #2200
This commit is contained in:
commit
1aa211f900
|
@ -32,6 +32,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.activemq</groupId>
|
||||||
|
<artifactId>artemis-commons</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xml-apis</groupId>
|
<groupId>xml-apis</groupId>
|
||||||
<artifactId>xml-apis</artifactId>
|
<artifactId>xml-apis</artifactId>
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.selector.filter;
|
package org.apache.activemq.artemis.selector.filter;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Filterable is the object being evaluated by the filters. It provides
|
* A Filterable is the object being evaluated by the filters. It provides
|
||||||
* access to filtered properties.
|
* access to filtered properties.
|
||||||
|
@ -41,7 +43,7 @@ public interface Filterable {
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Object getProperty(String name);
|
Object getProperty(SimpleString name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the NoLocal filter.
|
* Used by the NoLocal filter.
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.selector.filter;
|
package org.apache.activemq.artemis.selector.filter;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a property expression
|
* Represents a property expression
|
||||||
*
|
*
|
||||||
|
@ -23,9 +25,13 @@ package org.apache.activemq.artemis.selector.filter;
|
||||||
*/
|
*/
|
||||||
public class PropertyExpression implements Expression {
|
public class PropertyExpression implements Expression {
|
||||||
|
|
||||||
private final String name;
|
private final SimpleString name;
|
||||||
|
|
||||||
public PropertyExpression(String name) {
|
public PropertyExpression(String name) {
|
||||||
|
this(SimpleString.toSimpleString(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyExpression(SimpleString name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +41,7 @@ public class PropertyExpression implements Expression {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +49,7 @@ public class PropertyExpression implements Expression {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.activemq.artemis.selector;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
import org.apache.activemq.artemis.selector.filter.BooleanExpression;
|
import org.apache.activemq.artemis.selector.filter.BooleanExpression;
|
||||||
import org.apache.activemq.artemis.selector.filter.FilterException;
|
import org.apache.activemq.artemis.selector.filter.FilterException;
|
||||||
import org.apache.activemq.artemis.selector.filter.Filterable;
|
import org.apache.activemq.artemis.selector.filter.Filterable;
|
||||||
|
@ -100,14 +101,15 @@ public class SelectorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getProperty(String name) {
|
public Object getProperty(SimpleString name) {
|
||||||
if ("JMSType".equals(name)) {
|
String stringName = name.toString();
|
||||||
|
if ("JMSType".equals(stringName)) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
if ("JMSMessageID".equals(name)) {
|
if ("JMSMessageID".equals(stringName)) {
|
||||||
return messageId;
|
return messageId;
|
||||||
}
|
}
|
||||||
return properties.get(name);
|
return properties.get(stringName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getDestination() {
|
public Object getDestination() {
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class FilterImpl implements Filter {
|
||||||
// Proton stores JMSMessageID as NATIVE_MESSAGE_ID that is an arbitrary string
|
// Proton stores JMSMessageID as NATIVE_MESSAGE_ID that is an arbitrary string
|
||||||
String amqpNativeID = msg.getStringProperty(NATIVE_MESSAGE_ID);
|
String amqpNativeID = msg.getStringProperty(NATIVE_MESSAGE_ID);
|
||||||
if (amqpNativeID != null) {
|
if (amqpNativeID != null) {
|
||||||
return new SimpleString(amqpNativeID);
|
return SimpleString.toSimpleString(amqpNativeID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// It's the stringified (hex) representation of a user id that can be used in a selector expression
|
// It's the stringified (hex) representation of a user id that can be used in a selector expression
|
||||||
|
@ -162,7 +162,7 @@ public class FilterImpl implements Filter {
|
||||||
if (userID.startsWith("ID:")) {
|
if (userID.startsWith("ID:")) {
|
||||||
return SimpleString.toSimpleString(userID);
|
return SimpleString.toSimpleString(userID);
|
||||||
} else {
|
} else {
|
||||||
return new SimpleString("ID:" + msg.getUserID());
|
return SimpleString.toSimpleString("ID:" + msg.getUserID());
|
||||||
}
|
}
|
||||||
} else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) {
|
} else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) {
|
||||||
return Integer.valueOf(msg.getPriority());
|
return Integer.valueOf(msg.getPriority());
|
||||||
|
@ -190,10 +190,10 @@ public class FilterImpl implements Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getProperty(String id) {
|
public Object getProperty(SimpleString id) {
|
||||||
Object result = null;
|
Object result = null;
|
||||||
if (id.startsWith(FilterConstants.ACTIVEMQ_PREFIX.toString())) {
|
if (id.startsWith(FilterConstants.ACTIVEMQ_PREFIX)) {
|
||||||
result = getHeaderFieldValue(message, new SimpleString(id));
|
result = getHeaderFieldValue(message, id);
|
||||||
}
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = message.getObjectProperty(id);
|
result = message.getObjectProperty(id);
|
||||||
|
|
Loading…
Reference in New Issue