Author: gaohoward
Date: 2010-10-13 11:43:57 -0400 (Wed, 13 Oct 2010)
New Revision: 9784
Added:
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/wireformat/ConnectionSetClientIDMessage.java
Modified:
branches/hornetq-416/.project
branches/hornetq-416/src/main/org/hornetq/api/core/client/ClientSession.java
branches/hornetq-416/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
branches/hornetq-416/src/main/org/hornetq/core/client/impl/DelegatingSession.java
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/ServerSessionPacketHandler.java
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/PacketImpl.java
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/RemotingConnectionImpl.java
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/RemotingService.java
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
branches/hornetq-416/src/main/org/hornetq/core/server/ServerSession.java
branches/hornetq-416/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
branches/hornetq-416/src/main/org/hornetq/jms/client/HornetQConnection.java
branches/hornetq-416/src/main/org/hornetq/spi/core/protocol/RemotingConnection.java
branches/hornetq-416/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
Log:
setClientID
Modified: branches/hornetq-416/.project
===================================================================
--- branches/hornetq-416/.project 2010-10-13 08:54:31 UTC (rev 9783)
+++ branches/hornetq-416/.project 2010-10-13 15:43:57 UTC (rev 9784)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>trunk</name>
+ <name>hornetq416</name>
<comment></comment>
<projects>
</projects>
Modified: branches/hornetq-416/src/main/org/hornetq/api/core/client/ClientSession.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/api/core/client/ClientSession.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/api/core/client/ClientSession.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -562,4 +562,10 @@
*/
void setSendAcknowledgementHandler(SendAcknowledgementHandler handler);
+ /**
+ * Sets ClientID of the associated JMS connection.
+ * @param clientID the client ID
+ */
+ void setClientID(String clientID);
+
}
Modified:
branches/hornetq-416/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/client/impl/ClientSessionImpl.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -39,6 +39,7 @@
import org.hornetq.core.protocol.core.CoreRemotingConnection;
import org.hornetq.core.protocol.core.Packet;
import org.hornetq.core.protocol.core.impl.PacketImpl;
+import org.hornetq.core.protocol.core.impl.wireformat.ConnectionSetClientIDMessage;
import org.hornetq.core.protocol.core.impl.wireformat.CreateQueueMessage;
import org.hornetq.core.protocol.core.impl.wireformat.CreateSessionMessage;
import org.hornetq.core.protocol.core.impl.wireformat.ReattachSessionMessage;
@@ -1810,4 +1811,10 @@
}
}
+
+ public void setClientID(String clientID)
+ {
+ ConnectionSetClientIDMessage msg = new ConnectionSetClientIDMessage(clientID);
+ channel.send(msg);
+ }
}
Modified:
branches/hornetq-416/src/main/org/hornetq/core/client/impl/DelegatingSession.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/client/impl/DelegatingSession.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/client/impl/DelegatingSession.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -555,4 +555,9 @@
{
session.setPacketSize(packetSize);
}
+
+ public void setClientID(String clientID)
+ {
+ session.setClientID(clientID);
+ }
}
Modified:
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/ServerSessionPacketHandler.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/ServerSessionPacketHandler.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/ServerSessionPacketHandler.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -57,6 +57,7 @@
import org.hornetq.core.persistence.OperationContext;
import org.hornetq.core.persistence.StorageManager;
import org.hornetq.core.protocol.core.impl.PacketImpl;
+import org.hornetq.core.protocol.core.impl.wireformat.ConnectionSetClientIDMessage;
import org.hornetq.core.protocol.core.impl.wireformat.CreateQueueMessage;
import org.hornetq.core.protocol.core.impl.wireformat.HornetQExceptionMessage;
import org.hornetq.core.protocol.core.impl.wireformat.NullResponseMessage;
@@ -460,6 +461,11 @@
session.requestProducerCredits(message.getAddress(),
message.getCredits());
break;
}
+ case PacketImpl.CONNECTION_SET_CLIENTID:
+ {
+ ConnectionSetClientIDMessage message =
(ConnectionSetClientIDMessage)packet;
+ session.setConnectionClientID(message.getClientID());
+ }
}
}
catch (HornetQXAException e)
Modified:
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/PacketImpl.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/PacketImpl.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/PacketImpl.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -182,6 +182,8 @@
public static final byte REPLICATION_SYNC = 103;
+ public static final byte CONNECTION_SET_CLIENTID = 104;
+
// Static --------------------------------------------------------
public PacketImpl(final byte type)
Modified:
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/RemotingConnectionImpl.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/RemotingConnectionImpl.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/RemotingConnectionImpl.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -90,6 +90,8 @@
private volatile boolean executing;
private final long creationTime;
+
+ private String clientID;
// Constructors
// ---------------------------------------------------------------------------------
@@ -556,4 +558,9 @@
channel.close();
}
}
+
+ public void setClientID(String cID)
+ {
+ clientID = cID;
+ }
}
Added:
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/wireformat/ConnectionSetClientIDMessage.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/wireformat/ConnectionSetClientIDMessage.java
(rev 0)
+++
branches/hornetq-416/src/main/org/hornetq/core/protocol/core/impl/wireformat/ConnectionSetClientIDMessage.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.protocol.core.impl.wireformat;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.core.protocol.core.impl.PacketImpl;
+
+/**
+ * A ConnectionSetClientIDMessage
+ *
+ *
+ */
+public class ConnectionSetClientIDMessage extends PacketImpl
+{
+ private String clientID;
+
+ public ConnectionSetClientIDMessage(String cID)
+ {
+ super(PacketImpl.CONNECTION_SET_CLIENTID);
+ clientID = cID;
+ }
+
+ @Override
+ public void encodeRest(final HornetQBuffer buffer)
+ {
+ buffer.writeString(clientID);
+ }
+
+ @Override
+ public void decodeRest(final HornetQBuffer buffer)
+ {
+ clientID = buffer.readString();
+ }
+
+ public String getClientID()
+ {
+ return clientID;
+ }
+
+}
Modified:
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/RemotingService.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/RemotingService.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/RemotingService.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -45,4 +45,6 @@
void freeze();
RemotingConnection getServerSideReplicatingConnection();
+
+ void setConnectionClientID(Object connID, String clientID);
}
Modified:
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -570,4 +570,10 @@
}
}
}
+
+ public void setConnectionClientID(Object connID, String clientID)
+ {
+ ConnectionEntry conn = connections.get(connID);
+ conn.connection.setClientID(clientID);
+ }
}
\ No newline at end of file
Modified: branches/hornetq-416/src/main/org/hornetq/core/server/ServerSession.java
===================================================================
--- branches/hornetq-416/src/main/org/hornetq/core/server/ServerSession.java 2010-10-13
08:54:31 UTC (rev 9783)
+++ branches/hornetq-416/src/main/org/hornetq/core/server/ServerSession.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -113,4 +113,6 @@
void setTransferring(boolean transferring);
Set<ServerConsumer> getServerConsumers();
+
+ void setConnectionClientID(String clientID);
}
Modified:
branches/hornetq-416/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -1183,4 +1183,9 @@
routingContext.clear();
}
+ public void setConnectionClientID(String clientID)
+ {
+ this.server.getRemotingService().setConnectionClientID(this.getConnectionID(),
clientID);
+ }
+
}
Modified: branches/hornetq-416/src/main/org/hornetq/jms/client/HornetQConnection.java
===================================================================
--- branches/hornetq-416/src/main/org/hornetq/jms/client/HornetQConnection.java 2010-10-13
08:54:31 UTC (rev 9783)
+++ branches/hornetq-416/src/main/org/hornetq/jms/client/HornetQConnection.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -181,6 +181,7 @@
}
this.clientID = clientID;
+ initialSession.setClientID(clientID);
justCreated = false;
}
Modified:
branches/hornetq-416/src/main/org/hornetq/spi/core/protocol/RemotingConnection.java
===================================================================
---
branches/hornetq-416/src/main/org/hornetq/spi/core/protocol/RemotingConnection.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/src/main/org/hornetq/spi/core/protocol/RemotingConnection.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -165,4 +165,11 @@
*/
void flush();
+ /**
+ * set the connections's clientID
+ *
+ * @param clientID the clientID
+ */
+ void setClientID(String clientID);
+
}
Modified:
branches/hornetq-416/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java
===================================================================
---
branches/hornetq-416/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2010-10-13
08:54:31 UTC (rev 9783)
+++
branches/hornetq-416/tests/jms-tests/src/org/hornetq/jms/tests/message/MessageHeaderTest.java 2010-10-13
15:43:57 UTC (rev 9784)
@@ -1390,6 +1390,15 @@
// TODO Auto-generated method stub
}
+
+ /* (non-Javadoc)
+ * @see org.hornetq.api.core.client.ClientSession#setClientID(java.lang.String)
+ */
+ public void setClientID(String clientID)
+ {
+ // TODO Auto-generated method stub
+
+ }
}
}