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:26 UTC
[27/53] [abbrv] [partial] activemq-artemis git commit: automatic
checkstyle change
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
index 9efd2c1..a6a390e 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
@@ -103,8 +103,8 @@ import org.apache.activemq.artemis.utils.FutureLatch;
import static org.apache.activemq.artemis.utils.Base64.encodeBytes;
-public class NettyConnector extends AbstractConnector
-{
+public class NettyConnector extends AbstractConnector {
+
// Constants -----------------------------------------------------
public static final String JAVAX_KEYSTORE_PATH_PROP_NAME = "javax.net.ssl.keyStore";
public static final String JAVAX_KEYSTORE_PASSWORD_PROP_NAME = "javax.net.ssl.keyStorePassword";
@@ -130,13 +130,12 @@ public class NettyConnector extends AbstractConnector
// Default Configuration
public static final Map<String, Object> DEFAULT_CONFIG;
- static
- {
+ static {
// Disable resource leak detection for performance reasons by default
ResourceLeakDetector.setEnabled(false);
// Set default Configuration
- Map<String, Object> config = new HashMap<String , Object>();
+ Map<String, Object> config = new HashMap<String, Object>();
config.put(TransportConstants.HOST_PROP_NAME, TransportConstants.DEFAULT_HOST);
config.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT);
DEFAULT_CONFIG = Collections.unmodifiableMap(config);
@@ -235,31 +234,26 @@ public class NettyConnector extends AbstractConnector
final ConnectionLifeCycleListener listener,
final Executor closeExecutor,
final Executor threadPool,
- final ScheduledExecutorService scheduledThreadPool)
- {
+ final ScheduledExecutorService scheduledThreadPool) {
this(configuration, handler, listener, closeExecutor, threadPool, scheduledThreadPool, new ActiveMQClientProtocolManager());
}
-
public NettyConnector(final Map<String, Object> configuration,
final BufferHandler handler,
final ConnectionLifeCycleListener listener,
final Executor closeExecutor,
final Executor threadPool,
final ScheduledExecutorService scheduledThreadPool,
- final ClientProtocolManager protocolManager)
- {
+ final ClientProtocolManager protocolManager) {
super(configuration);
this.protocolManager = protocolManager;
- if (listener == null)
- {
+ if (listener == null) {
throw ActiveMQClientMessageBundle.BUNDLE.nullListener();
}
- if (handler == null)
- {
+ if (handler == null) {
throw ActiveMQClientMessageBundle.BUNDLE.nullHandler();
}
@@ -267,102 +261,50 @@ public class NettyConnector extends AbstractConnector
this.handler = handler;
- sslEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.SSL_ENABLED_PROP_NAME,
- TransportConstants.DEFAULT_SSL_ENABLED,
- configuration);
- httpEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_ENABLED_PROP_NAME,
- TransportConstants.DEFAULT_HTTP_ENABLED,
- configuration);
- servletPath = ConfigurationHelper.getStringProperty(TransportConstants.SERVLET_PATH,
- TransportConstants.DEFAULT_SERVLET_PATH,
- configuration);
- if (httpEnabled)
- {
- httpMaxClientIdleTime = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME,
- TransportConstants.DEFAULT_HTTP_CLIENT_IDLE_TIME,
- configuration);
- httpClientIdleScanPeriod = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD,
- TransportConstants.DEFAULT_HTTP_CLIENT_SCAN_PERIOD,
- configuration);
- httpRequiresSessionId = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_REQUIRES_SESSION_ID,
- TransportConstants.DEFAULT_HTTP_REQUIRES_SESSION_ID,
- configuration);
+ sslEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.SSL_ENABLED_PROP_NAME, TransportConstants.DEFAULT_SSL_ENABLED, configuration);
+ httpEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_ENABLED_PROP_NAME, TransportConstants.DEFAULT_HTTP_ENABLED, configuration);
+ servletPath = ConfigurationHelper.getStringProperty(TransportConstants.SERVLET_PATH, TransportConstants.DEFAULT_SERVLET_PATH, configuration);
+ if (httpEnabled) {
+ httpMaxClientIdleTime = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME, TransportConstants.DEFAULT_HTTP_CLIENT_IDLE_TIME, configuration);
+ httpClientIdleScanPeriod = ConfigurationHelper.getLongProperty(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, TransportConstants.DEFAULT_HTTP_CLIENT_SCAN_PERIOD, configuration);
+ httpRequiresSessionId = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_REQUIRES_SESSION_ID, TransportConstants.DEFAULT_HTTP_REQUIRES_SESSION_ID, configuration);
}
- else
- {
+ else {
httpMaxClientIdleTime = 0;
httpClientIdleScanPeriod = -1;
httpRequiresSessionId = false;
}
- httpUpgradeEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME,
- TransportConstants.DEFAULT_HTTP_UPGRADE_ENABLED,
- configuration);
-
- nioRemotingThreads = ConfigurationHelper.getIntProperty(TransportConstants.NIO_REMOTING_THREADS_PROPNAME,
- -1,
- configuration);
-
- useNioGlobalWorkerPool = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME,
- TransportConstants.DEFAULT_USE_NIO_GLOBAL_WORKER_POOL,
- configuration);
-
- useServlet = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_SERVLET_PROP_NAME,
- TransportConstants.DEFAULT_USE_SERVLET,
- configuration);
- host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME,
- TransportConstants.DEFAULT_HOST,
- configuration);
- port = ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME,
- TransportConstants.DEFAULT_PORT,
- configuration);
- localAddress = ConfigurationHelper.getStringProperty(TransportConstants.LOCAL_ADDRESS_PROP_NAME,
- TransportConstants.DEFAULT_LOCAL_ADDRESS,
- configuration);
-
- localPort = ConfigurationHelper.getIntProperty(TransportConstants.LOCAL_PORT_PROP_NAME,
- TransportConstants.DEFAULT_LOCAL_PORT,
- configuration);
- if (sslEnabled)
- {
- keyStoreProvider = ConfigurationHelper.getStringProperty(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME,
- TransportConstants.DEFAULT_KEYSTORE_PROVIDER,
- configuration);
-
- keyStorePath = ConfigurationHelper.getStringProperty(TransportConstants.KEYSTORE_PATH_PROP_NAME,
- TransportConstants.DEFAULT_KEYSTORE_PATH,
- configuration);
-
- keyStorePassword = ConfigurationHelper.getPasswordProperty(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME,
- TransportConstants.DEFAULT_KEYSTORE_PASSWORD,
- configuration,
- ActiveMQDefaultConfiguration.getPropMaskPassword(),
- ActiveMQDefaultConfiguration.getPropMaskPassword());
-
- trustStoreProvider = ConfigurationHelper.getStringProperty(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME,
- TransportConstants.DEFAULT_TRUSTSTORE_PROVIDER,
- configuration);
-
- trustStorePath = ConfigurationHelper.getStringProperty(TransportConstants.TRUSTSTORE_PATH_PROP_NAME,
- TransportConstants.DEFAULT_TRUSTSTORE_PATH,
- configuration);
-
- trustStorePassword = ConfigurationHelper.getPasswordProperty(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME,
- TransportConstants.DEFAULT_TRUSTSTORE_PASSWORD,
- configuration,
- ActiveMQDefaultConfiguration.getPropMaskPassword(),
- ActiveMQDefaultConfiguration.getPropMaskPassword());
-
- enabledCipherSuites = ConfigurationHelper.getStringProperty(TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME,
- TransportConstants.DEFAULT_ENABLED_CIPHER_SUITES,
- configuration);
-
- enabledProtocols = ConfigurationHelper.getStringProperty(TransportConstants.ENABLED_PROTOCOLS_PROP_NAME,
- TransportConstants.DEFAULT_ENABLED_PROTOCOLS,
- configuration);
+ httpUpgradeEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, TransportConstants.DEFAULT_HTTP_UPGRADE_ENABLED, configuration);
+
+ nioRemotingThreads = ConfigurationHelper.getIntProperty(TransportConstants.NIO_REMOTING_THREADS_PROPNAME, -1, configuration);
+
+ useNioGlobalWorkerPool = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_NIO_GLOBAL_WORKER_POOL_PROP_NAME, TransportConstants.DEFAULT_USE_NIO_GLOBAL_WORKER_POOL, configuration);
+
+ useServlet = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_SERVLET_PROP_NAME, TransportConstants.DEFAULT_USE_SERVLET, configuration);
+ host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME, TransportConstants.DEFAULT_HOST, configuration);
+ port = ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT, configuration);
+ localAddress = ConfigurationHelper.getStringProperty(TransportConstants.LOCAL_ADDRESS_PROP_NAME, TransportConstants.DEFAULT_LOCAL_ADDRESS, configuration);
+
+ localPort = ConfigurationHelper.getIntProperty(TransportConstants.LOCAL_PORT_PROP_NAME, TransportConstants.DEFAULT_LOCAL_PORT, configuration);
+ if (sslEnabled) {
+ keyStoreProvider = ConfigurationHelper.getStringProperty(TransportConstants.KEYSTORE_PROVIDER_PROP_NAME, TransportConstants.DEFAULT_KEYSTORE_PROVIDER, configuration);
+
+ keyStorePath = ConfigurationHelper.getStringProperty(TransportConstants.KEYSTORE_PATH_PROP_NAME, TransportConstants.DEFAULT_KEYSTORE_PATH, configuration);
+
+ keyStorePassword = ConfigurationHelper.getPasswordProperty(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, TransportConstants.DEFAULT_KEYSTORE_PASSWORD, configuration, ActiveMQDefaultConfiguration.getPropMaskPassword(), ActiveMQDefaultConfiguration.getPropMaskPassword());
+
+ trustStoreProvider = ConfigurationHelper.getStringProperty(TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME, TransportConstants.DEFAULT_TRUSTSTORE_PROVIDER, configuration);
+
+ trustStorePath = ConfigurationHelper.getStringProperty(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, TransportConstants.DEFAULT_TRUSTSTORE_PATH, configuration);
+
+ trustStorePassword = ConfigurationHelper.getPasswordProperty(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, TransportConstants.DEFAULT_TRUSTSTORE_PASSWORD, configuration, ActiveMQDefaultConfiguration.getPropMaskPassword(), ActiveMQDefaultConfiguration.getPropMaskPassword());
+
+ enabledCipherSuites = ConfigurationHelper.getStringProperty(TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME, TransportConstants.DEFAULT_ENABLED_CIPHER_SUITES, configuration);
+
+ enabledProtocols = ConfigurationHelper.getStringProperty(TransportConstants.ENABLED_PROTOCOLS_PROP_NAME, TransportConstants.DEFAULT_ENABLED_PROTOCOLS, configuration);
}
- else
- {
+ else {
keyStoreProvider = TransportConstants.DEFAULT_KEYSTORE_PROVIDER;
keyStorePath = TransportConstants.DEFAULT_KEYSTORE_PATH;
keyStorePassword = TransportConstants.DEFAULT_KEYSTORE_PASSWORD;
@@ -373,30 +315,19 @@ public class NettyConnector extends AbstractConnector
enabledProtocols = TransportConstants.DEFAULT_ENABLED_PROTOCOLS;
}
- tcpNoDelay = ConfigurationHelper.getBooleanProperty(TransportConstants.TCP_NODELAY_PROPNAME,
- TransportConstants.DEFAULT_TCP_NODELAY,
- configuration);
- tcpSendBufferSize = ConfigurationHelper.getIntProperty(TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME,
- TransportConstants.DEFAULT_TCP_SENDBUFFER_SIZE,
- configuration);
- tcpReceiveBufferSize = ConfigurationHelper.getIntProperty(TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME,
- TransportConstants.DEFAULT_TCP_RECEIVEBUFFER_SIZE,
- configuration);
-
- batchDelay = ConfigurationHelper.getLongProperty(TransportConstants.BATCH_DELAY,
- TransportConstants.DEFAULT_BATCH_DELAY,
- configuration);
-
- connectTimeoutMillis = ConfigurationHelper.getIntProperty(TransportConstants.NETTY_CONNECT_TIMEOUT,
- TransportConstants.DEFAULT_NETTY_CONNECT_TIMEOUT,
- configuration);
+ tcpNoDelay = ConfigurationHelper.getBooleanProperty(TransportConstants.TCP_NODELAY_PROPNAME, TransportConstants.DEFAULT_TCP_NODELAY, configuration);
+ tcpSendBufferSize = ConfigurationHelper.getIntProperty(TransportConstants.TCP_SENDBUFFER_SIZE_PROPNAME, TransportConstants.DEFAULT_TCP_SENDBUFFER_SIZE, configuration);
+ tcpReceiveBufferSize = ConfigurationHelper.getIntProperty(TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME, TransportConstants.DEFAULT_TCP_RECEIVEBUFFER_SIZE, configuration);
+
+ batchDelay = ConfigurationHelper.getLongProperty(TransportConstants.BATCH_DELAY, TransportConstants.DEFAULT_BATCH_DELAY, configuration);
+
+ connectTimeoutMillis = ConfigurationHelper.getIntProperty(TransportConstants.NETTY_CONNECT_TIMEOUT, TransportConstants.DEFAULT_NETTY_CONNECT_TIMEOUT, configuration);
this.closeExecutor = closeExecutor;
this.scheduledThreadPool = scheduledThreadPool;
}
@Override
- public String toString()
- {
+ public String toString() {
return "NettyConnector [host=" + host +
", port=" +
port +
@@ -415,34 +346,27 @@ public class NettyConnector extends AbstractConnector
"]";
}
- public synchronized void start()
- {
- if (channelClazz != null)
- {
+ public synchronized void start() {
+ if (channelClazz != null) {
return;
}
int threadsToUse;
- if (nioRemotingThreads == -1)
- {
+ if (nioRemotingThreads == -1) {
// Default to number of cores * 3
threadsToUse = Runtime.getRuntime().availableProcessors() * 3;
}
- else
- {
+ else {
threadsToUse = this.nioRemotingThreads;
}
-
- if (useNioGlobalWorkerPool)
- {
+ if (useNioGlobalWorkerPool) {
channelClazz = NioSocketChannel.class;
group = SharedNioEventLoopGroup.getInstance(threadsToUse);
}
- else
- {
+ else {
channelClazz = NioSocketChannel.class;
group = new NioEventLoopGroup(threadsToUse);
}
@@ -454,16 +378,13 @@ public class NettyConnector extends AbstractConnector
bootstrap.option(ChannelOption.TCP_NODELAY, tcpNoDelay);
- if (connectTimeoutMillis != -1)
- {
+ if (connectTimeoutMillis != -1) {
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeoutMillis);
}
- if (tcpReceiveBufferSize != -1)
- {
+ if (tcpReceiveBufferSize != -1) {
bootstrap.option(ChannelOption.SO_RCVBUF, tcpReceiveBufferSize);
}
- if (tcpSendBufferSize != -1)
- {
+ if (tcpSendBufferSize != -1) {
bootstrap.option(ChannelOption.SO_SNDBUF, tcpSendBufferSize);
}
bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
@@ -472,88 +393,70 @@ public class NettyConnector extends AbstractConnector
channelGroup = new DefaultChannelGroup("activemq-connector", GlobalEventExecutor.INSTANCE);
final SSLContext context;
- if (sslEnabled)
- {
- try
- {
+ if (sslEnabled) {
+ try {
// HORNETQ-680 - override the server-side config if client-side system properties are set
String realKeyStorePath = keyStorePath;
String realKeyStoreProvider = keyStoreProvider;
String realKeyStorePassword = keyStorePassword;
- if (System.getProperty(JAVAX_KEYSTORE_PATH_PROP_NAME) != null)
- {
+ if (System.getProperty(JAVAX_KEYSTORE_PATH_PROP_NAME) != null) {
realKeyStorePath = System.getProperty(JAVAX_KEYSTORE_PATH_PROP_NAME);
}
- if (System.getProperty(JAVAX_KEYSTORE_PASSWORD_PROP_NAME) != null)
- {
+ if (System.getProperty(JAVAX_KEYSTORE_PASSWORD_PROP_NAME) != null) {
realKeyStorePassword = System.getProperty(JAVAX_KEYSTORE_PASSWORD_PROP_NAME);
}
- if (System.getProperty(ACTIVEMQ_KEYSTORE_PROVIDER_PROP_NAME) != null)
- {
+ if (System.getProperty(ACTIVEMQ_KEYSTORE_PROVIDER_PROP_NAME) != null) {
realKeyStoreProvider = System.getProperty(ACTIVEMQ_KEYSTORE_PROVIDER_PROP_NAME);
}
- if (System.getProperty(ACTIVEMQ_KEYSTORE_PATH_PROP_NAME) != null)
- {
+ if (System.getProperty(ACTIVEMQ_KEYSTORE_PATH_PROP_NAME) != null) {
realKeyStorePath = System.getProperty(ACTIVEMQ_KEYSTORE_PATH_PROP_NAME);
}
- if (System.getProperty(ACTIVEMQ_KEYSTORE_PASSWORD_PROP_NAME) != null)
- {
+ if (System.getProperty(ACTIVEMQ_KEYSTORE_PASSWORD_PROP_NAME) != null) {
realKeyStorePassword = System.getProperty(ACTIVEMQ_KEYSTORE_PASSWORD_PROP_NAME);
}
String realTrustStorePath = trustStorePath;
String realTrustStoreProvider = trustStoreProvider;
String realTrustStorePassword = trustStorePassword;
- if (System.getProperty(JAVAX_TRUSTSTORE_PATH_PROP_NAME) != null)
- {
+ if (System.getProperty(JAVAX_TRUSTSTORE_PATH_PROP_NAME) != null) {
realTrustStorePath = System.getProperty(JAVAX_TRUSTSTORE_PATH_PROP_NAME);
}
- if (System.getProperty(JAVAX_TRUSTSTORE_PASSWORD_PROP_NAME) != null)
- {
+ if (System.getProperty(JAVAX_TRUSTSTORE_PASSWORD_PROP_NAME) != null) {
realTrustStorePassword = System.getProperty(JAVAX_TRUSTSTORE_PASSWORD_PROP_NAME);
}
- if (System.getProperty(ACTIVEMQ_TRUSTSTORE_PROVIDER_PROP_NAME) != null)
- {
+ if (System.getProperty(ACTIVEMQ_TRUSTSTORE_PROVIDER_PROP_NAME) != null) {
realTrustStoreProvider = System.getProperty(ACTIVEMQ_TRUSTSTORE_PROVIDER_PROP_NAME);
}
- if (System.getProperty(ACTIVEMQ_TRUSTSTORE_PATH_PROP_NAME) != null)
- {
+ if (System.getProperty(ACTIVEMQ_TRUSTSTORE_PATH_PROP_NAME) != null) {
realTrustStorePath = System.getProperty(ACTIVEMQ_TRUSTSTORE_PATH_PROP_NAME);
}
- if (System.getProperty(ACTIVEMQ_TRUSTSTORE_PASSWORD_PROP_NAME) != null)
- {
+ if (System.getProperty(ACTIVEMQ_TRUSTSTORE_PASSWORD_PROP_NAME) != null) {
realTrustStorePassword = System.getProperty(ACTIVEMQ_TRUSTSTORE_PASSWORD_PROP_NAME);
}
context = SSLSupport.createContext(realKeyStoreProvider, realKeyStorePath, realKeyStorePassword, realTrustStoreProvider, realTrustStorePath, realTrustStorePassword);
}
- catch (Exception e)
- {
+ catch (Exception e) {
close();
IllegalStateException ise = new IllegalStateException("Unable to create NettyConnector for " + host + ":" + port);
ise.initCause(e);
throw ise;
}
}
- else
- {
+ else {
context = null; // Unused
}
- if (context != null && useServlet)
- {
+ if (context != null && useServlet) {
// TODO: Fix me
//bootstrap.setOption("sslContext", context);
}
- bootstrap.handler(new ChannelInitializer<Channel>()
- {
- public void initChannel(Channel channel) throws Exception
- {
+ bootstrap.handler(new ChannelInitializer<Channel>() {
+ public void initChannel(Channel channel) throws Exception {
final ChannelPipeline pipeline = channel.pipeline();
- if (sslEnabled && !useServlet)
- {
+ if (sslEnabled && !useServlet) {
SSLEngine engine = context.createSSLEngine();
engine.setUseClientMode(true);
@@ -565,33 +468,26 @@ public class NettyConnector extends AbstractConnector
// we can reset the enabled protocols if a customer protocol isn't specified
String[] originalProtocols = engine.getEnabledProtocols();
- if (enabledCipherSuites != null)
- {
- try
- {
+ if (enabledCipherSuites != null) {
+ try {
engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites));
}
- catch (IllegalArgumentException e)
- {
+ catch (IllegalArgumentException e) {
ActiveMQClientLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites()));
throw e;
}
}
- if (enabledProtocols != null)
- {
- try
- {
+ if (enabledProtocols != null) {
+ try {
engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols));
}
- catch (IllegalArgumentException e)
- {
+ catch (IllegalArgumentException e) {
ActiveMQClientLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols()));
throw e;
}
}
- else
- {
+ else {
engine.setEnabledProtocols(originalProtocols);
}
@@ -600,8 +496,7 @@ public class NettyConnector extends AbstractConnector
pipeline.addLast(handler);
}
- if (httpEnabled)
- {
+ if (httpEnabled) {
pipeline.addLast(new HttpRequestEncoder());
pipeline.addLast(new HttpResponseDecoder());
@@ -611,8 +506,7 @@ public class NettyConnector extends AbstractConnector
pipeline.addLast(new HttpHandler());
}
- if (httpUpgradeEnabled)
- {
+ if (httpUpgradeEnabled) {
// prepare to handle a HTTP 101 response to upgrade the protocol.
final HttpClientCodec httpClientCodec = new HttpClientCodec();
pipeline.addLast(httpClientCodec);
@@ -625,8 +519,7 @@ public class NettyConnector extends AbstractConnector
}
});
- if (batchDelay > 0)
- {
+ if (batchDelay > 0) {
flusher = new BatchFlusher();
batchFlusherFuture = scheduledThreadPool.scheduleWithFixedDelay(flusher, batchDelay, batchDelay, TimeUnit.MILLISECONDS);
@@ -635,15 +528,12 @@ public class NettyConnector extends AbstractConnector
ActiveMQClientLogger.LOGGER.debug("Started Netty Connector version " + TransportConstants.NETTY_VERSION);
}
- public synchronized void close()
- {
- if (channelClazz == null)
- {
+ public synchronized void close() {
+ if (channelClazz == null) {
return;
}
- if (batchFlusherFuture != null)
- {
+ if (batchFlusherFuture != null) {
batchFlusherFuture.cancel(false);
flusher.cancel();
@@ -662,40 +552,32 @@ public class NettyConnector extends AbstractConnector
channelClazz = null;
- for (Connection connection : connections.values())
- {
+ for (Connection connection : connections.values()) {
listener.connectionDestroyed(connection.getID());
}
connections.clear();
}
- public boolean isStarted()
- {
+ public boolean isStarted() {
return channelClazz != null;
}
- public Connection createConnection()
- {
- if (channelClazz == null)
- {
+ public Connection createConnection() {
+ if (channelClazz == null) {
return null;
}
// HORNETQ-907 - strip off IPv6 scope-id (if necessary)
SocketAddress remoteDestination = new InetSocketAddress(host, port);
InetAddress inetAddress = ((InetSocketAddress) remoteDestination).getAddress();
- if (inetAddress instanceof Inet6Address)
- {
+ if (inetAddress instanceof Inet6Address) {
Inet6Address inet6Address = (Inet6Address) inetAddress;
- if (inet6Address.getScopeId() != 0)
- {
- try
- {
+ if (inet6Address.getScopeId() != 0) {
+ try {
remoteDestination = new InetSocketAddress(InetAddress.getByAddress(inet6Address.getAddress()), ((InetSocketAddress) remoteDestination).getPort());
}
- catch (UnknownHostException e)
- {
+ catch (UnknownHostException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
@@ -705,61 +587,49 @@ public class NettyConnector extends AbstractConnector
ChannelFuture future;
//port 0 does not work so only use local address if set
- if (localPort != 0)
- {
+ if (localPort != 0) {
SocketAddress localDestination;
- if (localAddress != null)
- {
+ if (localAddress != null) {
localDestination = new InetSocketAddress(localAddress, localPort);
}
- else
- {
+ else {
localDestination = new InetSocketAddress(localPort);
}
future = bootstrap.connect(remoteDestination, localDestination);
}
- else
- {
+ else {
future = bootstrap.connect(remoteDestination);
}
future.awaitUninterruptibly();
- if (future.isSuccess())
- {
+ if (future.isSuccess()) {
final Channel ch = future.channel();
SslHandler sslHandler = ch.pipeline().get(SslHandler.class);
- if (sslHandler != null)
- {
+ if (sslHandler != null) {
Future<Channel> handshakeFuture = sslHandler.handshakeFuture();
- if (handshakeFuture.awaitUninterruptibly(30000))
- {
- if (handshakeFuture.isSuccess())
- {
+ if (handshakeFuture.awaitUninterruptibly(30000)) {
+ if (handshakeFuture.isSuccess()) {
ChannelPipeline channelPipeline = ch.pipeline();
ActiveMQChannelHandler channelHandler = channelPipeline.get(ActiveMQChannelHandler.class);
channelHandler.active = true;
}
- else
- {
+ else {
ch.close().awaitUninterruptibly();
ActiveMQClientLogger.LOGGER.errorCreatingNettyConnection(handshakeFuture.cause());
return null;
}
}
- else
- {
+ else {
//handshakeFuture.setFailure(new SSLException("Handshake was not completed in 30 seconds"));
ch.close().awaitUninterruptibly();
return null;
}
}
- if (httpUpgradeEnabled)
- {
+ if (httpUpgradeEnabled) {
// Send a HTTP GET + Upgrade request that will be handled by the http-upgrade handler.
- try
- {
+ try {
//get this first incase it removes itself
HttpUpgradeHandler httpUpgradeHandler = (HttpUpgradeHandler) ch.pipeline().get("http-upgrade");
URI uri = new URI("http", null, host, port, null, null, null);
@@ -768,11 +638,8 @@ public class NettyConnector extends AbstractConnector
request.headers().set(HttpHeaders.Names.UPGRADE, ACTIVEMQ_REMOTING);
request.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE);
- final String endpoint = ConfigurationHelper.getStringProperty(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME,
- null,
- configuration);
- if (endpoint != null)
- {
+ final String endpoint = ConfigurationHelper.getStringProperty(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, null, configuration);
+ if (endpoint != null) {
request.headers().set(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, endpoint);
}
@@ -787,19 +654,16 @@ public class NettyConnector extends AbstractConnector
// Send the HTTP request.
ch.writeAndFlush(request);
- if (!httpUpgradeHandler.awaitHandshake())
- {
+ if (!httpUpgradeHandler.awaitHandshake()) {
return null;
}
}
- catch (URISyntaxException e)
- {
+ catch (URISyntaxException e) {
ActiveMQClientLogger.LOGGER.errorCreatingNettyConnection(e);
return null;
}
}
- else
- {
+ else {
ChannelPipeline channelPipeline = ch.pipeline();
ActiveMQChannelHandler channelHandler = channelPipeline.get(ActiveMQChannelHandler.class);
channelHandler.active = true;
@@ -811,12 +675,10 @@ public class NettyConnector extends AbstractConnector
connectionListener.connectionCreated(null, conn, protocolManager.getName());
return conn;
}
- else
- {
+ else {
Throwable t = future.cause();
- if (t != null && !(t instanceof ConnectException))
- {
+ if (t != null && !(t instanceof ConnectException)) {
ActiveMQClientLogger.LOGGER.errorCreatingNettyConnection(future.cause());
}
@@ -834,43 +696,36 @@ public class NettyConnector extends AbstractConnector
// Inner classes -------------------------------------------------
- private static final class ActiveMQClientChannelHandler extends ActiveMQChannelHandler
- {
+ private static final class ActiveMQClientChannelHandler extends ActiveMQChannelHandler {
+
ActiveMQClientChannelHandler(final ChannelGroup group,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
- {
+ final ConnectionLifeCycleListener listener) {
super(group, handler, listener);
}
}
- private static class HttpUpgradeHandler extends SimpleChannelInboundHandler<HttpObject>
- {
+ private static class HttpUpgradeHandler extends SimpleChannelInboundHandler<HttpObject> {
+
private final ChannelPipeline pipeline;
private final HttpClientCodec httpClientCodec;
private final CountDownLatch latch = new CountDownLatch(1);
private boolean handshakeComplete = false;
- public HttpUpgradeHandler(ChannelPipeline pipeline, HttpClientCodec httpClientCodec)
- {
+ public HttpUpgradeHandler(ChannelPipeline pipeline, HttpClientCodec httpClientCodec) {
this.pipeline = pipeline;
this.httpClientCodec = httpClientCodec;
}
@Override
- public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception
- {
- if (msg instanceof HttpResponse)
- {
+ public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
+ if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg;
- if (response.getStatus().code() == HttpResponseStatus.SWITCHING_PROTOCOLS.code()
- && response.headers().get(HttpHeaders.Names.UPGRADE).equals(ACTIVEMQ_REMOTING))
- {
+ if (response.getStatus().code() == HttpResponseStatus.SWITCHING_PROTOCOLS.code() && response.headers().get(HttpHeaders.Names.UPGRADE).equals(ACTIVEMQ_REMOTING)) {
String accept = response.headers().get(SEC_ACTIVEMQ_REMOTING_ACCEPT);
String expectedResponse = createExpectedResponse(MAGIC_NUMBER, ctx.channel().attr(REMOTING_KEY).get());
- if (expectedResponse.equals(accept))
- {
+ if (expectedResponse.equals(accept)) {
// remove the http handlers and flag the activemq channel handler as active
pipeline.remove(httpClientCodec);
pipeline.remove(this);
@@ -878,14 +733,12 @@ public class NettyConnector extends AbstractConnector
ActiveMQChannelHandler channelHandler = pipeline.get(ActiveMQChannelHandler.class);
channelHandler.active = true;
}
- else
- {
+ else {
ActiveMQClientLogger.LOGGER.httpHandshakeFailed(accept, expectedResponse);
ctx.close();
}
}
- else if (response.getStatus().code() == HttpResponseStatus.FORBIDDEN.code())
- {
+ else if (response.getStatus().code() == HttpResponseStatus.FORBIDDEN.code()) {
ActiveMQClientLogger.LOGGER.httpUpgradeNotSupportedByRemoteAcceptor();
ctx.close();
}
@@ -894,31 +747,26 @@ public class NettyConnector extends AbstractConnector
}
@Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
- {
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
ActiveMQClientLogger.LOGGER.errorCreatingNettyConnection(cause);
ctx.close();
}
- public boolean awaitHandshake()
- {
- try
- {
- if (!latch.await(30000, TimeUnit.MILLISECONDS))
- {
+ public boolean awaitHandshake() {
+ try {
+ if (!latch.await(30000, TimeUnit.MILLISECONDS)) {
return false;
}
}
- catch (InterruptedException e)
- {
+ catch (InterruptedException e) {
return false;
}
return handshakeComplete;
}
}
- class HttpHandler extends ChannelDuplexHandler
- {
+ class HttpHandler extends ChannelDuplexHandler {
+
private Channel channel;
private long lastSendTime = 0;
@@ -937,32 +785,24 @@ public class NettyConnector extends AbstractConnector
private String cookie;
- public HttpHandler() throws Exception
- {
+ public HttpHandler() throws Exception {
url = new URI("http", null, host, port, servletPath, null, null).toString();
}
@Override
- public void channelActive(final ChannelHandlerContext ctx) throws Exception
- {
+ public void channelActive(final ChannelHandlerContext ctx) throws Exception {
super.channelActive(ctx);
channel = ctx.channel();
- if (httpClientIdleScanPeriod > 0)
- {
+ if (httpClientIdleScanPeriod > 0) {
task = new HttpIdleTimer();
- java.util.concurrent.Future<?> future = scheduledThreadPool.scheduleAtFixedRate(task,
- httpClientIdleScanPeriod,
- httpClientIdleScanPeriod,
- TimeUnit.MILLISECONDS);
+ java.util.concurrent.Future<?> future = scheduledThreadPool.scheduleAtFixedRate(task, httpClientIdleScanPeriod, httpClientIdleScanPeriod, TimeUnit.MILLISECONDS);
task.setFuture(future);
}
}
@Override
- public void channelInactive(final ChannelHandlerContext ctx) throws Exception
- {
- if (task != null)
- {
+ public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
+ if (task != null) {
task.close();
}
@@ -970,16 +810,12 @@ public class NettyConnector extends AbstractConnector
}
@Override
- public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception
- {
+ public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
FullHttpResponse response = (FullHttpResponse) msg;
- if (httpRequiresSessionId && !active)
- {
+ if (httpRequiresSessionId && !active) {
Set<Cookie> cookieMap = CookieDecoder.decode(response.headers().get(HttpHeaders.Names.SET_COOKIE));
- for (Cookie cookie : cookieMap)
- {
- if (cookie.getName().equals("JSESSIONID"))
- {
+ for (Cookie cookie : cookieMap) {
+ if (cookie.getName().equals("JSESSIONID")) {
this.cookie = ClientCookieEncoder.encode(cookie);
}
}
@@ -991,20 +827,14 @@ public class NettyConnector extends AbstractConnector
}
@Override
- public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception
- {
- if (msg instanceof ByteBuf)
- {
- if (httpRequiresSessionId && !active)
- {
- if (handshaking)
- {
+ public void write(final ChannelHandlerContext ctx, final Object msg, ChannelPromise promise) throws Exception {
+ if (msg instanceof ByteBuf) {
+ if (httpRequiresSessionId && !active) {
+ if (handshaking) {
handshaking = true;
}
- else
- {
- if (!handShakeFuture.await(5000))
- {
+ else {
+ if (!handShakeFuture.await(5000)) {
throw new RuntimeException("Handshake failed after timeout");
}
}
@@ -1013,36 +843,31 @@ public class NettyConnector extends AbstractConnector
ByteBuf buf = (ByteBuf) msg;
FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, buf);
httpRequest.headers().add(HttpHeaders.Names.HOST, NettyConnector.this.host);
- if (cookie != null)
- {
+ if (cookie != null) {
httpRequest.headers().add(HttpHeaders.Names.COOKIE, cookie);
}
httpRequest.headers().add(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.readableBytes()));
ctx.write(httpRequest, promise);
lastSendTime = System.currentTimeMillis();
}
- else
- {
+ else {
ctx.write(msg, promise);
lastSendTime = System.currentTimeMillis();
}
}
- private class HttpIdleTimer implements Runnable
- {
+ private class HttpIdleTimer implements Runnable {
+
private boolean closed = false;
private java.util.concurrent.Future<?> future;
- public synchronized void run()
- {
- if (closed)
- {
+ public synchronized void run() {
+ if (closed) {
return;
}
- if (!waitingGet && System.currentTimeMillis() > lastSendTime + httpMaxClientIdleTime)
- {
+ if (!waitingGet && System.currentTimeMillis() > lastSendTime + httpMaxClientIdleTime) {
FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, url);
httpRequest.headers().add(HttpHeaders.Names.HOST, NettyConnector.this.host);
waitingGet = true;
@@ -1050,15 +875,12 @@ public class NettyConnector extends AbstractConnector
}
}
- public synchronized void setFuture(final java.util.concurrent.Future<?> future)
- {
+ public synchronized void setFuture(final java.util.concurrent.Future<?> future) {
this.future = future;
}
- public void close()
- {
- if (future != null)
- {
+ public void close() {
+ if (future != null) {
future.cancel(false);
}
@@ -1067,90 +889,73 @@ public class NettyConnector extends AbstractConnector
}
}
- private class Listener implements ConnectionLifeCycleListener
- {
- public void connectionCreated(final ActiveMQComponent component, final Connection connection, final String protocol)
- {
- if (connections.putIfAbsent(connection.getID(), connection) != null)
- {
+ private class Listener implements ConnectionLifeCycleListener {
+
+ public void connectionCreated(final ActiveMQComponent component,
+ final Connection connection,
+ final String protocol) {
+ if (connections.putIfAbsent(connection.getID(), connection) != null) {
throw ActiveMQClientMessageBundle.BUNDLE.connectionExists(connection.getID());
}
}
- public void connectionDestroyed(final Object connectionID)
- {
- if (connections.remove(connectionID) != null)
- {
+ public void connectionDestroyed(final Object connectionID) {
+ if (connections.remove(connectionID) != null) {
// Execute on different thread to avoid deadlocks
- closeExecutor.execute(new Runnable()
- {
- public void run()
- {
+ closeExecutor.execute(new Runnable() {
+ public void run() {
listener.connectionDestroyed(connectionID);
}
});
}
}
- public void connectionException(final Object connectionID, final ActiveMQException me)
- {
+ public void connectionException(final Object connectionID, final ActiveMQException me) {
// Execute on different thread to avoid deadlocks
- closeExecutor.execute(new Runnable()
- {
- public void run()
- {
+ closeExecutor.execute(new Runnable() {
+ public void run() {
listener.connectionException(connectionID, me);
}
});
}
- public void connectionReadyForWrites(Object connectionID, boolean ready)
- {
+ public void connectionReadyForWrites(Object connectionID, boolean ready) {
}
-
}
- private class BatchFlusher implements Runnable
- {
+ private class BatchFlusher implements Runnable {
+
private boolean cancelled;
- public synchronized void run()
- {
- if (!cancelled)
- {
- for (Connection connection : connections.values())
- {
+ public synchronized void run() {
+ if (!cancelled) {
+ for (Connection connection : connections.values()) {
connection.checkFlushBatchBuffer();
}
}
}
- public synchronized void cancel()
- {
+ public synchronized void cancel() {
cancelled = true;
}
}
- public boolean isEquivalent(Map<String, Object> configuration)
- {
+ public boolean isEquivalent(Map<String, Object> configuration) {
//here we only check host and port because these two parameters
//is sufficient to determine the target host
- String host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME,
- TransportConstants.DEFAULT_HOST,
- configuration);
- Integer port = ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME,
- TransportConstants.DEFAULT_PORT,
- configuration);
+ String host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME, TransportConstants.DEFAULT_HOST, configuration);
+ Integer port = ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT, configuration);
- if (!port.equals(this.port)) return false;
+ if (!port.equals(this.port))
+ return false;
- if (host.equals(this.host)) return true;
+ if (host.equals(this.host))
+ return true;
//The host may be an alias. We need to compare raw IP address.
boolean result = false;
- try
- {
+ try {
InetAddress inetAddr1 = InetAddress.getByName(host);
InetAddress inetAddr2 = InetAddress.getByName(this.host);
String ip1 = inetAddr1.getHostAddress();
@@ -1159,45 +964,37 @@ public class NettyConnector extends AbstractConnector
result = ip1.equals(ip2);
}
- catch (UnknownHostException e)
- {
+ catch (UnknownHostException e) {
ActiveMQClientLogger.LOGGER.error("Cannot resolve host", e);
}
return result;
}
- public void finalize() throws Throwable
- {
+ public void finalize() throws Throwable {
close();
super.finalize();
}
//for test purpose only
- public Bootstrap getBootStrap()
- {
+ public Bootstrap getBootStrap() {
return bootstrap;
}
- public static void clearThreadPools()
- {
+ public static void clearThreadPools() {
SharedNioEventLoopGroup.forceShutdown();
}
- private static ClassLoader getThisClassLoader()
- {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
- {
- public ClassLoader run()
- {
+ private static ClassLoader getThisClassLoader() {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
return ClientSessionFactoryImpl.class.getClassLoader();
}
});
}
- private static String base64(byte[] data)
- {
+ private static String base64(byte[] data) {
ByteBuf encodedData = Unpooled.wrappedBuffer(data);
ByteBuf encoded = Base64.encode(encodedData);
String encodedString = encoded.toString(StandardCharsets.UTF_8);
@@ -1211,27 +1008,22 @@ public class NettyConnector extends AbstractConnector
* @param size the number of random bytes to create
* @return An array of random bytes
*/
- private static byte[] randomBytes(int size)
- {
+ private static byte[] randomBytes(int size) {
byte[] bytes = new byte[size];
- for (int index = 0; index < size; index++)
- {
+ for (int index = 0; index < size; index++) {
bytes[index] = (byte) randomNumber(0, 255);
}
return bytes;
}
- private static int randomNumber(int minimum, int maximum)
- {
+ private static int randomNumber(int minimum, int maximum) {
return (int) (Math.random() * maximum + minimum);
}
- public static String createExpectedResponse(final String magicNumber, final String secretKey) throws IOException
- {
- try
- {
+ public static String createExpectedResponse(final String magicNumber, final String secretKey) throws IOException {
+ try {
final String concat = secretKey + magicNumber;
final MessageDigest digest = MessageDigest.getInstance("SHA1");
@@ -1239,8 +1031,7 @@ public class NettyConnector extends AbstractConnector
final byte[] bytes = digest.digest();
return encodeBytes(bytes);
}
- catch (NoSuchAlgorithmException e)
- {
+ catch (NoSuchAlgorithmException e) {
throw new IOException(e);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnectorFactory.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnectorFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnectorFactory.java
index 5d871d1..99c6a56 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnectorFactory.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnectorFactory.java
@@ -26,28 +26,25 @@ import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener
import org.apache.activemq.artemis.spi.core.remoting.Connector;
import org.apache.activemq.artemis.spi.core.remoting.ConnectorFactory;
-public class NettyConnectorFactory implements ConnectorFactory
-{
+public class NettyConnectorFactory implements ConnectorFactory {
+
public Connector createConnector(final Map<String, Object> configuration,
final BufferHandler handler,
final ConnectionLifeCycleListener listener,
final Executor closeExecutor,
final Executor threadPool,
final ScheduledExecutorService scheduledThreadPool,
- final ClientProtocolManager protocolManager)
- {
+ final ClientProtocolManager protocolManager) {
return new NettyConnector(configuration, handler, listener, closeExecutor, threadPool, scheduledThreadPool);
}
@Override
- public boolean isReliable()
- {
+ public boolean isReliable() {
return false;
}
@Override
- public Map<String, Object> getDefaults()
- {
+ public Map<String, Object> getDefaults() {
return NettyConnector.DEFAULT_CONFIG;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/PartialPooledByteBufAllocator.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/PartialPooledByteBufAllocator.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/PartialPooledByteBufAllocator.java
index 3bfd276..aeede30 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/PartialPooledByteBufAllocator.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/PartialPooledByteBufAllocator.java
@@ -22,133 +22,112 @@ import io.netty.buffer.CompositeByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.UnpooledByteBufAllocator;
-
/**
* A {@link ByteBufAllocator} which is partial pooled. Which means only direct {@link ByteBuf}s are pooled. The rest
* is unpooled.
*/
-public class PartialPooledByteBufAllocator implements ByteBufAllocator
-{
+public class PartialPooledByteBufAllocator implements ByteBufAllocator {
+
private static final ByteBufAllocator POOLED = new PooledByteBufAllocator(false);
private static final ByteBufAllocator UNPOOLED = new UnpooledByteBufAllocator(false);
public static final PartialPooledByteBufAllocator INSTANCE = new PartialPooledByteBufAllocator();
- private PartialPooledByteBufAllocator()
- {
+ private PartialPooledByteBufAllocator() {
}
@Override
- public ByteBuf buffer()
- {
+ public ByteBuf buffer() {
return UNPOOLED.heapBuffer();
}
@Override
- public ByteBuf buffer(int initialCapacity)
- {
+ public ByteBuf buffer(int initialCapacity) {
return UNPOOLED.heapBuffer(initialCapacity);
}
@Override
- public ByteBuf buffer(int initialCapacity, int maxCapacity)
- {
+ public ByteBuf buffer(int initialCapacity, int maxCapacity) {
return UNPOOLED.heapBuffer(initialCapacity, maxCapacity);
}
@Override
- public ByteBuf ioBuffer()
- {
+ public ByteBuf ioBuffer() {
return UNPOOLED.heapBuffer();
}
@Override
- public ByteBuf ioBuffer(int initialCapacity)
- {
+ public ByteBuf ioBuffer(int initialCapacity) {
return UNPOOLED.heapBuffer(initialCapacity);
}
@Override
- public ByteBuf ioBuffer(int initialCapacity, int maxCapacity)
- {
+ public ByteBuf ioBuffer(int initialCapacity, int maxCapacity) {
return UNPOOLED.heapBuffer(initialCapacity, maxCapacity);
}
@Override
- public ByteBuf heapBuffer()
- {
+ public ByteBuf heapBuffer() {
return UNPOOLED.heapBuffer();
}
@Override
- public ByteBuf heapBuffer(int initialCapacity)
- {
+ public ByteBuf heapBuffer(int initialCapacity) {
return UNPOOLED.heapBuffer(initialCapacity);
}
@Override
- public ByteBuf heapBuffer(int initialCapacity, int maxCapacity)
- {
+ public ByteBuf heapBuffer(int initialCapacity, int maxCapacity) {
return UNPOOLED.heapBuffer(initialCapacity, maxCapacity);
}
@Override
- public ByteBuf directBuffer()
- {
+ public ByteBuf directBuffer() {
return POOLED.directBuffer();
}
@Override
- public ByteBuf directBuffer(int initialCapacity)
- {
+ public ByteBuf directBuffer(int initialCapacity) {
return POOLED.directBuffer(initialCapacity);
}
@Override
- public ByteBuf directBuffer(int initialCapacity, int maxCapacity)
- {
+ public ByteBuf directBuffer(int initialCapacity, int maxCapacity) {
return POOLED.directBuffer(initialCapacity, maxCapacity);
}
@Override
- public CompositeByteBuf compositeBuffer()
- {
+ public CompositeByteBuf compositeBuffer() {
return UNPOOLED.compositeHeapBuffer();
}
@Override
- public CompositeByteBuf compositeBuffer(int maxNumComponents)
- {
+ public CompositeByteBuf compositeBuffer(int maxNumComponents) {
return UNPOOLED.compositeHeapBuffer(maxNumComponents);
}
@Override
- public CompositeByteBuf compositeHeapBuffer()
- {
+ public CompositeByteBuf compositeHeapBuffer() {
return UNPOOLED.compositeHeapBuffer();
}
@Override
- public CompositeByteBuf compositeHeapBuffer(int maxNumComponents)
- {
+ public CompositeByteBuf compositeHeapBuffer(int maxNumComponents) {
return UNPOOLED.compositeHeapBuffer(maxNumComponents);
}
@Override
- public CompositeByteBuf compositeDirectBuffer()
- {
+ public CompositeByteBuf compositeDirectBuffer() {
return POOLED.compositeDirectBuffer();
}
@Override
- public CompositeByteBuf compositeDirectBuffer(int maxNumComponents)
- {
+ public CompositeByteBuf compositeDirectBuffer(int maxNumComponents) {
return POOLED.compositeDirectBuffer();
}
@Override
- public boolean isDirectBufferPooled()
- {
+ public boolean isDirectBufferPooled() {
return true;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java
index 2e998fd..c553c37 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedNioEventLoopGroup.java
@@ -32,52 +32,42 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-public class SharedNioEventLoopGroup extends NioEventLoopGroup
-{
+public class SharedNioEventLoopGroup extends NioEventLoopGroup {
+
private static SharedNioEventLoopGroup instance;
private final AtomicReference<ScheduledFuture<?>> shutdown = new AtomicReference<ScheduledFuture<?>>();
private final AtomicLong nioChannelFactoryCount = new AtomicLong();
private final Promise<?> terminationPromise = ImmediateEventExecutor.INSTANCE.newPromise();
- private SharedNioEventLoopGroup(int numThreads, ThreadFactory factory)
- {
+ private SharedNioEventLoopGroup(int numThreads, ThreadFactory factory) {
super(numThreads, factory);
}
- private static ClassLoader getThisClassLoader()
- {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
- {
- public ClassLoader run()
- {
+ private static ClassLoader getThisClassLoader() {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
return ClientSessionFactoryImpl.class.getClassLoader();
}
});
}
- public static synchronized void forceShutdown()
- {
- if (instance != null)
- {
+ public static synchronized void forceShutdown() {
+ if (instance != null) {
instance.shutdown();
instance.nioChannelFactoryCount.set(0);
instance = null;
}
}
- public static synchronized SharedNioEventLoopGroup getInstance(int numThreads)
- {
- if (instance != null)
- {
+ public static synchronized SharedNioEventLoopGroup getInstance(int numThreads) {
+ if (instance != null) {
ScheduledFuture f = instance.shutdown.getAndSet(null);
- if (f != null)
- {
+ if (f != null) {
f.cancel(false);
}
}
- else
- {
+ else {
instance = new SharedNioEventLoopGroup(numThreads, new ActiveMQThreadFactory("ActiveMQ-client-netty-threads", true, getThisClassLoader()));
}
instance.nioChannelFactoryCount.incrementAndGet();
@@ -85,43 +75,31 @@ public class SharedNioEventLoopGroup extends NioEventLoopGroup
}
@Override
- public Future<?> terminationFuture()
- {
+ public Future<?> terminationFuture() {
return terminationPromise;
}
@Override
- public Future<?> shutdownGracefully()
- {
+ public Future<?> shutdownGracefully() {
return shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS);
}
@Override
- public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit)
- {
- if (nioChannelFactoryCount.decrementAndGet() == 0)
- {
- shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable()
- {
+ public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) {
+ if (nioChannelFactoryCount.decrementAndGet() == 0) {
+ shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() {
@Override
- public void run()
- {
- synchronized (SharedNioEventLoopGroup.class)
- {
- if (shutdown.get() != null)
- {
+ public void run() {
+ synchronized (SharedNioEventLoopGroup.class) {
+ if (shutdown.get() != null) {
Future<?> future = SharedNioEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit);
- future.addListener(new FutureListener<Object>()
- {
+ future.addListener(new FutureListener<Object>() {
@Override
- public void operationComplete(Future future) throws Exception
- {
- if (future.isSuccess())
- {
+ public void operationComplete(Future future) throws Exception {
+ if (future.isSuccess()) {
terminationPromise.setSuccess(null);
}
- else
- {
+ else {
terminationPromise.setFailure(future.cause());
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
index 9415339..d82d034 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/TransportConstants.java
@@ -23,8 +23,8 @@ import java.util.Set;
import io.netty.util.Version;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
-public class TransportConstants
-{
+public class TransportConstants {
+
public static final String SSL_ENABLED_PROP_NAME = "sslEnabled";
public static final String HTTP_ENABLED_PROP_NAME = "httpEnabled";
@@ -53,7 +53,9 @@ public class TransportConstants
public static final String USE_INVM_PROP_NAME = "useInvm";
- /** @deprecated use PROTOCOLS_PROP_NAME */
+ /**
+ * @deprecated use PROTOCOLS_PROP_NAME
+ */
@Deprecated
public static final String PROTOCOL_PROP_NAME = "protocol";
@@ -197,8 +199,7 @@ public class TransportConstants
public static final long DEFAULT_CONNECTIONS_ALLOWED = -1L;
- static
- {
+ static {
Set<String> allowableAcceptorKeys = new HashSet<String>();
allowableAcceptorKeys.add(TransportConstants.SSL_ENABLED_PROP_NAME);
allowableAcceptorKeys.add(TransportConstants.HTTP_RESPONSE_TIME_PROP_NAME);
@@ -273,12 +274,10 @@ public class TransportConstants
String version;
Version v = Version.identify().get("netty-transport");
- if (v == null)
- {
+ if (v == null) {
version = "unknown";
}
- else
- {
+ else {
version = v.artifactVersion();
}
NETTY_VERSION = version;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
index 4eb10a2..3593294 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
@@ -40,13 +40,15 @@ import org.apache.activemq.artemis.utils.ClassloadingUtil;
* (see java.security.Security#getProviders()). The main thing to keep in mind is that PKCS#11 keystores will have a
* null keystore path.
*/
-public class SSLSupport
-{
+public class SSLSupport {
// Public --------------------------------------------------------
- public static SSLContext createContext(final String keystoreProvider, final String keystorePath, final String keystorePassword,
- final String trustStoreProvider, final String trustStorePath, final String trustStorePassword) throws Exception
- {
+ public static SSLContext createContext(final String keystoreProvider,
+ final String keystorePath,
+ final String keystorePassword,
+ final String trustStoreProvider,
+ final String trustStorePath,
+ final String trustStorePassword) throws Exception {
SSLContext context = SSLContext.getInstance("TLS");
KeyManager[] keyManagers = SSLSupport.loadKeyManagers(keystoreProvider, keystorePath, keystorePassword);
TrustManager[] trustManagers = SSLSupport.loadTrustManager(trustStoreProvider, trustStorePath, trustStorePassword);
@@ -54,22 +56,18 @@ public class SSLSupport
return context;
}
- public static String[] parseCommaSeparatedListIntoArray(String suites)
- {
+ public static String[] parseCommaSeparatedListIntoArray(String suites) {
String[] cipherSuites = suites.split(",");
- for (int i = 0; i < cipherSuites.length; i++)
- {
+ for (int i = 0; i < cipherSuites.length; i++) {
cipherSuites[i] = cipherSuites[i].trim();
}
return cipherSuites;
}
- public static String parseArrayIntoCommandSeparatedList(String[] suites)
- {
+ public static String parseArrayIntoCommandSeparatedList(String[] suites) {
StringBuilder supportedSuites = new StringBuilder();
- for (int i = 0; i < suites.length; i++)
- {
+ for (int i = 0; i < suites.length; i++) {
supportedSuites.append(suites[i]);
supportedSuites.append(", ");
}
@@ -82,14 +80,11 @@ public class SSLSupport
private static TrustManager[] loadTrustManager(final String trustStoreProvider,
final String trustStorePath,
- final String trustStorePassword) throws Exception
- {
- if (trustStorePath == null && (trustStoreProvider == null || (trustStoreProvider != null && !"PKCS11".equals(trustStoreProvider.toUpperCase()))))
- {
+ final String trustStorePassword) throws Exception {
+ if (trustStorePath == null && (trustStoreProvider == null || (trustStoreProvider != null && !"PKCS11".equals(trustStoreProvider.toUpperCase())))) {
return null;
}
- else
- {
+ else {
TrustManagerFactory trustMgrFactory;
KeyStore trustStore = SSLSupport.loadKeystore(trustStoreProvider, trustStorePath, trustStorePassword);
trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
@@ -98,43 +93,37 @@ public class SSLSupport
}
}
- private static KeyStore loadKeystore(final String keystoreProvider, final String keystorePath, final String keystorePassword) throws Exception
- {
+ private static KeyStore loadKeystore(final String keystoreProvider,
+ final String keystorePath,
+ final String keystorePassword) throws Exception {
KeyStore ks = KeyStore.getInstance(keystoreProvider);
InputStream in = null;
- try
- {
- if (keystorePath != null)
- {
+ try {
+ if (keystorePath != null) {
URL keystoreURL = SSLSupport.validateStoreURL(keystorePath);
in = keystoreURL.openStream();
}
ks.load(in, keystorePassword.toCharArray());
}
- finally
- {
- if (in != null)
- {
- try
- {
+ finally {
+ if (in != null) {
+ try {
in.close();
}
- catch (IOException ignored)
- {
+ catch (IOException ignored) {
}
}
}
return ks;
}
- private static KeyManager[] loadKeyManagers(final String keyStoreProvider, final String keystorePath, final String keystorePassword) throws Exception
- {
- if (keystorePath == null && (keyStoreProvider == null || (keyStoreProvider != null && !"PKCS11".equals(keyStoreProvider.toUpperCase()))))
- {
+ private static KeyManager[] loadKeyManagers(final String keyStoreProvider,
+ final String keystorePath,
+ final String keystorePassword) throws Exception {
+ if (keystorePath == null && (keyStoreProvider == null || (keyStoreProvider != null && !"PKCS11".equals(keyStoreProvider.toUpperCase())))) {
return null;
}
- else
- {
+ else {
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
KeyStore ks = SSLSupport.loadKeystore(keyStoreProvider, keystorePath, keystorePassword);
kmf.init(ks, keystorePassword.toCharArray());
@@ -143,27 +132,21 @@ public class SSLSupport
}
}
- private static URL validateStoreURL(final String storePath) throws Exception
- {
+ private static URL validateStoreURL(final String storePath) throws Exception {
assert storePath != null;
// First see if this is a URL
- try
- {
+ try {
return new URL(storePath);
}
- catch (MalformedURLException e)
- {
+ catch (MalformedURLException e) {
File file = new File(storePath);
- if (file.exists() == true && file.isFile())
- {
+ if (file.exists() == true && file.isFile()) {
return file.toURI().toURL();
}
- else
- {
+ else {
URL url = findResource(storePath);
- if (url != null)
- {
+ if (url != null) {
return url;
}
}
@@ -172,16 +155,14 @@ public class SSLSupport
throw new Exception("Failed to find a store at " + storePath);
}
- /** This seems duplicate code all over the place, but for security reasons we can't let something like this to be open in a
- * utility class, as it would be a door to load anything you like in a safe VM.
- * For that reason any class trying to do a privileged block should do with the AccessController directly.
+ /**
+ * This seems duplicate code all over the place, but for security reasons we can't let something like this to be open in a
+ * utility class, as it would be a door to load anything you like in a safe VM.
+ * For that reason any class trying to do a privileged block should do with the AccessController directly.
*/
- private static URL findResource(final String resourceName)
- {
- return AccessController.doPrivileged(new PrivilegedAction<URL>()
- {
- public URL run()
- {
+ private static URL findResource(final String resourceName) {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
return ClassloadingUtil.findResource(resourceName);
}
});
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/ActiveMQPrincipal.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/ActiveMQPrincipal.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/ActiveMQPrincipal.java
index fc023fe..9be9223 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/ActiveMQPrincipal.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/ActiveMQPrincipal.java
@@ -16,25 +16,22 @@
*/
package org.apache.activemq.artemis.core.security;
-public class ActiveMQPrincipal
-{
+public class ActiveMQPrincipal {
+
private final String userName;
private final String password;
- public ActiveMQPrincipal(String userName, String password)
- {
+ public ActiveMQPrincipal(String userName, String password) {
this.userName = userName;
this.password = password;
}
- public String getUserName()
- {
+ public String getUserName() {
return userName;
}
- public String getPassword()
- {
+ public String getPassword() {
return password;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java
index 7f2cc75..9f98472 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java
@@ -21,8 +21,8 @@ import java.io.Serializable;
/**
* A role is used by the security store to define access rights and is configured on a connection factory or an address.
*/
-public class Role implements Serializable
-{
+public class Role implements Serializable {
+
private static final long serialVersionUID = 3560097227776448872L;
private final String name;
@@ -48,10 +48,8 @@ public class Role implements Serializable
final boolean deleteDurableQueue,
final boolean createNonDurableQueue,
final boolean deleteNonDurableQueue,
- final boolean manage)
- {
- if (name == null)
- {
+ final boolean manage) {
+ if (name == null) {
throw new NullPointerException("name is null");
}
this.name = name;
@@ -64,68 +62,54 @@ public class Role implements Serializable
this.manage = manage;
}
- public String getName()
- {
+ public String getName() {
return name;
}
- public boolean isSend()
- {
+ public boolean isSend() {
return send;
}
- public boolean isConsume()
- {
+ public boolean isConsume() {
return consume;
}
- public boolean isCreateDurableQueue()
- {
+ public boolean isCreateDurableQueue() {
return createDurableQueue;
}
- public boolean isDeleteDurableQueue()
- {
+ public boolean isDeleteDurableQueue() {
return deleteDurableQueue;
}
- public boolean isCreateNonDurableQueue()
- {
+ public boolean isCreateNonDurableQueue() {
return createNonDurableQueue;
}
- public boolean isDeleteNonDurableQueue()
- {
+ public boolean isDeleteNonDurableQueue() {
return deleteNonDurableQueue;
}
@Override
- public String toString()
- {
+ public String toString() {
StringBuffer stringReturn = new StringBuffer("Role {name=" + name + "; allows=[");
- if (send)
- {
+ if (send) {
stringReturn.append(" send ");
}
- if (consume)
- {
+ if (consume) {
stringReturn.append(" consume ");
}
- if (createDurableQueue)
- {
+ if (createDurableQueue) {
stringReturn.append(" createDurableQueue ");
}
- if (deleteDurableQueue)
- {
+ if (deleteDurableQueue) {
stringReturn.append(" deleteDurableQueue ");
}
- if (createNonDurableQueue)
- {
+ if (createNonDurableQueue) {
stringReturn.append(" createNonDurableQueue ");
}
- if (deleteNonDurableQueue)
- {
+ if (deleteNonDurableQueue) {
stringReturn.append(" deleteNonDurableQueue ");
}
@@ -135,45 +119,35 @@ public class Role implements Serializable
}
@Override
- public boolean equals(final Object o)
- {
- if (this == o)
- {
+ public boolean equals(final Object o) {
+ if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass())
- {
+ if (o == null || getClass() != o.getClass()) {
return false;
}
- Role role = (Role)o;
+ Role role = (Role) o;
- if (consume != role.consume)
- {
+ if (consume != role.consume) {
return false;
}
- if (createDurableQueue != role.createDurableQueue)
- {
+ if (createDurableQueue != role.createDurableQueue) {
return false;
}
- if (createNonDurableQueue != role.createNonDurableQueue)
- {
+ if (createNonDurableQueue != role.createNonDurableQueue) {
return false;
}
- if (deleteDurableQueue != role.deleteDurableQueue)
- {
+ if (deleteDurableQueue != role.deleteDurableQueue) {
return false;
}
- if (deleteNonDurableQueue != role.deleteNonDurableQueue)
- {
+ if (deleteNonDurableQueue != role.deleteNonDurableQueue) {
return false;
}
- if (send != role.send)
- {
+ if (send != role.send) {
return false;
}
- if (!name.equals(role.name))
- {
+ if (!name.equals(role.name)) {
return false;
}
@@ -181,8 +155,7 @@ public class Role implements Serializable
}
@Override
- public int hashCode()
- {
+ public int hashCode() {
int result;
result = name.hashCode();
result = 31 * result + (send ? 1 : 0);
@@ -194,8 +167,7 @@ public class Role implements Serializable
return result;
}
- public boolean isManage()
- {
+ public boolean isManage() {
return manage;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/QueueQueryResult.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/QueueQueryResult.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/QueueQueryResult.java
index 341cf5e..f9740de 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/QueueQueryResult.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/QueueQueryResult.java
@@ -18,8 +18,8 @@ package org.apache.activemq.artemis.core.server;
import org.apache.activemq.artemis.api.core.SimpleString;
-public class QueueQueryResult
-{
+public class QueueQueryResult {
+
private SimpleString name;
private boolean exists;
@@ -39,27 +39,25 @@ public class QueueQueryResult
private boolean autoCreateJmsQueues;
public QueueQueryResult(final SimpleString name,
- final SimpleString address,
- final boolean durable,
- final boolean temporary,
- final SimpleString filterString,
- final int consumerCount,
- final long messageCount,
- final boolean autoCreateJmsQueues)
- {
+ final SimpleString address,
+ final boolean durable,
+ final boolean temporary,
+ final SimpleString filterString,
+ final int consumerCount,
+ final long messageCount,
+ final boolean autoCreateJmsQueues) {
this(name, address, durable, temporary, filterString, consumerCount, messageCount, autoCreateJmsQueues, true);
}
public QueueQueryResult(final SimpleString name,
- final SimpleString address,
- final boolean durable,
- final boolean temporary,
- final SimpleString filterString,
- final int consumerCount,
- final long messageCount,
- final boolean autoCreateJmsQueues,
- final boolean exists)
- {
+ final SimpleString address,
+ final boolean durable,
+ final boolean temporary,
+ final SimpleString filterString,
+ final int consumerCount,
+ final long messageCount,
+ final boolean autoCreateJmsQueues,
+ final boolean exists) {
this.durable = durable;
this.temporary = temporary;
@@ -79,48 +77,39 @@ public class QueueQueryResult
this.exists = exists;
}
- public boolean isExists()
- {
+ public boolean isExists() {
return exists;
}
- public boolean isDurable()
- {
+ public boolean isDurable() {
return durable;
}
- public int getConsumerCount()
- {
+ public int getConsumerCount() {
return consumerCount;
}
- public long getMessageCount()
- {
+ public long getMessageCount() {
return messageCount;
}
- public SimpleString getFilterString()
- {
+ public SimpleString getFilterString() {
return filterString;
}
- public SimpleString getAddress()
- {
+ public SimpleString getAddress() {
return address;
}
- public SimpleString getName()
- {
+ public SimpleString getName() {
return name;
}
- public boolean isTemporary()
- {
+ public boolean isTemporary() {
return temporary;
}
- public boolean isAutoCreateJmsQueues()
- {
+ public boolean isAutoCreateJmsQueues() {
return autoCreateJmsQueues;
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/Notification.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/Notification.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/Notification.java
index 5eb9f05..ae1f91d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/Notification.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/Notification.java
@@ -21,42 +21,38 @@ import org.apache.activemq.artemis.utils.TypedProperties;
/**
* A Notification
+ *
* @see org.apache.activemq.artemis.core.server.management.NotificationListener
* @see NotificationType
*/
-public final class Notification
-{
+public final class Notification {
+
private final NotificationType type;
private final TypedProperties properties;
private final String uid;
- public Notification(final String uid, final NotificationType type, final TypedProperties properties)
- {
+ public Notification(final String uid, final NotificationType type, final TypedProperties properties) {
this.uid = uid;
this.type = type;
this.properties = properties;
}
- public NotificationType getType()
- {
+ public NotificationType getType() {
return type;
}
- public TypedProperties getProperties()
- {
+ public TypedProperties getProperties() {
return properties;
}
- public String getUID()
- {
+ public String getUID() {
return uid;
}
@Override
- public String toString()
- {
+ public String toString() {
return "Notification[uid=" + uid + ", type=" + type + ", properties=" + properties + "]";
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bac96047/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/NotificationListener.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/NotificationListener.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/NotificationListener.java
index 18cf4cb..7dabeae 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/NotificationListener.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/server/management/NotificationListener.java
@@ -16,8 +16,7 @@
*/
package org.apache.activemq.artemis.core.server.management;
+public interface NotificationListener {
-public interface NotificationListener
-{
void onNotification(Notification notification);
}