You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/08/10 17:13:16 UTC
[17/53] [abbrv] [partial] activemq-artemis git commit: automatic
checkstyle change
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
index cc3f255..db72dff 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java
@@ -45,54 +45,46 @@ import org.apache.activemq.artemis.core.message.impl.MessageInternal;
import org.apache.activemq.artemis.reader.MessageUtil;
import org.apache.activemq.artemis.utils.UUID;
-
/**
* ActiveMQ Artemis implementation of a JMS Message.
* <br>
* JMS Messages only live on the client side - the server only deals with MessageImpl
* instances
*/
-public class ActiveMQMessage implements javax.jms.Message
-{
+public class ActiveMQMessage implements javax.jms.Message {
+
// Constants -----------------------------------------------------
public static final byte TYPE = org.apache.activemq.artemis.api.core.Message.DEFAULT_TYPE;
- public static Map<String, Object> coreMaptoJMSMap(final Map<String, Object> coreMessage)
- {
+ public static Map<String, Object> coreMaptoJMSMap(final Map<String, Object> coreMessage) {
Map<String, Object> jmsMessage = new HashMap<String, Object>();
- String deliveryMode = (Boolean)coreMessage.get("durable") ? "PERSISTENT" : "NON_PERSISTENT";
- byte priority = (Byte)coreMessage.get("priority");
- long timestamp = (Long)coreMessage.get("timestamp");
- long expiration = (Long)coreMessage.get("expiration");
+ String deliveryMode = (Boolean) coreMessage.get("durable") ? "PERSISTENT" : "NON_PERSISTENT";
+ byte priority = (Byte) coreMessage.get("priority");
+ long timestamp = (Long) coreMessage.get("timestamp");
+ long expiration = (Long) coreMessage.get("expiration");
jmsMessage.put("JMSPriority", priority);
jmsMessage.put("JMSTimestamp", timestamp);
jmsMessage.put("JMSExpiration", expiration);
jmsMessage.put("JMSDeliveryMode", deliveryMode);
- for (Map.Entry<String, Object> entry : coreMessage.entrySet())
- {
+ for (Map.Entry<String, Object> entry : coreMessage.entrySet()) {
if (entry.getKey().equals("type") || entry.getKey().equals("durable") ||
- entry.getKey().equals("expiration") ||
- entry.getKey().equals("timestamp") ||
- entry.getKey().equals("priority"))
- {
+ entry.getKey().equals("expiration") ||
+ entry.getKey().equals("timestamp") ||
+ entry.getKey().equals("priority")) {
// Ignore
}
- else if (entry.getKey().equals("userID"))
- {
+ else if (entry.getKey().equals("userID")) {
jmsMessage.put("JMSMessageID", entry.getValue().toString());
}
- else
- {
+ else {
Object value = entry.getValue();
- if (value instanceof SimpleString)
- {
+ if (value instanceof SimpleString) {
jmsMessage.put(entry.getKey(), value.toString());
}
- else
- {
+ else {
jmsMessage.put(entry.getKey(), value);
}
}
@@ -104,8 +96,8 @@ public class ActiveMQMessage implements javax.jms.Message
// Static --------------------------------------------------------
private static final HashSet<String> reservedIdentifiers = new HashSet<String>();
- static
- {
+
+ static {
ActiveMQMessage.reservedIdentifiers.add("NULL");
ActiveMQMessage.reservedIdentifiers.add("TRUE");
ActiveMQMessage.reservedIdentifiers.add("FALSE");
@@ -119,14 +111,12 @@ public class ActiveMQMessage implements javax.jms.Message
ActiveMQMessage.reservedIdentifiers.add("ESCAPE");
}
- public static ActiveMQMessage createMessage(final ClientMessage message, final ClientSession session)
- {
+ public static ActiveMQMessage createMessage(final ClientMessage message, final ClientSession session) {
int type = message.getType();
ActiveMQMessage msg;
- switch (type)
- {
+ switch (type) {
case ActiveMQMessage.TYPE: // 0
{
msg = new ActiveMQMessage(message, session);
@@ -142,8 +132,7 @@ public class ActiveMQMessage implements javax.jms.Message
msg = new ActiveMQMapMessage(message, session);
break;
}
- case ActiveMQObjectMessage.TYPE:
- {
+ case ActiveMQObjectMessage.TYPE: {
msg = new ActiveMQObjectMessage(message, session);
break;
}
@@ -157,8 +146,7 @@ public class ActiveMQMessage implements javax.jms.Message
msg = new ActiveMQTextMessage(message, session);
break;
}
- default:
- {
+ default: {
throw new JMSRuntimeException("Invalid message type " + type);
}
}
@@ -203,22 +191,19 @@ public class ActiveMQMessage implements javax.jms.Message
/*
* Create a new message prior to sending
*/
- protected ActiveMQMessage(final byte type, final ClientSession session)
- {
- message = session.createMessage(type, true, 0, System.currentTimeMillis(), (byte)4);
+ protected ActiveMQMessage(final byte type, final ClientSession session) {
+ message = session.createMessage(type, true, 0, System.currentTimeMillis(), (byte) 4);
}
- protected ActiveMQMessage(final ClientSession session)
- {
+ protected ActiveMQMessage(final ClientSession session) {
this(ActiveMQMessage.TYPE, session);
}
/**
* Constructor for when receiving a message from the server
*/
- public ActiveMQMessage(final ClientMessage message, final ClientSession session)
- {
+ public ActiveMQMessage(final ClientMessage message, final ClientSession session) {
this.message = message;
readOnly = true;
@@ -231,17 +216,14 @@ public class ActiveMQMessage implements javax.jms.Message
/*
* A constructor that takes a foreign message
*/
- public ActiveMQMessage(final Message foreign, final ClientSession session) throws JMSException
- {
+ public ActiveMQMessage(final Message foreign, final ClientSession session) throws JMSException {
this(foreign, ActiveMQMessage.TYPE, session);
}
- public ActiveMQMessage()
- {
+ public ActiveMQMessage() {
}
- protected ActiveMQMessage(final Message foreign, final byte type, final ClientSession session) throws JMSException
- {
+ protected ActiveMQMessage(final Message foreign, final byte type, final ClientSession session) throws JMSException {
this(type, session);
setJMSTimestamp(foreign.getJMSTimestamp());
@@ -250,25 +232,20 @@ public class ActiveMQMessage implements javax.jms.Message
boolean supportBytesId = !"false".equals(value);
- if (supportBytesId)
- {
- try
- {
+ if (supportBytesId) {
+ try {
byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes();
setJMSCorrelationIDAsBytes(corrIDBytes);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
// specified as String
String corrIDString = foreign.getJMSCorrelationID();
- if (corrIDString != null)
- {
+ if (corrIDString != null) {
setJMSCorrelationID(corrIDString);
}
}
}
- else
- {
+ else {
// Some providers, like WSMQ do automatic conversions between native byte[] correlation id
// and String correlation id. This makes it impossible for ActiveMQ Artemis to guarantee to return the correct
// type as set by the user
@@ -276,8 +253,7 @@ public class ActiveMQMessage implements javax.jms.Message
// https://jira.jboss.org/jira/browse/HORNETQ-356
// https://jira.jboss.org/jira/browse/HORNETQ-332
String corrIDString = foreign.getJMSCorrelationID();
- if (corrIDString != null)
- {
+ if (corrIDString != null) {
setJMSCorrelationID(corrIDString);
}
}
@@ -290,8 +266,7 @@ public class ActiveMQMessage implements javax.jms.Message
setJMSType(foreign.getJMSType());
// We can't avoid a cast warning here since getPropertyNames() is on the JMS API
- for (Enumeration<String> props = foreign.getPropertyNames(); props.hasMoreElements();)
- {
+ for (Enumeration<String> props = foreign.getPropertyNames(); props.hasMoreElements(); ) {
String name = props.nextElement();
Object prop = foreign.getObjectProperty(name);
@@ -302,10 +277,8 @@ public class ActiveMQMessage implements javax.jms.Message
// javax.jmx.Message implementation ------------------------------
- public String getJMSMessageID()
- {
- if (msgID == null)
- {
+ public String getJMSMessageID() {
+ if (msgID == null) {
UUID uid = message.getUserID();
msgID = uid == null ? null : "ID:" + uid.toString();
@@ -313,10 +286,8 @@ public class ActiveMQMessage implements javax.jms.Message
return msgID;
}
- public void setJMSMessageID(final String jmsMessageID) throws JMSException
- {
- if (jmsMessageID != null && !jmsMessageID.startsWith("ID:"))
- {
+ public void setJMSMessageID(final String jmsMessageID) throws JMSException {
+ if (jmsMessageID != null && !jmsMessageID.startsWith("ID:")) {
throw new JMSException("JMSMessageID must start with ID:");
}
@@ -325,82 +296,66 @@ public class ActiveMQMessage implements javax.jms.Message
msgID = jmsMessageID;
}
- public long getJMSTimestamp() throws JMSException
- {
+ public long getJMSTimestamp() throws JMSException {
return message.getTimestamp();
}
- public void setJMSTimestamp(final long timestamp) throws JMSException
- {
+ public void setJMSTimestamp(final long timestamp) throws JMSException {
message.setTimestamp(timestamp);
}
- public byte[] getJMSCorrelationIDAsBytes() throws JMSException
- {
+ public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
return MessageUtil.getJMSCorrelationIDAsBytes(message);
}
- public void setJMSCorrelationIDAsBytes(final byte[] correlationID) throws JMSException
- {
- try
- {
+ public void setJMSCorrelationIDAsBytes(final byte[] correlationID) throws JMSException {
+ try {
MessageUtil.setJMSCorrelationIDAsBytes(message, correlationID);
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
JMSException ex = new JMSException(e.getMessage());
ex.initCause(e);
throw ex;
}
}
- public void setJMSCorrelationID(final String correlationID) throws JMSException
- {
+ public void setJMSCorrelationID(final String correlationID) throws JMSException {
MessageUtil.setJMSCorrelationID(message, correlationID);
jmsCorrelationID = correlationID;
}
- public String getJMSCorrelationID() throws JMSException
- {
- if (jmsCorrelationID == null)
- {
+ public String getJMSCorrelationID() throws JMSException {
+ if (jmsCorrelationID == null) {
jmsCorrelationID = MessageUtil.getJMSCorrelationID(message);
}
return jmsCorrelationID;
}
- public Destination getJMSReplyTo() throws JMSException
- {
- if (replyTo == null)
- {
+ public Destination getJMSReplyTo() throws JMSException {
+ if (replyTo == null) {
SimpleString repl = MessageUtil.getJMSReplyTo(message);
- if (repl != null)
- {
+ if (repl != null) {
replyTo = ActiveMQDestination.fromAddress(repl.toString());
}
}
return replyTo;
}
- public void setJMSReplyTo(final Destination dest) throws JMSException
- {
+ public void setJMSReplyTo(final Destination dest) throws JMSException {
- if (dest == null)
- {
+ if (dest == null) {
MessageUtil.setJMSReplyTo(message, null);
replyTo = null;
}
- else
- {
- if (dest instanceof ActiveMQDestination == false)
- {
+ else {
+ if (dest instanceof ActiveMQDestination == false) {
throw new InvalidDestinationException("Foreign destination " + dest);
}
- ActiveMQDestination jbd = (ActiveMQDestination)dest;
+ ActiveMQDestination jbd = (ActiveMQDestination) dest;
MessageUtil.setJMSReplyTo(message, jbd.getSimpleAddress());
@@ -408,10 +363,8 @@ public class ActiveMQMessage implements javax.jms.Message
}
}
- public Destination getJMSDestination() throws JMSException
- {
- if (dest == null)
- {
+ public Destination getJMSDestination() throws JMSException {
+ if (dest == null) {
SimpleString sdest = message.getAddress();
dest = sdest == null ? null : ActiveMQDestination.fromAddress(sdest.toString());
@@ -420,400 +373,315 @@ public class ActiveMQMessage implements javax.jms.Message
return dest;
}
- public void setJMSDestination(final Destination destination) throws JMSException
- {
+ public void setJMSDestination(final Destination destination) throws JMSException {
dest = destination;
}
- public int getJMSDeliveryMode() throws JMSException
- {
+ public int getJMSDeliveryMode() throws JMSException {
return message.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
- public void setJMSDeliveryMode(final int deliveryMode) throws JMSException
- {
- if (deliveryMode == DeliveryMode.PERSISTENT)
- {
+ public void setJMSDeliveryMode(final int deliveryMode) throws JMSException {
+ if (deliveryMode == DeliveryMode.PERSISTENT) {
message.setDurable(true);
}
- else if (deliveryMode == DeliveryMode.NON_PERSISTENT)
- {
+ else if (deliveryMode == DeliveryMode.NON_PERSISTENT) {
message.setDurable(false);
}
- else
- {
+ else {
throw ActiveMQJMSClientBundle.BUNDLE.illegalDeliveryMode(deliveryMode);
}
}
- public boolean getJMSRedelivered() throws JMSException
- {
+ public boolean getJMSRedelivered() throws JMSException {
return message.getDeliveryCount() > 1;
}
- public void setJMSRedelivered(final boolean redelivered) throws JMSException
- {
- if (!redelivered)
- {
+ public void setJMSRedelivered(final boolean redelivered) throws JMSException {
+ if (!redelivered) {
message.setDeliveryCount(1);
}
- else
- {
- if (message.getDeliveryCount() > 1)
- {
+ else {
+ if (message.getDeliveryCount() > 1) {
// do nothing
}
- else
- {
+ else {
message.setDeliveryCount(2);
}
}
}
- public void setJMSType(final String type) throws JMSException
- {
- if (type != null)
- {
+ public void setJMSType(final String type) throws JMSException {
+ if (type != null) {
MessageUtil.setJMSType(message, type);
jmsType = type;
}
}
- public String getJMSType() throws JMSException
- {
- if (jmsType == null)
- {
+ public String getJMSType() throws JMSException {
+ if (jmsType == null) {
jmsType = MessageUtil.getJMSType(message);
}
return jmsType;
}
- public long getJMSExpiration() throws JMSException
- {
+ public long getJMSExpiration() throws JMSException {
return message.getExpiration();
}
- public void setJMSExpiration(final long expiration) throws JMSException
- {
+ public void setJMSExpiration(final long expiration) throws JMSException {
message.setExpiration(expiration);
}
- public int getJMSPriority() throws JMSException
- {
+ public int getJMSPriority() throws JMSException {
return message.getPriority();
}
- public void setJMSPriority(final int priority) throws JMSException
- {
+ public void setJMSPriority(final int priority) throws JMSException {
checkPriority(priority);
- message.setPriority((byte)priority);
+ message.setPriority((byte) priority);
}
- public void clearProperties() throws JMSException
- {
+ public void clearProperties() throws JMSException {
MessageUtil.clearProperties(message);
propertiesReadOnly = false;
}
- public void clearBody() throws JMSException
- {
+ public void clearBody() throws JMSException {
readOnly = false;
}
- public boolean propertyExists(final String name) throws JMSException
- {
+ public boolean propertyExists(final String name) throws JMSException {
return MessageUtil.propertyExists(message, name);
}
- public boolean getBooleanProperty(final String name) throws JMSException
- {
- try
- {
+ public boolean getBooleanProperty(final String name) throws JMSException {
+ try {
return message.getBooleanProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public byte getByteProperty(final String name) throws JMSException
- {
- try
- {
+ public byte getByteProperty(final String name) throws JMSException {
+ try {
return message.getByteProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public short getShortProperty(final String name) throws JMSException
- {
- try
- {
+ public short getShortProperty(final String name) throws JMSException {
+ try {
return message.getShortProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public int getIntProperty(final String name) throws JMSException
- {
- if (MessageUtil.JMSXDELIVERYCOUNT.equals(name))
- {
+ public int getIntProperty(final String name) throws JMSException {
+ if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return message.getDeliveryCount();
}
- try
- {
+ try {
return message.getIntProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public long getLongProperty(final String name) throws JMSException
- {
- if (MessageUtil.JMSXDELIVERYCOUNT.equals(name))
- {
+ public long getLongProperty(final String name) throws JMSException {
+ if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return message.getDeliveryCount();
}
- try
- {
+ try {
return message.getLongProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public float getFloatProperty(final String name) throws JMSException
- {
- try
- {
+ public float getFloatProperty(final String name) throws JMSException {
+ try {
return message.getFloatProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public double getDoubleProperty(final String name) throws JMSException
- {
- try
- {
+ public double getDoubleProperty(final String name) throws JMSException {
+ try {
return message.getDoubleProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public String getStringProperty(final String name) throws JMSException
- {
- if (MessageUtil.JMSXDELIVERYCOUNT.equals(name))
- {
+ public String getStringProperty(final String name) throws JMSException {
+ if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return String.valueOf(message.getDeliveryCount());
}
- try
- {
- if (MessageUtil.JMSXGROUPID.equals(name))
- {
+ try {
+ if (MessageUtil.JMSXGROUPID.equals(name)) {
return message.getStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_GROUP_ID);
}
- else
- {
+ else {
return message.getStringProperty(new SimpleString(name));
}
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public Object getObjectProperty(final String name) throws JMSException
- {
- if (MessageUtil.JMSXDELIVERYCOUNT.equals(name))
- {
+ public Object getObjectProperty(final String name) throws JMSException {
+ if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return String.valueOf(message.getDeliveryCount());
}
Object val = message.getObjectProperty(name);
- if (val instanceof SimpleString)
- {
- val = ((SimpleString)val).toString();
+ if (val instanceof SimpleString) {
+ val = ((SimpleString) val).toString();
}
return val;
}
@SuppressWarnings("rawtypes")
@Override
- public Enumeration getPropertyNames() throws JMSException
- {
+ public Enumeration getPropertyNames() throws JMSException {
return Collections.enumeration(MessageUtil.getPropertyNames(message));
}
- public void setBooleanProperty(final String name, final boolean value) throws JMSException
- {
+ public void setBooleanProperty(final String name, final boolean value) throws JMSException {
checkProperty(name);
message.putBooleanProperty(new SimpleString(name), value);
}
- public void setByteProperty(final String name, final byte value) throws JMSException
- {
+ public void setByteProperty(final String name, final byte value) throws JMSException {
checkProperty(name);
message.putByteProperty(new SimpleString(name), value);
}
- public void setShortProperty(final String name, final short value) throws JMSException
- {
+ public void setShortProperty(final String name, final short value) throws JMSException {
checkProperty(name);
message.putShortProperty(new SimpleString(name), value);
}
- public void setIntProperty(final String name, final int value) throws JMSException
- {
+ public void setIntProperty(final String name, final int value) throws JMSException {
checkProperty(name);
message.putIntProperty(new SimpleString(name), value);
}
- public void setLongProperty(final String name, final long value) throws JMSException
- {
+ public void setLongProperty(final String name, final long value) throws JMSException {
checkProperty(name);
message.putLongProperty(new SimpleString(name), value);
}
- public void setFloatProperty(final String name, final float value) throws JMSException
- {
+ public void setFloatProperty(final String name, final float value) throws JMSException {
checkProperty(name);
message.putFloatProperty(new SimpleString(name), value);
}
- public void setDoubleProperty(final String name, final double value) throws JMSException
- {
+ public void setDoubleProperty(final String name, final double value) throws JMSException {
checkProperty(name);
message.putDoubleProperty(new SimpleString(name), value);
}
- public void setStringProperty(final String name, final String value) throws JMSException
- {
+ public void setStringProperty(final String name, final String value) throws JMSException {
checkProperty(name);
- if (MessageUtil.JMSXGROUPID.equals(name))
- {
+ if (MessageUtil.JMSXGROUPID.equals(name)) {
message.putStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_GROUP_ID, SimpleString.toSimpleString(value));
}
- else
- {
- message.putStringProperty(new SimpleString(name), SimpleString.toSimpleString(value));
+ else {
+ message.putStringProperty(new SimpleString(name), SimpleString.toSimpleString(value));
}
}
- public void setObjectProperty(final String name, final Object value) throws JMSException
- {
- if (ActiveMQJMSConstants.JMS_ACTIVEMQ_OUTPUT_STREAM.equals(name))
- {
- setOutputStream((OutputStream)value);
+ public void setObjectProperty(final String name, final Object value) throws JMSException {
+ if (ActiveMQJMSConstants.JMS_ACTIVEMQ_OUTPUT_STREAM.equals(name)) {
+ setOutputStream((OutputStream) value);
return;
}
- else if (ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM.equals(name))
- {
- saveToOutputStream((OutputStream)value);
+ else if (ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM.equals(name)) {
+ saveToOutputStream((OutputStream) value);
return;
}
checkProperty(name);
- if (ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM.equals(name))
- {
- setInputStream((InputStream)value);
+ if (ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM.equals(name)) {
+ setInputStream((InputStream) value);
return;
}
- try
- {
+ try {
message.putObjectProperty(new SimpleString(name), value);
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public void acknowledge() throws JMSException
- {
- if (session != null)
- {
- try
- {
- if (individualAck)
- {
+ public void acknowledge() throws JMSException {
+ if (session != null) {
+ try {
+ if (individualAck) {
message.individualAcknowledge();
}
session.commit();
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
}
@Override
- public long getJMSDeliveryTime() throws JMSException
- {
+ public long getJMSDeliveryTime() throws JMSException {
Long value;
- try
- {
+ try {
value = message.getLongProperty(org.apache.activemq.artemis.api.core.Message.HDR_SCHEDULED_DELIVERY_TIME);
}
- catch (Exception e)
- {
+ catch (Exception e) {
return 0;
}
- if (value == null)
- {
+ if (value == null) {
return 0;
}
- else
- {
+ else {
return value.longValue();
}
}
@Override
- public void setJMSDeliveryTime(long deliveryTime) throws JMSException
- {
+ public void setJMSDeliveryTime(long deliveryTime) throws JMSException {
message.putLongProperty(org.apache.activemq.artemis.api.core.Message.HDR_SCHEDULED_DELIVERY_TIME, deliveryTime);
}
@Override
- public <T> T getBody(Class<T> c) throws JMSException
- {
- if (isBodyAssignableTo(c))
- {
+ public <T> T getBody(Class<T> c) throws JMSException {
+ if (isBodyAssignableTo(c)) {
return getBodyInternal(c);
}
// XXX HORNETQ-1209 Do we need translations here?
@@ -821,24 +689,19 @@ public class ActiveMQMessage implements javax.jms.Message
}
@SuppressWarnings("unchecked")
- protected <T> T getBodyInternal(Class<T> c) throws MessageFormatException
- {
- InputStream is = ((MessageInternal)message).getBodyInputStream();
- try
- {
+ protected <T> T getBodyInternal(Class<T> c) throws MessageFormatException {
+ InputStream is = ((MessageInternal) message).getBodyInputStream();
+ try {
ObjectInputStream ois = new ObjectInputStream(is);
- return (T)ois.readObject();
+ return (T) ois.readObject();
}
- catch (Exception e)
- {
+ catch (Exception e) {
throw new MessageFormatException(e.getMessage());
}
}
-
@Override
- public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class c)
- {
+ public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class c) {
/**
* From the specs:
* <p>
@@ -850,120 +713,98 @@ public class ActiveMQMessage implements javax.jms.Message
/**
* Helper method for {@link #isBodyAssignableTo(Class)}.
+ *
* @return true if the message has no body.
*/
- protected boolean hasNoBody()
- {
+ protected boolean hasNoBody() {
return message.getBodySize() == 0;
}
// Public --------------------------------------------------------
- public void setIndividualAcknowledge()
- {
+ public void setIndividualAcknowledge() {
this.individualAck = true;
}
- public void resetMessageID(final String newMsgID)
- {
+ public void resetMessageID(final String newMsgID) {
this.msgID = newMsgID;
}
- public ClientMessage getCoreMessage()
- {
+ public ClientMessage getCoreMessage() {
return message;
}
- public void doBeforeSend() throws Exception
- {
+ public void doBeforeSend() throws Exception {
message.getBodyBuffer().resetReaderIndex();
}
- public void checkBuffer()
- {
+ public void checkBuffer() {
message.getBodyBuffer();
}
- public void doBeforeReceive() throws ActiveMQException
- {
+ public void doBeforeReceive() throws ActiveMQException {
message.checkCompletion();
ActiveMQBuffer body = message.getBodyBuffer();
- if (body != null)
- {
+ if (body != null) {
body.resetReaderIndex();
}
}
- public byte getType()
- {
+ public byte getType() {
return ActiveMQMessage.TYPE;
}
- public void setInputStream(final InputStream input) throws JMSException
- {
+ public void setInputStream(final InputStream input) throws JMSException {
checkStream();
- if (readOnly)
- {
+ if (readOnly) {
throw ActiveMQJMSClientBundle.BUNDLE.messageNotWritable();
}
message.setBodyInputStream(input);
}
- public void setOutputStream(final OutputStream output) throws JMSException
- {
+ public void setOutputStream(final OutputStream output) throws JMSException {
checkStream();
- if (!readOnly)
- {
+ if (!readOnly) {
throw new IllegalStateException("OutputStream property is only valid on received messages");
}
- try
- {
+ try {
message.setOutputStream(output);
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
- public void saveToOutputStream(final OutputStream output) throws JMSException
- {
+ public void saveToOutputStream(final OutputStream output) throws JMSException {
checkStream();
- if (!readOnly)
- {
+ if (!readOnly) {
throw new IllegalStateException("OutputStream property is only valid on received messages");
}
- try
- {
+ try {
message.saveToOutputStream(output);
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
- public boolean waitCompletionOnStream(final long timeWait) throws JMSException
- {
+ public boolean waitCompletionOnStream(final long timeWait) throws JMSException {
checkStream();
- try
- {
+ try {
return message.waitOutputStreamCompletion(timeWait);
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
@Override
- public String toString()
- {
+ public String toString() {
StringBuffer sb = new StringBuffer("ActiveMQMessage[");
sb.append(getJMSMessageID());
sb.append("]:");
@@ -976,93 +817,73 @@ public class ActiveMQMessage implements javax.jms.Message
// Protected -----------------------------------------------------
- protected void checkWrite() throws JMSException
- {
- if (readOnly)
- {
+ protected void checkWrite() throws JMSException {
+ if (readOnly) {
throw ActiveMQJMSClientBundle.BUNDLE.messageNotWritable();
}
}
- protected void checkRead() throws JMSException
- {
- if (!readOnly)
- {
+ protected void checkRead() throws JMSException {
+ if (!readOnly) {
throw ActiveMQJMSClientBundle.BUNDLE.messageNotReadable();
}
}
// Private ------------------------------------------------------------
- private void checkStream() throws JMSException
- {
- if (!(message.getType() == ActiveMQBytesMessage.TYPE || message.getType() == ActiveMQStreamMessage.TYPE))
- {
+ private void checkStream() throws JMSException {
+ if (!(message.getType() == ActiveMQBytesMessage.TYPE || message.getType() == ActiveMQStreamMessage.TYPE)) {
throw ActiveMQJMSClientBundle.BUNDLE.onlyValidForByteOrStreamMessages();
}
}
- private void checkProperty(final String name) throws JMSException
- {
- if (propertiesReadOnly)
- {
- if (name.equals(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM))
- {
+ private void checkProperty(final String name) throws JMSException {
+ if (propertiesReadOnly) {
+ if (name.equals(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM)) {
throw new MessageNotWriteableException("You cannot set the Input Stream on received messages. Did you mean " + ActiveMQJMSConstants.JMS_ACTIVEMQ_OUTPUT_STREAM +
- " or " +
- ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM +
- "?");
+ " or " +
+ ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM +
+ "?");
}
- else
- {
+ else {
throw ActiveMQJMSClientBundle.BUNDLE.messageNotWritable();
}
}
- if (name == null)
- {
+ if (name == null) {
throw ActiveMQJMSClientBundle.BUNDLE.nullArgumentNotAllowed("property");
}
- if (name.equals(""))
- {
+ if (name.equals("")) {
throw new IllegalArgumentException("The name of a property must not be an empty String.");
}
- if (!isValidJavaIdentifier(name))
- {
+ if (!isValidJavaIdentifier(name)) {
throw ActiveMQJMSClientBundle.BUNDLE.invalidJavaIdentifier(name);
}
- if (ActiveMQMessage.reservedIdentifiers.contains(name))
- {
+ if (ActiveMQMessage.reservedIdentifiers.contains(name)) {
throw new JMSRuntimeException("The property name '" + name + "' is reserved due to selector syntax.");
}
- if (name.startsWith("JMS_ACTIVEMQ"))
- {
+ if (name.startsWith("JMS_ACTIVEMQ")) {
throw new JMSRuntimeException("The property name '" + name + "' is illegal since it starts with JMS_ACTIVEMQ");
}
}
- private boolean isValidJavaIdentifier(final String s)
- {
- if (s == null || s.length() == 0)
- {
+ private boolean isValidJavaIdentifier(final String s) {
+ if (s == null || s.length() == 0) {
return false;
}
char[] c = s.toCharArray();
- if (!Character.isJavaIdentifierStart(c[0]))
- {
+ if (!Character.isJavaIdentifierStart(c[0])) {
return false;
}
- for (int i = 1; i < c.length; i++)
- {
- if (!Character.isJavaIdentifierPart(c[i]))
- {
+ for (int i = 1; i < c.length; i++) {
+ if (!Character.isJavaIdentifierPart(c[i])) {
return false;
}
}
@@ -1070,10 +891,8 @@ public class ActiveMQMessage implements javax.jms.Message
return true;
}
- private void checkPriority(final int priority) throws JMSException
- {
- if (priority < 0 || priority > 9)
- {
+ private void checkPriority(final int priority) throws JMSException {
+ if (priority < 0 || priority > 9) {
throw new JMSException(priority + " is not valid: priority must be between 0 and 9");
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
index b3cc69a..8841f2a 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java
@@ -36,8 +36,8 @@ import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants;
/**
* ActiveMQ Artemis implementation of a JMS MessageConsumer.
*/
-public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscriber
-{
+public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscriber {
+
private final ClientConsumer consumer;
private MessageListener listener;
@@ -66,8 +66,7 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr
final boolean noLocal,
final ActiveMQDestination destination,
final String selector,
- final SimpleString autoDeleteQueueName) throws JMSException
- {
+ final SimpleString autoDeleteQueueName) throws JMSException {
this.connection = connection;
this.session = session;
@@ -87,91 +86,76 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr
// MessageConsumer implementation --------------------------------
- public String getMessageSelector() throws JMSException
- {
+ public String getMessageSelector() throws JMSException {
checkClosed();
return selector;
}
- public MessageListener getMessageListener() throws JMSException
- {
+ public MessageListener getMessageListener() throws JMSException {
checkClosed();
return listener;
}
- public void setMessageListener(final MessageListener listener) throws JMSException
- {
+ public void setMessageListener(final MessageListener listener) throws JMSException {
this.listener = listener;
coreListener = listener == null ? null : new JMSMessageListenerWrapper(connection, session, consumer, listener, ackMode);
- try
- {
+ try {
consumer.setMessageHandler(coreListener);
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
- public Message receive() throws JMSException
- {
+ public Message receive() throws JMSException {
return getMessage(0, false);
}
- public Message receive(final long timeout) throws JMSException
- {
+ public Message receive(final long timeout) throws JMSException {
return getMessage(timeout, false);
}
- public Message receiveNoWait() throws JMSException
- {
+ public Message receiveNoWait() throws JMSException {
return getMessage(0, true);
}
- public void close() throws JMSException
- {
- try
- {
+ public void close() throws JMSException {
+ try {
consumer.close();
- if (autoDeleteQueueName != null)
- {
+ if (autoDeleteQueueName != null) {
// If non durable subscriber need to delete subscription too
session.deleteQueue(autoDeleteQueueName);
}
session.removeConsumer(this);
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
// QueueReceiver implementation ----------------------------------
- public Queue getQueue() throws JMSException
- {
+ public Queue getQueue() throws JMSException {
checkClosed();
- return (Queue)destination;
+ return (Queue) destination;
}
// TopicSubscriber implementation --------------------------------
- public Topic getTopic() throws JMSException
- {
+ public Topic getTopic() throws JMSException {
checkClosed();
- return (Topic)destination;
+ return (Topic) destination;
}
- public boolean getNoLocal() throws JMSException
- {
+ public boolean getNoLocal() throws JMSException {
checkClosed();
return noLocal;
@@ -180,72 +164,58 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr
// Public --------------------------------------------------------
@Override
- public String toString()
- {
+ public String toString() {
return "ActiveMQMessageConsumer[" + consumer + "]";
}
- public boolean isClosed()
- {
+ public boolean isClosed() {
return consumer.isClosed();
}
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
- private void checkClosed() throws JMSException
- {
- if (consumer.isClosed() || session.getCoreSession().isClosed())
- {
+ private void checkClosed() throws JMSException {
+ if (consumer.isClosed() || session.getCoreSession().isClosed()) {
throw new IllegalStateException("Consumer is closed");
}
}
- private ActiveMQMessage getMessage(final long timeout, final boolean noWait) throws JMSException
- {
- try
- {
+ private ActiveMQMessage getMessage(final long timeout, final boolean noWait) throws JMSException {
+ try {
ClientMessage coreMessage;
- if (noWait)
- {
+ if (noWait) {
coreMessage = consumer.receiveImmediate();
}
- else
- {
+ else {
coreMessage = consumer.receive(timeout);
}
ActiveMQMessage jmsMsg = null;
- if (coreMessage != null)
- {
- boolean needSession =
- ackMode == Session.CLIENT_ACKNOWLEDGE || ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE;
+ if (coreMessage != null) {
+ boolean needSession = ackMode == Session.CLIENT_ACKNOWLEDGE || ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE;
jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? session.getCoreSession() : null);
jmsMsg.doBeforeReceive();
// We Do the ack after doBeforeRecive, as in the case of large messages, this may fail so we don't want messages redelivered
// https://issues.jboss.org/browse/JBPAPP-6110
- if (session.getAcknowledgeMode() == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE)
- {
+ if (session.getAcknowledgeMode() == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE) {
jmsMsg.setIndividualAcknowledge();
}
- else
- {
+ else {
coreMessage.acknowledge();
}
}
return jmsMsg;
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
index 4dce39f..e7a6912 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
@@ -42,11 +42,12 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.SendAcknowledgementHandler;
import org.apache.activemq.artemis.utils.UUID;
import org.apache.activemq.artemis.utils.UUIDGenerator;
+
/**
* ActiveMQ Artemis implementation of a JMS MessageProducer.
*/
-public class ActiveMQMessageProducer implements MessageProducer, QueueSender, TopicPublisher
-{
+public class ActiveMQMessageProducer implements MessageProducer, QueueSender, TopicPublisher {
+
private final ActiveMQConnection connection;
private final SimpleString connID;
@@ -66,9 +67,10 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
private final ActiveMQDestination defaultDestination;
// Constructors --------------------------------------------------
- protected ActiveMQMessageProducer(final ActiveMQConnection connection, final ClientProducer producer,
- final ActiveMQDestination defaultDestination, final ClientSession clientSession) throws JMSException
- {
+ protected ActiveMQMessageProducer(final ActiveMQConnection connection,
+ final ClientProducer producer,
+ final ActiveMQDestination defaultDestination,
+ final ClientSession clientSession) throws JMSException {
this.connection = connection;
connID = connection.getClientID() != null ? new SimpleString(connection.getClientID()) : connection.getUID();
@@ -82,243 +84,228 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
// MessageProducer implementation --------------------------------
- public void setDisableMessageID(final boolean value) throws JMSException
- {
+ public void setDisableMessageID(final boolean value) throws JMSException {
checkClosed();
disableMessageID = value;
}
- public boolean getDisableMessageID() throws JMSException
- {
+ public boolean getDisableMessageID() throws JMSException {
checkClosed();
return disableMessageID;
}
- public void setDisableMessageTimestamp(final boolean value) throws JMSException
- {
+ public void setDisableMessageTimestamp(final boolean value) throws JMSException {
checkClosed();
disableMessageTimestamp = value;
}
- public boolean getDisableMessageTimestamp() throws JMSException
- {
+ public boolean getDisableMessageTimestamp() throws JMSException {
checkClosed();
return disableMessageTimestamp;
}
- public void setDeliveryMode(final int deliveryMode) throws JMSException
- {
+ public void setDeliveryMode(final int deliveryMode) throws JMSException {
checkClosed();
- if (deliveryMode != DeliveryMode.NON_PERSISTENT && deliveryMode != DeliveryMode.PERSISTENT)
- {
+ if (deliveryMode != DeliveryMode.NON_PERSISTENT && deliveryMode != DeliveryMode.PERSISTENT) {
throw ActiveMQJMSClientBundle.BUNDLE.illegalDeliveryMode(deliveryMode);
}
defaultDeliveryMode = deliveryMode;
}
- public int getDeliveryMode() throws JMSException
- {
+ public int getDeliveryMode() throws JMSException {
checkClosed();
return defaultDeliveryMode;
}
- public void setPriority(final int defaultPriority) throws JMSException
- {
+ public void setPriority(final int defaultPriority) throws JMSException {
checkClosed();
- if (defaultPriority < 0 || defaultPriority > 9)
- {
+ if (defaultPriority < 0 || defaultPriority > 9) {
throw new JMSException("Illegal priority value: " + defaultPriority);
}
this.defaultPriority = defaultPriority;
}
- public int getPriority() throws JMSException
- {
+ public int getPriority() throws JMSException {
checkClosed();
return defaultPriority;
}
- public void setTimeToLive(final long timeToLive) throws JMSException
- {
+ public void setTimeToLive(final long timeToLive) throws JMSException {
checkClosed();
defaultTimeToLive = timeToLive;
}
- public long getTimeToLive() throws JMSException
- {
+ public long getTimeToLive() throws JMSException {
checkClosed();
return defaultTimeToLive;
}
- public Destination getDestination() throws JMSException
- {
+ public Destination getDestination() throws JMSException {
checkClosed();
return defaultDestination;
}
- public void close() throws JMSException
- {
+ public void close() throws JMSException {
connection.getThreadAwareContext().assertNotCompletionListenerThread();
- try
- {
+ try {
clientProducer.close();
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
- public void send(final Message message) throws JMSException
- {
+ public void send(final Message message) throws JMSException {
checkDefaultDestination();
doSendx(defaultDestination, message, defaultDeliveryMode, defaultPriority, defaultTimeToLive, null);
}
public void send(final Message message,
final int deliveryMode,
- final int priority, final long timeToLive) throws JMSException
- {
+ final int priority,
+ final long timeToLive) throws JMSException {
checkDefaultDestination();
doSendx(defaultDestination, message, deliveryMode, priority, timeToLive, null);
}
- public void send(final Destination destination, final Message message) throws JMSException
- {
+ public void send(final Destination destination, final Message message) throws JMSException {
send(destination, message, defaultDeliveryMode, defaultPriority, defaultTimeToLive);
}
- public void send(final Destination destination, final Message message, final int deliveryMode, final int priority,
- final long timeToLive) throws JMSException
- {
+ public void send(final Destination destination,
+ final Message message,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive) throws JMSException {
checkClosed();
checkDestination(destination);
- doSendx((ActiveMQDestination)destination, message, deliveryMode, priority, timeToLive, null);
+ doSendx((ActiveMQDestination) destination, message, deliveryMode, priority, timeToLive, null);
}
@Override
- public void setDeliveryDelay(long deliveryDelay) throws JMSException
- {
+ public void setDeliveryDelay(long deliveryDelay) throws JMSException {
this.defaultDeliveryDelay = deliveryDelay;
}
@Override
- public long getDeliveryDelay() throws JMSException
- {
+ public long getDeliveryDelay() throws JMSException {
return defaultDeliveryDelay;
}
@Override
- public void send(Message message, CompletionListener completionListener) throws JMSException
- {
+ public void send(Message message, CompletionListener completionListener) throws JMSException {
send(message, defaultDeliveryMode, defaultPriority, defaultTimeToLive, completionListener);
}
@Override
- public void send(Message message, int deliveryMode, int priority, long timeToLive,
- CompletionListener completionListener) throws JMSException
- {
+ public void send(Message message,
+ int deliveryMode,
+ int priority,
+ long timeToLive,
+ CompletionListener completionListener) throws JMSException {
checkCompletionListener(completionListener);
checkDefaultDestination();
doSendx(defaultDestination, message, deliveryMode, priority, timeToLive, completionListener);
}
@Override
- public void send(Destination destination, Message message, CompletionListener completionListener) throws JMSException
- {
+ public void send(Destination destination,
+ Message message,
+ CompletionListener completionListener) throws JMSException {
send(destination, message, defaultDeliveryMode, defaultPriority, defaultTimeToLive, completionListener);
}
@Override
- public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive,
- CompletionListener completionListener) throws JMSException
- {
+ public void send(Destination destination,
+ Message message,
+ int deliveryMode,
+ int priority,
+ long timeToLive,
+ CompletionListener completionListener) throws JMSException {
checkClosed();
checkCompletionListener(completionListener);
checkDestination(destination);
- doSendx((ActiveMQDestination)destination, message, deliveryMode, priority, timeToLive, completionListener);
+ doSendx((ActiveMQDestination) destination, message, deliveryMode, priority, timeToLive, completionListener);
}
// TopicPublisher Implementation ---------------------------------
- public Topic getTopic() throws JMSException
- {
- return (Topic)getDestination();
+ public Topic getTopic() throws JMSException {
+ return (Topic) getDestination();
}
- public void publish(final Message message) throws JMSException
- {
+ public void publish(final Message message) throws JMSException {
send(message);
}
- public void publish(final Topic topic, final Message message) throws JMSException
- {
+ public void publish(final Topic topic, final Message message) throws JMSException {
send(topic, message);
}
- public void publish(final Message message, final int deliveryMode, final int priority, final long timeToLive) throws JMSException
- {
+ public void publish(final Message message,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive) throws JMSException {
send(message, deliveryMode, priority, timeToLive);
}
- public void publish(final Topic topic, final Message message, final int deliveryMode, final int priority,
- final long timeToLive) throws JMSException
- {
+ public void publish(final Topic topic,
+ final Message message,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive) throws JMSException {
checkDestination(topic);
- doSendx((ActiveMQDestination)topic, message, deliveryMode, priority, timeToLive, null);
+ doSendx((ActiveMQDestination) topic, message, deliveryMode, priority, timeToLive, null);
}
// QueueSender Implementation ------------------------------------
- public void send(final Queue queue, final Message message) throws JMSException
- {
- send((Destination)queue, message);
+ public void send(final Queue queue, final Message message) throws JMSException {
+ send((Destination) queue, message);
}
- public void send(final Queue queue, final Message message, final int deliveryMode, final int priority,
- final long timeToLive) throws JMSException
- {
+ public void send(final Queue queue,
+ final Message message,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive) throws JMSException {
checkDestination(queue);
- doSendx((ActiveMQDestination)queue, message, deliveryMode, priority, timeToLive, null);
+ doSendx((ActiveMQDestination) queue, message, deliveryMode, priority, timeToLive, null);
}
- public Queue getQueue() throws JMSException
- {
- return (Queue)getDestination();
+ public Queue getQueue() throws JMSException {
+ return (Queue) getDestination();
}
// Public --------------------------------------------------------
@Override
- public String toString()
- {
+ public String toString() {
return "ActiveMQMessageProducer->" + clientProducer;
}
/**
* Check if the default destination has been set
*/
- private void checkDefaultDestination()
- {
- if (defaultDestination == null)
- {
+ private void checkDefaultDestination() {
+ if (defaultDestination == null) {
throw new UnsupportedOperationException("Cannot specify destination if producer has a default destination");
}
}
@@ -326,103 +313,81 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
/**
* Check if the destination is sent correctly
*/
- private void checkDestination(Destination destination) throws InvalidDestinationException
- {
- if (destination != null && !(destination instanceof ActiveMQDestination))
- {
+ private void checkDestination(Destination destination) throws InvalidDestinationException {
+ if (destination != null && !(destination instanceof ActiveMQDestination)) {
throw new InvalidDestinationException("Foreign destination:" + destination);
}
- if (destination != null && defaultDestination != null)
- {
+ if (destination != null && defaultDestination != null) {
throw new UnsupportedOperationException("Cannot specify destination if producer has a default destination");
}
- if (destination == null)
- {
+ if (destination == null) {
throw ActiveMQJMSClientBundle.BUNDLE.nullTopic();
}
}
- private void checkCompletionListener(CompletionListener completionListener)
- {
- if (completionListener == null)
- {
+ private void checkCompletionListener(CompletionListener completionListener) {
+ if (completionListener == null) {
throw ActiveMQJMSClientBundle.BUNDLE.nullArgumentNotAllowed("CompletionListener");
}
}
-
- private void doSendx(ActiveMQDestination destination, final Message jmsMessage, final int deliveryMode,
- final int priority, final long timeToLive,
- CompletionListener completionListener) throws JMSException
- {
+ private void doSendx(ActiveMQDestination destination,
+ final Message jmsMessage,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive,
+ CompletionListener completionListener) throws JMSException {
jmsMessage.setJMSDeliveryMode(deliveryMode);
jmsMessage.setJMSPriority(priority);
-
- if (timeToLive == 0)
- {
+ if (timeToLive == 0) {
jmsMessage.setJMSExpiration(0);
}
- else
- {
+ else {
jmsMessage.setJMSExpiration(System.currentTimeMillis() + timeToLive);
}
- if (!disableMessageTimestamp)
- {
+ if (!disableMessageTimestamp) {
jmsMessage.setJMSTimestamp(System.currentTimeMillis());
}
- else
- {
+ else {
jmsMessage.setJMSTimestamp(0);
}
SimpleString address = null;
- if (destination == null)
- {
- if (defaultDestination == null)
- {
+ if (destination == null) {
+ if (defaultDestination == null) {
throw new UnsupportedOperationException("Destination must be specified on send with an anonymous producer");
}
destination = defaultDestination;
}
- else
- {
- if (defaultDestination != null)
- {
- if (!destination.equals(defaultDestination))
- {
- throw new UnsupportedOperationException("Where a default destination is specified " + "for the sender and a destination is "
- + "specified in the arguments to the send, "
- + "these destinations must be equal");
+ else {
+ if (defaultDestination != null) {
+ if (!destination.equals(defaultDestination)) {
+ throw new UnsupportedOperationException("Where a default destination is specified " + "for the sender and a destination is " + "specified in the arguments to the send, " + "these destinations must be equal");
}
}
address = destination.getSimpleAddress();
- if (!connection.containsKnownDestination(address))
- {
- try
- {
+ if (!connection.containsKnownDestination(address)) {
+ try {
ClientSession.AddressQuery query = clientSession.addressQuery(address);
// if it's autoCreateJMSQueue we will let the PostOffice.route to execute the creation at the server's side
// as that's a more efficient path for such operation
- if (!query.isExists() && !query.isAutoCreateJmsQueues())
- {
+ if (!query.isExists() && !query.isAutoCreateJmsQueues()) {
throw new InvalidDestinationException("Destination " + address + " does not exist");
}
- else
- {
+ else {
connection.addKnownDestination(address);
}
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
@@ -433,33 +398,26 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
boolean foreign = false;
// First convert from foreign message if appropriate
- if (!(jmsMessage instanceof ActiveMQMessage))
- {
+ if (!(jmsMessage instanceof ActiveMQMessage)) {
// JMS 1.1 Sect. 3.11.4: A provider must be prepared to accept, from a client,
// a message whose implementation is not one of its own.
- if (jmsMessage instanceof BytesMessage)
- {
- activeMQJmsMessage = new ActiveMQBytesMessage((BytesMessage)jmsMessage, clientSession);
+ if (jmsMessage instanceof BytesMessage) {
+ activeMQJmsMessage = new ActiveMQBytesMessage((BytesMessage) jmsMessage, clientSession);
}
- else if (jmsMessage instanceof MapMessage)
- {
- activeMQJmsMessage = new ActiveMQMapMessage((MapMessage)jmsMessage, clientSession);
+ else if (jmsMessage instanceof MapMessage) {
+ activeMQJmsMessage = new ActiveMQMapMessage((MapMessage) jmsMessage, clientSession);
}
- else if (jmsMessage instanceof ObjectMessage)
- {
- activeMQJmsMessage = new ActiveMQObjectMessage((ObjectMessage)jmsMessage, clientSession);
+ else if (jmsMessage instanceof ObjectMessage) {
+ activeMQJmsMessage = new ActiveMQObjectMessage((ObjectMessage) jmsMessage, clientSession);
}
- else if (jmsMessage instanceof StreamMessage)
- {
- activeMQJmsMessage = new ActiveMQStreamMessage((StreamMessage)jmsMessage, clientSession);
+ else if (jmsMessage instanceof StreamMessage) {
+ activeMQJmsMessage = new ActiveMQStreamMessage((StreamMessage) jmsMessage, clientSession);
}
- else if (jmsMessage instanceof TextMessage)
- {
- activeMQJmsMessage = new ActiveMQTextMessage((TextMessage)jmsMessage, clientSession);
+ else if (jmsMessage instanceof TextMessage) {
+ activeMQJmsMessage = new ActiveMQTextMessage((TextMessage) jmsMessage, clientSession);
}
- else
- {
+ else {
activeMQJmsMessage = new ActiveMQMessage(jmsMessage, clientSession);
}
@@ -468,13 +426,11 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
foreign = true;
}
- else
- {
- activeMQJmsMessage = (ActiveMQMessage)jmsMessage;
+ else {
+ activeMQJmsMessage = (ActiveMQMessage) jmsMessage;
}
- if (!disableMessageID)
- {
+ if (!disableMessageID) {
// Generate a JMS id
UUID uid = UUIDGenerator.getInstance().generateUUID();
@@ -484,19 +440,16 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
activeMQJmsMessage.resetMessageID(null);
}
- if (foreign)
- {
+ if (foreign) {
jmsMessage.setJMSMessageID(activeMQJmsMessage.getJMSMessageID());
}
activeMQJmsMessage.setJMSDestination(destination);
- try
- {
+ try {
activeMQJmsMessage.doBeforeSend();
}
- catch (Exception e)
- {
+ catch (Exception e) {
JMSException je = new JMSException(e.getMessage());
je.initCause(e);
@@ -504,45 +457,38 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
throw je;
}
- if (defaultDeliveryDelay > 0)
- {
+ if (defaultDeliveryDelay > 0) {
activeMQJmsMessage.setJMSDeliveryTime(System.currentTimeMillis() + defaultDeliveryDelay);
}
ClientMessage coreMessage = activeMQJmsMessage.getCoreMessage();
coreMessage.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME, connID);
- try
- {
+ try {
/**
* Using a completionListener requires wrapping using a {@link CompletionListenerWrapper},
* so we avoid it if we can.
*/
- if (completionListener != null)
- {
+ if (completionListener != null) {
clientProducer.send(address, coreMessage, new CompletionListenerWrapper(completionListener, jmsMessage, this));
}
- else
- {
+ else {
clientProducer.send(address, coreMessage);
}
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
- private void checkClosed() throws JMSException
- {
- if (clientProducer.isClosed() || clientSession.isClosed())
- {
+ private void checkClosed() throws JMSException {
+ if (clientProducer.isClosed() || clientSession.isClosed()) {
throw new IllegalStateException("Producer is closed");
}
}
- private static final class CompletionListenerWrapper implements SendAcknowledgementHandler
- {
+ private static final class CompletionListenerWrapper implements SendAcknowledgementHandler {
+
private final CompletionListener completionListener;
private final Message jmsMessage;
private final ActiveMQMessageProducer producer;
@@ -551,53 +497,44 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
* @param jmsMessage
* @param producer
*/
- public CompletionListenerWrapper(CompletionListener listener, Message jmsMessage, ActiveMQMessageProducer producer)
- {
+ public CompletionListenerWrapper(CompletionListener listener,
+ Message jmsMessage,
+ ActiveMQMessageProducer producer) {
this.completionListener = listener;
this.jmsMessage = jmsMessage;
this.producer = producer;
}
@Override
- public void sendAcknowledged(org.apache.activemq.artemis.api.core.Message clientMessage)
- {
- if (jmsMessage instanceof StreamMessage)
- {
- try
- {
- ((StreamMessage)jmsMessage).reset();
+ public void sendAcknowledged(org.apache.activemq.artemis.api.core.Message clientMessage) {
+ if (jmsMessage instanceof StreamMessage) {
+ try {
+ ((StreamMessage) jmsMessage).reset();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
// HORNETQ-1209 XXX ignore?
}
}
- if (jmsMessage instanceof BytesMessage)
- {
- try
- {
- ((BytesMessage)jmsMessage).reset();
+ if (jmsMessage instanceof BytesMessage) {
+ try {
+ ((BytesMessage) jmsMessage).reset();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
// HORNETQ-1209 XXX ignore?
}
}
- try
- {
+ try {
producer.connection.getThreadAwareContext().setCurrentThread(true);
completionListener.onCompletion(jmsMessage);
}
- finally
- {
+ finally {
producer.connection.getThreadAwareContext().clearCurrentThread(true);
}
}
@Override
- public String toString()
- {
+ public String toString() {
return CompletionListenerWrapper.class.getSimpleName() + "( completionListener=" + completionListener + ")";
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java
index e382c30..eebccd1 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java
@@ -38,8 +38,7 @@ import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
* <p>
* Serialization is slooooow!
*/
-public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage
-{
+public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage {
// Constants -----------------------------------------------------
public static final byte TYPE = Message.OBJECT_TYPE;
@@ -53,21 +52,18 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
// Constructors --------------------------------------------------
- protected ActiveMQObjectMessage(final ClientSession session)
- {
+ protected ActiveMQObjectMessage(final ClientSession session) {
super(ActiveMQObjectMessage.TYPE, session);
}
- protected ActiveMQObjectMessage(final ClientMessage message, final ClientSession session)
- {
+ protected ActiveMQObjectMessage(final ClientMessage message, final ClientSession session) {
super(message, session);
}
/**
* A copy constructor for foreign JMS ObjectMessages.
*/
- public ActiveMQObjectMessage(final ObjectMessage foreign, final ClientSession session) throws JMSException
- {
+ public ActiveMQObjectMessage(final ObjectMessage foreign, final ClientSession session) throws JMSException {
super(foreign, ActiveMQObjectMessage.TYPE, session);
setObject(foreign.getObject());
@@ -76,17 +72,14 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
// Public --------------------------------------------------------
@Override
- public byte getType()
- {
+ public byte getType() {
return ActiveMQObjectMessage.TYPE;
}
@Override
- public void doBeforeSend() throws Exception
- {
+ public void doBeforeSend() throws Exception {
message.getBodyBuffer().clear();
- if (data != null)
- {
+ if (data != null) {
message.getBodyBuffer().writeInt(data.length);
message.getBodyBuffer().writeBytes(data);
}
@@ -95,17 +88,14 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
}
@Override
- public void doBeforeReceive() throws ActiveMQException
- {
+ public void doBeforeReceive() throws ActiveMQException {
super.doBeforeReceive();
- try
- {
+ try {
int len = message.getBodyBuffer().readInt();
data = new byte[len];
message.getBodyBuffer().readBytes(data);
}
- catch (Exception e)
- {
+ catch (Exception e) {
data = null;
}
@@ -113,14 +103,11 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
// ObjectMessage implementation ----------------------------------
- public void setObject(final Serializable object) throws JMSException
- {
+ public void setObject(final Serializable object) throws JMSException {
checkWrite();
- if (object != null)
- {
- try
- {
+ if (object != null) {
+ try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
ObjectOutputStream oos = new ObjectOutputStream(baos);
@@ -131,8 +118,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
data = baos.toByteArray();
}
- catch (Exception e)
- {
+ catch (Exception e) {
JMSException je = new JMSException("Failed to serialize object");
je.setLinkedException(e);
je.initCause(e);
@@ -142,22 +128,18 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
}
// lazy deserialize the Object the first time the client requests it
- public Serializable getObject() throws JMSException
- {
- if (data == null || data.length == 0)
- {
+ public Serializable getObject() throws JMSException {
+ if (data == null || data.length == 0) {
return null;
}
- try
- {
+ try {
ByteArrayInputStream bais = new ByteArrayInputStream(data);
ObjectInputStream ois = new ObjectInputStreamWithClassLoader(bais);
- Serializable object = (Serializable)ois.readObject();
+ Serializable object = (Serializable) ois.readObject();
return object;
}
- catch (Exception e)
- {
+ catch (Exception e) {
JMSException je = new JMSException(e.getMessage());
je.setStackTrace(e.getStackTrace());
throw je;
@@ -165,38 +147,30 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
}
@Override
- public void clearBody() throws JMSException
- {
+ public void clearBody() throws JMSException {
super.clearBody();
data = null;
}
@Override
- protected <T> T getBodyInternal(Class<T> c) throws MessageFormatException
- {
- try
- {
- return (T)getObject();
+ protected <T> T getBodyInternal(Class<T> c) throws MessageFormatException {
+ try {
+ return (T) getObject();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw new MessageFormatException("Deserialization error on ActiveMQObjectMessage");
}
}
@Override
- public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes")
- Class c)
- {
+ public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class c) {
if (data == null) // we have no body
return true;
- try
- {
+ try {
return Serializable.class == c || Object.class == c || c.isInstance(getObject());
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
return false;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueue.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueue.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueue.java
index 0fac316..7660dfa 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueue.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueue.java
@@ -25,15 +25,14 @@ import org.apache.activemq.artemis.api.core.SimpleString;
* <br>
* This class can be instantiated directly.
*/
-public class ActiveMQQueue extends ActiveMQDestination implements Queue
-{
+public class ActiveMQQueue extends ActiveMQDestination implements Queue {
+
// Constants -----------------------------------------------------
private static final long serialVersionUID = -1106092883162295462L;
// Static --------------------------------------------------------
- public static SimpleString createAddressFromName(final String name)
- {
+ public static SimpleString createAddressFromName(final String name) {
return new SimpleString(JMS_QUEUE_ADDRESS_PREFIX + name);
}
@@ -41,31 +40,25 @@ public class ActiveMQQueue extends ActiveMQDestination implements Queue
// Constructors --------------------------------------------------
- public ActiveMQQueue(final String name)
- {
+ public ActiveMQQueue(final String name) {
super(JMS_QUEUE_ADDRESS_PREFIX + name, name, false, true, null);
}
- public ActiveMQQueue(final String name, boolean temporary)
- {
+ public ActiveMQQueue(final String name, boolean temporary) {
super(JMS_QUEUE_ADDRESS_PREFIX + name, name, temporary, true, null);
}
-
-
/**
* @param address
* @param name
* @param temporary
* @param session
*/
- public ActiveMQQueue(String address, String name, boolean temporary, ActiveMQSession session)
- {
+ public ActiveMQQueue(String address, String name, boolean temporary, ActiveMQSession session) {
super(address, name, temporary, true, session);
}
- public ActiveMQQueue(final String address, final String name)
- {
+ public ActiveMQQueue(final String address, final String name) {
super(address, name, false, true, null);
}
@@ -73,14 +66,12 @@ public class ActiveMQQueue extends ActiveMQDestination implements Queue
// Public --------------------------------------------------------
- public String getQueueName()
- {
+ public String getQueueName() {
return name;
}
@Override
- public String toString()
- {
+ public String toString() {
return "ActiveMQQueue[" + name + "]";
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java
index a716eff..493029b 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java
@@ -32,8 +32,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
/**
* ActiveMQ Artemis implementation of a JMS QueueBrowser.
*/
-public final class ActiveMQQueueBrowser implements QueueBrowser
-{
+public final class ActiveMQQueueBrowser implements QueueBrowser {
// Constants ------------------------------------------------------------------------------------
// Static ---------------------------------------------------------------------------------------
@@ -50,65 +49,55 @@ public final class ActiveMQQueueBrowser implements QueueBrowser
// Constructors ---------------------------------------------------------------------------------
- protected ActiveMQQueueBrowser(final ActiveMQQueue queue, final String messageSelector, final ClientSession session) throws JMSException
- {
+ protected ActiveMQQueueBrowser(final ActiveMQQueue queue,
+ final String messageSelector,
+ final ClientSession session) throws JMSException {
this.session = session;
this.queue = queue;
- if (messageSelector != null)
- {
+ if (messageSelector != null) {
filterString = new SimpleString(SelectorTranslator.convertToActiveMQFilterString(messageSelector));
}
}
// QueueBrowser implementation -------------------------------------------------------------------
- public void close() throws JMSException
- {
- if (consumer != null)
- {
- try
- {
+ public void close() throws JMSException {
+ if (consumer != null) {
+ try {
consumer.close();
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
}
- public Enumeration getEnumeration() throws JMSException
- {
- try
- {
+ public Enumeration getEnumeration() throws JMSException {
+ try {
close();
consumer = session.createConsumer(queue.getSimpleAddress(), filterString, true);
return new BrowserEnumeration();
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
throw JMSExceptionHelper.convertFromActiveMQException(e);
}
}
- public String getMessageSelector() throws JMSException
- {
+ public String getMessageSelector() throws JMSException {
return filterString == null ? null : filterString.toString();
}
- public Queue getQueue() throws JMSException
- {
+ public Queue getQueue() throws JMSException {
return queue;
}
// Public ---------------------------------------------------------------------------------------
@Override
- public String toString()
- {
+ public String toString() {
return "ActiveMQQueueBrowser->" + consumer;
}
@@ -120,48 +109,39 @@ public final class ActiveMQQueueBrowser implements QueueBrowser
// Inner classes --------------------------------------------------------------------------------
- private final class BrowserEnumeration implements Enumeration<ActiveMQMessage>
- {
+ private final class BrowserEnumeration implements Enumeration<ActiveMQMessage> {
+
ClientMessage current = null;
- public boolean hasMoreElements()
- {
- if (current == null)
- {
- try
- {
+ public boolean hasMoreElements() {
+ if (current == null) {
+ try {
current = consumer.receiveImmediate();
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
return false;
}
}
return current != null;
}
- public ActiveMQMessage nextElement()
- {
+ public ActiveMQMessage nextElement() {
ActiveMQMessage msg;
- if (hasMoreElements())
- {
+ if (hasMoreElements()) {
ClientMessage next = current;
current = null;
msg = ActiveMQMessage.createMessage(next, session);
- try
- {
+ try {
msg.doBeforeReceive();
}
- catch (Exception e)
- {
+ catch (Exception e) {
ActiveMQJMSClientLogger.LOGGER.errorCreatingMessage(e);
return null;
}
return msg;
}
- else
- {
+ else {
throw new NoSuchElementException();
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueConnectionFactory.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueConnectionFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueConnectionFactory.java
index 64da716..6fdce70 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueConnectionFactory.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueConnectionFactory.java
@@ -26,42 +26,35 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType;
/**
* {@inheritDoc}
*/
-public class ActiveMQQueueConnectionFactory extends ActiveMQConnectionFactory implements QueueConnectionFactory
-{
+public class ActiveMQQueueConnectionFactory extends ActiveMQConnectionFactory implements QueueConnectionFactory {
+
private static final long serialVersionUID = 5312455021322463546L;
- public ActiveMQQueueConnectionFactory()
- {
+ public ActiveMQQueueConnectionFactory() {
super();
}
- public ActiveMQQueueConnectionFactory(String url)
- {
+ public ActiveMQQueueConnectionFactory(String url) {
super(url);
}
- public ActiveMQQueueConnectionFactory(ServerLocator serverLocator)
- {
+ public ActiveMQQueueConnectionFactory(ServerLocator serverLocator) {
super(serverLocator);
}
- public ActiveMQQueueConnectionFactory(boolean ha, final DiscoveryGroupConfiguration groupConfiguration)
- {
+ public ActiveMQQueueConnectionFactory(boolean ha, final DiscoveryGroupConfiguration groupConfiguration) {
super(ha, groupConfiguration);
}
- public ActiveMQQueueConnectionFactory(String url, String user, String password)
- {
+ public ActiveMQQueueConnectionFactory(String url, String user, String password) {
super(url, user, password);
}
- public ActiveMQQueueConnectionFactory(boolean ha, TransportConfiguration... initialConnectors)
- {
+ public ActiveMQQueueConnectionFactory(boolean ha, TransportConfiguration... initialConnectors) {
super(ha, initialConnectors);
}
- public int getFactoryType()
- {
+ public int getFactoryType() {
return JMSFactoryType.QUEUE_CF.intValue();
}
}