Skip to content

Commit

Permalink
Merge pull request #1261 from andytaylor/master
Browse files Browse the repository at this point in the history
replace ProtocolType with String
  • Loading branch information
clebertsuconic committed Sep 6, 2013
2 parents a319f7c + 14993e5 commit 387a36f
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public final class HornetQClient

public static final boolean DEFAULT_HA = false;

public static final String DEFAULT_CORE_PROTOCOL = "CORE";

/**
* Create a ServerLocator which creates session factories using a static list of transportConfigurations, the ServerLocator is not updated automatically
* as the cluster topology changes, and no HA backup information is propagated to the client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.hornetq.core.remoting.FailureListener;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.version.Version;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.spi.core.remoting.BufferHandler;
import org.hornetq.spi.core.remoting.Connection;
import org.hornetq.spi.core.remoting.ConnectionLifeCycleListener;
Expand Down Expand Up @@ -411,7 +410,7 @@ public ClientSession createSession(final boolean xa,

// ConnectionLifeCycleListener implementation --------------------------------------------------

public void connectionCreated(final HornetQComponent component, final Connection connection, final ProtocolType protocol)
public void connectionCreated(final HornetQComponent component, final Connection connection, final String protocol)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@

import org.hornetq.api.config.HornetQDefaultConfiguration;
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.core.remoting.impl.ssl.SSLSupport;
import org.hornetq.core.client.HornetQClientLogger;
import org.hornetq.core.client.HornetQClientMessageBundle;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.spi.core.remoting.AbstractConnector;
import org.hornetq.spi.core.remoting.BufferHandler;
import org.hornetq.spi.core.remoting.Connection;
import org.hornetq.spi.core.remoting.ConnectionLifeCycleListener;
import org.hornetq.utils.ConfigurationHelper;
import org.hornetq.utils.FutureLatch;
import org.hornetq.utils.VersionLoader;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
Expand Down Expand Up @@ -684,7 +683,7 @@ public Connection createConnection()
// No acceptor on a client connection
Listener connectionListener = new Listener();
NettyConnection conn = new NettyConnection(configuration, ch, connectionListener, !httpEnabled && batchDelay > 0, false);
connectionListener.connectionCreated(null, conn, ProtocolType.CORE);
connectionListener.connectionCreated(null, conn, HornetQClient.DEFAULT_CORE_PROTOCOL);

return conn;
}
Expand Down Expand Up @@ -880,7 +879,7 @@ public void close()

private class Listener implements ConnectionLifeCycleListener
{
public void connectionCreated(final HornetQComponent component, final Connection connection, final ProtocolType protocol)
public void connectionCreated(final HornetQComponent component, final Connection connection, final String protocol)
{
if (connections.putIfAbsent(connection.getID(), connection) != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.Set;

import org.hornetq.api.config.HornetQDefaultConfiguration;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.api.core.client.HornetQClient;

/**
* A TransportConstants
Expand Down Expand Up @@ -113,7 +113,7 @@ public class TransportConstants

public static final boolean DEFAULT_USE_SERVLET = false;

public static final String DEFAULT_PROTOCOL = ProtocolType.CORE.toString();
public static final String DEFAULT_PROTOCOL = HornetQClient.DEFAULT_CORE_PROTOCOL;

public static final String DEFAULT_HOST = "localhost";

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import org.hornetq.api.core.HornetQException;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.spi.core.protocol.ProtocolType;

/**
* A ConnectionLifeCycleListener is called by the remoting implementation to notify of connection events.
Expand All @@ -37,7 +36,7 @@ public interface ConnectionLifeCycleListener
* @param connection the connection that has been created
* @param protocol the messaging protocol type this connection uses
*/
void connectionCreated(HornetQComponent component, Connection connection, ProtocolType protocol);
void connectionCreated(HornetQComponent component, Connection connection, String protocol);

