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:17 UTC
[18/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/ActiveMQJMSContext.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java
index c449e8b..3065f27 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSContext.java
@@ -45,8 +45,8 @@ import java.io.Serializable;
/**
* ActiveMQ Artemis implementation of a JMSContext.
*/
-public class ActiveMQJMSContext implements JMSContext
-{
+public class ActiveMQJMSContext implements JMSContext {
+
private static final boolean DEFAULT_AUTO_START = true;
private final int sessionMode;
@@ -64,38 +64,37 @@ public class ActiveMQJMSContext implements JMSContext
private boolean xa;
private boolean closed;
- ActiveMQJMSContext(final ActiveMQConnectionForContext connection, final int ackMode, final boolean xa, ThreadAwareContext threadAwareContext)
- {
+ ActiveMQJMSContext(final ActiveMQConnectionForContext connection,
+ final int ackMode,
+ final boolean xa,
+ ThreadAwareContext threadAwareContext) {
this.connection = connection;
this.sessionMode = ackMode;
this.xa = xa;
this.threadAwareContext = threadAwareContext;
}
- public ActiveMQJMSContext(ActiveMQConnectionForContext connection, int ackMode, ThreadAwareContext threadAwareContext)
- {
+ public ActiveMQJMSContext(ActiveMQConnectionForContext connection,
+ int ackMode,
+ ThreadAwareContext threadAwareContext) {
this(connection, ackMode, false, threadAwareContext);
}
- public ActiveMQJMSContext(ActiveMQConnectionForContext connection, ThreadAwareContext threadAwareContext)
- {
+ public ActiveMQJMSContext(ActiveMQConnectionForContext connection, ThreadAwareContext threadAwareContext) {
this(connection, SESSION_TRANSACTED, true, threadAwareContext);
}
// XAJMSContext implementation -------------------------------------
- public JMSContext getContext()
- {
+ public JMSContext getContext() {
return this;
}
- public Session getSession()
- {
+ public Session getSession() {
return session;
}
- public XAResource getXAResource()
- {
+ public XAResource getXAResource() {
checkSession();
return ((XASession) session).getXAResource();
}
@@ -103,29 +102,23 @@ public class ActiveMQJMSContext implements JMSContext
// JMSContext implementation -------------------------------------
@Override
- public JMSContext createContext(int sessionMode)
- {
+ public JMSContext createContext(int sessionMode) {
return connection.createContext(sessionMode);
}
@Override
- public JMSProducer createProducer()
- {
+ public JMSProducer createProducer() {
checkSession();
- try
- {
+ try {
return new ActiveMQJMSProducer(this, getInnerProducer());
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
- private synchronized MessageProducer getInnerProducer() throws JMSException
- {
- if (innerProducer == null)
- {
+ private synchronized MessageProducer getInnerProducer() throws JMSException {
+ if (innerProducer == null) {
innerProducer = session.createProducer(null);
}
@@ -135,29 +128,21 @@ public class ActiveMQJMSContext implements JMSContext
/**
*
*/
- private void checkSession()
- {
- if (session == null)
- {
- synchronized (this)
- {
+ private void checkSession() {
+ if (session == null) {
+ synchronized (this) {
if (closed)
throw new IllegalStateRuntimeException("Context is closed");
- if (session == null)
- {
- try
- {
- if (xa)
- {
+ if (session == null) {
+ try {
+ if (xa) {
session = ((XAConnection) connection).createXASession();
}
- else
- {
+ else {
session = connection.createSession(sessionMode);
}
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@@ -166,567 +151,451 @@ public class ActiveMQJMSContext implements JMSContext
}
@Override
- public String getClientID()
- {
- try
- {
+ public String getClientID() {
+ try {
return connection.getClientID();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void setClientID(String clientID)
- {
- try
- {
+ public void setClientID(String clientID) {
+ try {
connection.setClientID(clientID);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public ConnectionMetaData getMetaData()
- {
- try
- {
+ public ConnectionMetaData getMetaData() {
+ try {
return connection.getMetaData();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public ExceptionListener getExceptionListener()
- {
- try
- {
+ public ExceptionListener getExceptionListener() {
+ try {
return connection.getExceptionListener();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void setExceptionListener(ExceptionListener listener)
- {
- try
- {
+ public void setExceptionListener(ExceptionListener listener) {
+ try {
connection.setExceptionListener(listener);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void start()
- {
- try
- {
+ public void start() {
+ try {
connection.start();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void stop()
- {
+ public void stop() {
threadAwareContext.assertNotMessageListenerThreadRuntime();
- try
- {
+ try {
connection.stop();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void setAutoStart(boolean autoStart)
- {
+ public void setAutoStart(boolean autoStart) {
this.autoStart = autoStart;
}
@Override
- public boolean getAutoStart()
- {
+ public boolean getAutoStart() {
return autoStart;
}
@Override
- public void close()
- {
+ public void close() {
threadAwareContext.assertNotCompletionListenerThreadRuntime();
threadAwareContext.assertNotMessageListenerThreadRuntime();
- try
- {
- synchronized (this)
- {
+ try {
+ synchronized (this) {
if (session != null)
session.close();
connection.closeFromContext();
closed = true;
}
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public BytesMessage createBytesMessage()
- {
+ public BytesMessage createBytesMessage() {
checkSession();
- try
- {
+ try {
return session.createBytesMessage();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public MapMessage createMapMessage()
- {
+ public MapMessage createMapMessage() {
checkSession();
- try
- {
+ try {
return session.createMapMessage();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public Message createMessage()
- {
+ public Message createMessage() {
checkSession();
- try
- {
+ try {
return session.createMessage();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public ObjectMessage createObjectMessage()
- {
+ public ObjectMessage createObjectMessage() {
checkSession();
- try
- {
+ try {
return session.createObjectMessage();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public ObjectMessage createObjectMessage(Serializable object)
- {
+ public ObjectMessage createObjectMessage(Serializable object) {
checkSession();
- try
- {
+ try {
return session.createObjectMessage(object);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public StreamMessage createStreamMessage()
- {
+ public StreamMessage createStreamMessage() {
checkSession();
- try
- {
+ try {
return session.createStreamMessage();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public TextMessage createTextMessage()
- {
+ public TextMessage createTextMessage() {
checkSession();
- try
- {
+ try {
return session.createTextMessage();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public TextMessage createTextMessage(String text)
- {
+ public TextMessage createTextMessage(String text) {
checkSession();
- try
- {
+ try {
return session.createTextMessage(text);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public boolean getTransacted()
- {
+ public boolean getTransacted() {
checkSession();
- try
- {
+ try {
return session.getTransacted();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public int getSessionMode()
- {
+ public int getSessionMode() {
return sessionMode;
}
@Override
- public void commit()
- {
+ public void commit() {
threadAwareContext.assertNotCompletionListenerThreadRuntime();
checkSession();
- try
- {
+ try {
session.commit();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void rollback()
- {
+ public void rollback() {
threadAwareContext.assertNotCompletionListenerThreadRuntime();
checkSession();
- try
- {
+ try {
session.rollback();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void recover()
- {
+ public void recover() {
checkSession();
- try
- {
+ try {
session.recover();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createConsumer(Destination destination)
- {
+ public JMSConsumer createConsumer(Destination destination) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createConsumer(destination));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createConsumer(Destination destination, String messageSelector)
- {
+ public JMSConsumer createConsumer(Destination destination, String messageSelector) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createConsumer(destination, messageSelector));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal)
- {
+ public JMSConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createConsumer(destination, messageSelector, noLocal));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public Queue createQueue(String queueName)
- {
+ public Queue createQueue(String queueName) {
checkSession();
- try
- {
+ try {
return session.createQueue(queueName);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public Topic createTopic(String topicName)
- {
+ public Topic createTopic(String topicName) {
checkSession();
- try
- {
+ try {
return session.createTopic(topicName);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createDurableConsumer(Topic topic, String name)
- {
+ public JMSConsumer createDurableConsumer(Topic topic, String name) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createDurableConsumer(topic, name));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createDurableConsumer(Topic topic, String name, String messageSelector, boolean noLocal)
- {
+ public JMSConsumer createDurableConsumer(Topic topic, String name, String messageSelector, boolean noLocal) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createDurableConsumer(topic, name, messageSelector, noLocal));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createSharedDurableConsumer(Topic topic, String name)
- {
+ public JMSConsumer createSharedDurableConsumer(Topic topic, String name) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedDurableConsumer(topic, name));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector)
- {
+ public JMSConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedDurableConsumer(topic, name, messageSelector));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName)
- {
+ public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector)
- {
+ public JMSConsumer createSharedConsumer(Topic topic, String sharedSubscriptionName, String messageSelector) {
checkSession();
- try
- {
+ try {
ActiveMQJMSConsumer consumer = new ActiveMQJMSConsumer(this, session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector));
checkAutoStart();
return consumer;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public QueueBrowser createBrowser(Queue queue)
- {
+ public QueueBrowser createBrowser(Queue queue) {
checkSession();
- try
- {
+ try {
QueueBrowser browser = session.createBrowser(queue);
checkAutoStart();
return browser;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public QueueBrowser createBrowser(Queue queue, String messageSelector)
- {
+ public QueueBrowser createBrowser(Queue queue, String messageSelector) {
checkSession();
- try
- {
+ try {
QueueBrowser browser = session.createBrowser(queue, messageSelector);
checkAutoStart();
return browser;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public TemporaryQueue createTemporaryQueue()
- {
+ public TemporaryQueue createTemporaryQueue() {
checkSession();
- try
- {
+ try {
return session.createTemporaryQueue();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public TemporaryTopic createTemporaryTopic()
- {
+ public TemporaryTopic createTemporaryTopic() {
checkSession();
- try
- {
+ try {
return session.createTemporaryTopic();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void unsubscribe(String name)
- {
+ public void unsubscribe(String name) {
checkSession();
- try
- {
+ try {
session.unsubscribe(name);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public void acknowledge()
- {
+ public void acknowledge() {
checkSession();
if (closed)
throw new IllegalStateRuntimeException("Context is closed");
- try
- {
- if (lastMessagesWaitingAck != null)
- {
+ try {
+ if (lastMessagesWaitingAck != null) {
lastMessagesWaitingAck.acknowledge();
}
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@@ -737,17 +606,14 @@ public class ActiveMQJMSContext implements JMSContext
*
* @return
*/
- public Session getUsedSession()
- {
+ public Session getUsedSession() {
return this.session;
}
- private synchronized void checkAutoStart() throws JMSException
- {
+ private synchronized void checkAutoStart() throws JMSException {
if (closed)
throw new IllegalStateRuntimeException("Context is closed");
- if (autoStart)
- {
+ if (autoStart) {
connection.start();
}
}
@@ -755,17 +621,14 @@ public class ActiveMQJMSContext implements JMSContext
/**
* this is to ensure Context.acknowledge would work on ClientACK
*/
- Message setLastMessage(final JMSConsumer consumer, final Message lastMessageReceived)
- {
- if (sessionMode == CLIENT_ACKNOWLEDGE)
- {
+ Message setLastMessage(final JMSConsumer consumer, final Message lastMessageReceived) {
+ if (sessionMode == CLIENT_ACKNOWLEDGE) {
lastMessagesWaitingAck = lastMessageReceived;
}
return lastMessageReceived;
}
- public ThreadAwareContext getThreadAwareContext()
- {
+ public ThreadAwareContext getThreadAwareContext() {
return threadAwareContext;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java
index 538b43d..cd86e86 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQJMSProducer.java
@@ -47,8 +47,8 @@ import org.apache.activemq.artemis.utils.TypedProperties;
* {@link MessageProducer}. IF the user is using the producer in async mode, this may lead to races.
* We allow/tolerate this because these are just optional optimizations.
*/
-public final class ActiveMQJMSProducer implements JMSProducer
-{
+public final class ActiveMQJMSProducer implements JMSProducer {
+
private final ActiveMQJMSContext context;
private final MessageProducer producer;
private final TypedProperties properties = new TypedProperties();
@@ -64,53 +64,42 @@ public final class ActiveMQJMSProducer implements JMSProducer
private byte[] jmsHeaderCorrelationIDAsBytes;
private String jmsHeaderType;
- ActiveMQJMSProducer(ActiveMQJMSContext context, MessageProducer producer)
- {
+ ActiveMQJMSProducer(ActiveMQJMSContext context, MessageProducer producer) {
this.context = context;
this.producer = producer;
}
@Override
- public JMSProducer send(Destination destination, Message message)
- {
- if (message == null)
- {
+ public JMSProducer send(Destination destination, Message message) {
+ if (message == null) {
throw new MessageFormatRuntimeException("null message");
}
- try
- {
- if (jmsHeaderCorrelationID != null)
- {
+ try {
+ if (jmsHeaderCorrelationID != null) {
message.setJMSCorrelationID(jmsHeaderCorrelationID);
}
- if (jmsHeaderCorrelationIDAsBytes != null && jmsHeaderCorrelationIDAsBytes.length > 0)
- {
+ if (jmsHeaderCorrelationIDAsBytes != null && jmsHeaderCorrelationIDAsBytes.length > 0) {
message.setJMSCorrelationIDAsBytes(jmsHeaderCorrelationIDAsBytes);
}
- if (jmsHeaderReplyTo != null)
- {
+ if (jmsHeaderReplyTo != null) {
message.setJMSReplyTo(jmsHeaderReplyTo);
}
- if (jmsHeaderType != null)
- {
+ if (jmsHeaderType != null) {
message.setJMSType(jmsHeaderType);
}
// XXX HORNETQ-1209 "JMS 2.0" can this be a foreign msg?
// if so, then "SimpleString" properties will trigger an error.
setProperties(message);
- if (completionListener != null)
- {
+ if (completionListener != null) {
CompletionListener wrapped = new CompletionListenerWrapper(completionListener);
producer.send(destination, message, wrapped);
}
- else
- {
+ else {
producer.send(destination, message);
}
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
return this;
@@ -122,83 +111,64 @@ public final class ActiveMQJMSProducer implements JMSProducer
* @param message
* @throws JMSException
*/
- private void setProperties(Message message) throws JMSException
- {
- for (SimpleString name : properties.getPropertyNames())
- {
+ private void setProperties(Message message) throws JMSException {
+ for (SimpleString name : properties.getPropertyNames()) {
message.setObjectProperty(name.toString(), properties.getProperty(name));
}
}
@Override
- public JMSProducer send(Destination destination, String body)
- {
+ public JMSProducer send(Destination destination, String body) {
TextMessage message = context.createTextMessage(body);
send(destination, message);
return this;
}
@Override
- public JMSProducer send(Destination destination, Map<String, Object> body)
- {
+ public JMSProducer send(Destination destination, Map<String, Object> body) {
MapMessage message = context.createMapMessage();
- if (body != null)
- {
- try
- {
- for (Entry<String, Object> entry : body.entrySet())
- {
+ if (body != null) {
+ try {
+ for (Entry<String, Object> entry : body.entrySet()) {
final String name = entry.getKey();
final Object v = entry.getValue();
- if (v instanceof String)
- {
+ if (v instanceof String) {
message.setString(name, (String) v);
}
- else if (v instanceof Long)
- {
+ else if (v instanceof Long) {
message.setLong(name, (Long) v);
}
- else if (v instanceof Double)
- {
+ else if (v instanceof Double) {
message.setDouble(name, (Double) v);
}
- else if (v instanceof Integer)
- {
+ else if (v instanceof Integer) {
message.setInt(name, (Integer) v);
}
- else if (v instanceof Character)
- {
+ else if (v instanceof Character) {
message.setChar(name, (Character) v);
}
- else if (v instanceof Short)
- {
+ else if (v instanceof Short) {
message.setShort(name, (Short) v);
}
- else if (v instanceof Boolean)
- {
+ else if (v instanceof Boolean) {
message.setBoolean(name, (Boolean) v);
}
- else if (v instanceof Float)
- {
+ else if (v instanceof Float) {
message.setFloat(name, (Float) v);
}
- else if (v instanceof Byte)
- {
+ else if (v instanceof Byte) {
message.setByte(name, (Byte) v);
}
- else if (v instanceof byte[])
- {
+ else if (v instanceof byte[]) {
byte[] array = (byte[]) v;
message.setBytes(name, array, 0, array.length);
}
- else
- {
+ else {
message.setObject(name, v);
}
}
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw new MessageFormatRuntimeException(e.getMessage());
}
}
@@ -207,17 +177,13 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public JMSProducer send(Destination destination, byte[] body)
- {
+ public JMSProducer send(Destination destination, byte[] body) {
BytesMessage message = context.createBytesMessage();
- if (body != null)
- {
- try
- {
+ if (body != null) {
+ try {
message.writeBytes(body);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw new MessageFormatRuntimeException(e.getMessage());
}
}
@@ -226,76 +192,60 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public JMSProducer send(Destination destination, Serializable body)
- {
+ public JMSProducer send(Destination destination, Serializable body) {
ObjectMessage message = context.createObjectMessage(body);
send(destination, message);
return this;
}
@Override
- public JMSProducer setDisableMessageID(boolean value)
- {
- try
- {
+ public JMSProducer setDisableMessageID(boolean value) {
+ try {
producer.setDisableMessageID(value);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
return this;
}
@Override
- public boolean getDisableMessageID()
- {
- try
- {
+ public boolean getDisableMessageID() {
+ try {
return producer.getDisableMessageID();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSProducer setDisableMessageTimestamp(boolean value)
- {
- try
- {
+ public JMSProducer setDisableMessageTimestamp(boolean value) {
+ try {
producer.setDisableMessageTimestamp(value);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
return this;
}
@Override
- public boolean getDisableMessageTimestamp()
- {
- try
- {
+ public boolean getDisableMessageTimestamp() {
+ try {
return producer.getDisableMessageTimestamp();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
@Override
- public JMSProducer setDeliveryMode(int deliveryMode)
- {
- try
- {
+ public JMSProducer setDeliveryMode(int deliveryMode) {
+ try {
producer.setDeliveryMode(deliveryMode);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -304,14 +254,11 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public int getDeliveryMode()
- {
- try
- {
+ public int getDeliveryMode() {
+ try {
return producer.getDeliveryMode();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -319,14 +266,11 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public JMSProducer setPriority(int priority)
- {
- try
- {
+ public JMSProducer setPriority(int priority) {
+ try {
producer.setPriority(priority);
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -335,14 +279,11 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public int getPriority()
- {
- try
- {
+ public int getPriority() {
+ try {
return producer.getPriority();
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -350,15 +291,12 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public JMSProducer setTimeToLive(long timeToLive)
- {
- try
- {
+ public JMSProducer setTimeToLive(long timeToLive) {
+ try {
producer.setTimeToLive(timeToLive);
return this;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -366,16 +304,13 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public long getTimeToLive()
- {
+ public long getTimeToLive() {
long timeToLive = 0;
- try
- {
+ try {
timeToLive = producer.getTimeToLive();
return timeToLive;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -383,15 +318,12 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public JMSProducer setDeliveryDelay(long deliveryDelay)
- {
- try
- {
+ public JMSProducer setDeliveryDelay(long deliveryDelay) {
+ try {
producer.setDeliveryDelay(deliveryDelay);
return this;
}
- catch (JMSException e)
- {
+ catch (JMSException e) {
JMSRuntimeException e2 = new JMSRuntimeException(e.getMessage());
e2.initCause(e);
throw e2;
@@ -399,91 +331,78 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public long getDeliveryDelay()
- {
+ public long getDeliveryDelay() {
long deliveryDelay = 0;
- try
- {
+ try {
deliveryDelay = producer.getDeliveryDelay();
}
- catch (Exception ignored)
- {
+ catch (Exception ignored) {
}
return deliveryDelay;
}
@Override
- public JMSProducer setAsync(CompletionListener completionListener)
- {
+ public JMSProducer setAsync(CompletionListener completionListener) {
this.completionListener = completionListener;
return this;
}
@Override
- public CompletionListener getAsync()
- {
+ public CompletionListener getAsync() {
return completionListener;
}
@Override
- public JMSProducer setProperty(String name, boolean value)
- {
+ public JMSProducer setProperty(String name, boolean value) {
checkName(name);
properties.putBooleanProperty(new SimpleString(name), value);
return this;
}
@Override
- public JMSProducer setProperty(String name, byte value)
- {
+ public JMSProducer setProperty(String name, byte value) {
checkName(name);
properties.putByteProperty(new SimpleString(name), value);
return this;
}
@Override
- public JMSProducer setProperty(String name, short value)
- {
+ public JMSProducer setProperty(String name, short value) {
checkName(name);
properties.putShortProperty(new SimpleString(name), value);
return this;
}
@Override
- public JMSProducer setProperty(String name, int value)
- {
+ public JMSProducer setProperty(String name, int value) {
checkName(name);
properties.putIntProperty(new SimpleString(name), value);
return this;
}
@Override
- public JMSProducer setProperty(String name, long value)
- {
+ public JMSProducer setProperty(String name, long value) {
checkName(name);
properties.putLongProperty(new SimpleString(name), value);
return this;
}
@Override
- public JMSProducer setProperty(String name, float value)
- {
+ public JMSProducer setProperty(String name, float value) {
checkName(name);
properties.putFloatProperty(new SimpleString(name), value);
return this;
}
@Override
- public JMSProducer setProperty(String name, double value)
- {
+ public JMSProducer setProperty(String name, double value) {
checkName(name);
properties.putDoubleProperty(new SimpleString(name), value);
return this;
}
@Override
- public JMSProducer setProperty(String name, String value)
- {
+ public JMSProducer setProperty(String name, String value) {
checkName(name);
SimpleString key = new SimpleString(name);
properties.putSimpleStringProperty(key, new SimpleString(value));
@@ -492,212 +411,166 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public JMSProducer setProperty(String name, Object value)
- {
+ public JMSProducer setProperty(String name, Object value) {
checkName(name);
- try
- {
+ try {
TypedProperties.setObjectProperty(new SimpleString(name), value, properties);
}
- catch (ActiveMQPropertyConversionException amqe)
- {
+ catch (ActiveMQPropertyConversionException amqe) {
throw new MessageFormatRuntimeException(amqe.getMessage());
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
return this;
}
@Override
- public JMSProducer clearProperties()
- {
- try
- {
+ public JMSProducer clearProperties() {
+ try {
stringPropertyNames.clear();
properties.clear();
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
return this;
}
@Override
- public boolean propertyExists(String name)
- {
+ public boolean propertyExists(String name) {
return properties.containsProperty(new SimpleString(name));
}
@Override
- public boolean getBooleanProperty(String name)
- {
- try
- {
+ public boolean getBooleanProperty(String name) {
+ try {
return properties.getBooleanProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
}
@Override
- public byte getByteProperty(String name)
- {
- try
- {
+ public byte getByteProperty(String name) {
+ try {
return properties.getByteProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
}
@Override
- public short getShortProperty(String name)
- {
- try
- {
+ public short getShortProperty(String name) {
+ try {
return properties.getShortProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
}
@Override
- public int getIntProperty(String name)
- {
- try
- {
+ public int getIntProperty(String name) {
+ try {
return properties.getIntProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
}
@Override
- public long getLongProperty(String name)
- {
- try
- {
+ public long getLongProperty(String name) {
+ try {
return properties.getLongProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
}
@Override
- public float getFloatProperty(String name)
- {
- try
- {
+ public float getFloatProperty(String name) {
+ try {
return properties.getFloatProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
}
@Override
- public double getDoubleProperty(String name)
- {
- try
- {
+ public double getDoubleProperty(String name) {
+ try {
return properties.getDoubleProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
}
@Override
- public String getStringProperty(String name)
- {
- try
- {
+ public String getStringProperty(String name) {
+ try {
SimpleString prop = properties.getSimpleStringProperty(new SimpleString(name));
if (prop == null)
return null;
return prop.toString();
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
}
@Override
- public Object getObjectProperty(String name)
- {
- try
- {
+ public Object getObjectProperty(String name) {
+ try {
SimpleString key = new SimpleString(name);
Object property = properties.getProperty(key);
- if (stringPropertyNames.contains(key))
- {
+ if (stringPropertyNames.contains(key)) {
property = property.toString();
}
return property;
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
}
@Override
- public Set<String> getPropertyNames()
- {
- try
- {
+ public Set<String> getPropertyNames() {
+ try {
Set<SimpleString> simplePropNames = properties.getPropertyNames();
Set<String> propNames = new HashSet<String>(simplePropNames.size());
- for (SimpleString str : simplePropNames)
- {
+ for (SimpleString str : simplePropNames) {
propNames.add(str.toString());
}
return propNames;
}
- catch (ActiveMQPropertyConversionException ce)
- {
+ catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
}
@Override
- public JMSProducer setJMSCorrelationIDAsBytes(byte[] correlationID)
- {
- if (correlationID == null || correlationID.length == 0)
- {
+ public JMSProducer setJMSCorrelationIDAsBytes(byte[] correlationID) {
+ if (correlationID == null || correlationID.length == 0) {
throw new JMSRuntimeException("Please specify a non-zero length byte[]");
}
jmsHeaderCorrelationIDAsBytes = Arrays.copyOf(correlationID, correlationID.length);
@@ -705,96 +578,78 @@ public final class ActiveMQJMSProducer implements JMSProducer
}
@Override
- public byte[] getJMSCorrelationIDAsBytes()
- {
+ public byte[] getJMSCorrelationIDAsBytes() {
return Arrays.copyOf(jmsHeaderCorrelationIDAsBytes, jmsHeaderCorrelationIDAsBytes.length);
}
@Override
- public JMSProducer setJMSCorrelationID(String correlationID)
- {
+ public JMSProducer setJMSCorrelationID(String correlationID) {
jmsHeaderCorrelationID = correlationID;
return this;
}
@Override
- public String getJMSCorrelationID()
- {
+ public String getJMSCorrelationID() {
return jmsHeaderCorrelationID;
}
@Override
- public JMSProducer setJMSType(String type)
- {
+ public JMSProducer setJMSType(String type) {
jmsHeaderType = type;
return this;
}
@Override
- public String getJMSType()
- {
+ public String getJMSType() {
return jmsHeaderType;
}
@Override
- public JMSProducer setJMSReplyTo(Destination replyTo)
- {
+ public JMSProducer setJMSReplyTo(Destination replyTo) {
jmsHeaderReplyTo = replyTo;
return this;
}
@Override
- public Destination getJMSReplyTo()
- {
+ public Destination getJMSReplyTo() {
return jmsHeaderReplyTo;
}
- private void checkName(String name)
- {
- if (name == null)
- {
+ private void checkName(String name) {
+ if (name == null) {
throw ActiveMQJMSClientBundle.BUNDLE.nameCannotBeNull();
}
- if (name.equals(""))
- {
+ if (name.equals("")) {
throw ActiveMQJMSClientBundle.BUNDLE.nameCannotBeEmpty();
}
}
- final class CompletionListenerWrapper implements CompletionListener
- {
+ final class CompletionListenerWrapper implements CompletionListener {
private final CompletionListener wrapped;
- public CompletionListenerWrapper(CompletionListener wrapped)
- {
+ public CompletionListenerWrapper(CompletionListener wrapped) {
this.wrapped = wrapped;
}
@Override
- public void onCompletion(Message message)
- {
+ public void onCompletion(Message message) {
context.getThreadAwareContext().setCurrentThread(true);
- try
- {
+ try {
wrapped.onCompletion(message);
}
- finally
- {
+ finally {
context.getThreadAwareContext().clearCurrentThread(true);
}
}
@Override
- public void onException(Message message, Exception exception)
- {
+ public void onException(Message message, Exception exception) {
context.getThreadAwareContext().setCurrentThread(true);
- try
- {
+ try {
wrapped.onException(message, exception);
}
- finally
- {
+ finally {
context.getThreadAwareContext().clearCurrentThread(true);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java
index 44b19aa..35ee0e4 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java
@@ -32,15 +32,13 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.utils.TypedProperties;
-
import static org.apache.activemq.artemis.reader.MapMessageUtil.writeBodyMap;
import static org.apache.activemq.artemis.reader.MapMessageUtil.readBodyMap;
/**
* ActiveMQ Artemis implementation of a JMS MapMessage.
*/
-public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage
-{
+public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage {
// Constants -----------------------------------------------------
public static final byte TYPE = Message.MAP_TYPE;
@@ -58,8 +56,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
/*
* This constructor is used to construct messages prior to sending
*/
- protected ActiveMQMapMessage(final ClientSession session)
- {
+ protected ActiveMQMapMessage(final ClientSession session) {
super(ActiveMQMapMessage.TYPE, session);
invalid = true;
@@ -68,15 +65,13 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
/*
* This constructor is used during reading
*/
- protected ActiveMQMapMessage(final ClientMessage message, final ClientSession session)
- {
+ protected ActiveMQMapMessage(final ClientMessage message, final ClientSession session) {
super(message, session);
invalid = false;
}
- public ActiveMQMapMessage()
- {
+ public ActiveMQMapMessage() {
invalid = false;
}
@@ -86,12 +81,10 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
* @param foreign
* @throws JMSException
*/
- public ActiveMQMapMessage(final MapMessage foreign, final ClientSession session) throws JMSException
- {
+ public ActiveMQMapMessage(final MapMessage foreign, final ClientSession session) throws JMSException {
super(foreign, ActiveMQMapMessage.TYPE, session);
Enumeration<?> names = foreign.getMapNames();
- while (names.hasMoreElements())
- {
+ while (names.hasMoreElements()) {
String name = (String) names.nextElement();
Object obj = foreign.getObject(name);
setObject(name, obj);
@@ -101,88 +94,75 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
// Public --------------------------------------------------------
@Override
- public byte getType()
- {
+ public byte getType() {
return ActiveMQMapMessage.TYPE;
}
// MapMessage implementation -------------------------------------
- public void setBoolean(final String name, final boolean value) throws JMSException
- {
+ public void setBoolean(final String name, final boolean value) throws JMSException {
checkName(name);
map.putBooleanProperty(new SimpleString(name), value);
invalid = true;
}
- public void setByte(final String name, final byte value) throws JMSException
- {
+ public void setByte(final String name, final byte value) throws JMSException {
checkName(name);
map.putByteProperty(new SimpleString(name), value);
invalid = true;
}
- public void setShort(final String name, final short value) throws JMSException
- {
+ public void setShort(final String name, final short value) throws JMSException {
checkName(name);
map.putShortProperty(new SimpleString(name), value);
invalid = true;
}
- public void setChar(final String name, final char value) throws JMSException
- {
+ public void setChar(final String name, final char value) throws JMSException {
checkName(name);
map.putCharProperty(new SimpleString(name), value);
invalid = true;
}
- public void setInt(final String name, final int value) throws JMSException
- {
+ public void setInt(final String name, final int value) throws JMSException {
checkName(name);
map.putIntProperty(new SimpleString(name), value);
invalid = true;
}
- public void setLong(final String name, final long value) throws JMSException
- {
+ public void setLong(final String name, final long value) throws JMSException {
checkName(name);
map.putLongProperty(new SimpleString(name), value);
invalid = true;
}
- public void setFloat(final String name, final float value) throws JMSException
- {
+ public void setFloat(final String name, final float value) throws JMSException {
checkName(name);
map.putFloatProperty(new SimpleString(name), value);
invalid = true;
}
- public void setDouble(final String name, final double value) throws JMSException
- {
+ public void setDouble(final String name, final double value) throws JMSException {
checkName(name);
map.putDoubleProperty(new SimpleString(name), value);
invalid = true;
}
- public void setString(final String name, final String value) throws JMSException
- {
+ public void setString(final String name, final String value) throws JMSException {
checkName(name);
map.putSimpleStringProperty(new SimpleString(name), value == null ? null : new SimpleString(value));
invalid = true;
}
- public void setBytes(final String name, final byte[] value) throws JMSException
- {
+ public void setBytes(final String name, final byte[] value) throws JMSException {
checkName(name);
map.putBytesProperty(new SimpleString(name), value);
invalid = true;
}
- public void setBytes(final String name, final byte[] value, final int offset, final int length) throws JMSException
- {
+ public void setBytes(final String name, final byte[] value, final int offset, final int length) throws JMSException {
checkName(name);
- if (offset + length > value.length)
- {
+ if (offset + length > value.length) {
throw new JMSException("Invalid offset/length");
}
byte[] newBytes = new byte[length];
@@ -191,184 +171,142 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
invalid = true;
}
- public void setObject(final String name, final Object value) throws JMSException
- {
+ public void setObject(final String name, final Object value) throws JMSException {
checkName(name);
- try
- {
+ try {
TypedProperties.setObjectProperty(new SimpleString(name), value, map);
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
invalid = true;
}
- public boolean getBoolean(final String name) throws JMSException
- {
- try
- {
+ public boolean getBoolean(final String name) throws JMSException {
+ try {
return map.getBooleanProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public byte getByte(final String name) throws JMSException
- {
- try
- {
+ public byte getByte(final String name) throws JMSException {
+ try {
return map.getByteProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public short getShort(final String name) throws JMSException
- {
- try
- {
+ public short getShort(final String name) throws JMSException {
+ try {
return map.getShortProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public char getChar(final String name) throws JMSException
- {
- try
- {
+ public char getChar(final String name) throws JMSException {
+ try {
return map.getCharProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public int getInt(final String name) throws JMSException
- {
- try
- {
+ public int getInt(final String name) throws JMSException {
+ try {
return map.getIntProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public long getLong(final String name) throws JMSException
- {
- try
- {
+ public long getLong(final String name) throws JMSException {
+ try {
return map.getLongProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public float getFloat(final String name) throws JMSException
- {
- try
- {
+ public float getFloat(final String name) throws JMSException {
+ try {
return map.getFloatProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public double getDouble(final String name) throws JMSException
- {
- try
- {
+ public double getDouble(final String name) throws JMSException {
+ try {
return map.getDoubleProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public String getString(final String name) throws JMSException
- {
- try
- {
+ public String getString(final String name) throws JMSException {
+ try {
SimpleString str = map.getSimpleStringProperty(new SimpleString(name));
- if (str == null)
- {
+ if (str == null) {
return null;
}
- else
- {
+ else {
return str.toString();
}
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public byte[] getBytes(final String name) throws JMSException
- {
- try
- {
+ public byte[] getBytes(final String name) throws JMSException {
+ try {
return map.getBytesProperty(new SimpleString(name));
}
- catch (ActiveMQPropertyConversionException e)
- {
+ catch (ActiveMQPropertyConversionException e) {
throw new MessageFormatException(e.getMessage());
}
}
- public Object getObject(final String name) throws JMSException
- {
+ public Object getObject(final String name) throws JMSException {
Object val = map.getProperty(new SimpleString(name));
- if (val instanceof SimpleString)
- {
+ if (val instanceof SimpleString) {
val = ((SimpleString) val).toString();
}
return val;
}
- public Enumeration getMapNames() throws JMSException
- {
+ public Enumeration getMapNames() throws JMSException {
Set<SimpleString> simplePropNames = map.getPropertyNames();
Set<String> propNames = new HashSet<String>(simplePropNames.size());
- for (SimpleString str : simplePropNames)
- {
+ for (SimpleString str : simplePropNames) {
propNames.add(str.toString());
}
return Collections.enumeration(propNames);
}
- public boolean itemExists(final String name) throws JMSException
- {
+ public boolean itemExists(final String name) throws JMSException {
return map.containsProperty(new SimpleString(name));
}
-
// ActiveMQRAMessage overrides ----------------------------------------
@Override
- public void clearBody() throws JMSException
- {
+ public void clearBody() throws JMSException {
super.clearBody();
map.clear();
@@ -377,10 +315,8 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
@Override
- public void doBeforeSend() throws Exception
- {
- if (invalid)
- {
+ public void doBeforeSend() throws Exception {
+ if (invalid) {
writeBodyMap(message, map);
invalid = false;
}
@@ -389,8 +325,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
@Override
- public void doBeforeReceive() throws ActiveMQException
- {
+ public void doBeforeReceive() throws ActiveMQException {
super.doBeforeReceive();
readBodyMap(message, map);
@@ -407,32 +342,25 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
*
* @param name the name
*/
- private void checkName(final String name) throws JMSException
- {
+ private void checkName(final String name) throws JMSException {
checkWrite();
- if (name == null)
- {
+ if (name == null) {
throw ActiveMQJMSClientBundle.BUNDLE.nameCannotBeNull();
}
- if (name.equals(""))
- {
+ if (name.equals("")) {
throw ActiveMQJMSClientBundle.BUNDLE.nameCannotBeEmpty();
}
}
@Override
- protected boolean hasNoBody()
- {
+ protected boolean hasNoBody() {
return map.isEmpty();
}
@Override
- public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes")
- Class c)
- {
- if (hasNoBody())
- {
+ public boolean isBodyAssignableTo(@SuppressWarnings("rawtypes") Class c) {
+ if (hasNoBody()) {
return true;
}
return c.isAssignableFrom(java.util.Map.class);
@@ -440,8 +368,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
@SuppressWarnings("unchecked")
@Override
- protected <T> T getBodyInternal(Class<T> c)
- {
+ protected <T> T getBodyInternal(Class<T> c) {
return (T) map.getMap();
}
}