/
CommandTransferClient.java
executable file
·95 lines (86 loc) · 3.31 KB
/
CommandTransferClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* This file is part of SynchronizeFX.
*
* Copyright (C) 2013-2014 Saxonia Systems AG
*
* SynchronizeFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SynchronizeFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with SynchronizeFX. If not, see <http://www.gnu.org/licenses/>.
*/
package de.saxsys.synchronizefx.core.clientserver;
import java.util.List;
import javafx.beans.property.Property;
import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException;
import de.saxsys.synchronizefx.core.metamodel.commands.Command;
/**
* <p>
* This is the interface to the underlying network library that serializes and transfers the {@link Command}s produced
* by this framework.
* </p>
*
* <p>
* All methods defined in here are intended to be used by {@link SynchronizeFxClient} and not by the user.
* </p>
*
* <p>
* Any implementation must be capable of transferring all classes in the package
* {@link de.saxsys.synchronizefx.core.metamodel.commands}, the class {@code java.util.UUID} and all classes of the user
* domain model that doesn't contain any Fields that extend {@link Property}. You may wan't the user to provide them
* manually if your implementation hasn't any generic system to handle any {@link Object} that is thrown on it.
* </p>
*
* <p>
* It is guaranteed that {@link CommandTransferClient#setTopologyCallback(NetworkToTopologyCallbackClient)} is only
* called before {@link CommandTransferClient#connect()} and {@link CommandTransferClient#send(List)} only after
* {@link CommandTransferClient#connect()} (maybe multiple times). It is also guaranteed that no more methods are called
* after {@link CommandTransferClient#disconnect()} was called.
* </p>
*
* <p>
* If you support user supplied serializers, please use the {@link Serializer} interface for them. This way serializers
* are usable for multiple {@link CommandTransferClient} implementations.
* </p>
*
* <p>
* This is the client side. For the server side see {@link CommandTransferServer}.
* </p>
*
* @author raik.bieniek
*/
public interface CommandTransferClient {
/**
* Sets the callback to the topology layer for events like incoming commands or errors.
*
* @param callback
* The callback
*/
void setTopologyCallback(NetworkToTopologyCallbackClient callback);
/**
* Open the connection to the server.
*
* @throws SynchronizeFXException
* When the connection to the server failed.
*/
void connect() throws SynchronizeFXException;
/**
* Sends commands to the server.
*
* @param commands
* The commands to send. The commands don't need to be send all at once but their order must not be
* changed.
*/
void send(List<Command> commands);
/**
* Closes the connection to the server.
*/
void disconnect();
}