public class WebSocketEndpointManager
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
closeServlets()
Close all servlet websocket endpoints.
|
static WebSocketEndpointManager |
getInstance()
Get the factory instance, creating a new one if none created yet.
|
PtolemyWebSocketServlet |
getServlet(java.lang.String path)
Get the servlet for the given path.
|
static boolean |
isRemoteURI(java.lang.String path)
Return true if the path refers to a remote resource; false otherwise.
|
static boolean |
isRemoteURI(java.net.URI uri)
Return true if the path refers to a remote resource; false otherwise.
|
static boolean |
isValidURI(java.lang.String path)
Check if the given path is a valid URI.
|
void |
openLocalServices(java.util.HashSet<WebSocketService> services,
int portNumber)
Open connections for the given set of services by looking up each
service's affiliated endpoint and opening a connection for that endpoint.
|
static java.net.URI |
pathToURI(java.lang.String path)
Check the given path to see if it is a valid websocket URI and return a
URI.
|
void |
subscribe(WebSocketService service,
java.lang.String path)
Add the given service as a subscriber to the endpoint for this path.
|
void |
unsubscribe(WebSocketService service,
java.lang.String path)
Remove the given service as a subscriber to the endpoint for this path.
|
public static WebSocketEndpointManager getInstance()
public void closeServlets()
public PtolemyWebSocketServlet getServlet(java.lang.String path) throws IllegalActionException
path
- The URI the servlet should be mapped to.IllegalActionException
- Not thrown in this base class.public static boolean isRemoteURI(java.lang.String path) throws IllegalActionException
path
- The candidate URI.IllegalActionException
- If the path is not a valid URI.public static boolean isRemoteURI(java.net.URI uri)
uri
- The candidate URI.public static boolean isValidURI(java.lang.String path)
path
- The candidate URI.public void openLocalServices(java.util.HashSet<WebSocketService> services, int portNumber) throws IllegalActionException
services
- The set of services to open connections for.portNumber
- The port number of the local web server.IllegalActionException
- If one or more services cannot be opened.public static java.net.URI pathToURI(java.lang.String path) throws IllegalActionException
path
- The string representation of a websocket URI.IllegalActionException
- If the path is not a valid URI.public void subscribe(WebSocketService service, java.lang.String path) throws IllegalActionException
service
- The service to add as a subscriber.path
- The URL to subscribe to.IllegalActionException
- If the URI is not valid.unsubscribe(WebSocketService, String)
public void unsubscribe(WebSocketService service, java.lang.String path)
service
- The service to remove as a subscriberpath
- The URL to subscribe tosubscribe(WebSocketService, String)