source: profileconnection/src/main/java/geniusweb/profileconnection/ProfileConnectionFactory.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 1.2 KB
Line 
1package geniusweb.profileconnection;
2
3import java.io.IOException;
4import java.net.URI;
5
6import javax.websocket.ContainerProvider;
7import javax.websocket.DeploymentException;
8
9import geniusweb.profile.Profile;
10import tudelft.utilities.logging.Reporter;
11
12/**
13 * factory that provides a ProfileInterface given an URI, supporting both the ws
14 * and the file scheme for the uri
15 */
16public class ProfileConnectionFactory {
17
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 public static ProfileInterface create(URI uri, Reporter reporter)
27 throws IOException, DeploymentException {
28 switch (uri.getScheme()) {
29 case "ws":
30 return new WebsocketProfileConnector(uri, reporter,
31 ContainerProvider.getWebSocketContainer());
32 case "file":
33 return new FileProfileConnector(uri.getSchemeSpecificPart());
34 default:
35 }
36 throw new IllegalArgumentException(
37 "Unsupported profile scheme " + uri.getScheme());
38 }
39
40}
Note: See TracBrowser for help on using the repository browser.