/**
* Called when a connection is destroyed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
*/
public class StompProtocolManagerFactory implements ProtocolManagerFactory
{
final static String STOMP_PROTOCOL_NAME = "STOMP";
public final static String STOMP_PROTOCOL_NAME = "STOMP";

final static String STOMP_WS_PROTOCOL_NAME = "STOMP_WS";
public final static String STOMP_WS_PROTOCOL_NAME = "STOMP_WS";

private static String[] SUPPORTED_PROTOCOLS = {STOMP_PROTOCOL_NAME, STOMP_WS_PROTOCOL_NAME};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import java.util.List;

import org.hornetq.api.core.Interceptor;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.spi.core.protocol.ProtocolManager;
import org.hornetq.spi.core.protocol.ProtocolManagerFactory;
import org.hornetq.spi.core.protocol.ProtocolType;

/**
* A CoreProtocolManagerFactory
Expand All @@ -30,9 +30,7 @@
*/
public class CoreProtocolManagerFactory implements ProtocolManagerFactory
{
final static String CORE_PROTOCOL_NAME = "CORE";

private static String[] SUPPORTED_PROTOCOLS = {CORE_PROTOCOL_NAME};
private static String[] SUPPORTED_PROTOCOLS = {HornetQClient.DEFAULT_CORE_PROTOCOL};

public ProtocolManager createProtocolManager(final HornetQServer server, final List<Interceptor> incomingInterceptors, List<Interceptor> outgoingInterceptors)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@

import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.management.NotificationType;
import org.hornetq.core.protocol.core.impl.CoreProtocolManagerFactory;
import org.hornetq.core.security.HornetQPrincipal;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.HornetQMessageBundle;
import org.hornetq.core.server.cluster.ClusterConnection;
import org.hornetq.core.server.management.Notification;
import org.hornetq.core.server.management.NotificationService;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.spi.core.remoting.Acceptor;
import org.hornetq.spi.core.remoting.BufferHandler;
import org.hornetq.spi.core.remoting.Connection;
Expand Down Expand Up @@ -215,7 +216,7 @@ public void connect(final String connectionID,

InVMConnection inVMConnection = new InVMConnection(id, connectionID, remoteHandler, connectionListener, clientExecutor, defaultHornetQPrincipal);

connectionListener.connectionCreated(this, inVMConnection, ProtocolType.CORE);
connectionListener.connectionCreated(this, inVMConnection, HornetQClient.DEFAULT_CORE_PROTOCOL);
}

public void disconnect(final String connectionID)
Expand Down Expand Up @@ -259,7 +260,7 @@ private class Listener implements ConnectionLifeCycleListener
this.connector = connector;
}

public void connectionCreated(final HornetQComponent component, final Connection connection, final ProtocolType protocol)
public void connectionCreated(final HornetQComponent component, final Connection connection, final String protocol)
{
if (connections.putIfAbsent((String)connection.getID(), connection) != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
import java.util.concurrent.Executor;

import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.core.protocol.core.impl.CoreProtocolManagerFactory;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.HornetQServerLogger;
import org.hornetq.core.server.HornetQMessageBundle;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.spi.core.remoting.AbstractConnector;
import org.hornetq.spi.core.remoting.Acceptor;
import org.hornetq.spi.core.remoting.BufferHandler;
Expand Down Expand Up @@ -175,7 +176,7 @@ protected Connection internalCreateConnection(final BufferHandler handler,
{
// No acceptor on a client connection
InVMConnection inVMConnection = new InVMConnection(id, handler, listener, serverExecutor);
listener.connectionCreated(null, inVMConnection, ProtocolType.CORE);
listener.connectionCreated(null, inVMConnection, HornetQClient.DEFAULT_CORE_PROTOCOL);
return inVMConnection;
}

Expand All @@ -189,7 +190,7 @@ public boolean isEquivalent(Map<String, Object> configuration)

private class Listener implements ConnectionLifeCycleListener
{
public void connectionCreated(final HornetQComponent component, final Connection connection, final ProtocolType protocol)
public void connectionCreated(final HornetQComponent component, final Connection connection, final String protocol)
{
if (connections.putIfAbsent((String)connection.getID(), connection) != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

import org.hornetq.api.config.HornetQDefaultConfiguration;
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.HornetQInterruptedException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.management.NotificationType;
import org.hornetq.core.protocol.stomp.WebSocketServerHandler;
import org.hornetq.core.protocol.core.impl.CoreProtocolManagerFactory;
import org.hornetq.core.remoting.impl.ssl.SSLSupport;
import org.hornetq.core.security.HornetQPrincipal;
import org.hornetq.core.server.HornetQComponent;
Expand All @@ -46,15 +46,13 @@
import org.hornetq.core.server.management.Notification;
import org.hornetq.core.server.management.NotificationService;
import org.hornetq.spi.core.protocol.ProtocolManager;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.spi.core.remoting.Acceptor;
import org.hornetq.spi.core.remoting.BufferDecoder;
import org.hornetq.spi.core.remoting.BufferHandler;
import org.hornetq.spi.core.remoting.Connection;
import org.hornetq.spi.core.remoting.ConnectionLifeCycleListener;
import org.hornetq.utils.ConfigurationHelper;
import org.hornetq.utils.TypedProperties;
import org.hornetq.utils.VersionLoader;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
Expand Down Expand Up @@ -674,7 +672,7 @@ public void channelConnected(final ChannelHandlerContext ctx, final ChannelState

NettyConnection nc = new NettyConnection(configuration, e.getChannel(), connectionListener, !httpEnabled && batchDelay > 0, directDeliver);

connectionListener.connectionCreated(NettyAcceptor.this, nc, ProtocolType.CORE);
connectionListener.connectionCreated(NettyAcceptor.this, nc, HornetQClient.DEFAULT_CORE_PROTOCOL);

SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
if (sslHandler != null)
Expand Down Expand Up @@ -703,14 +701,14 @@ public void operationComplete(final ChannelFuture future) throws Exception

private class Listener implements ConnectionLifeCycleListener
{
public void connectionCreated(final HornetQComponent component, final Connection connection, final ProtocolType protocol)
public void connectionCreated(final HornetQComponent component, final Connection connection, final String protocol)
{
if (connections.putIfAbsent(connection.getID(), (NettyConnection)connection) != null)
{
throw HornetQMessageBundle.BUNDLE.connectionExists(connection.getID());
}

listener.connectionCreated(component, connection, ProtocolType.valueOf(NettyAcceptor.this.protocol));
listener.connectionCreated(component, connection, NettyAcceptor.this.protocol);
}

public void connectionDestroyed(final Object connectionID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -55,7 +54,6 @@
import org.hornetq.spi.core.protocol.ConnectionEntry;
import org.hornetq.spi.core.protocol.ProtocolManager;
import org.hornetq.spi.core.protocol.ProtocolManagerFactory;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.spi.core.remoting.Acceptor;
import org.hornetq.spi.core.remoting.AcceptorFactory;
Expand Down Expand Up @@ -241,8 +239,8 @@ public ClassLoader run()
}

String protocol = ConfigurationHelper.getStringProperty(TransportConstants.PROTOCOL_PROP_NAME,
TransportConstants.DEFAULT_PROTOCOL,
info.getParams());
TransportConstants.DEFAULT_PROTOCOL,
info.getParams());

ProtocolManager manager = protocolMap.get(protocol);

Expand Down Expand Up @@ -454,7 +452,7 @@ private ProtocolManager getProtocolManager(String protocol)
return protocolMap.get(protocol);
}

public void connectionCreated(final HornetQComponent component, final Connection connection, final ProtocolType protocol)
public void connectionCreated(final HornetQComponent component, final Connection connection, final String protocol)
{
if (server == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.protocol.core.impl.wireformat.ReplicationSyncFileMessage;
import org.hornetq.core.security.CheckType;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.jboss.logging.Cause;
import org.jboss.logging.Message;
import org.jboss.logging.MessageBundle;
Expand Down Expand Up @@ -261,7 +260,7 @@ public interface HornetQMessageBundle
IllegalArgumentException acceptorNotExists(Integer id);

@Message(id = 119064, value = "Unknown protocol {0}", format = Message.Format.MESSAGE_FORMAT)
IllegalArgumentException unknownProtocol(ProtocolType protocol);
IllegalArgumentException unknownProtocol(String protocol);

@Message(id = 119065, value = "node id is null", format = Message.Format.MESSAGE_FORMAT)
IllegalArgumentException nodeIdNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import org.hornetq.core.server.cluster.impl.ClusterConnectionImpl;
import org.hornetq.core.server.impl.HornetQServerImpl;
import org.hornetq.core.server.impl.ServerSessionImpl;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.utils.FutureLatch;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Cause;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
*/
package org.hornetq.spi.core.remoting;

import org.hornetq.spi.core.protocol.ProtocolType;

/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
* 10/11/12
Expand All @@ -36,5 +34,5 @@ public interface ServerConnectionLifeCycleListener extends ConnectionLifeCycleLi
* @param The acceptor here will be always null on a client connection created event.
* @param connection the connection that has been created
*/
void connectionCreated(Acceptor acceptor, Connection connection, ProtocolType protocol);
void connectionCreated(Acceptor acceptor, Connection connection, String protocol);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@
*/
package org.hornetq.tests.integration.http;
import org.hornetq.core.protocol.core.impl.CoreProtocolManagerFactory;
import org.hornetq.spi.core.protocol.ConnectionEntry;
import org.hornetq.spi.core.protocol.ProtocolManager;
import org.hornetq.spi.core.protocol.RemotingConnection;
import org.hornetq.spi.core.remoting.Acceptor;
import org.hornetq.spi.core.remoting.BufferDecoder;
import org.jboss.netty.channel.ChannelHandler;
import org.junit.Before;
import org.junit.After;

import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand All @@ -41,7 +35,6 @@
import org.hornetq.core.remoting.impl.netty.NettyConnector;
import org.hornetq.core.remoting.impl.netty.TransportConstants;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.spi.core.protocol.ProtocolType;
import org.hornetq.spi.core.remoting.BufferHandler;
import org.hornetq.spi.core.remoting.Connection;
import org.hornetq.spi.core.remoting.ConnectionLifeCycleListener;
Expand Down Expand Up @@ -569,7 +562,7 @@ public DummyConnectionLifeCycleListener(final CountDownLatch connCreatedLatch)
latch = connCreatedLatch;
}

public void connectionCreated(final HornetQComponent component, final Connection connection, final ProtocolType protocol)
public void connectionCreated(final HornetQComponent component, final Connection connection, final String protocol)
{
this.connection = connection;
if (latch != null)
Expand Down

0 comments on commit 387a36f

Please sign in to comment.