-
-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for #508 [runtime] WebSocketProcessor must be pluggable to suppor…
…t JSR 356
- Loading branch information
Showing
12 changed files
with
477 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
modules/cpr/src/main/java/org/atmosphere/cpr/WebSocketProcessorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.atmosphere.cpr; | ||
|
||
import org.atmosphere.websocket.DefaultWebSocketProcessor; | ||
import org.atmosphere.websocket.WebSocket; | ||
import org.atmosphere.websocket.WebSocketProcessor; | ||
|
||
public class WebSocketProcessorFactory { | ||
|
||
private static WebSocketProcessorFactory factory; | ||
private final AtmosphereConfig config; | ||
private final String webSocketProcessorName; | ||
|
||
protected WebSocketProcessorFactory(AtmosphereConfig config) { | ||
this.config = config; | ||
factory = this; | ||
webSocketProcessorName = config.framework().getWebSocketProcessorClassName(); | ||
} | ||
|
||
public final static WebSocketProcessorFactory getDefault() { | ||
return factory; | ||
} | ||
|
||
public WebSocketProcessor newWebSocketProcessor(WebSocket webSocket) { | ||
WebSocketProcessor wp = null; | ||
if (webSocketProcessorName.equalsIgnoreCase(WebSocketProcessor.class.getName())) { | ||
try { | ||
wp = (WebSocketProcessor) Thread.currentThread().getContextClassLoader() | ||
.loadClass(webSocketProcessorName).newInstance(); | ||
} catch (Exception ex) { | ||
try { | ||
wp = (WebSocketProcessor) getClass().getClassLoader() | ||
.loadClass(webSocketProcessorName).newInstance(); | ||
} catch (Exception ex2) { | ||
} | ||
} | ||
} | ||
|
||
if (wp == null) { | ||
wp = new DefaultWebSocketProcessor(config.framework(), webSocket, config.framework().getWebSocketProtocol()); | ||
} | ||
|
||
return wp; | ||
} | ||
|
||
} |
Oops, something went wrong.