]> git.basschouten.com Git - openhab-addons.git/blob
2cd428b634b1ee849a97bd236c1aa5e6a0a05d68
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.webthing.internal.client;
14
15 import java.io.IOException;
16 import java.net.URI;
17 import java.util.concurrent.ScheduledExecutorService;
18 import java.util.function.Consumer;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jetty.client.HttpClient;
22 import org.eclipse.jetty.websocket.client.WebSocketClient;
23
24 /**
25  * Factory to create new instances of the WebThing client-side proxy
26  *
27  * @author Gregor Roth - Initial contribution
28  */
29 @NonNullByDefault
30 public interface ConsumedThingFactory {
31
32     /**
33      * @param webSocketClient the webSocketClient to use
34      * @param httpClient the http client to use
35      * @param webThingURI the identifier of a WebThing resource
36      * @param executor executor
37      * @param errorHandler the error handler
38      * @return the newly created WebThing
39      * @throws IOException if the WebThing can not be connected
40      */
41     ConsumedThing create(WebSocketClient webSocketClient, HttpClient httpClient, URI webThingURI,
42             ScheduledExecutorService executor, Consumer<String> errorHandler) throws IOException;
43
44     /**
45      * @return the default instance of the factory
46      */
47     static ConsumedThingFactory instance() {
48         return ConsumedThingImpl::new;
49     }
50 }