Skip to content

Commit 65fcdf1

Browse files
authored
Merge pull request #3 from grgrzybek/AMQ-9359
Amq 9359
2 parents 32abf9b + 76ea6a5 commit 65fcdf1

File tree

4 files changed

+43
-44
lines changed

4 files changed

+43
-44
lines changed

activemq-http/src/main/java/org/apache/activemq/transport/ws/StompWSConnection.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,17 @@
2525

2626
import org.apache.activemq.transport.stomp.StompFrame;
2727
import org.apache.activemq.transport.stomp.StompWireFormat;
28-
import org.eclipse.jetty.ee9.websocket.api.Session;
29-
import org.eclipse.jetty.ee9.websocket.api.WebSocketAdapter;
30-
import org.eclipse.jetty.ee9.websocket.api.WebSocketListener;
28+
import org.eclipse.jetty.websocket.api.Session;
3129
import org.slf4j.Logger;
3230
import org.slf4j.LoggerFactory;
3331

3432
/**
3533
* STOMP over WS based Connection class
3634
*/
37-
public class StompWSConnection extends WebSocketAdapter implements WebSocketListener {
35+
public class StompWSConnection extends org.eclipse.jetty.websocket.api.Session.Listener.AbstractAutoDemanding implements Session.Listener.AutoDemanding {
3836

3937
private static final Logger LOG = LoggerFactory.getLogger(StompWSConnection.class);
4038

41-
private Session connection;
4239
private final CountDownLatch connectLatch = new CountDownLatch(1);
4340

4441
private final BlockingQueue<String> prefetch = new LinkedBlockingDeque<String>();
@@ -47,36 +44,37 @@ public class StompWSConnection extends WebSocketAdapter implements WebSocketList
4744
private int closeCode = -1;
4845
private String closeMessage;
4946

50-
@Override
5147
public boolean isConnected() {
52-
return connection != null ? connection.isOpen() : false;
48+
Session session = getSession();
49+
return session != null && session.isOpen();
5350
}
5451

5552
public void close() {
56-
if (connection != null) {
57-
connection.close();
53+
Session session = getSession();
54+
if (session != null) {
55+
session.close();
5856
}
5957
}
6058

6159
protected Session getConnection() {
62-
return connection;
60+
return getSession();
6361
}
6462

6563
//---- Send methods ------------------------------------------------------//
6664

6765
public synchronized void sendRawFrame(String rawFrame) throws Exception {
6866
checkConnected();
69-
connection.getRemote().sendString(rawFrame);
67+
getSession().sendText(rawFrame, null);
7068
}
7169

7270
public synchronized void sendFrame(StompFrame frame) throws Exception {
7371
checkConnected();
74-
connection.getRemote().sendString(wireFormat.marshalToString(frame));
72+
getSession().sendText(wireFormat.marshalToString(frame), null);
7573
}
7674

7775
public synchronized void keepAlive() throws Exception {
7876
checkConnected();
79-
connection.getRemote().sendString("\n");
77+
getSession().sendText("\n", null);
8078
}
8179

8280
//----- Receive methods --------------------------------------------------//
@@ -136,22 +134,21 @@ public void onWebSocketText(String data) {
136134
public void onWebSocketClose(int statusCode, String reason) {
137135
LOG.trace("STOMP WS Connection closed, code:{} message:{}", statusCode, reason);
138136

139-
this.connection = null;
140137
this.closeCode = statusCode;
141138
this.closeMessage = reason;
142139
}
143140

144141
@Override
145-
public void onWebSocketConnect(org.eclipse.jetty.ee9.websocket.api.Session session) {
146-
this.connection = session;
147-
this.connection.setIdleTimeout(Duration.ZERO);
142+
public void onWebSocketOpen(Session session) {
143+
super.onWebSocketOpen(session);
144+
session.setIdleTimeout(Duration.ZERO);
148145
this.connectLatch.countDown();
149146
}
150147

151148
//----- Internal implementation ------------------------------------------//
152149

153150
private void checkConnected() throws IOException {
154-
if (!isConnected()) {
151+
if (!isOpen()) {
155152
throw new IOException("STOMP WS Connection is closed.");
156153
}
157154
}

activemq-web-console/pom.xml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,18 @@
5252
</configuration>
5353
</plugin>
5454
<plugin>
55-
<groupId>${jetty.maven.groupid}</groupId>
56-
<artifactId>jetty-maven-plugin</artifactId>
55+
<groupId>org.eclipse.jetty.ee9</groupId>
56+
<artifactId>jetty-ee9-maven-plugin</artifactId>
5757
<version>${jetty-version}</version>
5858
<configuration>
59-
<connectors>
60-
<connector implementation="org.eclipse.jetty.server.ServerConnector">
61-
<port>${jetty.port}</port>
62-
<maxIdleTime>60000</maxIdleTime>
63-
</connector>
64-
</connectors>
65-
66-
<webAppConfig>
59+
<httpConnector>
60+
<port>${jetty.port}</port>
61+
<idleTimeout>60000</idleTimeout>
62+
</httpConnector>
63+
<scan>10</scan>
64+
<webApp>
6765
<contextPath>/</contextPath>
68-
</webAppConfig>
66+
</webApp>
6967

7068
<systemProperties>
7169
<!-- enable easy connection to JConsole -->
@@ -100,7 +98,6 @@
10098
</systemProperty>
10199
-->
102100
</systemProperties>
103-
<scanIntervalSeconds>10</scanIntervalSeconds>
104101
</configuration>
105102
</plugin>
106103
<plugin>
@@ -288,18 +285,24 @@
288285
<scope>provided</scope>
289286
</dependency>
290287

291-
<!-- Tag Libs -->
288+
<!-- Tag Libs -->
289+
<!--
290+
These two should be available either in the WAR itself or from the container. We can't configure
291+
jetty-ee9-maven-plugin with <useProvidedScope>true</useProvidedScope> because we don't need ALL provided
292+
dependencies. But we shouldn't build the WAR with these two included either, because _full_ web container
293+
may provide own taglibs... Not me to decide ;)
294+
-->
292295
<dependency>
293296
<groupId>jakarta.servlet.jsp.jstl</groupId>
294297
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
295298
<version>3.0.0</version>
296-
<scope>provided</scope>
299+
<!-- <scope>provided</scope>-->
297300
</dependency>
298301
<dependency>
299302
<groupId>org.glassfish.web</groupId>
300303
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
301304
<version>3.0.1</version>
302-
<scope>provided</scope>
305+
<!-- <scope>provided</scope>-->
303306
</dependency>
304307
<!--
305308
<dependency>

activemq-web-demo/pom.xml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@
3333
<build>
3434
<plugins>
3535
<plugin>
36-
<groupId>org.eclipse.jetty</groupId>
37-
<artifactId>jetty-maven-plugin</artifactId>
36+
<groupId>org.eclipse.jetty.ee9</groupId>
37+
<artifactId>jetty-ee9-maven-plugin</artifactId>
3838
<configuration>
39-
<connectors>
40-
<connector implementation="org.eclipse.jetty.server.ServerConnector">
41-
<port>${jetty.port}</port>
42-
<maxIdleTime>60000</maxIdleTime>
43-
</connector>
44-
</connectors>
45-
<scanIntervalSeconds>10</scanIntervalSeconds>
39+
<httpConnector>
40+
<port>${jetty.port}</port>
41+
<idleTimeout>60000</idleTimeout>
42+
</httpConnector>
43+
<scan>10</scan>
44+
<useTestScope>true</useTestScope>
4645
</configuration>
4746
</plugin>
4847

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,8 @@
10481048
<version>${javacc-maven-plugin-version}</version>
10491049
</plugin>
10501050
<plugin>
1051-
<groupId>org.eclipse.jetty</groupId>
1052-
<artifactId>jetty-maven-plugin</artifactId>
1051+
<groupId>org.eclipse.jetty.ee9</groupId>
1052+
<artifactId>jetty-ee9-maven-plugin</artifactId>
10531053
<version>${jetty-version}</version>
10541054
</plugin>
10551055
<plugin>

0 commit comments

Comments
 (0)