Last change
on this file since 90 was 90, checked in by Bart Vastenhouw, 3 years ago |
Refactor to help reusing partiesserver.
|
File size:
1.3 KB
|
Line | |
---|
1 | from tudelft_utilities_logging.Reporter import Reporter
|
---|
2 | from uri.uri import URI # type:ignore
|
---|
3 |
|
---|
4 | from geniusweb.profileconnection.FileProfileConnector import FileProfileConnector
|
---|
5 | from geniusweb.profileconnection.ProfileInterface import ProfileInterface
|
---|
6 | from geniusweb.profileconnection.WebSocketContainer import DefaultWebSocketContainer
|
---|
7 | from geniusweb.profileconnection.WebsocketProfileConnector import WebsocketProfileConnector
|
---|
8 |
|
---|
9 |
|
---|
10 | class ProfileConnectionFactory:
|
---|
11 | '''
|
---|
12 | * factory that provides a ProfileInterface given an URI, supporting both the ws
|
---|
13 | * and the file scheme for the uri
|
---|
14 | '''
|
---|
15 |
|
---|
16 | @staticmethod
|
---|
17 | def create( uri:URI, reporter:Reporter) -> ProfileInterface:
|
---|
18 | '''
|
---|
19 | @param uri the URI that can provide the {@link Profile}. Support
|
---|
20 | both the ws and the file scheme for the uri.
|
---|
21 | @param reporter the {@link Reporter} to log issues to
|
---|
22 | @return a {@link ProfileInterface}
|
---|
23 | @throws IOException if connection can't be made
|
---|
24 | @throws DeploymentException if endpoint can't be published
|
---|
25 | '''
|
---|
26 | scheme=str(uri.getScheme())
|
---|
27 | if "ws"==scheme:
|
---|
28 | return WebsocketProfileConnector(uri, reporter, DefaultWebSocketContainer())
|
---|
29 | if "file"==scheme:
|
---|
30 | return FileProfileConnector(uri.getPath());
|
---|
31 | raise ValueError("Unsupported profile scheme " + str(uri));
|
---|
32 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.