http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java ---------------------------------------------------------------------- diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java index 6a204ea..1402513 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCLIPlugin.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -21,6 +21,7 @@ import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; +import org.apache.activemq.artemis.boot.Artemis; import org.apache.activemq.artemis.cli.commands.Run; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.maven.plugin.MojoExecutionException; @@ -30,7 +31,6 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.activemq.artemis.boot.Artemis; @Mojo(name = "cli", defaultPhase = LifecyclePhase.VERIFY) public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { @@ -99,7 +99,6 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { return ignore; } - @Override protected void doExecute() throws MojoExecutionException, MojoFailureException { // This is to avoid the Run issuing a kill at any point @@ -110,8 +109,7 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { if (!lookupHome(home.toPath())) { if (lookupHome(alternateHome.toPath())) { home = alternateHome; - } - else { + } else { getLog().error("********************************************************************************************"); getLog().error("Could not locate suitable Artemis.home on either " + home + " or " + alternateHome); getLog().error("Use the binary distribution or build the distribution before running the examples"); @@ -137,13 +135,11 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { try (ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(testURI)) { if (testUser != null && testPassword != null) { cf.createConnection(testUser, testPassword).close(); - } - else { + } else { cf.createConnection().close(); } getLog().info("Server started"); - } - catch (Exception e) { + } catch (Exception e) { getLog().info("awaiting server to start"); Thread.sleep(500); continue; @@ -151,16 +147,14 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin { break; } } - } - else { + } else { Artemis.execute(home, location, args); } Thread.sleep(600); org.apache.activemq.artemis.cli.process.ProcessBuilder.cleanupProcess(); - } - catch (Throwable e) { + } catch (Throwable e) { throw new MojoExecutionException(e.getMessage(), e); } }
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java ---------------------------------------------------------------------- diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java index 6023cc1..533fc6b 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java @@ -59,8 +59,7 @@ public class ArtemisClientPlugin extends ArtemisAbstractPlugin { Class aClass = Class.forName(clientClass); Method method = aClass.getDeclaredMethod("main", new Class[]{String[].class}); method.invoke(null, new Object[]{args}); - } - catch (Exception e) { + } catch (Exception e) { getLog().error(e); throw new MojoFailureException(e.getMessage()); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java ---------------------------------------------------------------------- diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java index b8359f0..fdc308a 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -128,7 +128,6 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { @Parameter private String[] libListWithDeps; - @Parameter(defaultValue = "${localRepository}") private org.apache.maven.artifact.repository.ArtifactRepository localRepository; @@ -178,8 +177,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { if (!lookupHome(home.toPath())) { if (lookupHome(alternateHome.toPath())) { home = alternateHome; - } - else { + } else { getLog().error("********************************************************************************************"); getLog().error("Could not locate suitable Artemis.home on either " + home + " or " + alternateHome); getLog().error("Use the binary distribution or build the distribution before running the examples"); @@ -204,8 +202,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { if (allowAnonymous) { add(listCommands, "--allow-anonymous"); - } - else { + } else { add(listCommands, "--require-login"); } @@ -256,8 +253,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { FileOutputStream outputStream; try { outputStream = new FileOutputStream(commandLine); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new MojoExecutionException(e.getMessage(), e); } @@ -282,7 +278,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { Set<File> files = resolveDependencies(libListWithDeps, libList); - if (!files.isEmpty() ) { + if (!files.isEmpty()) { commandLineStream.println(); commandLineStream.println("# This is a list of files that need to be installed under ./lib."); commandLineStream.println("# We are copying them from your maven lib home"); @@ -300,14 +296,16 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { getLog().info("under " + commandLine.getParent()); getLog().info("###################################################################################################"); - } - catch (Throwable e) { + } catch (Throwable e) { getLog().error(e); throw new MojoFailureException(e.getMessage()); } } - private void copyConfigurationFiles(String[] list, Path sourcePath, Path targetPath, PrintStream commandLineStream) throws IOException { + private void copyConfigurationFiles(String[] list, + Path sourcePath, + Path targetPath, + PrintStream commandLineStream) throws IOException { for (String file : list) { Path target = targetPath.resolve(file); @@ -322,8 +320,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { commandLineStream.println("mkdir " + target); copyConfigurationFiles(originalFile.toFile().list(), originalFile, target, commandLineStream); - } - else { + } else { getLog().debug("Copying " + file + " to " + target); commandLineStream.println("# copying config file " + originalFile.getFileName()); commandLineStream.println("cp " + originalFile + " " + target); @@ -349,7 +346,6 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin { commandLineStream.println("mkdir " + file.getParent()); } - commandLineStream.println("cp " + projectLib.getAbsolutePath() + " " + target); getLog().debug("Copying " + projectLib.getName() + " as " + target.toFile().getAbsolutePath()); Files.copy(projectLib.toPath(), target, StandardCopyOption.REPLACE_EXISTING); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java ---------------------------------------------------------------------- diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java index 3b00c99..e59bc36 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisDependencyScanPlugin.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -76,7 +76,6 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin { getLog().info("... key=" + entry.getKey() + " = " + entry.getValue()); } - try { StringBuffer buffer = new StringBuffer(); Set<File> filesSet = resolveDependencies(libListWithDeps, libList); @@ -100,8 +99,7 @@ public class ArtemisDependencyScanPlugin extends ArtemisAbstractPlugin { Files.copy(file.toPath(), targetFolder.toPath(), StandardCopyOption.REPLACE_EXISTING); } } - } - catch (Throwable e) { + } catch (Throwable e) { getLog().error(e); throw new MojoFailureException(e.getMessage()); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java ---------------------------------------------------------------------- diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java index df4c61b..8049a97 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java @@ -67,12 +67,10 @@ public class LibaioContext<Callback extends SubmitInfo> implements Closeable { if (getNativeVersion() != EXPECTED_NATIVE_VERSION) { NativeLogger.LOGGER.incompatibleNativeLibrary(); return false; - } - else { + } else { return true; } - } - catch (Throwable e) { + } catch (Throwable e) { NativeLogger.LOGGER.debug(name + " -> error loading the native library", e); return false; } @@ -93,8 +91,7 @@ public class LibaioContext<Callback extends SubmitInfo> implements Closeable { } }); break; - } - else { + } else { NativeLogger.LOGGER.debug("Library " + library + " not found!"); } } @@ -161,16 +158,14 @@ public class LibaioContext<Callback extends SubmitInfo> implements Closeable { try { contexts.incrementAndGet(); this.ioContext = newContext(queueSize); - } - catch (Exception e) { + } catch (Exception e) { throw e; } this.queueSize = queueSize; totalMaxIO.addAndGet(queueSize); if (useSemaphore) { this.ioSpace = new Semaphore(queueSize); - } - else { + } else { this.ioSpace = null; } } @@ -197,8 +192,7 @@ public class LibaioContext<Callback extends SubmitInfo> implements Closeable { if (ioSpace != null) { ioSpace.acquire(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException(e.getMessage(), e); } @@ -217,8 +211,7 @@ public class LibaioContext<Callback extends SubmitInfo> implements Closeable { if (ioSpace != null) { ioSpace.acquire(); } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IOException(e.getMessage(), e); } @@ -238,8 +231,7 @@ public class LibaioContext<Callback extends SubmitInfo> implements Closeable { if (ioSpace != null) { try { ioSpace.tryAcquire(queueSize, 10, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { NativeLogger.LOGGER.error(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java ---------------------------------------------------------------------- diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java index 92a6733..43d80ea 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java @@ -121,8 +121,7 @@ public final class LibaioFile<Callback extends SubmitInfo> implements AutoClosea public void fill(long size) { try { LibaioContext.fill(fd, size); - } - catch (OutOfMemoryError e) { + } catch (OutOfMemoryError e) { NativeLogger.LOGGER.debug("Didn't have enough memory to allocate " + size + " bytes in memory, using simple fallocate"); LibaioContext.fallocate(fd, size); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java ---------------------------------------------------------------------- diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java index 2205103..afde2fc 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/util/CallbackCache.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -42,8 +42,7 @@ public class CallbackCache<Callback extends SubmitInfo> { synchronized (lock) { if (available <= 0) { return null; - } - else { + } else { Callback retValue = (Callback) pool[get]; pool[get] = null; if (retValue == null) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java ---------------------------------------------------------------------- diff --git a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java index 6785d78..bed9da3 100644 --- a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java +++ b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/CallbackCachelTest.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -14,13 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.activemq.artemis.jlibaio.test; import java.util.HashSet; -import org.apache.activemq.artemis.jlibaio.util.CallbackCache; import org.apache.activemq.artemis.jlibaio.SubmitInfo; +import org.apache.activemq.artemis.jlibaio.util.CallbackCache; import org.junit.Assert; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java ---------------------------------------------------------------------- diff --git a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java index fec742c..7f98f0d 100644 --- a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java +++ b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java @@ -53,19 +53,16 @@ public class LibaioTest { try { parent.mkdirs(); - boolean failed = false; try (LibaioContext control = new LibaioContext<>(1, true); LibaioFile fileDescriptor = control.openFile(file, true)) { fileDescriptor.fallocate(4 * 1024); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); failed = true; } Assume.assumeFalse("There is not enough support to libaio", failed); - } - finally { + } finally { file.delete(); } } @@ -218,8 +215,7 @@ public class LibaioTest { file.close(); } - } - finally { + } finally { LibaioContext.freeBuffer(buffer); } } @@ -270,8 +266,7 @@ public class LibaioTest { for (int i = 0; i < 512; i++) { Assert.assertEquals('B', buffer.get()); } - } - finally { + } finally { LibaioContext.freeBuffer(buffer); fileDescriptor.close(); } @@ -330,8 +325,7 @@ public class LibaioTest { for (int i = 0; i < BUFFER_SIZE; i++) { Assert.assertEquals('B', buffer.get()); } - } - finally { + } finally { fileDescriptor.close(); } } @@ -372,8 +366,7 @@ public class LibaioTest { for (int i = 0; i < BUFFER_SIZE; i++) { Assert.assertEquals('@', buffer.get()); } - } - finally { + } finally { LibaioContext.freeBuffer(buffer); fileDescriptor.close(); } @@ -432,8 +425,7 @@ public class LibaioTest { callback = null; TestInfo.checkLeaks(); - } - finally { + } finally { fileDescriptor.close(); } } @@ -470,8 +462,7 @@ public class LibaioTest { } TestInfo.checkLeaks(); - } - finally { + } finally { LibaioContext.freeBuffer(bufferWrite); } } @@ -501,8 +492,7 @@ public class LibaioTest { boolean failed = false; try { LibaioContext.freeBuffer(null); - } - catch (Exception expected) { + } catch (Exception expected) { failed = true; } @@ -546,8 +536,7 @@ public class LibaioTest { try { // There is no space for a queue this huge, the native layer should throw the exception LibaioContext newController = new LibaioContext(Integer.MAX_VALUE, false); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { exceptionThrown = true; } @@ -557,8 +546,7 @@ public class LibaioTest { try { // this should throw an exception, we shouldn't be able to open a directory! control.openFile(temporaryFolder.getRoot(), true); - } - catch (IOException expected) { + } catch (IOException expected) { exceptionThrown = true; } @@ -570,8 +558,7 @@ public class LibaioTest { fileDescriptor.close(); try { fileDescriptor.close(); - } - catch (IOException expected) { + } catch (IOException expected) { exceptionThrown = true; } @@ -593,8 +580,7 @@ public class LibaioTest { boolean ex = false; try { fileDescriptor.write(0, 512, buffer, new TestInfo()); - } - catch (Exception e) { + } catch (Exception e) { ex = true; } @@ -623,8 +609,7 @@ public class LibaioTest { exceptionThrown = false; try { LibaioContext.newAlignedBuffer(300, 512); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { exceptionThrown = true; } @@ -633,14 +618,12 @@ public class LibaioTest { exceptionThrown = false; try { LibaioContext.newAlignedBuffer(-512, 512); - } - catch (RuntimeException e) { + } catch (RuntimeException e) { exceptionThrown = true; } Assert.assertTrue(exceptionThrown); - } - finally { + } finally { LibaioContext.freeBuffer(buffer); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java ---------------------------------------------------------------------- diff --git a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java index 6c7d69b..c04bff4 100644 --- a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java +++ b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/OpenCloseContextTest.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -48,7 +48,8 @@ public class OpenCloseContextTest { @Test public void testRepeatOpenCloseContext() throws Exception { ByteBuffer buffer = LibaioContext.newAlignedBuffer(512, 512); - for (int i = 0; i < 512; i++) buffer.put((byte)'x'); + for (int i = 0; i < 512; i++) + buffer.put((byte) 'x'); for (int i = 0; i < 10; i++) { System.out.println("#test " + i); @@ -75,8 +76,7 @@ public class OpenCloseContextTest { insideMethod.countDown(); try { awaitInside.await(); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } System.out.println("done"); @@ -98,17 +98,16 @@ public class OpenCloseContextTest { awaitInside.countDown(); control.close(); - t.join(); } - } @Test public void testRepeatOpenCloseContext2() throws Exception { ByteBuffer buffer = LibaioContext.newAlignedBuffer(512, 512); - for (int i = 0; i < 512; i++) buffer.put((byte)'x'); + for (int i = 0; i < 512; i++) + buffer.put((byte) 'x'); for (int i = 0; i < 10; i++) { System.out.println("#test " + i); @@ -135,8 +134,7 @@ public class OpenCloseContextTest { insideMethod.countDown(); try { awaitInside.await(100, TimeUnit.MILLISECONDS); - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } System.out.println("done"); @@ -162,7 +160,6 @@ public class OpenCloseContextTest { t.join(); } - } @Test @@ -173,7 +170,6 @@ public class OpenCloseContextTest { control.close(); control.poll(); - control2.close(); control2.poll(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/pom.xml ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/pom.xml b/artemis-protocols/artemis-amqp-protocol/pom.xml index aac507e..b5be461 100644 --- a/artemis-protocols/artemis-amqp-protocol/pom.xml +++ b/artemis-protocols/artemis-amqp-protocol/pom.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>artemis-protocols</artifactId> <groupId>org.apache.activemq</groupId> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java index fd79547..31abf87 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java @@ -30,15 +30,21 @@ import io.netty.channel.ChannelFutureListener; import org.apache.activemq.artemis.api.core.ActiveMQBuffers; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper; -import org.apache.activemq.artemis.protocol.amqp.sasl.AnonymousServerSASL; -import org.apache.activemq.artemis.protocol.amqp.sasl.PlainSASL; import org.apache.activemq.artemis.core.remoting.CloseListener; import org.apache.activemq.artemis.core.remoting.FailureListener; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl; import org.apache.activemq.artemis.core.transaction.impl.XidImpl; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; +import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; import org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport; +import org.apache.activemq.artemis.protocol.amqp.proton.handler.ExtCapability; +import org.apache.activemq.artemis.protocol.amqp.sasl.AnonymousServerSASL; +import org.apache.activemq.artemis.protocol.amqp.sasl.PlainSASL; +import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; +import org.apache.activemq.artemis.protocol.amqp.sasl.ServerSASL; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.utils.ReusableLatch; import org.apache.activemq.artemis.utils.UUIDGenerator; @@ -46,14 +52,9 @@ import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.Symbol; import org.apache.qpid.proton.amqp.transport.AmqpError; import org.jboss.logging.Logger; -import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; -import org.apache.activemq.artemis.protocol.amqp.sasl.ServerSASL; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; -import org.apache.activemq.artemis.protocol.amqp.proton.handler.ExtCapability; -import org.apache.activemq.artemis.protocol.amqp.logger.ActiveMQAMQPProtocolMessageBundle; public class AMQPConnectionCallback implements FailureListener, CloseListener { + private static final Logger logger = Logger.getLogger(AMQPConnectionCallback.class); private ConcurrentMap<XidImpl, Transaction> transactions = new ConcurrentHashMap<>(); @@ -92,8 +93,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { if (isSupportsAnonymous()) { result = new ServerSASL[]{new PlainSASL(manager.getServer().getSecurityStore()), new AnonymousServerSASL()}; - } - else { + } else { result = new ServerSASL[]{new PlainSASL(manager.getServer().getSecurityStore())}; } @@ -105,8 +105,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { try { manager.getServer().getSecurityStore().authenticate(null, null, null); supportsAnonymous = true; - } - catch (Exception e) { + } catch (Exception e) { // authentication failed so no anonymous support } return supportsAnonymous; @@ -119,13 +118,11 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { } connection.close(); amqpConnection.close(); - } - finally { + } finally { for (Transaction tx : transactions.values()) { try { tx.rollback(); - } - catch (Exception e) { + } catch (Exception e) { logger.warn(e.getMessage(), e); } } @@ -135,8 +132,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { public Executor getExeuctor() { if (protonConnectionDelegate != null) { return protonConnectionDelegate.getExecutor(); - } - else { + } else { return null; } } @@ -172,8 +168,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { if (amqpConnection.isSyncOnFlush()) { try { latch.await(5, TimeUnit.SECONDS); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -245,7 +240,6 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { transactions.remove(xid); } - protected XidImpl newXID() { return newXID(UUIDGenerator.getInstance().generateStringUUID().getBytes()); } @@ -254,7 +248,4 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { return new XidImpl("amqp".getBytes(), 1, bytes); } - - - } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java index 9bdf4e1..46ed1c9 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java @@ -28,8 +28,6 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.paging.PagingStore; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; -import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; import org.apache.activemq.artemis.core.server.BindingQueryResult; import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.QueueQueryResult; @@ -39,7 +37,15 @@ import org.apache.activemq.artemis.core.server.ServerSession; import org.apache.activemq.artemis.core.server.impl.ServerConsumerImpl; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.jms.client.ActiveMQConnection; +import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPInternalErrorException; +import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPResourceLimitExceededException; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPSessionContext; +import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext; import org.apache.activemq.artemis.protocol.amqp.sasl.PlainSASLResult; +import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; import org.apache.activemq.artemis.spi.core.protocol.SessionCallback; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ReadyListener; @@ -56,12 +62,6 @@ import org.apache.qpid.proton.engine.Delivery; import org.apache.qpid.proton.engine.Link; import org.apache.qpid.proton.engine.Receiver; import org.apache.qpid.proton.message.ProtonJMessage; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPSessionContext; -import org.apache.activemq.artemis.protocol.amqp.sasl.SASLResult; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; -import org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException; -import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPResourceLimitExceededException; public class AMQPSessionCallback implements SessionCallback { @@ -111,15 +111,13 @@ public class AMQPSessionCallback implements SessionCallback { public void run() { try { plugSender.getSender().drained(); - } - finally { + } finally { draining.set(false); } } }); } - } - else { + } else { serverConsumer.receiveCredits(-1); } } @@ -203,8 +201,7 @@ public class AMQPSessionCallback implements SessionCallback { if (!queueQueryResult.isExists() && queueQueryResult.isAutoCreateJmsQueues() && autoCreate) { try { serverSession.createQueue(new SimpleString(queueName), new SimpleString(queueName), null, false, true); - } - catch (ActiveMQQueueExistsException e) { + } catch (ActiveMQQueueExistsException e) { // The queue may have been created by another thread in the mean time. Catch and do nothing. } queueQueryResult = new QueueQueryResult(queueQueryResult.getName(), queueQueryResult.getAddress(), queueQueryResult.isDurable(), queueQueryResult.isTemporary(), queueQueryResult.getFilterString(), queueQueryResult.getConsumerCount(), queueQueryResult.getMessageCount(), queueQueryResult.isAutoCreateJmsQueues(), true); @@ -217,8 +214,7 @@ public class AMQPSessionCallback implements SessionCallback { if (!bindingQueryResult.isExists() && bindingQueryResult.isAutoCreateJmsQueues()) { try { serverSession.createQueue(new SimpleString(address), new SimpleString(address), null, false, true); - } - catch (ActiveMQQueueExistsException e) { + } catch (ActiveMQQueueExistsException e) { // The queue may have been created by another thread in the mean time. Catch and do nothing. } bindingQueryResult = serverSession.executeBindingQuery(SimpleString.toSimpleString(address)); @@ -237,8 +233,7 @@ public class AMQPSessionCallback implements SessionCallback { try { consumer.close(false); latch.countDown(); - } - catch (Exception e) { + } catch (Exception e) { } } }; @@ -250,15 +245,13 @@ public class AMQPSessionCallback implements SessionCallback { if (executor != null) { executor.execute(runnable); - } - else { + } else { runnable.run(); } try { latch.await(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ActiveMQAMQPInternalErrorException("Unable to close consumers for queue: " + consumer.getQueue()); } } @@ -277,8 +270,7 @@ public class AMQPSessionCallback implements SessionCallback { recoverContext(); try { serverSession.close(false); - } - finally { + } finally { resetContext(); } } @@ -291,8 +283,7 @@ public class AMQPSessionCallback implements SessionCallback { recoverContext(); try { ((ServerConsumer) brokerConsumer).individualAcknowledge(transaction, ((ServerMessage) message).getMessageID()); - } - finally { + } finally { resetContext(); } } @@ -301,8 +292,7 @@ public class AMQPSessionCallback implements SessionCallback { recoverContext(); try { ((ServerConsumer) brokerConsumer).individualCancel(((ServerMessage) message).getMessageID(), updateCounts); - } - finally { + } finally { resetContext(); } } @@ -336,12 +326,10 @@ public class AMQPSessionCallback implements SessionCallback { ActiveMQException e = new ActiveMQAMQPResourceLimitExceededException("Address is full: " + amqpAddress); transaction.markAsRollbackOnly(e); } - } - else { + } else { rejectMessage(delivery); } - } - else { + } else { serverSend(transaction, message, delivery, receiver); } } @@ -355,7 +343,10 @@ public class AMQPSessionCallback implements SessionCallback { connection.flush(); } - private void serverSend(final Transaction transaction, final ServerMessage message, final Delivery delivery, final Receiver receiver) throws Exception { + private void serverSend(final Transaction transaction, + final ServerMessage message, + final Delivery delivery, + final Receiver receiver) throws Exception { try { message.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME.toString(), receiver.getSession().getConnection().getRemoteContainer()); @@ -380,8 +371,7 @@ public class AMQPSessionCallback implements SessionCallback { } } }); - } - finally { + } finally { resetContext(); } } @@ -390,7 +380,10 @@ public class AMQPSessionCallback implements SessionCallback { return manager.getPubSubPrefix(); } - public void offerProducerCredit(final String address, final int credits, final int threshold, final Receiver receiver) { + public void offerProducerCredit(final String address, + final int credits, + final int threshold, + final Receiver receiver) { try { final PagingStore store = manager.getServer().getPagingManager().getPageStore(new SimpleString(address)); store.checkMemory(new Runnable() { @@ -402,8 +395,7 @@ public class AMQPSessionCallback implements SessionCallback { } } }); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } @@ -442,8 +434,7 @@ public class AMQPSessionCallback implements SessionCallback { try { return plugSender.deliverMessage(message, deliveryCount); - } - catch (Exception e) { + } catch (Exception e) { synchronized (connection.getLock()) { plugSender.getSender().setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, e.getMessage())); connection.flush(); @@ -454,7 +445,11 @@ public class AMQPSessionCallback implements SessionCallback { } @Override - public int sendLargeMessage(MessageReference ref, ServerMessage message, ServerConsumer consumer, long bodySize, int deliveryCount) { + public int sendLargeMessage(MessageReference ref, + ServerMessage message, + ServerConsumer consumer, + long bodySize, + int deliveryCount) { return 0; } @@ -484,8 +479,7 @@ public class AMQPSessionCallback implements SessionCallback { if (plugSender != null && plugSender.getSender().getCredit() > 0) { return true; - } - else { + } else { return false; } } @@ -498,7 +492,6 @@ public class AMQPSessionCallback implements SessionCallback { return protonSPI.newTransaction(); } - public void commitTX(Binary txid) throws Exception { Transaction tx = protonSPI.getTransaction(txid); tx.commit(true); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java index 8fd3169..7f129a1 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ActiveMQProtonRemotingConnection.java @@ -22,9 +22,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; import org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection; import org.apache.activemq.artemis.spi.core.remoting.Connection; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; /** * This is a Server's Connection representation used by ActiveMQ Artemis. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java index fe7b976..f5b6c78 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManager.java @@ -25,13 +25,14 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.BaseInterceptor; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConstants; -import org.apache.activemq.artemis.protocol.amqp.converter.ProtonMessageConverter; import org.apache.activemq.artemis.core.remoting.impl.netty.NettyServerConnection; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.management.Notification; import org.apache.activemq.artemis.core.server.management.NotificationListener; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.protocol.amqp.converter.ProtonMessageConverter; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; +import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConstants; import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry; import org.apache.activemq.artemis.spi.core.protocol.MessageConverter; import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager; @@ -39,7 +40,6 @@ import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.remoting.Acceptor; import org.apache.activemq.artemis.spi.core.remoting.Connection; -import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext; /** * A proton protocol manager, basically reads the Proton Input and maps proton resources to ActiveMQ Artemis resources @@ -108,8 +108,7 @@ public class ProtonProtocolManager implements ProtocolManager<Interceptor>, Noti } String id = server.getConfiguration().getName(); - AMQPConnectionContext amqpConnection = - new AMQPConnectionContext(connectionCallback, id, (int) ttl, getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, server.getExecutorFactory().getExecutor(), server.getScheduledPool()); + AMQPConnectionContext amqpConnection = new AMQPConnectionContext(connectionCallback, id, (int) ttl, getMaxFrameSize(), AMQPConstants.Connection.DEFAULT_CHANNEL_MAX, server.getExecutorFactory().getExecutor(), server.getScheduledPool()); Executor executor = server.getExecutorFactory().getExecutor(); @@ -161,7 +160,6 @@ public class ProtonProtocolManager implements ProtocolManager<Interceptor>, Noti this.pubSubPrefix = pubSubPrefix; } - public int getMaxFrameSize() { return maxFrameSize; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java index 7255ca0..bef8ef0 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/ProtonProtocolManagerFactory.java @@ -16,6 +16,10 @@ */ package org.apache.activemq.artemis.protocol.amqp.broker; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import org.apache.activemq.artemis.api.core.BaseInterceptor; import org.apache.activemq.artemis.api.core.Interceptor; import org.apache.activemq.artemis.core.server.ActiveMQServer; @@ -25,10 +29,6 @@ import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory; import org.apache.activemq.artemis.utils.uri.BeanSupport; import org.osgi.service.component.annotations.Component; -import java.util.Collections; -import java.util.List; -import java.util.Map; - @Component(service = ProtocolManagerFactory.class) public class ProtonProtocolManagerFactory extends AbstractProtocolManagerFactory<Interceptor> { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java index 7e3ba67..0b28660 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ActiveMQJMSVendor.java @@ -26,17 +26,17 @@ import javax.jms.StreamMessage; import javax.jms.TextMessage; import org.apache.activemq.artemis.core.buffers.impl.ResetLimitWrappedActiveMQBuffer; +import org.apache.activemq.artemis.core.server.ServerMessage; +import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerDestination; -import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage; -import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSVendor; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage; +import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage; -import org.apache.activemq.artemis.core.server.ServerMessage; -import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSVendor; import org.apache.activemq.artemis.utils.IDGenerator; public class ActiveMQJMSVendor implements JMSVendor { @@ -90,8 +90,7 @@ public class ActiveMQJMSVendor implements JMSVendor { public void setJMSXGroupID(Message message, String s) { try { message.setStringProperty("_AMQ_GROUP_ID", s); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -100,8 +99,7 @@ public class ActiveMQJMSVendor implements JMSVendor { public void setJMSXGroupSequence(Message message, int i) { try { message.setIntProperty("JMSXGroupSeq", i); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } @@ -110,8 +108,7 @@ public class ActiveMQJMSVendor implements JMSVendor { public void setJMSXDeliveryCount(Message message, long l) { try { message.setLongProperty("JMSXDeliveryCount", l); - } - catch (JMSException e) { + } catch (JMSException e) { throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java index f520387..6eb78d0 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/ProtonMessageConverter.java @@ -16,20 +16,20 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter; +import javax.jms.BytesMessage; +import java.io.IOException; + import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; +import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage; import org.apache.activemq.artemis.protocol.amqp.converter.message.AMQPNativeOutboundTransformer; import org.apache.activemq.artemis.protocol.amqp.converter.message.EncodedMessage; import org.apache.activemq.artemis.protocol.amqp.converter.message.InboundTransformer; import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSMappingInboundTransformer; import org.apache.activemq.artemis.protocol.amqp.converter.message.JMSMappingOutboundTransformer; -import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.spi.core.protocol.MessageConverter; import org.apache.activemq.artemis.utils.IDGenerator; -import javax.jms.BytesMessage; -import java.io.IOException; - public class ProtonMessageConverter implements MessageConverter { ActiveMQJMSVendor activeMQJMSVendor; @@ -58,7 +58,7 @@ public class ProtonMessageConverter implements MessageConverter { * * @param messageSource * @return - * @throws Exception https://issues.jboss.org/browse/ENTMQ-1560 + * @throws Exception https://issues.jboss.org/browse/ENTMQ-1560 */ public ServerJMSMessage inboundJMSType(EncodedMessage messageSource) throws Exception { EncodedMessage encodedMessageSource = messageSource; @@ -70,8 +70,7 @@ public class ProtonMessageConverter implements MessageConverter { try { transformedMessage = (ServerJMSMessage) transformer.transform(encodedMessageSource); break; - } - catch (Exception e) { + } catch (Exception e) { ActiveMQClientLogger.LOGGER.debug("Transform of message using [{}] transformer, failed" + inboundTransformer.getTransformerName()); ActiveMQClientLogger.LOGGER.trace("Transformation error:", e); @@ -97,12 +96,10 @@ public class ProtonMessageConverter implements MessageConverter { if (jmsMessage.getBooleanProperty(prefixVendor + "NATIVE")) { if (jmsMessage instanceof BytesMessage) { return AMQPNativeOutboundTransformer.transform(outboundTransformer, (BytesMessage) jmsMessage); - } - else { + } else { return null; } - } - else { + } else { return outboundTransformer.convert(jmsMessage); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java index 967ba08..8e82b89 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerDestination.java @@ -16,16 +16,17 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.jms; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; - import javax.jms.JMSException; import javax.jms.Queue; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; + /** * This is just here to avoid all the client checks we need with valid JMS destinations, protocol convertors don't need to * adhere to the jms. semantics. */ public class ServerDestination extends ActiveMQDestination implements Queue { + public ServerDestination(String name) { super(name, name, false, false, null); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java index 548deb3..0268065 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMapMessage.java @@ -123,8 +123,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe public void setObject(final String name, final Object value) throws JMSException { try { TypedProperties.setObjectProperty(new SimpleString(name), value, map); - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -133,8 +132,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -143,8 +141,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -153,8 +150,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -163,8 +159,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -173,8 +168,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -183,8 +177,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -193,8 +186,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -203,8 +195,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } @@ -215,12 +206,10 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe SimpleString str = map.getSimpleStringProperty(new SimpleString(name)); if (str == null) { return null; - } - else { + } else { return str.toString(); } - } - catch (ActiveMQPropertyConversionException e) { + } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } } @@ -229,8 +218,7 @@ public final class ServerJMSMapMessage extends ServerJMSMessage implements MapMe 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()); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java index d15d22b..a6eac1d 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSMessage.java @@ -49,7 +49,9 @@ public class ServerJMSMessage implements Message { private ActiveMQBuffer readBodyBuffer; - /** When reading we use a protected copy so multi-threads can work fine */ + /** + * When reading we use a protected copy so multi-threads can work fine + */ protected ActiveMQBuffer getReadBodyBuffer() { if (readBodyBuffer == null) { // to avoid clashes between multiple threads @@ -58,13 +60,14 @@ public class ServerJMSMessage implements Message { return readBodyBuffer; } - /** When writing on the conversion we use the buffer directly */ + /** + * When writing on the conversion we use the buffer directly + */ protected ActiveMQBuffer getWriteBodyBuffer() { readBodyBuffer = null; // it invalidates this buffer if anything is written return message.getBodyBuffer(); } - @Override public final String getJMSMessageID() throws JMSException { if (message.containsProperty(NATIVE_MESSAGE_ID)) { @@ -99,8 +102,7 @@ public class ServerJMSMessage implements Message { public final void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException { try { MessageUtil.setJMSCorrelationIDAsBytes(message, correlationID); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new JMSException(e.getMessage()); } } @@ -120,8 +122,7 @@ public class ServerJMSMessage implements Message { SimpleString reply = MessageUtil.getJMSReplyTo(message); if (reply != null) { return new ServerDestination(reply.toString()); - } - else { + } else { return null; } } @@ -138,8 +139,7 @@ public class ServerJMSMessage implements Message { if (sdest == null) { return null; - } - else { + } else { return new ServerDestination(sdest.toString()); } } @@ -148,8 +148,7 @@ public class ServerJMSMessage implements Message { public final void setJMSDestination(Destination destination) throws JMSException { if (destination == null) { message.setAddress(null); - } - else { + } else { message.setAddress(((ActiveMQDestination) destination).getSimpleAddress()); } @@ -164,11 +163,9 @@ public class ServerJMSMessage implements Message { public final void setJMSDeliveryMode(int deliveryMode) throws JMSException { if (deliveryMode == DeliveryMode.PERSISTENT) { message.setDurable(true); - } - else if (deliveryMode == DeliveryMode.NON_PERSISTENT) { + } else if (deliveryMode == DeliveryMode.NON_PERSISTENT) { message.setDurable(false); - } - else { + } else { throw new JMSException("Invalid mode " + deliveryMode); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java index c8fb003..349934b 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSObjectMessage.java @@ -16,10 +16,6 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.jms; -import org.apache.activemq.artemis.api.core.Message; -import org.apache.activemq.artemis.core.message.impl.MessageInternal; -import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; - import javax.jms.JMSException; import javax.jms.ObjectMessage; import java.io.ByteArrayInputStream; @@ -27,17 +23,21 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; +import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.core.message.impl.MessageInternal; +import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; + +public class ServerJMSObjectMessage extends ServerJMSMessage implements ObjectMessage { -public class ServerJMSObjectMessage extends ServerJMSMessage implements ObjectMessage { private static final String DEFAULT_WHITELIST; private static final String DEFAULT_BLACKLIST; static { - DEFAULT_WHITELIST = System.getProperty(ObjectInputStreamWithClassLoader.WHITELIST_PROPERTY, - "java.lang,java.math,javax.security,java.util,org.apache.activemq,org.apache.qpid.proton.amqp"); + DEFAULT_WHITELIST = System.getProperty(ObjectInputStreamWithClassLoader.WHITELIST_PROPERTY, "java.lang,java.math,javax.security,java.util,org.apache.activemq,org.apache.qpid.proton.amqp"); DEFAULT_BLACKLIST = System.getProperty(ObjectInputStreamWithClassLoader.BLACKLIST_PROPERTY, null); } + public static final byte TYPE = Message.STREAM_TYPE; private Serializable object; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java index c63b701..a53fc0e 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSStreamMessage.java @@ -55,11 +55,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadBoolean(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -68,11 +66,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St public byte readByte() throws JMSException { try { return streamReadByte(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -82,11 +78,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadShort(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -96,11 +90,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadChar(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -110,11 +102,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadInteger(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -124,11 +114,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadLong(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -138,11 +126,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadFloat(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -152,11 +138,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadDouble(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -166,11 +150,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St try { return streamReadString(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -188,11 +170,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St len = pairRead.getA(); return pairRead.getB(); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -205,11 +185,9 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St } try { return streamReadObject(getReadBodyBuffer()); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { throw new MessageFormatException(e.getMessage()); - } - catch (IndexOutOfBoundsException e) { + } catch (IndexOutOfBoundsException e) { throw new MessageEOFException(""); } } @@ -297,38 +275,27 @@ public final class ServerJMSStreamMessage extends ServerJMSMessage implements St public void writeObject(final Object value) throws JMSException { if (value instanceof String) { writeString((String) value); - } - else if (value instanceof Boolean) { + } else if (value instanceof Boolean) { writeBoolean((Boolean) value); - } - else if (value instanceof Byte) { + } else if (value instanceof Byte) { writeByte((Byte) value); - } - else if (value instanceof Short) { + } else if (value instanceof Short) { writeShort((Short) value); - } - else if (value instanceof Integer) { + } else if (value instanceof Integer) { writeInt((Integer) value); - } - else if (value instanceof Long) { + } else if (value instanceof Long) { writeLong((Long) value); - } - else if (value instanceof Float) { + } else if (value instanceof Float) { writeFloat((Float) value); - } - else if (value instanceof Double) { + } else if (value instanceof Double) { writeDouble((Double) value); - } - else if (value instanceof byte[]) { + } else if (value instanceof byte[]) { writeBytes((byte[]) value); - } - else if (value instanceof Character) { + } else if (value instanceof Character) { writeChar((Character) value); - } - else if (value == null) { + } else if (value == null) { writeString(null); - } - else { + } else { throw new MessageFormatException("Invalid object type: " + value.getClass()); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java index 5178dc2..eb88de0 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/jms/ServerJMSTextMessage.java @@ -59,8 +59,7 @@ public class ServerJMSTextMessage extends ServerJMSMessage implements TextMessag public void setText(final String text) throws JMSException { if (text != null) { this.text = new SimpleString(text); - } - else { + } else { this.text = null; } @@ -71,8 +70,7 @@ public class ServerJMSTextMessage extends ServerJMSMessage implements TextMessag public String getText() { if (text != null) { return text.toString(); - } - else { + } else { return null; } } @@ -96,4 +94,4 @@ public class ServerJMSTextMessage extends ServerJMSMessage implements TextMessag text = readBodyText(getReadBodyBuffer()); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java index 9e172fa..dc7891c 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageIdHelper.java @@ -20,13 +20,13 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.message; +import java.nio.ByteBuffer; +import java.util.UUID; + import org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPIllegalStateException; import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.UnsignedLong; -import java.nio.ByteBuffer; -import java.util.UUID; - /** * Helper class for identifying and converting message-id and correlation-id values between * the AMQP types and the Strings values used by JMS. @@ -73,8 +73,7 @@ public class AMQPMessageIdHelper { public String toBaseMessageIdString(Object messageId) { if (messageId == null) { return null; - } - else if (messageId instanceof String) { + } else if (messageId instanceof String) { String stringId = (String) messageId; // If the given string has a type encoding prefix, @@ -82,18 +81,14 @@ public class AMQPMessageIdHelper { // the existing encoding prefix was also for string) if (hasTypeEncodingPrefix(stringId)) { return AMQP_STRING_PREFIX + stringId; - } - else { + } else { return stringId; } - } - else if (messageId instanceof UUID) { + } else if (messageId instanceof UUID) { return AMQP_UUID_PREFIX + messageId.toString(); - } - else if (messageId instanceof UnsignedLong) { + } else if (messageId instanceof UnsignedLong) { return AMQP_ULONG_PREFIX + messageId.toString(); - } - else if (messageId instanceof Binary) { + } else if (messageId instanceof Binary) { ByteBuffer dup = ((Binary) messageId).asByteBuffer(); byte[] bytes = new byte[dup.remaining()]; @@ -102,8 +97,7 @@ public class AMQPMessageIdHelper { String hex = convertBinaryToHexString(bytes); return AMQP_BINARY_PREFIX + hex; - } - else { + } else { throw new IllegalArgumentException("Unsupported type provided: " + messageId.getClass()); } } @@ -125,25 +119,20 @@ public class AMQPMessageIdHelper { if (hasAmqpUuidPrefix(baseId)) { String uuidString = strip(baseId, AMQP_UUID_PREFIX_LENGTH); return UUID.fromString(uuidString); - } - else if (hasAmqpUlongPrefix(baseId)) { + } else if (hasAmqpUlongPrefix(baseId)) { String longString = strip(baseId, AMQP_ULONG_PREFIX_LENGTH); return UnsignedLong.valueOf(longString); - } - else if (hasAmqpStringPrefix(baseId)) { + } else if (hasAmqpStringPrefix(baseId)) { return strip(baseId, AMQP_STRING_PREFIX_LENGTH); - } - else if (hasAmqpBinaryPrefix(baseId)) { + } else if (hasAmqpBinaryPrefix(baseId)) { String hexString = strip(baseId, AMQP_BINARY_PREFIX_LENGTH); byte[] bytes = convertHexStringToBinary(hexString); return new Binary(bytes); - } - else { + } else { // We have a string without any type prefix, transmit it as-is. return baseId; } - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { throw new ActiveMQAMQPIllegalStateException("Unable to convert ID value"); } } @@ -213,7 +202,7 @@ public class AMQPMessageIdHelper { private boolean hasTypeEncodingPrefix(String stringId) { return hasAmqpBinaryPrefix(stringId) || hasAmqpUuidPrefix(stringId) || - hasAmqpUlongPrefix(stringId) || hasAmqpStringPrefix(stringId); + hasAmqpUlongPrefix(stringId) || hasAmqpStringPrefix(stringId); } private boolean hasAmqpStringPrefix(String stringId) { @@ -240,13 +229,11 @@ public class AMQPMessageIdHelper { if (ch >= '0' && ch <= '9') { // subtract '0' to get difference in position as an int return ch - '0'; - } - else if (ch >= 'A' && ch <= 'F') { + } else if (ch >= 'A' && ch <= 'F') { // subtract 'A' to get difference in position as an int // and then add 10 for the offset of 'A' return ch - 'A' + 10; - } - else if (ch >= 'a' && ch <= 'f') { + } else if (ch >= 'a' && ch <= 'f') { // subtract 'a' to get difference in position as an int // and then add 10 for the offset of 'a' return ch - 'a' + 10; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java index 613de6d..9b0635a 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPMessageTypes.java @@ -17,6 +17,7 @@ package org.apache.activemq.artemis.protocol.amqp.converter.message; public class AMQPMessageTypes { + public static final String AMQP_TYPE_KEY = "amqp:type"; public static final String AMQP_SEQUENCE = "amqp:sequence"; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java index 67175ab..ac18a94 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/converter/message/AMQPNativeOutboundTransformer.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.protocol.amqp.converter.message; +import javax.jms.BytesMessage; +import javax.jms.JMSException; + import org.apache.qpid.proton.amqp.UnsignedInteger; import org.apache.qpid.proton.amqp.messaging.Header; import org.apache.qpid.proton.message.ProtonJMessage; -import javax.jms.BytesMessage; -import javax.jms.JMSException; - public class AMQPNativeOutboundTransformer extends OutboundTransformer { public AMQPNativeOutboundTransformer(JMSVendor vendor) {
