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:14 UTC
[15/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/ActiveMQXASession.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXASession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXASession.java
index b4b9df3..815b488 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXASession.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXASession.java
@@ -21,8 +21,7 @@ import javax.jms.XATopicSession;
import org.apache.activemq.artemis.api.core.client.ClientSession;
-public class ActiveMQXASession extends ActiveMQSession implements XAQueueSession, XATopicSession
-{
+public class ActiveMQXASession extends ActiveMQSession implements XAQueueSession, XATopicSession {
/**
* @param connection
@@ -37,8 +36,7 @@ public class ActiveMQXASession extends ActiveMQSession implements XAQueueSession
boolean xa,
int ackMode,
ClientSession session,
- int sessionType)
- {
+ int sessionType) {
super(connection, transacted, xa, ackMode, session, sessionType);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXATopicConnectionFactory.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXATopicConnectionFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXATopicConnectionFactory.java
index 6e52d19..de20159 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXATopicConnectionFactory.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQXATopicConnectionFactory.java
@@ -26,42 +26,35 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType;
/**
* {@inheritDoc}
*/
-public class ActiveMQXATopicConnectionFactory extends ActiveMQConnectionFactory implements XATopicConnectionFactory
-{
+public class ActiveMQXATopicConnectionFactory extends ActiveMQConnectionFactory implements XATopicConnectionFactory {
+
private static final long serialVersionUID = -7018290426884419693L;
- public ActiveMQXATopicConnectionFactory()
- {
+ public ActiveMQXATopicConnectionFactory() {
super();
}
- public ActiveMQXATopicConnectionFactory(String uri)
- {
+ public ActiveMQXATopicConnectionFactory(String uri) {
super(uri);
}
- public ActiveMQXATopicConnectionFactory(String url, String user, String password)
- {
+ public ActiveMQXATopicConnectionFactory(String url, String user, String password) {
super(url, user, password);
}
- public ActiveMQXATopicConnectionFactory(final ServerLocator serverLocator)
- {
+ public ActiveMQXATopicConnectionFactory(final ServerLocator serverLocator) {
super(serverLocator);
}
- public ActiveMQXATopicConnectionFactory(final boolean ha, final DiscoveryGroupConfiguration groupConfiguration)
- {
+ public ActiveMQXATopicConnectionFactory(final boolean ha, final DiscoveryGroupConfiguration groupConfiguration) {
super(ha, groupConfiguration);
}
- public ActiveMQXATopicConnectionFactory(final boolean ha, final TransportConfiguration... initialConnectors)
- {
+ public ActiveMQXATopicConnectionFactory(final boolean ha, final TransportConfiguration... initialConnectors) {
super(ha, initialConnectors);
}
- public int getFactoryType()
- {
+ public int getFactoryType() {
return JMSFactoryType.TOPIC_XA_CF.intValue();
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/DefaultConnectionProperties.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/DefaultConnectionProperties.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/DefaultConnectionProperties.java
index fbe50dc..328ab71 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/DefaultConnectionProperties.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/DefaultConnectionProperties.java
@@ -32,8 +32,8 @@ import java.security.PrivilegedAction;
* <tr><td>AMQ_PASSWORD or org.apache.activemq.AMQ_PASSWORD</td> <td>null</td></tr>
* </table>
*/
-public class DefaultConnectionProperties
-{
+public class DefaultConnectionProperties {
+
public static final String DEFAULT_BROKER_HOST;
public static final int DEFAULT_BROKER_PORT;
public static final String DEFAULT_BROKER_BIND_URL;
@@ -41,18 +41,13 @@ public class DefaultConnectionProperties
public static final String DEFAULT_USER;
public static final String DEFAULT_PASSWORD;
- static String getProperty(final String defaultValue, final String... propertyNames)
- {
- return AccessController.doPrivileged(new PrivilegedAction<String>()
- {
+ static String getProperty(final String defaultValue, final String... propertyNames) {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
- public String run()
- {
- for (String name : propertyNames)
- {
+ public String run() {
+ for (String name : propertyNames) {
String property = System.getProperty(name);
- if (property != null && !property.isEmpty())
- {
+ if (property != null && !property.isEmpty()) {
return property;
}
}
@@ -61,8 +56,7 @@ public class DefaultConnectionProperties
});
}
- static
- {
+ static {
String host = getProperty("localhost", "AMQ_HOST", "org.apache.activemq.AMQ_HOST");
String port = getProperty("61616", "AMQ_PORT", "org.apache.activemq.AMQ_PORT");
DEFAULT_BROKER_HOST = host;
@@ -71,8 +65,7 @@ public class DefaultConnectionProperties
DEFAULT_USER = getProperty(null, "AMQ_USER", "org.apache.activemq.AMQ_USER");
DEFAULT_PASSWORD = getProperty(null, "AMQ_PASSWORD", "org.apache.activemq.AMQ_PASSWORD");
- if (DEFAULT_USER != null && DEFAULT_PASSWORD != null)
- {
+ if (DEFAULT_USER != null && DEFAULT_PASSWORD != null) {
url += "?user=" + DEFAULT_USER + "&password=" + DEFAULT_PASSWORD;
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSExceptionHelper.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSExceptionHelper.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSExceptionHelper.java
index ae85f56..666fa9d 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSExceptionHelper.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSExceptionHelper.java
@@ -23,14 +23,11 @@ import javax.jms.JMSSecurityException;
import org.apache.activemq.artemis.api.core.ActiveMQException;
-public final class JMSExceptionHelper
-{
+public final class JMSExceptionHelper {
- public static JMSException convertFromActiveMQException(final ActiveMQException me)
- {
+ public static JMSException convertFromActiveMQException(final ActiveMQException me) {
JMSException je;
- switch (me.getType())
- {
+ switch (me.getType()) {
case CONNECTION_TIMEDOUT:
je = new JMSException(me.getMessage());
break;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java
index a5a7d2d..1a6c95a 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java
@@ -25,8 +25,8 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.MessageHandler;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants;
-public class JMSMessageListenerWrapper implements MessageHandler
-{
+public class JMSMessageListenerWrapper implements MessageHandler {
+
private final ActiveMQConnection connection;
private final ActiveMQSession session;
@@ -43,8 +43,7 @@ public class JMSMessageListenerWrapper implements MessageHandler
final ActiveMQSession session,
final ClientConsumer consumer,
final MessageListener listener,
- final int ackMode)
- {
+ final int ackMode) {
this.connection = connection;
this.session = session;
@@ -62,55 +61,43 @@ public class JMSMessageListenerWrapper implements MessageHandler
* In this method we apply the JMS acknowledgement and redelivery semantics
* as per JMS spec
*/
- public void onMessage(final ClientMessage message)
- {
+ public void onMessage(final ClientMessage message) {
ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session.getCoreSession());
- if (individualACK)
- {
+ if (individualACK) {
msg.setIndividualAcknowledge();
}
- try
- {
+ try {
msg.doBeforeReceive();
}
- catch (Exception e)
- {
+ catch (Exception e) {
ActiveMQJMSClientLogger.LOGGER.errorPreparingMessageForReceipt(e);
return;
}
- if (transactedOrClientAck)
- {
- try
- {
+ if (transactedOrClientAck) {
+ try {
message.acknowledge();
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
ActiveMQJMSClientLogger.LOGGER.errorProcessingMessage(e);
}
}
- try
- {
+ try {
connection.getThreadAwareContext().setCurrentThread(false);
listener.onMessage(msg);
}
- catch (RuntimeException e)
- {
+ catch (RuntimeException e) {
// See JMS 1.1 spec, section 4.5.2
ActiveMQJMSClientLogger.LOGGER.onMessageError(e);
- if (!transactedOrClientAck)
- {
- try
- {
- if (individualACK)
- {
+ if (!transactedOrClientAck) {
+ try {
+ if (individualACK) {
message.individualAcknowledge();
}
@@ -118,28 +105,22 @@ public class JMSMessageListenerWrapper implements MessageHandler
session.setRecoverCalled(true);
}
- catch (Exception e2)
- {
+ catch (Exception e2) {
ActiveMQJMSClientLogger.LOGGER.errorRecoveringSession(e2);
}
}
}
- finally
- {
+ finally {
connection.getThreadAwareContext().clearCurrentThread(false);
}
- if (!session.isRecoverCalled() && !individualACK)
- {
- try
- {
+ if (!session.isRecoverCalled() && !individualACK) {
+ try {
// We don't want to call this if the consumer was closed from inside onMessage
- if (!consumer.isClosed() && !transactedOrClientAck)
- {
+ if (!consumer.isClosed() && !transactedOrClientAck) {
message.acknowledge();
}
}
- catch (ActiveMQException e)
- {
+ catch (ActiveMQException e) {
ActiveMQJMSClientLogger.LOGGER.errorProcessingMessage(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/JmsExceptionUtils.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JmsExceptionUtils.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JmsExceptionUtils.java
index a69cd6a..aea050f 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JmsExceptionUtils.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JmsExceptionUtils.java
@@ -41,59 +41,48 @@ import javax.jms.TransactionRolledBackRuntimeException;
/**
*
*/
-public final class JmsExceptionUtils
-{
- private JmsExceptionUtils()
- {
+public final class JmsExceptionUtils {
+
+ private JmsExceptionUtils() {
// utility class
}
/**
* Converts instances of sub-classes of {@link JMSException} into the corresponding sub-class of
* {@link JMSRuntimeException}.
+ *
* @param e
* @return
*/
- public static JMSRuntimeException convertToRuntimeException(JMSException e)
- {
- if (e instanceof javax.jms.IllegalStateException)
- {
+ public static JMSRuntimeException convertToRuntimeException(JMSException e) {
+ if (e instanceof javax.jms.IllegalStateException) {
return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof InvalidClientIDException)
- {
+ if (e instanceof InvalidClientIDException) {
return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof InvalidDestinationException)
- {
+ if (e instanceof InvalidDestinationException) {
return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof InvalidSelectorException)
- {
+ if (e instanceof InvalidSelectorException) {
return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof JMSSecurityException)
- {
+ if (e instanceof JMSSecurityException) {
return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof MessageFormatException)
- {
+ if (e instanceof MessageFormatException) {
return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof MessageNotWriteableException)
- {
+ if (e instanceof MessageNotWriteableException) {
return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof ResourceAllocationException)
- {
+ if (e instanceof ResourceAllocationException) {
return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof TransactionInProgressException)
- {
+ if (e instanceof TransactionInProgressException) {
return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
- if (e instanceof TransactionRolledBackException)
- {
+ if (e instanceof TransactionRolledBackException) {
return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), 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/SelectorTranslator.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/SelectorTranslator.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/SelectorTranslator.java
index 15509f9..d227f89 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/SelectorTranslator.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/SelectorTranslator.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
/**
- *
* This class converts a JMS selector expression into an ActiveMQ Artemis core filter expression.
*
* JMS selector and ActiveMQ Artemis filters use the same syntax but have different identifiers.
@@ -33,12 +32,10 @@ import java.util.List;
*
* This makes it less trivial than a simple search and replace.
*/
-public class SelectorTranslator
-{
- public static String convertToActiveMQFilterString(final String selectorString)
- {
- if (selectorString == null)
- {
+public class SelectorTranslator {
+
+ public static String convertToActiveMQFilterString(final String selectorString) {
+ if (selectorString == null) {
return null;
}
@@ -56,8 +53,7 @@ public class SelectorTranslator
}
- private static String parse(final String input, final String match, final String replace)
- {
+ private static String parse(final String input, final String match, final String replace) {
final char quote = '\'';
boolean inQuote = false;
@@ -68,42 +64,35 @@ public class SelectorTranslator
boolean replaceInQuotes = match.charAt(0) == quote;
- for (int i = 0; i < input.length(); i++)
- {
+ for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
- if (c == quote)
- {
+ if (c == quote) {
inQuote = !inQuote;
}
- if ((!inQuote || replaceInQuotes) && c == match.charAt(matchPos))
- {
+ if ((!inQuote || replaceInQuotes) && c == match.charAt(matchPos)) {
matchPos++;
- if (matchPos == match.length())
- {
+ if (matchPos == match.length()) {
boolean matched = true;
// Check that name is not part of another identifier name
// Check character after match
- if (i < input.length() - 1 && Character.isJavaIdentifierPart(input.charAt(i + 1)))
- {
+ if (i < input.length() - 1 && Character.isJavaIdentifierPart(input.charAt(i + 1))) {
matched = false;
}
// Check character before match
int posBeforeStart = i - match.length();
- if (posBeforeStart >= 0 && Character.isJavaIdentifierPart(input.charAt(posBeforeStart)))
- {
+ if (posBeforeStart >= 0 && Character.isJavaIdentifierPart(input.charAt(posBeforeStart))) {
matched = false;
}
- if (matched)
- {
+ if (matched) {
positions.add(i - match.length() + 1);
}
@@ -112,20 +101,17 @@ public class SelectorTranslator
matchPos = 0;
}
}
- else
- {
+ else {
matchPos = 0;
}
}
- if (!positions.isEmpty())
- {
+ if (!positions.isEmpty()) {
StringBuffer buff = new StringBuffer();
int startPos = 0;
- for (int pos : positions)
- {
+ for (int pos : positions) {
String substr = input.substring(startPos, pos);
buff.append(substr);
@@ -135,15 +121,13 @@ public class SelectorTranslator
startPos = pos + match.length();
}
- if (startPos < input.length())
- {
+ if (startPos < input.length()) {
buff.append(input.substring(startPos, input.length()));
}
return buff.toString();
}
- else
- {
+ else {
return input;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java
index 4828b34..10624ce 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java
@@ -24,12 +24,13 @@ import java.util.Set;
/**
* Restricts what can be called on context passed in wrapped CompletionListener.
*/
-public class ThreadAwareContext
-{
+public class ThreadAwareContext {
+
/**
* Necessary in order to assert some methods ({@link javax.jms.JMSContext#stop()}
* {@link javax.jms.JMSContext#close()} etc) are not getting called from within a
* {@link javax.jms.CompletionListener}.
+ *
* @see ThreadAwareContext#assertNotMessageListenerThread()
*/
private Thread completionListenerThread;
@@ -45,36 +46,30 @@ public class ThreadAwareContext
* <p>
* Meant to inform an JMSContext which is the thread that CANNOT call some of its methods.
* </p>
+ *
* @param isCompletionListener : indicating whether current thread is from CompletionListener
- * or from MessageListener.
+ * or from MessageListener.
*/
- public void setCurrentThread(boolean isCompletionListener)
- {
- if (isCompletionListener)
- {
+ public void setCurrentThread(boolean isCompletionListener) {
+ if (isCompletionListener) {
completionListenerThread = Thread.currentThread();
}
- else
- {
+ else {
messageListenerThreads.add(Thread.currentThread().getId());
}
}
-
/**
* Clear current thread from the context
*
* @param isCompletionListener : indicating whether current thread is from CompletionListener
- * or from MessageListener.
+ * or from MessageListener.
*/
- public void clearCurrentThread(boolean isCompletionListener)
- {
- if (isCompletionListener)
- {
+ public void clearCurrentThread(boolean isCompletionListener) {
+ if (isCompletionListener) {
completionListenerThread = null;
}
- else
- {
+ else {
messageListenerThreads.remove(Thread.currentThread().getId());
}
}
@@ -85,15 +80,14 @@ public class ThreadAwareContext
* Note that the code must work without any need for further synchronization, as there is the
* requirement that only one CompletionListener be called at a time. In other words,
* CompletionListener calling is single-threaded.
+ *
* @see javax.jms.JMSContext#close()
* @see javax.jms.JMSContext#stop()
* @see javax.jms.JMSContext#commit()
* @see javax.jms.JMSContext#rollback()
*/
- public void assertNotCompletionListenerThreadRuntime()
- {
- if (completionListenerThread == Thread.currentThread())
- {
+ public void assertNotCompletionListenerThreadRuntime() {
+ if (completionListenerThread == Thread.currentThread()) {
throw ActiveMQJMSClientBundle.BUNDLE.callingMethodFromCompletionListenerRuntime();
}
}
@@ -109,10 +103,8 @@ public class ThreadAwareContext
* @see javax.jms.Connection#close()
* @see javax.jms.MessageProducer#close()
*/
- public void assertNotCompletionListenerThread() throws javax.jms.IllegalStateException
- {
- if (completionListenerThread == Thread.currentThread())
- {
+ public void assertNotCompletionListenerThread() throws javax.jms.IllegalStateException {
+ if (completionListenerThread == Thread.currentThread()) {
throw ActiveMQJMSClientBundle.BUNDLE.callingMethodFromCompletionListener();
}
}
@@ -123,20 +115,19 @@ public class ThreadAwareContext
* Note that the code must work without any need for further synchronization, as there is the
* requirement that only one MessageListener be called at a time. In other words,
* MessageListener calling is single-threaded.
+ *
* @see javax.jms.JMSContext#close()
* @see javax.jms.JMSContext#stop()
*/
- public void assertNotMessageListenerThreadRuntime()
- {
- if (messageListenerThreads.contains(Thread.currentThread().getId()))
- {
+ public void assertNotMessageListenerThreadRuntime() {
+ if (messageListenerThreads.contains(Thread.currentThread().getId())) {
throw ActiveMQJMSClientBundle.BUNDLE.callingMethodFromListenerRuntime();
}
}
/**
* Asserts a {@link javax.jms.MessageListener} is not calling from its own {@link javax.jms.Connection} or
- * {@link javax.jms.MessageConsumer}.
+ * {@link javax.jms.MessageConsumer}.
* <p>
* Note that the code must work without any need for further synchronization, as there is the
* requirement that only one MessageListener be called at a time. In other words,
@@ -145,10 +136,8 @@ public class ThreadAwareContext
* @see javax.jms.Connection#close()
* @see javax.jms.MessageConsumer#close()
*/
- public void assertNotMessageListenerThread() throws IllegalStateException
- {
- if (messageListenerThreads.contains(Thread.currentThread().getId()))
- {
+ public void assertNotMessageListenerThread() throws IllegalStateException {
+ if (messageListenerThreads.contains(Thread.currentThread().getId())) {
throw ActiveMQJMSClientBundle.BUNDLE.callingMethodFromListener();
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java
index ca9ab6d..b61a51e 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/ConnectionFactoryObjectFactory.java
@@ -24,18 +24,19 @@ import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
/**
- *
* A ConnectionFactoryObjectFactory.
*
* Given a reference - reconstructs an ActiveMQRAConnectionFactory
*/
-public class ConnectionFactoryObjectFactory implements ObjectFactory
-{
- public Object getObjectInstance(final Object ref, final Name name, final Context ctx, final Hashtable props) throws Exception
- {
- Reference r = (Reference)ref;
+public class ConnectionFactoryObjectFactory implements ObjectFactory {
+
+ public Object getObjectInstance(final Object ref,
+ final Name name,
+ final Context ctx,
+ final Hashtable props) throws Exception {
+ Reference r = (Reference) ref;
- byte[] bytes = (byte[])r.get("ActiveMQ-CF").getContent();
+ byte[] bytes = (byte[]) r.get("ActiveMQ-CF").getContent();
// Deserialize
return SerializableObjectRefAddr.deserialize(bytes);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java
index 7ae8ed1..59533e0 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/DestinationObjectFactory.java
@@ -24,18 +24,19 @@ import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
/**
- *
* A DestinationObjectFactory.
*
* Given a Reference - reconstructs an ActiveMQDestination
*/
-public class DestinationObjectFactory implements ObjectFactory
-{
- public Object getObjectInstance(final Object ref, final Name name, final Context ctx, final Hashtable props) throws Exception
- {
- Reference r = (Reference)ref;
+public class DestinationObjectFactory implements ObjectFactory {
+
+ public Object getObjectInstance(final Object ref,
+ final Name name,
+ final Context ctx,
+ final Hashtable props) throws Exception {
+ Reference r = (Reference) ref;
- byte[] bytes = (byte[])r.get("ActiveMQ-DEST").getContent();
+ byte[] bytes = (byte[]) r.get("ActiveMQ-DEST").getContent();
// Deserialize
return SerializableObjectRefAddr.deserialize(bytes);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java
index d4877c1..a6e227f 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/referenceable/SerializableObjectRefAddr.java
@@ -26,25 +26,22 @@ import javax.naming.NamingException;
import javax.naming.RefAddr;
/**
- *
* A SerializableObjectRefAddr.
*
* A RefAddr that can be used for any serializable object.
*
* Basically the address is the serialized form of the object as a byte[]
*/
-public class SerializableObjectRefAddr extends RefAddr
-{
+public class SerializableObjectRefAddr extends RefAddr {
+
private static final long serialVersionUID = 9158134548376171898L;
private final byte[] bytes;
- public SerializableObjectRefAddr(final String type, final Object content) throws NamingException
- {
+ public SerializableObjectRefAddr(final String type, final Object content) throws NamingException {
super(type);
- try
- {
+ try {
// Serialize the object
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -56,20 +53,17 @@ public class SerializableObjectRefAddr extends RefAddr
bytes = bos.toByteArray();
}
- catch (IOException e)
- {
+ catch (IOException e) {
throw new NamingException("Failed to serialize object:" + content + ", " + e.getMessage());
}
}
@Override
- public Object getContent()
- {
+ public Object getContent() {
return bytes;
}
- public static Object deserialize(final byte[] bytes) throws IOException, ClassNotFoundException
- {
+ public static Object deserialize(final byte[] bytes) throws IOException, ClassNotFoundException {
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bis);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java
index 31e76db..ba7474f 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ActiveMQInitialContextFactory.java
@@ -37,8 +37,8 @@ import org.apache.activemq.artemis.uri.ConnectionFactoryParser;
* child context depending on the QoS such as transient or durable and queue or
* topic.
*/
-public class ActiveMQInitialContextFactory implements InitialContextFactory
-{
+public class ActiveMQInitialContextFactory implements InitialContextFactory {
+
public static final String REFRESH_TIMEOUT = "refreshTimeout";
public static final String DISCOVERY_INITIAL_WAIT_TIMEOUT = "discoveryInitialWaitTimeout";
public static final String DYNAMIC_QUEUE_CONTEXT = "dynamicQueues";
@@ -47,50 +47,39 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory
private String queuePrefix = "queue.";
private String topicPrefix = "topic.";
- public Context getInitialContext(Hashtable environment) throws NamingException
- {
+ public Context getInitialContext(Hashtable environment) throws NamingException {
// lets create a factory
Map<String, Object> data = new ConcurrentHashMap<>();
- for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); )
- {
+ for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
String key = entry.getKey().toString();
- if (key.startsWith(connectionFactoryPrefix))
- {
+ if (key.startsWith(connectionFactoryPrefix)) {
String jndiName = key.substring(connectionFactoryPrefix.length());
- try
- {
+ try {
ConnectionFactory factory = createConnectionFactory((String) environment.get(key), jndiName);
data.put(jndiName, factory);
}
- catch (Exception e)
- {
+ catch (Exception e) {
e.printStackTrace();
throw new NamingException("Invalid broker URL");
}
}
}
-
-
createQueues(data, environment);
createTopics(data, environment);
- data.put(DYNAMIC_QUEUE_CONTEXT, new LazyCreateContext()
- {
+ data.put(DYNAMIC_QUEUE_CONTEXT, new LazyCreateContext() {
private static final long serialVersionUID = 6503881346214855588L;
- protected Object createEntry(String name)
- {
+ protected Object createEntry(String name) {
return ActiveMQJMSClient.createQueue(name);
}
});
- data.put(DYNAMIC_TOPIC_CONTEXT, new LazyCreateContext()
- {
+ data.put(DYNAMIC_TOPIC_CONTEXT, new LazyCreateContext() {
private static final long serialVersionUID = 2019166796234979615L;
- protected Object createEntry(String name)
- {
+ protected Object createEntry(String name) {
return ActiveMQJMSClient.createTopic(name);
}
});
@@ -100,56 +89,45 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory
// Properties
// -------------------------------------------------------------------------
- public String getTopicPrefix()
- {
+ public String getTopicPrefix() {
return topicPrefix;
}
- public void setTopicPrefix(String topicPrefix)
- {
+ public void setTopicPrefix(String topicPrefix) {
this.topicPrefix = topicPrefix;
}
- public String getQueuePrefix()
- {
+ public String getQueuePrefix() {
return queuePrefix;
}
- public void setQueuePrefix(String queuePrefix)
- {
+ public void setQueuePrefix(String queuePrefix) {
this.queuePrefix = queuePrefix;
}
// Implementation methods
// -------------------------------------------------------------------------
- protected ReadOnlyContext createContext(Hashtable environment, Map<String, Object> data)
- {
+ protected ReadOnlyContext createContext(Hashtable environment, Map<String, Object> data) {
return new ReadOnlyContext(environment, data);
}
- protected void createQueues(Map<String, Object> data, Hashtable environment)
- {
- for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); )
- {
+ protected void createQueues(Map<String, Object> data, Hashtable environment) {
+ for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
String key = entry.getKey().toString();
- if (key.startsWith(queuePrefix))
- {
+ if (key.startsWith(queuePrefix)) {
String jndiName = key.substring(queuePrefix.length());
data.put(jndiName, createQueue(entry.getValue().toString()));
}
}
}
- protected void createTopics(Map<String, Object> data, Hashtable environment)
- {
- for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); )
- {
+ protected void createTopics(Map<String, Object> data, Hashtable environment) {
+ for (Iterator iter = environment.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
String key = entry.getKey().toString();
- if (key.startsWith(topicPrefix))
- {
+ if (key.startsWith(topicPrefix)) {
String jndiName = key.substring(topicPrefix.length());
data.put(jndiName, createTopic(entry.getValue().toString()));
}
@@ -159,24 +137,21 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory
/**
* Factory method to create new Queue instances
*/
- protected Queue createQueue(String name)
- {
+ protected Queue createQueue(String name) {
return ActiveMQJMSClient.createQueue(name);
}
/**
* Factory method to create new Topic instances
*/
- protected Topic createTopic(String name)
- {
+ protected Topic createTopic(String name) {
return ActiveMQJMSClient.createTopic(name);
}
/**
* Factory method to create a new connection factory from the given environment
*/
- protected ConnectionFactory createConnectionFactory(String uri, String name) throws Exception
- {
+ protected ConnectionFactory createConnectionFactory(String uri, String name) throws Exception {
ConnectionFactoryParser parser = new ConnectionFactoryParser();
return parser.newObject(parser.expandURI(uri), name);
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java
index b2e8353..a817d69 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/LazyCreateContext.java
@@ -19,19 +19,15 @@ package org.apache.activemq.artemis.jndi;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-public abstract class LazyCreateContext extends ReadOnlyContext
-{
- public Object lookup(String name) throws NamingException
- {
- try
- {
+public abstract class LazyCreateContext extends ReadOnlyContext {
+
+ public Object lookup(String name) throws NamingException {
+ try {
return super.lookup(name);
}
- catch (NameNotFoundException e)
- {
+ catch (NameNotFoundException e) {
Object answer = createEntry(name);
- if (answer == null)
- {
+ if (answer == null) {
throw e;
}
internalBind(name, answer);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/NameParserImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/NameParserImpl.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/NameParserImpl.java
index ae7f417..b469cb8 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/NameParserImpl.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/NameParserImpl.java
@@ -21,10 +21,9 @@ import javax.naming.Name;
import javax.naming.NameParser;
import javax.naming.NamingException;
-public class NameParserImpl implements NameParser
-{
- public Name parse(String name) throws NamingException
- {
+public class NameParserImpl implements NameParser {
+
+ public Name parse(String name) throws NamingException {
return new CompositeName(name);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java
index 69f5e9c..f0daa9f 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jndi/ReadOnlyContext.java
@@ -60,8 +60,8 @@ import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
* </code>
*/
@SuppressWarnings("unchecked")
-public class ReadOnlyContext implements Context, Serializable
-{
+public class ReadOnlyContext implements Context, Serializable {
+
public static final String SEPARATOR = "/";
protected static final NameParser NAME_PARSER = new NameParserImpl();
private static final long serialVersionUID = -5754338187296859149L;
@@ -73,49 +73,38 @@ public class ReadOnlyContext implements Context, Serializable
private boolean frozen;
private String nameInNamespace = "";
- public ReadOnlyContext()
- {
+ public ReadOnlyContext() {
environment = new Hashtable<String, Object>();
bindings = new HashMap<String, Object>();
treeBindings = new HashMap<String, Object>();
}
- public ReadOnlyContext(Hashtable env)
- {
- if (env == null)
- {
+ public ReadOnlyContext(Hashtable env) {
+ if (env == null) {
this.environment = new Hashtable<String, Object>();
}
- else
- {
+ else {
this.environment = new Hashtable<String, Object>(env);
}
this.bindings = Collections.EMPTY_MAP;
this.treeBindings = Collections.EMPTY_MAP;
}
- public ReadOnlyContext(Hashtable environment, Map<String, Object> bindings)
- {
- if (environment == null)
- {
+ public ReadOnlyContext(Hashtable environment, Map<String, Object> bindings) {
+ if (environment == null) {
this.environment = new Hashtable<String, Object>();
}
- else
- {
+ else {
this.environment = new Hashtable<String, Object>(environment);
}
this.bindings = new HashMap<String, Object>();
treeBindings = new HashMap<String, Object>();
- if (bindings != null)
- {
- for (Map.Entry<String, Object> binding : bindings.entrySet())
- {
- try
- {
+ if (bindings != null) {
+ for (Map.Entry<String, Object> binding : bindings.entrySet()) {
+ try {
internalBind(binding.getKey(), binding.getValue());
}
- catch (Throwable e)
- {
+ catch (Throwable e) {
ActiveMQClientLogger.LOGGER.error("Failed to bind " + binding.getKey() + "=" + binding.getValue(), e);
}
}
@@ -123,32 +112,27 @@ public class ReadOnlyContext implements Context, Serializable
frozen = true;
}
- public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace)
- {
+ public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace) {
this(environment, bindings);
this.nameInNamespace = nameInNamespace;
}
- protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env)
- {
+ protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env) {
this.bindings = clone.bindings;
this.treeBindings = clone.treeBindings;
this.environment = new Hashtable<String, Object>(env);
}
- protected ReadOnlyContext(ReadOnlyContext clone, Hashtable<String, Object> env, String nameInNamespace)
- {
+ protected ReadOnlyContext(ReadOnlyContext clone, Hashtable<String, Object> env, String nameInNamespace) {
this(clone, env);
this.nameInNamespace = nameInNamespace;
}
- public void freeze()
- {
+ public void freeze() {
frozen = true;
}
- boolean isFrozen()
- {
+ boolean isFrozen() {
return frozen;
}
@@ -167,44 +151,37 @@ public class ReadOnlyContext implements Context, Serializable
* @return
* @throws javax.naming.NamingException
*/
- protected Map<String, Object> internalBind(String name, Object value) throws NamingException
- {
+ protected Map<String, Object> internalBind(String name, Object value) throws NamingException {
assert name != null && name.length() > 0;
assert !frozen;
Map<String, Object> newBindings = new HashMap<String, Object>();
int pos = name.indexOf('/');
- if (pos == -1)
- {
- if (treeBindings.put(name, value) != null)
- {
+ if (pos == -1) {
+ if (treeBindings.put(name, value) != null) {
throw new NamingException("Something already bound at " + name);
}
bindings.put(name, value);
newBindings.put(name, value);
}
- else
- {
+ else {
String segment = name.substring(0, pos);
assert segment != null;
assert !segment.equals("");
Object o = treeBindings.get(segment);
- if (o == null)
- {
+ if (o == null) {
o = newContext();
treeBindings.put(segment, o);
bindings.put(segment, o);
newBindings.put(segment, o);
}
- else if (!(o instanceof ReadOnlyContext))
- {
+ else if (!(o instanceof ReadOnlyContext)) {
throw new NamingException("Something already bound where a subcontext should go");
}
ReadOnlyContext readOnlyContext = (ReadOnlyContext) o;
String remainder = name.substring(pos + 1);
Map<String, Object> subBindings = readOnlyContext.internalBind(remainder, value);
- for (Iterator iterator = subBindings.entrySet().iterator(); iterator.hasNext(); )
- {
+ for (Iterator iterator = subBindings.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry entry = (Map.Entry) iterator.next();
String subName = segment + "/" + (String) entry.getKey();
Object bound = entry.getValue();
@@ -215,70 +192,55 @@ public class ReadOnlyContext implements Context, Serializable
return newBindings;
}
- protected ReadOnlyContext newContext()
- {
+ protected ReadOnlyContext newContext() {
return new ReadOnlyContext();
}
- public Object addToEnvironment(String propName, Object propVal) throws NamingException
- {
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException {
return environment.put(propName, propVal);
}
- public Hashtable<String, Object> getEnvironment() throws NamingException
- {
+ public Hashtable<String, Object> getEnvironment() throws NamingException {
return (Hashtable<String, Object>) environment.clone();
}
- public Object removeFromEnvironment(String propName) throws NamingException
- {
+ public Object removeFromEnvironment(String propName) throws NamingException {
return environment.remove(propName);
}
- public Object lookup(String name) throws NamingException
- {
- if (name.length() == 0)
- {
+ public Object lookup(String name) throws NamingException {
+ if (name.length() == 0) {
return this;
}
Object result = treeBindings.get(name);
- if (result == null)
- {
+ if (result == null) {
result = bindings.get(name);
}
- if (result == null)
- {
+ if (result == null) {
int pos = name.indexOf(':');
- if (pos > 0)
- {
+ if (pos > 0) {
String scheme = name.substring(0, pos);
Context ctx = NamingManager.getURLContext(scheme, environment);
- if (ctx == null)
- {
+ if (ctx == null) {
throw new NamingException("scheme " + scheme + " not recognized");
}
return ctx.lookup(name);
}
- else
- {
+ else {
// Split out the first name of the path
// and look for it in the bindings map.
CompositeName path = new CompositeName(name);
- if (path.size() == 0)
- {
+ if (path.size() == 0) {
return this;
}
- else
- {
+ else {
String first = path.get(0);
Object obj = bindings.get(first);
- if (obj == null)
- {
+ if (obj == null) {
throw new NameNotFoundException(name);
}
- else if (obj instanceof Context && path.size() > 1)
- {
+ else if (obj instanceof Context && path.size() > 1) {
Context subContext = (Context) obj;
obj = subContext.lookup(path.getSuffix(1));
}
@@ -286,31 +248,24 @@ public class ReadOnlyContext implements Context, Serializable
}
}
}
- if (result instanceof LinkRef)
- {
+ if (result instanceof LinkRef) {
LinkRef ref = (LinkRef) result;
result = lookup(ref.getLinkName());
}
- if (result instanceof Reference)
- {
- try
- {
+ if (result instanceof Reference) {
+ try {
result = NamingManager.getObjectInstance(result, null, null, this.environment);
}
- catch (NamingException e)
- {
+ catch (NamingException e) {
throw e;
}
- catch (Exception e)
- {
+ catch (Exception e) {
throw (NamingException) new NamingException("could not look up : " + name).initCause(e);
}
}
- if (result instanceof ReadOnlyContext)
- {
+ if (result instanceof ReadOnlyContext) {
String prefix = getNameInNamespace();
- if (prefix.length() > 0)
- {
+ if (prefix.length() > 0) {
prefix = prefix + SEPARATOR;
}
result = new ReadOnlyContext((ReadOnlyContext) result, environment, prefix + name);
@@ -318,217 +273,173 @@ public class ReadOnlyContext implements Context, Serializable
return result;
}
- public Object lookup(Name name) throws NamingException
- {
+ public Object lookup(Name name) throws NamingException {
return lookup(name.toString());
}
- public Object lookupLink(String name) throws NamingException
- {
+ public Object lookupLink(String name) throws NamingException {
return lookup(name);
}
- public Name composeName(Name name, Name prefix) throws NamingException
- {
+ public Name composeName(Name name, Name prefix) throws NamingException {
Name result = (Name) prefix.clone();
result.addAll(name);
return result;
}
- public String composeName(String name, String prefix) throws NamingException
- {
+ public String composeName(String name, String prefix) throws NamingException {
CompositeName result = new CompositeName(prefix);
result.addAll(new CompositeName(name));
return result.toString();
}
- public NamingEnumeration list(String name) throws NamingException
- {
+ public NamingEnumeration list(String name) throws NamingException {
Object o = lookup(name);
- if (o == this)
- {
+ if (o == this) {
return new ListEnumeration();
}
- else if (o instanceof Context)
- {
+ else if (o instanceof Context) {
return ((Context) o).list("");
}
- else
- {
+ else {
throw new NotContextException();
}
}
- public NamingEnumeration listBindings(String name) throws NamingException
- {
+ public NamingEnumeration listBindings(String name) throws NamingException {
Object o = lookup(name);
- if (o == this)
- {
+ if (o == this) {
return new ListBindingEnumeration();
}
- else if (o instanceof Context)
- {
+ else if (o instanceof Context) {
return ((Context) o).listBindings("");
}
- else
- {
+ else {
throw new NotContextException();
}
}
- public Object lookupLink(Name name) throws NamingException
- {
+ public Object lookupLink(Name name) throws NamingException {
return lookupLink(name.toString());
}
- public NamingEnumeration list(Name name) throws NamingException
- {
+ public NamingEnumeration list(Name name) throws NamingException {
return list(name.toString());
}
- public NamingEnumeration listBindings(Name name) throws NamingException
- {
+ public NamingEnumeration listBindings(Name name) throws NamingException {
return listBindings(name.toString());
}
- public void bind(Name name, Object obj) throws NamingException
- {
+ public void bind(Name name, Object obj) throws NamingException {
throw new OperationNotSupportedException();
}
- public void bind(String name, Object obj) throws NamingException
- {
+ public void bind(String name, Object obj) throws NamingException {
throw new OperationNotSupportedException();
}
- public void close() throws NamingException
- {
+ public void close() throws NamingException {
// ignore
}
- public Context createSubcontext(Name name) throws NamingException
- {
+ public Context createSubcontext(Name name) throws NamingException {
throw new OperationNotSupportedException();
}
- public Context createSubcontext(String name) throws NamingException
- {
+ public Context createSubcontext(String name) throws NamingException {
throw new OperationNotSupportedException();
}
- public void destroySubcontext(Name name) throws NamingException
- {
+ public void destroySubcontext(Name name) throws NamingException {
throw new OperationNotSupportedException();
}
- public void destroySubcontext(String name) throws NamingException
- {
+ public void destroySubcontext(String name) throws NamingException {
throw new OperationNotSupportedException();
}
- public String getNameInNamespace() throws NamingException
- {
+ public String getNameInNamespace() throws NamingException {
return nameInNamespace;
}
- public NameParser getNameParser(Name name) throws NamingException
- {
+ public NameParser getNameParser(Name name) throws NamingException {
return NAME_PARSER;
}
- public NameParser getNameParser(String name) throws NamingException
- {
+ public NameParser getNameParser(String name) throws NamingException {
return NAME_PARSER;
}
- public void rebind(Name name, Object obj) throws NamingException
- {
+ public void rebind(Name name, Object obj) throws NamingException {
throw new OperationNotSupportedException();
}
- public void rebind(String name, Object obj) throws NamingException
- {
+ public void rebind(String name, Object obj) throws NamingException {
throw new OperationNotSupportedException();
}
- public void rename(Name oldName, Name newName) throws NamingException
- {
+ public void rename(Name oldName, Name newName) throws NamingException {
throw new OperationNotSupportedException();
}
- public void rename(String oldName, String newName) throws NamingException
- {
+ public void rename(String oldName, String newName) throws NamingException {
throw new OperationNotSupportedException();
}
- public void unbind(Name name) throws NamingException
- {
+ public void unbind(Name name) throws NamingException {
throw new OperationNotSupportedException();
}
- public void unbind(String name) throws NamingException
- {
+ public void unbind(String name) throws NamingException {
throw new OperationNotSupportedException();
}
- private abstract class LocalNamingEnumeration implements NamingEnumeration
- {
- private final Iterator i = bindings.entrySet()
- .iterator();
+ private abstract class LocalNamingEnumeration implements NamingEnumeration {
+
+ private final Iterator i = bindings.entrySet().iterator();
- public boolean hasMore() throws NamingException
- {
+ public boolean hasMore() throws NamingException {
return i.hasNext();
}
- public boolean hasMoreElements()
- {
+ public boolean hasMoreElements() {
return i.hasNext();
}
- protected Map.Entry getNext()
- {
+ protected Map.Entry getNext() {
return (Map.Entry) i.next();
}
- public void close() throws NamingException
- {
+ public void close() throws NamingException {
}
}
- private class ListEnumeration extends LocalNamingEnumeration
- {
- ListEnumeration()
- {
+ private class ListEnumeration extends LocalNamingEnumeration {
+
+ ListEnumeration() {
}
- public Object next() throws NamingException
- {
+ public Object next() throws NamingException {
return nextElement();
}
- public Object nextElement()
- {
+ public Object nextElement() {
Map.Entry entry = getNext();
- return new NameClassPair((String) entry.getKey(), entry.getValue()
- .getClass()
- .getName());
+ return new NameClassPair((String) entry.getKey(), entry.getValue().getClass().getName());
}
}
- private class ListBindingEnumeration extends LocalNamingEnumeration
- {
- ListBindingEnumeration()
- {
+ private class ListBindingEnumeration extends LocalNamingEnumeration {
+
+ ListBindingEnumeration() {
}
- public Object next() throws NamingException
- {
+ public Object next() throws NamingException {
return nextElement();
}
- public Object nextElement()
- {
+ public Object nextElement() {
Map.Entry entry = getNext();
return new Binding((String) entry.getKey(), entry.getValue());
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/AbstractCFSchema.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/AbstractCFSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/AbstractCFSchema.java
index 407c9db..b93d2ea 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/AbstractCFSchema.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/AbstractCFSchema.java
@@ -24,15 +24,12 @@ import org.apache.activemq.artemis.core.client.ActiveMQClientLogger;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.utils.uri.URISchema;
-public abstract class AbstractCFSchema extends URISchema<ActiveMQConnectionFactory, String>
-{
+public abstract class AbstractCFSchema extends URISchema<ActiveMQConnectionFactory, String> {
- protected JMSConnectionOptions newConectionOptions(URI uri, Map<String, String> query) throws Exception
- {
+ protected JMSConnectionOptions newConectionOptions(URI uri, Map<String, String> query) throws Exception {
String type = query.get("type");
// We do this check here to guarantee proper logging
- if (JMSConnectionOptions.convertCFType(type) == null)
- {
+ if (JMSConnectionOptions.convertCFType(type) == null) {
ActiveMQClientLogger.LOGGER.invalidCFType(type, uri.toString());
}
return setData(uri, new JMSConnectionOptions(), query);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/ConnectionFactoryParser.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/ConnectionFactoryParser.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/ConnectionFactoryParser.java
index 50a3644..1e3e32d 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/ConnectionFactoryParser.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/ConnectionFactoryParser.java
@@ -20,10 +20,9 @@ package org.apache.activemq.artemis.uri;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.utils.uri.URIFactory;
-public class ConnectionFactoryParser extends URIFactory<ActiveMQConnectionFactory, String>
-{
- public ConnectionFactoryParser()
- {
+public class ConnectionFactoryParser extends URIFactory<ActiveMQConnectionFactory, String> {
+
+ public ConnectionFactoryParser() {
registerSchema(new TCPSchema());
registerSchema(new UDPSchema());
registerSchema(new JGroupsSchema());
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java
index adbff66..b161786 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/InVMSchema.java
@@ -23,27 +23,24 @@ import org.apache.activemq.artemis.utils.uri.SchemaConstants;
import java.net.URI;
import java.util.Map;
-public class InVMSchema extends AbstractCFSchema
-{
+public class InVMSchema extends AbstractCFSchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.VM;
}
@Override
- protected ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected ActiveMQConnectionFactory internalNewObject(URI uri,
+ Map<String, String> query,
+ String name) throws Exception {
JMSConnectionOptions options = newConectionOptions(uri, query);
- ActiveMQConnectionFactory factory =
- ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(),
- InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"));
+ ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), InVMTransportConfigurationSchema.createTransportConfiguration(uri, query, name, "org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory"));
return setData(uri, factory, query);
}
@Override
- protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception
- {
+ protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
return InVMServerLocatorSchema.getUri(bean.getStaticConnectors());
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java
index 15e5865..a6b3680 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JGroupsSchema.java
@@ -30,53 +30,47 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.utils.uri.SchemaConstants;
import org.apache.activemq.artemis.utils.uri.URISchema;
-public class JGroupsSchema extends AbstractCFSchema
-{
+public class JGroupsSchema extends AbstractCFSchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.JGROUPS;
}
@Override
- public ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ public ActiveMQConnectionFactory internalNewObject(URI uri,
+ Map<String, String> query,
+ String name) throws Exception {
JMSConnectionOptions options = newConectionOptions(uri, query);
DiscoveryGroupConfiguration dcConfig = JGroupsServerLocatorSchema.getDiscoveryGroupConfiguration(uri, query, name);
ActiveMQConnectionFactory factory;
- if (options.isHa())
- {
+ if (options.isHa()) {
factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dcConfig, options.getFactoryTypeEnum());
}
- else
- {
- factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dcConfig, options.getFactoryTypeEnum());
+ else {
+ factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dcConfig, options.getFactoryTypeEnum());
}
return URISchema.setData(uri, factory, query);
}
@Override
- protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception
- {
+ protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration();
- BroadcastEndpointFactory endpoint = dgc.getBroadcastEndpointFactory();
+ BroadcastEndpointFactory endpoint = dgc.getBroadcastEndpointFactory();
String auth;
- if (endpoint instanceof JGroupsFileBroadcastEndpointFactory)
- {
+ if (endpoint instanceof JGroupsFileBroadcastEndpointFactory) {
auth = ((JGroupsFileBroadcastEndpointFactory) endpoint).getChannelName();
}
- else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory)
- {
+ else if (endpoint instanceof JGroupsPropertiesBroadcastEndpointFactory) {
auth = ((JGroupsPropertiesBroadcastEndpointFactory) endpoint).getChannelName();
}
- else
- {
+ else {
throw new NotSerializableException(endpoint + "not serializable");
}
String query = URISchema.getData(null, bean, dgc, endpoint);
dgc.setBroadcastEndpointFactory(endpoint);
- return new URI(SchemaConstants.JGROUPS, null, auth, -1, null, query, null);
+ return new URI(SchemaConstants.JGROUPS, null, auth, -1, null, query, null);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java
index 0f15800..04d8e8f 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/JMSConnectionOptions.java
@@ -24,52 +24,41 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType;
* When parsing the URL this will serve as an intermediate object
* And it could also be a pl
*/
-public class JMSConnectionOptions extends ConnectionOptions
-{
+public class JMSConnectionOptions extends ConnectionOptions {
+
private JMSFactoryType factoryType = JMSFactoryType.CF;
- public JMSFactoryType getFactoryTypeEnum()
- {
+ public JMSFactoryType getFactoryTypeEnum() {
return factoryType;
}
- public String getType()
- {
+ public String getType() {
return factoryType.toString();
}
-
- public void setType(final String type)
- {
+ public void setType(final String type) {
this.factoryType = convertCFType(type);
- if (factoryType == null)
- {
+ if (factoryType == null) {
factoryType = JMSFactoryType.CF;
}
}
- public static JMSFactoryType convertCFType(String type)
- {
- try
- {
- if (type == null)
- {
+ public static JMSFactoryType convertCFType(String type) {
+ try {
+ if (type == null) {
return JMSFactoryType.CF;
}
- else
- {
+ else {
return Enum.valueOf(JMSFactoryType.class, type);
}
}
- catch (Exception e)
- {
+ catch (Exception e) {
return null;
}
}
@Override
- public String toString()
- {
+ public String toString() {
return "JMSConnectionOptions{" +
", factoryType=" + factoryType +
'}';
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java
index b318718..7a35a41 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/TCPSchema.java
@@ -28,21 +28,20 @@ import java.net.URI;
import java.util.List;
import java.util.Map;
-public class TCPSchema extends AbstractCFSchema
-{
+public class TCPSchema extends AbstractCFSchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.TCP;
}
@Override
- protected ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ protected ActiveMQConnectionFactory internalNewObject(URI uri,
+ Map<String, String> query,
+ String name) throws Exception {
JMSConnectionOptions options = newConectionOptions(uri, query);
- List<TransportConfiguration> configurations =
- TCPTransportConfigurationSchema.getTransportConfigurations(uri, query, TransportConstants.ALLOWABLE_CONNECTOR_KEYS, name, NettyConnectorFactory.class.getName());
+ List<TransportConfiguration> configurations = TCPTransportConfigurationSchema.getTransportConfigurations(uri, query, TransportConstants.ALLOWABLE_CONNECTOR_KEYS, name, NettyConnectorFactory.class.getName());
TransportConfiguration[] tcs = new TransportConfiguration[configurations.size()];
@@ -50,21 +49,18 @@ public class TCPSchema extends AbstractCFSchema
ActiveMQConnectionFactory factory;
- if (options.isHa())
- {
+ if (options.isHa()) {
factory = ActiveMQJMSClient.createConnectionFactoryWithHA(options.getFactoryTypeEnum(), tcs);
}
- else
- {
- factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), tcs);
+ else {
+ factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(options.getFactoryTypeEnum(), tcs);
}
return URISchema.setData(uri, factory, query);
}
@Override
- protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception
- {
+ protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
String query = URISchema.getData(null, bean);
TransportConfiguration[] staticConnectors = bean.getStaticConnectors();
return TCPServerLocatorSchema.getURI(query, staticConnectors);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java
index e0a6faa..9c83755 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/uri/UDPSchema.java
@@ -27,40 +27,37 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.utils.uri.SchemaConstants;
import org.apache.activemq.artemis.utils.uri.URISchema;
-public class UDPSchema extends AbstractCFSchema
-{
+public class UDPSchema extends AbstractCFSchema {
+
@Override
- public String getSchemaName()
- {
+ public String getSchemaName() {
return SchemaConstants.UDP;
}
@Override
- public ActiveMQConnectionFactory internalNewObject(URI uri, Map<String, String> query, String name) throws Exception
- {
+ public ActiveMQConnectionFactory internalNewObject(URI uri,
+ Map<String, String> query,
+ String name) throws Exception {
JMSConnectionOptions options = newConectionOptions(uri, query);
DiscoveryGroupConfiguration dgc = UDPServerLocatorSchema.getDiscoveryGroupConfiguration(uri, query, getHost(uri), getPort(uri), name);
ActiveMQConnectionFactory factory;
- if (options.isHa())
- {
+ if (options.isHa()) {
factory = ActiveMQJMSClient.createConnectionFactoryWithHA(dgc, options.getFactoryTypeEnum());
}
- else
- {
- factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dgc, options.getFactoryTypeEnum());
+ else {
+ factory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(dgc, options.getFactoryTypeEnum());
}
return URISchema.setData(uri, factory, query);
}
@Override
- protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception
- {
+ protected URI internalNewURI(ActiveMQConnectionFactory bean) throws Exception {
DiscoveryGroupConfiguration dgc = bean.getDiscoveryGroupConfiguration();
UDPBroadcastEndpointFactory endpoint = (UDPBroadcastEndpointFactory) dgc.getBroadcastEndpointFactory();
String query = URISchema.getData(UDPServerLocatorSchema.IGNORED, bean, dgc, endpoint);
dgc.setBroadcastEndpointFactory(endpoint);
- return new URI(SchemaConstants.UDP, null, endpoint.getGroupAddress(), endpoint.getGroupPort(), null, query, null);
+ return new URI(SchemaConstants.UDP, null, endpoint.getGroupAddress(), endpoint.getGroupPort(), null, query, null);
}
}