├── .gitattributes ├── .gitignore ├── src ├── devconfig │ ├── README │ ├── checkstyle.properties │ ├── java.header │ └── checkstyle-suppressions.xml └── site │ ├── resources │ └── images │ │ └── synchronizeFX_logo.png │ ├── site.xml │ ├── pdf.xml │ └── markdown │ └── index.md ├── demos ├── sliderdemo │ ├── client_screenshot.png │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── de │ │ │ └── saxsys │ │ │ └── synchronizefx │ │ │ └── sliderdemo │ │ │ ├── server │ │ │ ├── Model.java │ │ │ └── ServerApp.java │ │ │ └── client │ │ │ ├── View.java │ │ │ └── ClientApp.java │ └── pom.xml ├── pinboarddemo-server │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── logback.xml │ │ │ └── java │ │ │ └── de │ │ │ └── saxsys │ │ │ └── synchronizefx │ │ │ └── pinboarddemo │ │ │ ├── domain │ │ │ ├── package-info.java │ │ │ ├── Board.java │ │ │ ├── Note.java │ │ │ └── Position2D.java │ │ │ └── server │ │ │ └── package-info.java │ └── pom.xml └── pinboarddemo-client │ ├── src │ └── main │ │ └── java │ │ └── de │ │ └── saxsys │ │ └── synchronizefx │ │ └── pinboarddemo │ │ └── client │ │ └── package-info.java │ └── pom.xml ├── synchronizefx ├── src │ ├── test │ │ ├── resources │ │ │ └── logback.xml │ │ └── java │ │ │ └── de │ │ │ └── saxsys │ │ │ └── synchronizefx │ │ │ ├── WaitForModelReadyLock.java │ │ │ └── testapp │ │ │ ├── DummyApplication.java │ │ │ ├── MessageContainer.java │ │ │ ├── Message.java │ │ │ └── ExampleServer.java │ └── main │ │ ├── java │ │ └── de │ │ │ └── saxsys │ │ │ └── synchronizefx │ │ │ ├── package-info.java │ │ │ ├── ServerModelStep.java │ │ │ ├── ClientAddressStep.java │ │ │ ├── OptionalClientStep.java │ │ │ ├── OptionalServerStep.java │ │ │ ├── InitialStep.java │ │ │ ├── ServerCallbackStep.java │ │ │ ├── ClientCallbackStep.java │ │ │ ├── SynchronizeFxBuilder.java │ │ │ ├── ServerBuilder.java │ │ │ ├── ClientBuilder.java │ │ │ └── OptionalStep.java │ │ └── assemble │ │ └── bin.xml └── pom.xml ├── README.md ├── kryo-serializer ├── pom.xml └── src │ └── main │ └── java │ └── de │ └── saxsys │ └── synchronizefx │ └── kryo │ ├── package-info.java │ └── serializer │ ├── package-info.java │ ├── UUIDSerializer.java │ ├── SetPropertyValueSerializer.java │ ├── RemoveFromListSerializer.java │ ├── AddToListSerializer.java │ ├── ReplaceInListSerializer.java │ └── ValueSerializer.java ├── transmitter ├── netty-transmitter │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── de │ │ └── saxsys │ │ └── synchronizefx │ │ └── netty │ │ ├── package-info.java │ │ ├── base │ │ ├── package-info.java │ │ ├── client │ │ │ ├── package-info.java │ │ │ └── InboundCommandHandlerClient.java │ │ ├── server │ │ │ ├── package-info.java │ │ │ └── InboundCommandHandlerServer.java │ │ ├── Codec.java │ │ └── CommandToBinaryByteBuf.java │ │ ├── tcp │ │ ├── package-info.java │ │ ├── LengthFieldBasedCodec.java │ │ ├── NettyServer.java │ │ └── NettyClient.java │ │ └── websockets │ │ ├── package-info.java │ │ ├── ByteBufToWebSocketFrameCodec.java │ │ └── WhiteSpaceInPathWebSocketClientHandshaker13.java ├── websocket-transmitter │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── de │ │ │ └── saxsys │ │ │ └── synchronizefx │ │ │ └── websocket │ │ │ └── package-info.java │ └── pom.xml └── tomcat-transmitter │ ├── src │ ├── main │ │ └── java │ │ │ └── de │ │ │ └── saxsys │ │ │ └── synchronizefx │ │ │ └── tomcat │ │ │ ├── package-info.java │ │ │ └── SynchronizeFXTomcatConnection.java │ └── site │ │ └── markdown │ │ └── index.md.vm │ └── pom.xml └── synchronizefx-core ├── src ├── main │ └── java │ │ └── de │ │ └── saxsys │ │ └── synchronizefx │ │ └── core │ │ ├── exceptions │ │ ├── package-info.java │ │ ├── ObjectToIdMappingException.java │ │ └── SynchronizeFXException.java │ │ ├── metamodel │ │ ├── commands │ │ │ ├── package-info.java │ │ │ ├── Command.java │ │ │ ├── SetRootElement.java │ │ │ ├── ClearReferences.java │ │ │ ├── RemoveFromSet.java │ │ │ ├── AddToSet.java │ │ │ ├── RemoveFromMap.java │ │ │ ├── ReplaceInList.java │ │ │ ├── PutToMap.java │ │ │ ├── AddToList.java │ │ │ ├── RemoveFromList.java │ │ │ ├── CreateObservableObject.java │ │ │ └── Value.java │ │ ├── executors │ │ │ ├── lists │ │ │ │ ├── package-info.java │ │ │ │ └── ListPropertyCommandExecutor.java │ │ │ ├── SingleValuePropertyCommandExecutor.java │ │ │ ├── package-info.java │ │ │ ├── SimpleSingleValuePropertyCommandExecutor.java │ │ │ └── CommandLogDispatcher.java │ │ ├── package-info.java │ │ ├── Supplier.java │ │ ├── CommandsForDomainModelCallback.java │ │ ├── SilentChangeExecutor.java │ │ ├── ValueMapper.java │ │ └── TopologyLayerCallback.java │ │ └── clientserver │ │ ├── package-info.java │ │ ├── ServerCallback.java │ │ ├── ClientCallback.java │ │ ├── NetworkToTopologyCallbackClient.java │ │ ├── Serializer.java │ │ └── NetworkToTopologyCallbackServer.java └── test │ └── java │ └── de │ └── saxsys │ └── synchronizefx │ └── core │ ├── testutils │ ├── EasyCommandsForDomainModel.java │ └── SaveParameterCallback.java │ └── metamodel │ ├── SilentChangeExecutorTest.java │ ├── TemporaryReferenceKeeperTest.java │ └── ChangesWhileConnectIT.java └── pom.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .classpath 3 | .project 4 | .settings/ 5 | .checkstyle 6 | 7 | .idea 8 | *.iml -------------------------------------------------------------------------------- /src/devconfig/README: -------------------------------------------------------------------------------- 1 | This directory contains various configuration files for the development that can not be generated automatically. -------------------------------------------------------------------------------- /demos/sliderdemo/client_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeiss-digital-innovation/SynchronizeFX/HEAD/demos/sliderdemo/client_screenshot.png -------------------------------------------------------------------------------- /src/devconfig/checkstyle.properties: -------------------------------------------------------------------------------- 1 | checkstyle.suppressions.file=${samedir}checkstyle-suppressions.xml 2 | checkstyle.header.file=${samedir}java.header -------------------------------------------------------------------------------- /src/site/resources/images/synchronizeFX_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeiss-digital-innovation/SynchronizeFX/HEAD/src/site/resources/images/synchronizeFX_logo.png -------------------------------------------------------------------------------- /synchronizefx/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /demos/pinboarddemo-server/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![SynchronizeFX](https://raw.github.com/saxsys/SynchronizeFX/master/src/site/resources/images/synchronizeFX_logo.png) 2 | 3 | SynchronizeFX is a library for **JavaFX 2 and later** that enables property bindings between different JVMs, both on a local computer and over the network. 4 | 5 | It's build for applications that need realtime synchronization of the UI or other data. 6 | 7 | ## Authors 8 | SynchronizeFX is developed by [Saxonia Systems AG](https://github.com/saxsys). The main developer is [Raik Bieniek](https://github.com/rbi) . Contributors are [Alexander Casall](https://github.com/sialcasa), [Manuel Mauky](https://github.com/lestard) and Michael Thiele. 9 | 10 | ## License 11 | SynchronizeFX is released under the **LGPLv3** license. 12 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/devconfig/java.header: -------------------------------------------------------------------------------- 1 | ^/\*\*$ 2 | ^ \* This file is part of SynchronizeFX\.$ 3 | ^ \* $ 4 | ^ \* Copyright \(C\) 2013-2014 .+$ 5 | ^ \*$ 6 | ^ \* SynchronizeFX is free software: you can redistribute it and/or modify$ 7 | ^ \* it under the terms of the GNU Lesser General Public License as published by$ 8 | ^ \* the Free Software Foundation, either version 3 of the License, or$ 9 | ^ \* \(at your option\) any later version\.$ 10 | ^ \*$ 11 | ^ \* SynchronizeFX is distributed in the hope that it will be useful,$ 12 | ^ \* but WITHOUT ANY WARRANTY; without even the implied warranty of$ 13 | ^ \* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\. See the$ 14 | ^ \* GNU Lesser General Public License for more details\.$ 15 | ^ \*$ 16 | ^ \* You should have received a copy of the GNU Lesser General Public License$ 17 | ^ \* along with SynchronizeFX\. If not, see \.$ 18 | ^ \*/$ 19 | ^$ 20 | ^((package)|(/\*\*)) 21 | -------------------------------------------------------------------------------- /kryo-serializer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | .. 9 | 10 | 11 | kryo-serializer 12 | Kryo Serializer 13 | Kryo based Serializer for SynchronizeFX 14 | 15 | 16 | 17 | ${project.parent.groupId} 18 | synchronizefx-core 19 | 20 | 21 | com.esotericsoftware.kryo 22 | kryo 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/devconfig/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains a builder for easy initialization of the SynchronizeFX framework. 22 | */ 23 | package de.saxsys.synchronizefx; -------------------------------------------------------------------------------- /demos/sliderdemo/src/main/java/de/saxsys/synchronizefx/sliderdemo/server/Model.java: -------------------------------------------------------------------------------- 1 | package de.saxsys.synchronizefx.sliderdemo.server; 2 | 3 | import javafx.beans.property.DoubleProperty; 4 | import javafx.beans.property.SimpleDoubleProperty; 5 | 6 | /** 7 | * The domain model that contains the synchronized values. 8 | * 9 | * @author manuel.mauky 10 | * 11 | */ 12 | public class Model { 13 | 14 | private final DoubleProperty sliderValue = new SimpleDoubleProperty(); 15 | 16 | /** 17 | * @return the slider value as property. 18 | */ 19 | public DoubleProperty sliderValueProperty() { 20 | return sliderValue; 21 | } 22 | 23 | /** 24 | * @param value 25 | * the new value for the slider. 26 | */ 27 | public void setSliderValue(final double value) { 28 | sliderValue.set(value); 29 | } 30 | 31 | /** 32 | * @return the current slider value. 33 | */ 34 | public double getSliderValue() { 35 | return sliderValue.get(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * This package contains a serializer for the SynchronizeFX framework which is based on Kryo. 22 | */ 23 | package de.saxsys.synchronizefx.kryo; -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains custom kryo serializers for the Command classes of SynchronizeFX. 22 | */ 23 | package de.saxsys.synchronizefx.kryo.serializer; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | ../.. 9 | 10 | netty-transmitter 11 | Netty Transmitter 12 | Netty Transmitter for SynchronizeFX 13 | 14 | 15 | 16 | ${project.parent.groupId} 17 | synchronizefx-core 18 | 19 | 20 | io.netty 21 | netty-all 22 | 23 | 24 | org.slf4j 25 | slf4j-api 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/site/pdf.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | ${project.name} 9 | Raik Bieniek 10 | 11 | 12 | 13 | ${project.name} 14 | Version ${project.version} 15 | Documentation 16 | ${project.name} 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /transmitter/websocket-transmitter/src/main/java/de/saxsys/synchronizefx/websocket/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * A server-side SynchronizeFX transmitter that uses the JSR 356 Websocket API. 22 | */ 23 | package de.saxsys.synchronizefx.websocket; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Transfers messages produced by the SynchronizeFX with the help of the netty networking library. 22 | */ 23 | package de.saxsys.synchronizefx.netty; -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains the exceptions that are thrown by the framework in case of erroneous conditions. 22 | */ 23 | package de.saxsys.synchronizefx.core.exceptions; -------------------------------------------------------------------------------- /transmitter/websocket-transmitter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | ../.. 9 | 10 | websocket-transmitter 11 | Websocket Transmitter 12 | A server side SynchronizeFX Transmitter that uses the JSR 356 Websocket API. 13 | 14 | 15 | 16 | ${project.parent.groupId} 17 | synchronizefx-core 18 | 19 | 20 | javax.websocket 21 | javax.websocket-api 22 | provided 23 | 24 | 25 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * This package contains the commands that the meta model layer produces and evaluates. 22 | */ 23 | package de.saxsys.synchronizefx.core.metamodel.commands; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/base/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains the code common to all Netty based client and server implementations 22 | * provided in this module. 23 | */ 24 | package de.saxsys.synchronizefx.netty.base; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/base/client/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains the code common to all Netty based client implementations 22 | * provided in this module. 23 | */ 24 | package de.saxsys.synchronizefx.netty.base.client; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/base/server/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains the code common to all Netty based server implementations 22 | * provided in this module. 23 | */ 24 | package de.saxsys.synchronizefx.netty.base.server; -------------------------------------------------------------------------------- /demos/pinboarddemo-server/src/main/java/de/saxsys/synchronizefx/pinboarddemo/domain/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * The domain model for a bulletin board that is synchronized between the example server and example client. 22 | */ 23 | package de.saxsys.synchronizefx.pinboarddemo.domain; -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Like the package de.saxsys.synchronizefx.core.metamodel.executors but especially for list properties. 22 | */ 23 | package de.saxsys.synchronizefx.core.metamodel.executors.lists; -------------------------------------------------------------------------------- /transmitter/tomcat-transmitter/src/main/java/de/saxsys/synchronizefx/tomcat/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Provides an implementation for the server side of the network layer of SynchronizeFX using the 22 | * Websocket implementation of Tomcat. 23 | */ 24 | package de.saxsys.synchronizefx.tomcat; -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/Command.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | /** 23 | * A marker interface for commands that are used to reproduce changes on one domain model on an other. 24 | */ 25 | public interface Command { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * This package is an implementation of the network layer. 22 | * It provides the necessary classes to synchronize changes between peers with a client / server semantic. 23 | */ 24 | package de.saxsys.synchronizefx.core.clientserver; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/tcp/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Provides server and client implementations that use plain TCP sockets. 22 | * 23 | *

24 | * Message chunking is done by prepending the length of a coherent message before the message itself. 25 | *

26 | */ 27 | package de.saxsys.synchronizefx.netty.tcp; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/websockets/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains a codec for sending and recieving messages in a websocket conform way. 22 | * 23 | * At the moment only the client side is implemented. For the server side you can use the tomcat-transmitter. 24 | */ 25 | package de.saxsys.synchronizefx.netty.websockets; -------------------------------------------------------------------------------- /synchronizefx/src/test/java/de/saxsys/synchronizefx/WaitForModelReadyLock.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | /** 23 | * 24 | * @author raik.bieniek 25 | * 26 | */ 27 | public final class WaitForModelReadyLock { 28 | 29 | public static final WaitForModelReadyLock INSTANCE = new WaitForModelReadyLock(); 30 | 31 | private WaitForModelReadyLock() { 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * The classes in this package build up a meta model around the users domain model. 22 | * 23 | * The purpose of this meta model is to produce commands for all changes the user does on the local domain model 24 | * and apply commands to it that originate from other peers. 25 | */ 26 | package de.saxsys.synchronizefx.core.metamodel; -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/ServerModelStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | /** 23 | * Mandatory Step to set the model for the server. 24 | */ 25 | public interface ServerModelStep { 26 | 27 | /** 28 | * @param model The root object of the domain model that should be used. 29 | * @return The builder to provide a fluent API. 30 | */ 31 | ServerCallbackStep model(Object model); 32 | } 33 | -------------------------------------------------------------------------------- /demos/pinboarddemo-server/src/main/java/de/saxsys/synchronizefx/pinboarddemo/server/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * An example server thats purpose is to demonstrate how the SynchronizeFX framework could be used. 22 | * 23 | * This server serves a domain model for a minimalist bulletin board. 24 | * On server side it is possible to add new notes and remove random ones. 25 | * When example clients connect, they can move the notes around. 26 | */ 27 | package de.saxsys.synchronizefx.pinboarddemo.server; -------------------------------------------------------------------------------- /demos/pinboarddemo-client/src/main/java/de/saxsys/synchronizefx/pinboarddemo/client/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * An example client thats purpose is to demonstrate how the SynchronizeFX framework could be used. 22 | * 23 | * The client is a minimalist bulletin board. On this board you can move notes around. 24 | * To synchronize the notes of multiple clients, 25 | * it needs to connect to the example server which holds the shared domain model. 26 | */ 27 | package de.saxsys.synchronizefx.pinboarddemo.client; -------------------------------------------------------------------------------- /transmitter/tomcat-transmitter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | ../.. 9 | 10 | tomcat-transmitter 11 | Tomcat Transmitter 12 | Tomcat Websocket Servlet Transmitter for SynchronizeFX 13 | 14 | 15 | 16 | ${project.parent.groupId} 17 | synchronizefx-core 18 | 19 | 20 | org.slf4j 21 | slf4j-api 22 | 23 | 24 | org.apache.tomcat 25 | tomcat-catalina 26 | provided 27 | 28 | 29 | 30 | org.apache.tomcat 31 | tomcat-coyote 32 | provided 33 | 34 | 35 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/ClientAddressStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | /** 23 | * Mandatory step to set the address for the client. 24 | */ 25 | public interface ClientAddressStep { 26 | 27 | /** 28 | * @param address 29 | * The server address to connect to. This can be a DNS name or an 30 | * IP address. 31 | * 32 | * @return The builder to provide a fluent API. 33 | */ 34 | ClientCallbackStep address(String address); 35 | } 36 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/Supplier.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | /** 23 | * Returns an result of a given type. 24 | * 25 | *

26 | * This interface is intended to be replaced by the interface of with the same name in Java 8 once Java 7 support is 27 | * dropped. 28 | *

29 | * 30 | * @param The type of the result that is expected. 31 | */ 32 | public interface Supplier { 33 | 34 | /** 35 | * The next result. 36 | * 37 | * @return The next result. 38 | */ 39 | T get(); 40 | } 41 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/SingleValuePropertyCommandExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.executors; 21 | 22 | import de.saxsys.synchronizefx.core.metamodel.commands.SetPropertyValue; 23 | 24 | /** 25 | * Executes {@link SetPropertyValue} commands received from other peers. 26 | * 27 | * @author Raik Bieniek 28 | */ 29 | public interface SingleValuePropertyCommandExecutor { 30 | 31 | /** 32 | * Executes an command that was received from an other peer if appropriate. 33 | * 34 | * @param command 35 | * The received event. 36 | */ 37 | void execute(SetPropertyValue command); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/OptionalClientStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxClient; 23 | 24 | /** 25 | * Optional Steps for the client and the final build step. 26 | */ 27 | public interface OptionalClientStep extends OptionalStep { 28 | 29 | /** 30 | * Creates a client instance to request a domain model from a server. 31 | * 32 | * The returned client does not automatically connect. You have to call {@link SynchronizeFxClient#connect()} to 33 | * do so. 34 | * 35 | * @return The new client instance. 36 | */ 37 | SynchronizeFxClient build(); 38 | } 39 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/OptionalServerStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxServer; 23 | 24 | /** 25 | * Optional Steps for the server and the final build step. 26 | */ 27 | public interface OptionalServerStep extends OptionalStep { 28 | 29 | /** 30 | * Creates a server instance for serving a domain model. 31 | * 32 | * The returned server is not automatically started yet. You have call You have to call 33 | * {@link SynchronizeFxServer#start()} to actually start it. 34 | * 35 | * @return The new server instance. 36 | */ 37 | SynchronizeFxServer build(); 38 | } 39 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/exceptions/ObjectToIdMappingException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.exceptions; 21 | 22 | /** 23 | * Indicates an error with the observable object to id mapping. 24 | */ 25 | public class ObjectToIdMappingException extends SynchronizeFXException { 26 | 27 | private static final long serialVersionUID = 3997295840965130660L; 28 | 29 | /** 30 | * 31 | * @param message 32 | * A user readable message that describes the problem and optionally some advice for the user how the 33 | * problem can be fixed. 34 | */ 35 | public ObjectToIdMappingException(final String message) { 36 | super(message); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/InitialStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxClient; 23 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxServer; 24 | 25 | /** 26 | * The initial step to choose whether to create a server or a client instance. 27 | */ 28 | public interface InitialStep { 29 | 30 | /** 31 | * Creates a Builder to create a {@link SynchronizeFxServer}. 32 | * 33 | * @return The builder to provide a fluent API. 34 | */ 35 | ServerModelStep server(); 36 | 37 | /** 38 | * Creates a Builder to create a {@link SynchronizeFxClient}. 39 | * 40 | * @return The builder to provide a fluent API. 41 | */ 42 | ClientAddressStep client(); 43 | } 44 | -------------------------------------------------------------------------------- /synchronizefx-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | .. 9 | 10 | synchronizefx-core 11 | SynchronizeFX core 12 | 13 | 14 | 15 | com.oracle 16 | javafx 17 | 18 | 19 | org.slf4j 20 | slf4j-api 21 | 22 | 23 | commons-collections 24 | commons-collections 25 | 26 | 27 | ch.qos.logback 28 | logback-classic 29 | test 30 | 31 | 32 | junit 33 | junit 34 | test 35 | 36 | 37 | org.mockito 38 | mockito-all 39 | test 40 | 41 | 42 | org.assertj 43 | assertj-core 44 | test 45 | 46 | 47 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | /** 21 | * Contains the classes that evaluate incoming change commands to synchronize the local models with 22 | * remote models. 23 | * 24 | *

The executors in this package are execute changes in a way that all models are eventually synchronous. 25 | * That means that these classes repair non-synchronous states on their managed properties on the own. 26 | * Non-synchronous states can happen when multiple peers change the same property at the same time. 27 | * Non-synchronous states can be detected because the server does not only send change events of other peers 28 | * but also change events of the own peer in the order that they where executed on the server.

29 | */ 30 | package de.saxsys.synchronizefx.core.metamodel.executors; -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/tcp/LengthFieldBasedCodec.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.tcp; 21 | 22 | import de.saxsys.synchronizefx.netty.base.Codec; 23 | 24 | import io.netty.channel.ChannelPipeline; 25 | import io.netty.handler.codec.LengthFieldBasedFrameDecoder; 26 | import io.netty.handler.codec.LengthFieldPrepender; 27 | 28 | /** 29 | * A codec that collects coherent messages by prepending the size of the message to the message itself. 30 | * 31 | * @author Raik Bieniek 32 | */ 33 | class LengthFieldBasedCodec implements Codec { 34 | @Override 35 | public void addToPipeline(final ChannelPipeline pipeline) { 36 | pipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4)); 37 | pipeline.addLast(new LengthFieldPrepender(4)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/ServerCallbackStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.ServerCallback; 23 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxServer; 24 | 25 | /** 26 | * Mandatory Step to set the callback for the server. 27 | */ 28 | public interface ServerCallbackStep { 29 | 30 | /** 31 | * @param callback As the SynchronizeFx framework works asynchronously, you must provide this callback instance 32 | * for the framework to be able to inform you of errors than occurred. The methods in the callback are 33 | * not called before you call {@link SynchronizeFxServer#start()}. 34 | * @return The builder to provide a fluent API. 35 | */ 36 | OptionalServerStep callback(ServerCallback callback); 37 | } 38 | -------------------------------------------------------------------------------- /synchronizefx/src/test/java/de/saxsys/synchronizefx/testapp/DummyApplication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.testapp; 21 | 22 | import javafx.application.Application; 23 | import javafx.stage.Stage; 24 | 25 | /** 26 | * Represents a dummy, which is used for starting the JavaFX-Thread. 27 | * 28 | * @author ragna-diana.steglich 29 | * 30 | */ 31 | public class DummyApplication extends Application { 32 | 33 | private static boolean running; 34 | 35 | @Override 36 | public void start(final Stage stage) throws Exception { 37 | running = true; 38 | } 39 | 40 | /** 41 | * Returns whether an application is running. 42 | * 43 | * @return true, if the instance is running, otherwise false 44 | */ 45 | public static boolean isRunning() { 46 | return running; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/site/markdown/index.md: -------------------------------------------------------------------------------- 1 | JavaFX extends the concept of properties of objects known from JavaBeans. 2 | Instead of using plain fields for properties, special wrapper objects are used for them. 3 | This allows the binding of properties in the model to GUI elements. 4 | E.g. if you have a property _money_ in some domain object you can bind it to some GUI-Label which shows this value. 5 | You can then update this property anywhere in the application and all the GUI-Elements bound to this property would be updated automatically. 6 | When a property is updated there is no need to know what is bound to it and it is no necessary to initiate any update process. 7 | A good introduction to JavaFX properties is the article [Using JavaFX Properties and Binding][jfx-properties] 8 | 9 | [jfx-properties]: http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm "Using JavaFX Properties and Binding" 10 | 11 | Using only standard JavaFX classes, this concept works only within a single JVM. 12 | The goal of this library is to overcome this limitation. 13 | The main idea is to have a domain model which consists of Java classes containing JavaFX Properties. 14 | A single instance of the domain model is than shared between multiple JVM processes running on different machines. 15 | If a property on any object of the model instance on any machine is changed, all other machines get this change too. 16 | GUI-Elements that are bound to the property on any machine will update them self automatically. 17 | From the user perspective it looks like the change was done in the local JVM. 18 | 19 | Only the root object of the shared model has to be retrieved with some special code. 20 | After that changes on the shared model instance can be done as if it was not shared. 21 | This makes upgrading of existing JavaFX applications very easy. 22 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/ClientCallbackStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.ClientCallback; 23 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxClient; 24 | 25 | /** 26 | * Mandatory step to set the callback for the client. 27 | */ 28 | public interface ClientCallbackStep { 29 | 30 | /** 31 | * @param callback As the SynchronizeFx framework works asynchronously, you must provide this callback instance 32 | * for the framework to be able to inform you when the initial transfer of the domain model from the 33 | * server has completed and of errors that have occurred. The methods in the callback are not called 34 | * before you call {@link SynchronizeFxClient#connect()}. 35 | * @return The builder to provide a fluent API. 36 | */ 37 | OptionalClientStep callback(ClientCallback callback); 38 | } 39 | -------------------------------------------------------------------------------- /demos/pinboarddemo-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | ../.. 9 | 10 | 11 | pinboarddemo-server 12 | Pinboard Demo - Server 13 | A simple pinboard thats notes are synchronized between multiple instances with SynchronizeFX. This is the server part of the application. 14 | 15 | 16 | 17 | ${project.parent.groupId} 18 | synchronizefx 19 | 20 | 21 | com.oracle 22 | javafx 23 | 24 | 25 | org.slf4j 26 | slf4j-api 27 | 28 | 29 | ch.qos.logback 30 | logback-classic 31 | 32 | 33 | 34 | 35 | 36 | 38 | org.apache.maven.plugins 39 | maven-deploy-plugin 40 | 41 | true 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/UUIDSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.kryo.serializer; 21 | 22 | import java.util.UUID; 23 | 24 | import com.esotericsoftware.kryo.Kryo; 25 | import com.esotericsoftware.kryo.Serializer; 26 | import com.esotericsoftware.kryo.io.Input; 27 | import com.esotericsoftware.kryo.io.Output; 28 | 29 | /** 30 | * Serializes and deserializes {@link UUID} instances. 31 | * 32 | * @author raik.bieniek 33 | * 34 | */ 35 | public final class UUIDSerializer extends Serializer { 36 | @Override 37 | public UUID read(final Kryo kryo, final Input input, final Class type) { 38 | return new UUID(input.readLong(), input.readLong()); 39 | } 40 | 41 | @Override 42 | public void write(final Kryo kryo, final Output output, final UUID object) { 43 | output.writeLong(object.getMostSignificantBits()); 44 | output.writeLong(object.getLeastSignificantBits()); 45 | } 46 | } -------------------------------------------------------------------------------- /demos/pinboarddemo-server/src/main/java/de/saxsys/synchronizefx/pinboarddemo/domain/Board.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.pinboarddemo.domain; 21 | 22 | import java.util.List; 23 | 24 | import javafx.beans.property.ListProperty; 25 | import javafx.beans.property.SimpleListProperty; 26 | import javafx.collections.FXCollections; 27 | 28 | /** 29 | * Represents the board that contains the notes. 30 | * 31 | * @author raik.bieniek 32 | * 33 | */ 34 | public class Board { 35 | private ListProperty notes = new SimpleListProperty<>(FXCollections. observableArrayList()); 36 | 37 | /** 38 | * 39 | * @return the notes that are currently placed on the board. 40 | */ 41 | public List getNotes() { 42 | return notes.get(); 43 | } 44 | 45 | /** 46 | * 47 | * @see Board#getNotes() 48 | * @return the property 49 | */ 50 | public ListProperty notesProperty() { 51 | return notes; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /synchronizefx/src/test/java/de/saxsys/synchronizefx/testapp/MessageContainer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.testapp; 21 | 22 | import java.util.List; 23 | 24 | import javafx.beans.property.ListProperty; 25 | import javafx.beans.property.SimpleListProperty; 26 | import javafx.collections.FXCollections; 27 | 28 | /** 29 | * Represents the container, which contains several messages. 30 | * 31 | * @author ragna-diana.steglich 32 | * 33 | */ 34 | public class MessageContainer { 35 | 36 | private ListProperty messages = new SimpleListProperty<>(FXCollections. observableArrayList()); 37 | 38 | /** 39 | * @return the messages, which are managed by the server 40 | */ 41 | public List getMessages() { 42 | return messages.get(); 43 | } 44 | 45 | /** 46 | * @see MessageContainer##getMessages() 47 | * @return the property 48 | */ 49 | public ListProperty messageProperty() { 50 | return messages; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /demos/sliderdemo/src/main/java/de/saxsys/synchronizefx/sliderdemo/client/View.java: -------------------------------------------------------------------------------- 1 | package de.saxsys.synchronizefx.sliderdemo.client; 2 | 3 | import javafx.beans.binding.Bindings; 4 | import javafx.beans.property.DoubleProperty; 5 | import javafx.geometry.Insets; 6 | import javafx.scene.control.Label; 7 | import javafx.scene.control.Slider; 8 | import javafx.scene.layout.VBox; 9 | import javafx.scene.paint.Color; 10 | import javafx.scene.text.Text; 11 | 12 | /** 13 | * The javafx view component. 14 | * 15 | * @author manuel.mauky 16 | * 17 | */ 18 | public class View extends VBox { 19 | 20 | private final Slider slider; 21 | 22 | /** 23 | * Create an instance of the View. 24 | */ 25 | public View() { 26 | setSpacing(20); 27 | setPadding(new Insets(20)); 28 | 29 | final Text header = new Text("SynchronizeFX Example"); 30 | header.setFill(Color.DIMGRAY); 31 | header.setStyle("-fx-font-size:24"); 32 | 33 | slider = new Slider(); 34 | slider.setMin(0); 35 | slider.setMax(100); 36 | slider.setShowTickLabels(true); 37 | slider.setShowTickMarks(true); 38 | slider.setMajorTickUnit(20); 39 | slider.setMinorTickCount(5); 40 | slider.setSnapToTicks(true); 41 | 42 | 43 | final Label valueLabel = new Label(); 44 | valueLabel.setTextFill(Color.DIMGRAY); 45 | valueLabel.setStyle("-fx-font-size:15"); 46 | 47 | valueLabel.textProperty() 48 | .bind(Bindings.format("Current Value: %1$.1f", 49 | slider.valueProperty())); 50 | 51 | getChildren().addAll(header, slider, valueLabel); 52 | } 53 | 54 | /** 55 | * @return the slider value as property. 56 | */ 57 | public DoubleProperty sliderValue() { 58 | return slider.valueProperty(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/SetRootElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A {@link Command} that tells which object should be treated as the root object of the domain model. 26 | * 27 | * @author Raik Bieniek 28 | */ 29 | public class SetRootElement implements Command { 30 | private UUID rootElementId; 31 | 32 | /** 33 | * @return The id of the root element. 34 | */ 35 | public UUID getRootElementId() { 36 | return rootElementId; 37 | } 38 | 39 | /** 40 | * 41 | * @see SetRootElement#getRootElementId() 42 | * @param rootElementId 43 | * the id 44 | */ 45 | public void setRootElementId(final UUID rootElementId) { 46 | this.rootElementId = rootElementId; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "SetRootElement [rootElementId=" + rootElementId + "]"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/SynchronizeFxBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | /** 23 | * This is a Step Builder Pattern implementation to create client and server instances for SynchronizeFX. 24 | * 25 | * @author manuel.mauky 26 | * 27 | */ 28 | public final class SynchronizeFxBuilder { 29 | private SynchronizeFxBuilder() { 30 | } 31 | 32 | /** 33 | * Initial step to create the builder instance. 34 | * 35 | * @return the builder. 36 | */ 37 | public static InitialStep create() { 38 | return new Builder(); 39 | } 40 | 41 | /** 42 | * The default implementation of {@link InitialStep}. 43 | * 44 | * @see InitialStep 45 | */ 46 | private static class Builder implements InitialStep { 47 | @Override 48 | public ServerModelStep server() { 49 | return new ServerBuilder(); 50 | } 51 | 52 | @Override 53 | public ClientAddressStep client() { 54 | return new ClientBuilder(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /demos/pinboarddemo-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | ../.. 9 | 10 | 11 | pinboarddemo-client 12 | Pinboard Demo - Client 13 | A simple pinboard thats notes are synchronized between multiple instances with SynchronizeFX. This is the client part of the application. 14 | 15 | 16 | 17 | ${project.parent.groupId} 18 | synchronizefx 19 | 20 | 21 | ${project.parent.groupId} 22 | pinboarddemo-server 23 | 24 | 25 | com.oracle 26 | javafx 27 | 28 | 29 | org.slf4j 30 | slf4j-api 31 | 32 | 33 | ch.qos.logback 34 | logback-classic 35 | 36 | 37 | 38 | 39 | 40 | 42 | org.apache.maven.plugins 43 | maven-deploy-plugin 44 | 45 | true 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/CommandsForDomainModelCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 25 | 26 | /** 27 | * A callback that is informed when the commands that where requested via 28 | * {@link MetaModel#commandsForDomainModel(CommandsForDomainModelCallback)} are ready. 29 | */ 30 | public interface CommandsForDomainModelCallback { 31 | 32 | /** 33 | * Used to inform when the commands are ready. 34 | * 35 | * Before you return from this method make sure that steps have been taken that ensure that commands passed to you 36 | * via future calls of {@link TopologyLayerCallback#sendCommands(List)} are also send to the peer that you've 37 | * requested this initial command set for. {@link TopologyLayerCallback#sendCommands(List)} will not been called as 38 | * long as you've not returned from this method. 39 | * 40 | * @param commands the commands 41 | */ 42 | void commandsReady(List commands); 43 | } 44 | -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/base/client/InboundCommandHandlerClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.base.client; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.clientserver.NetworkToTopologyCallbackClient; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | 27 | import io.netty.channel.ChannelHandlerContext; 28 | import io.netty.channel.SimpleChannelInboundHandler; 29 | 30 | /** 31 | * Passes received messages to the core parts of SynchronizeFX. 32 | */ 33 | class InboundCommandHandlerClient extends SimpleChannelInboundHandler> { 34 | 35 | private NetworkToTopologyCallbackClient callback; 36 | 37 | /** 38 | * Inititalizes the instance. 39 | * 40 | * @param callback The callback to the upper layer to inform it on new commands. 41 | */ 42 | InboundCommandHandlerClient(final NetworkToTopologyCallbackClient callback) { 43 | this.callback = callback; 44 | } 45 | 46 | @Override 47 | protected void channelRead0(final ChannelHandlerContext ctx, final List msg) throws Exception { 48 | callback.recive(msg); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/ClearReferences.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import javafx.beans.property.Property; 23 | 24 | /** 25 | * Tells the other side, that hard references that where created during the assembling of the objects can now be 26 | * deleted. 27 | * 28 | * The commands to create the values of {@link Property} fields in domain object are in some cases send before the 29 | * command to create the domain object. Until the values are attached to the domain object there would normally only 30 | * weak references to these values which could mean that they are already garbage collected before they are attached to 31 | * the domain obejct. To prevent this all created object are put into a set to have a hard reference. To prevent memory 32 | * leaks this set has to be emptied to make the objects garbage collectible when they are no longer used by the user. 33 | * This is done by this command. 34 | * 35 | * @author Raik Bieniek 36 | */ 37 | public class ClearReferences implements Command { 38 | 39 | @Override 40 | public String toString() { 41 | return "ClearReferences []"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/RemoveFromSet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A command to remove an element in a set. 26 | * 27 | */ 28 | public class RemoveFromSet implements Command { 29 | 30 | private UUID setId; 31 | private Value value; 32 | 33 | /** 34 | * @return The id of the set where an element should be added. 35 | */ 36 | public UUID getSetId() { 37 | return setId; 38 | } 39 | 40 | /** 41 | * @see #getSetId() 42 | * @param setId The id 43 | */ 44 | public void setSetId(final UUID setId) { 45 | this.setId = setId; 46 | } 47 | 48 | /** 49 | * @return The value that should be removed from the set. 50 | */ 51 | public Value getValue() { 52 | return value; 53 | } 54 | 55 | /** 56 | * @see #getValue() 57 | * @param value the value 58 | */ 59 | public void setValue(final Value value) { 60 | this.value = value; 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return "RemoveFromSet [setId=" + setId + ", value=" + value + "]"; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/base/server/InboundCommandHandlerServer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.base.server; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.clientserver.NetworkToTopologyCallbackServer; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | 27 | import io.netty.channel.ChannelHandlerContext; 28 | import io.netty.channel.SimpleChannelInboundHandler; 29 | 30 | /** 31 | * Handles messages received from clients. 32 | * 33 | * @author Raik Bieniek 34 | */ 35 | class InboundCommandHandlerServer extends SimpleChannelInboundHandler> { 36 | 37 | private final NetworkToTopologyCallbackServer callback; 38 | 39 | /** 40 | * Initializes an instance with its dependencies. 41 | * 42 | * @param callback The callback to inform on received commands. 43 | */ 44 | InboundCommandHandlerServer(final NetworkToTopologyCallbackServer callback) { 45 | this.callback = callback; 46 | } 47 | 48 | @Override 49 | protected void channelRead0(final ChannelHandlerContext client, final List commands) throws Exception { 50 | callback.recive(commands, client.channel()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/AddToSet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A command that states that an element should be added to a set. 26 | * 27 | */ 28 | public class AddToSet implements Command { 29 | private UUID setId; 30 | private Value value; 31 | 32 | /** 33 | * @return The id of the set where an element should be added. 34 | */ 35 | public UUID getSetId() { 36 | return setId; 37 | } 38 | 39 | /** 40 | * @see AddToSet#getSetId() 41 | * @param setId The id 42 | */ 43 | public void setSetId(final UUID setId) { 44 | this.setId = setId; 45 | } 46 | 47 | /** 48 | * @return The value that should be added to the set. 49 | */ 50 | public Value getValue() { 51 | return value; 52 | } 53 | 54 | /** 55 | * @see AddToSet#getValue() 56 | * @param value the value 57 | */ 58 | public void setValue(final Value value) { 59 | this.value = value; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "AddToSet [setId=" + setId + ", value=" + value + "]"; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/RemoveFromMap.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A command that indicates that a mapping should be removed from a map. 26 | * 27 | * @author raik.bieniek 28 | */ 29 | public class RemoveFromMap implements Command { 30 | 31 | private UUID mapId; 32 | private Value key; 33 | 34 | /** 35 | * @return the id of the map where a mapping should be removed. 36 | */ 37 | public UUID getMapId() { 38 | return mapId; 39 | } 40 | 41 | /** 42 | * @see RemoveFromMap#getMapId() 43 | * @param mapId the id 44 | */ 45 | public void setMapId(final UUID mapId) { 46 | this.mapId = mapId; 47 | } 48 | 49 | /** 50 | * @return The key of the mapping to remove from this map. 51 | */ 52 | public Value getKey() { 53 | return key; 54 | } 55 | 56 | /** 57 | * @see #getKey() 58 | * @param key the key 59 | */ 60 | public void setKey(final Value key) { 61 | this.key = key; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "RemoveFromMap [mapId=" + mapId + ", key=" + key + "]"; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/base/Codec.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.base; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.Serializer; 23 | 24 | import io.netty.buffer.ByteBuf; 25 | import io.netty.channel.ChannelPipeline; 26 | 27 | /** 28 | * A codec that collects all data of a message created by a {@link Serializer} and passes it to the next pipeline 29 | * stage. 30 | * 31 | * @author Raik Bieniek 32 | */ 33 | public interface Codec { 34 | 35 | /** 36 | * Adds the neccessary handler to the pipeline that ensure that coherent messages created by {@link Serializer} 37 | * are passed as on unit to the next pipeline stage. 38 | * 39 | *

40 | * Data recieved over the network enteres the handlers as it comes in in the form of {@link ByteBuf}s. Usually a 41 | * large message will be recieved in multiple small chunks. A chunk can also contain data of multiple messages. 42 | * The handlers added to this pipeline must ensure that further handlers recieve coherent {@link Serializer} 43 | * messages in form of {@link ByteBuf}s. 44 | *

45 | * 46 | * @param pipeline The pipeline to add the handler to. 47 | */ 48 | void addToPipeline(ChannelPipeline pipeline); 49 | } 50 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/exceptions/SynchronizeFXException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.exceptions; 21 | 22 | /** 23 | * A exception for any kind of failures that appear in this framework. 24 | * 25 | * @author raik.bieniek 26 | * 27 | */ 28 | public class SynchronizeFXException extends RuntimeException { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | /** 33 | * 34 | * @param e The exception that caused this failure. 35 | */ 36 | public SynchronizeFXException(final Throwable e) { 37 | super(e); 38 | } 39 | 40 | /** 41 | * 42 | * @param message A user readable message that describes the problem and optionally some advice for the user how the 43 | * problem can be fixed. 44 | * @param e The exception that caused this failure. 45 | */ 46 | public SynchronizeFXException(final String message, final Throwable e) { 47 | super(message, e); 48 | } 49 | 50 | /** 51 | * 52 | * @param message A user readable message that describes the problem and optionally some advice for the user how the 53 | * problem can be fixed. 54 | */ 55 | public SynchronizeFXException(final String message) { 56 | super(message); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /demos/sliderdemo/src/main/java/de/saxsys/synchronizefx/sliderdemo/server/ServerApp.java: -------------------------------------------------------------------------------- 1 | package de.saxsys.synchronizefx.sliderdemo.server; 2 | 3 | import java.util.Scanner; 4 | 5 | import de.saxsys.synchronizefx.SynchronizeFxBuilder; 6 | import de.saxsys.synchronizefx.core.clientserver.ServerCallback; 7 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxServer; 8 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 9 | 10 | /** 11 | * The Server application. 12 | * 13 | * @author manuel.mauky 14 | * 15 | */ 16 | public final class ServerApp { 17 | 18 | private ServerApp() { 19 | } 20 | 21 | /** 22 | * The main entry point to the server application. 23 | * 24 | * @param args the CLI arguments. 25 | */ 26 | public static void main(final String... args) { 27 | System.out.println("starting server"); 28 | final Model model = new Model(); 29 | 30 | final SynchronizeFxServer syncFxServer = 31 | SynchronizeFxBuilder.create().server().model(model).callback(new ServerCallback() { 32 | 33 | @Override 34 | public void onError(final SynchronizeFXException exception) { 35 | System.err.println("Server Error:" + exception.getLocalizedMessage()); 36 | } 37 | 38 | @Override 39 | public void onClientConnectionError(final Object client, final SynchronizeFXException exception) { 40 | System.err.println("An exception in the communication to a client occurred." + exception); 41 | } 42 | 43 | }).build(); 44 | 45 | syncFxServer.start(); 46 | 47 | final Scanner console = new Scanner(System.in); 48 | 49 | boolean exit = false; 50 | 51 | while (!exit) { 52 | System.out.println("press 'q' for quit"); 53 | 54 | final String input = console.next(); 55 | 56 | if ("q".equals(input)) { 57 | exit = true; 58 | } 59 | } 60 | 61 | console.close(); 62 | 63 | syncFxServer.shutdown(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/ServerCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.clientserver; 21 | 22 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 23 | 24 | /** 25 | * This interface has to be implemented by the server to handle errors. 26 | * 27 | * @author raik.bieniek 28 | * 29 | */ 30 | public interface ServerCallback { 31 | 32 | /** 33 | * Called when a fatal error occurred in the synchronization code. 34 | * 35 | *

36 | * This includes errors occurred in the {@link CommandTransferServer} implementation. 37 | *

38 | * 39 | * @param error the exception that describes the error. 40 | */ 41 | void onError(SynchronizeFXException error); 42 | 43 | /** 44 | * Called when an error with the connection to a client occurred. 45 | * 46 | *

47 | * When this event occurs, the server will still work. Just the connection to the affected client is broken. 48 | *

49 | * 50 | * @param client The client for which an error occurred. The type of this object depends on the network layer 51 | * that is used. 52 | * @param error The error that occurred. 53 | */ 54 | void onClientConnectionError(Object client, SynchronizeFXException error); 55 | } 56 | -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/SetPropertyValueSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.kryo.serializer; 21 | 22 | import java.util.UUID; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.commands.SetPropertyValue; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Value; 26 | 27 | import com.esotericsoftware.kryo.Kryo; 28 | import com.esotericsoftware.kryo.Serializer; 29 | import com.esotericsoftware.kryo.io.Input; 30 | import com.esotericsoftware.kryo.io.Output; 31 | 32 | /** 33 | * Serializes and deserialzes {@link SetPropertyValue} commands. 34 | * 35 | * @author Raik Bieniek 36 | */ 37 | public class SetPropertyValueSerializer extends Serializer { 38 | 39 | @Override 40 | public void write(final Kryo kryo, final Output output, final SetPropertyValue object) { 41 | kryo.writeObject(output, object.getCommandId()); 42 | kryo.writeObject(output, object.getPropertyId()); 43 | kryo.writeObject(output, object.getValue()); 44 | } 45 | 46 | @Override 47 | public SetPropertyValue read(final Kryo kryo, final Input input, final Class type) { 48 | return new SetPropertyValue(kryo.readObject(input, UUID.class), kryo.readObject(input, UUID.class), 49 | kryo.readObject(input, Value.class)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/lists/ListPropertyCommandExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.executors.lists; 21 | 22 | import de.saxsys.synchronizefx.core.metamodel.commands.AddToList; 23 | import de.saxsys.synchronizefx.core.metamodel.commands.ListCommand; 24 | import de.saxsys.synchronizefx.core.metamodel.commands.RemoveFromList; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.ReplaceInList; 26 | 27 | /** 28 | * Executes {@link ListCommand}s received from other peers if appropriate. 29 | * 30 | * @author Raik Bieniek 31 | */ 32 | public interface ListPropertyCommandExecutor { 33 | 34 | /** 35 | * Executes an command that was received from an other peer if appropriate. 36 | * 37 | * @param command 38 | * The received command. 39 | */ 40 | void execute(AddToList command); 41 | 42 | /** 43 | * Executes an command that was received from an other peer if appropriate. 44 | * 45 | * @param command 46 | * The received command. 47 | */ 48 | void execute(RemoveFromList command); 49 | 50 | /** 51 | * Executes an command that was received from an other peer if appropriate. 52 | * 53 | * @param command 54 | * The received command. 55 | */ 56 | void execute(ReplaceInList command); 57 | } 58 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/ClientCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.clientserver; 21 | 22 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 23 | 24 | /** 25 | * This interface has to be implemented by clients handle events like the initial transfer of the model or errors. 26 | * 27 | * @author raik.bieniek 28 | * 29 | */ 30 | public interface ClientCallback { 31 | 32 | /** 33 | * Called when the initial transfer of the model has completed. 34 | * 35 | * @param model The root object of the synchronized object tree. 36 | */ 37 | void modelReady(Object model); 38 | 39 | /** 40 | * Called when an error occurred in the synchronization code. 41 | * 42 | * This includes errors occurred in the {@link CommandTransferClient} implementation. When this method is called, 43 | * the connection to the server has to be already closed. 44 | * 45 | * @param error the exception that describes the error. 46 | */ 47 | void onError(SynchronizeFXException error); 48 | 49 | /** 50 | * This method is called when the server closed the connection to this client. 51 | * 52 | * This method is called when the server shut the connection down normally. When the connection just aborted 53 | * {@link ClientCallback#onError(SynchronizeFXException)} is called instead. 54 | */ 55 | void onServerDisconnect(); 56 | } 57 | -------------------------------------------------------------------------------- /demos/sliderdemo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | synchronizefx 4 | sliderdemo 5 | 0.8.0-SNAPSHOT 6 | 7 | 8 | UTF-8 9 | 10 | 11 | 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-compiler-plugin 16 | 2.5.1 17 | 18 | 1.7 19 | 1.7 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-deploy-plugin 26 | 2.7 27 | 28 | true 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | de.saxsys.synchronizefx 37 | synchronizefx 38 | 0.8.0-SNAPSHOT 39 | 40 | 41 | 42 | org.slf4j 43 | slf4j-nop 44 | 1.7.5 45 | 46 | 47 | 48 | 49 | 50 | 52 | jfx-jar-in-java7 53 | 54 | 1.7 55 | 56 | 57 | 58 | com.oracle 59 | javafx 60 | 2.2 61 | system 62 | ${java.home}/lib/jfxrt.jar 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /transmitter/tomcat-transmitter/src/site/markdown/index.md.vm: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | This module provides an implementation for the server side of the network layer of SynchronizeFX. 4 | It uses the Websocket implementation of Tomcat for this purpose. 5 | 6 | ## Maven Config 7 | 8 | To add this module to a Maven based project add the following to your pom.xml 9 | 10 | 11 | de.saxsys.synchronizefx 12 | synchronizefx 13 | ${currentVersion} 14 | 15 | 16 | ## Usage 17 | 18 | The network layer is provided in form of a servlet. 19 | This servlet needs to get a `de.saxsys.synchronizefx.core.clientserver.Serializer` implementation to work properly. 20 | To do this you need to sub class `SynchronizeFXTomcatServlet` and implement the abstract method `newSerializer()`. 21 | Make sure this servlet get's loaded in your Tomcat e.g. by using the `javax.servlet.annotation.WebServlet` annotation 22 | or registering it in your web.xml. 23 | You can then use it to create `SynchronizeFxServer` like this 24 | 25 | //Get the servlet you just implemented somehow. 26 | //This could be done with `@Inject` or ` = this;` if you put the following code directly in this servlet 27 | SynchronizeFXTomcatServlet myServlet = ...; 28 | 29 | //Your implementation that handles errors that can occur while the framework is running. 30 | //This could be directly implemented here as anonymous class, it could be `this` or some extra class. 31 | ServerCallback callback = ...; 32 | 33 | //The root of the domain model you want to share. 34 | Object root = ...; 35 | 36 | //A unique name for the model that should be shared. Multipe models can be shared at the same time 37 | //by using different channel names. 38 | String channelName = "someChannel"; 39 | 40 | [...] 41 | 42 | //Create a new channel at the servlet that servers the domain model. 43 | SynchronizeFxServer server = myServlet.newChannel(root, channelName, callback); 44 | 45 | //Finally start the server. 46 | server.start(); 47 | 48 | [...] 49 | 50 | //When the domain model should no longer be served call the following. This will disconnect all remaining 51 | //connected clients. 52 | server.shutdown(); 53 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/SilentChangeExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | 23 | /** 24 | * Changes an Observable without notifying listeners of these changes. 25 | */ 26 | public class SilentChangeExecutor { 27 | 28 | private Listeners listeners; 29 | 30 | /** 31 | * Initializes an instance with its dependencies. 32 | */ 33 | public SilentChangeExecutor() { 34 | } 35 | 36 | /** 37 | * Executes a change to an observable of the users domain model without generating change commands for this change. 38 | * 39 | *

40 | * Any changes done to the users domain model are executed over the model change executor passed in the constructor. 41 | *

42 | * 43 | * @param observable 44 | * The observable that is changed. 45 | * @param change 46 | * The change that is done to the observable. 47 | */ 48 | public void execute(final Object observable, final Runnable change) { 49 | listeners.disableFor(observable); 50 | change.run(); 51 | listeners.enableFor(observable); 52 | } 53 | 54 | /** 55 | * Registers the listener that should be suspended while modifying observables. 56 | * 57 | * @param listeners 58 | * the listeners 59 | */ 60 | public void registerListenersToSilence(final Listeners listeners) { 61 | this.listeners = listeners; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /synchronizefx/src/main/assemble/bin.xml: -------------------------------------------------------------------------------- 1 | 5 | bin 6 | 7 | tar.gz 8 | zip 9 | 10 | false 11 | 12 | 13 | ${project.basedir}/.. 14 | ${artifactId}-${version}/ 15 | 16 | README* 17 | LICENSE* 18 | NOTICE* 19 | 20 | true 21 | 22 | 23 | 24 | 25 | true 26 | 27 | de.saxsys.synchronizefx:synchronizefx 28 | 29 | 30 | ${artifactId}-${version}/bin/ 31 | false 32 | true 33 | 34 | 35 | ${artifactId}-${version}/bin/ 36 | 37 | true 38 | 39 | ch.qos.logback:logback-classic 40 | 41 | 42 | 43 | 44 | 45 | 46 | true 47 | 48 | de.saxsys.synchronizefx:synchronizefx 49 | 50 | 51 | ${artifactId}-${version}/bin/ 52 | false 53 | 54 | 55 | ${artifactId}-${version}/bin-optional/ 56 | true 57 | 58 | ch.qos.logback:logback-classic 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/ReplaceInList.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A command to replace elements in a list. 26 | * 27 | * @see java.util.List#set(int, Object) 28 | * @author michael.thiele 29 | */ 30 | public class ReplaceInList extends ListCommand { 31 | 32 | private final int position; 33 | private final Value value; 34 | 35 | /** 36 | * Initializes an instance. 37 | * 38 | * @param listId 39 | * see {@link #getListId()} 40 | * @param listVersionChange 41 | * see {@link #getListVersionChange()} 42 | * @param value 43 | * see {@link #getValue()} 44 | * @param position 45 | * see {@link #getPosition()} 46 | */ 47 | public ReplaceInList(final UUID listId, final ListVersionChange listVersionChange, final Value value, 48 | final int position) { 49 | super(listId, listVersionChange); 50 | this.value = value; 51 | this.position = position; 52 | } 53 | 54 | /** 55 | * The index of the element that should be replaced. 56 | * 57 | * @return the index 58 | */ 59 | public int getPosition() { 60 | return position; 61 | } 62 | 63 | /** 64 | * @return The value to set in the specified position in the list. 65 | */ 66 | public Value getValue() { 67 | return value; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/RemoveFromListSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.kryo.serializer; 21 | 22 | import java.util.UUID; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.commands.ListCommand.ListVersionChange; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.RemoveFromList; 26 | 27 | import com.esotericsoftware.kryo.Kryo; 28 | import com.esotericsoftware.kryo.Serializer; 29 | import com.esotericsoftware.kryo.io.Input; 30 | import com.esotericsoftware.kryo.io.Output; 31 | 32 | /** 33 | * Serializes and deserializes {@link RemoveFromList} commands. 34 | * 35 | * @author Raik Bieniek 36 | * 37 | */ 38 | public class RemoveFromListSerializer extends Serializer { 39 | 40 | @Override 41 | public void write(final Kryo kryo, final Output output, final RemoveFromList input) { 42 | kryo.writeObject(output, input.getListId()); 43 | kryo.writeObject(output, input.getListVersionChange().getFromVersion()); 44 | kryo.writeObject(output, input.getListVersionChange().getToVersion()); 45 | output.writeInt(input.getStartPosition()); 46 | output.writeInt(input.getRemoveCount()); 47 | } 48 | 49 | @Override 50 | public RemoveFromList read(final Kryo kryo, final Input input, final Class clazz) { 51 | return new RemoveFromList(kryo.readObject(input, UUID.class), new ListVersionChange(kryo.readObject(input, 52 | UUID.class), kryo.readObject(input, UUID.class)), input.readInt(), input.readInt()); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/tcp/NettyServer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.tcp; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.Serializer; 23 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxServer; 24 | import de.saxsys.synchronizefx.netty.base.server.BasicChannelInitializerServer; 25 | import de.saxsys.synchronizefx.netty.base.server.NettyBasicServer; 26 | 27 | /** 28 | * 29 | * A server side transmitter implementation for SynchronizeFX that uses Netty and transfers messages. 30 | * 31 | *

32 | * This class is intended to be used as input for {@link SynchronizeFxServer}. 33 | *

34 | * 35 | * @author Raik Bieniek 36 | */ 37 | public class NettyServer extends NettyBasicServer { 38 | 39 | private Serializer serializer; 40 | 41 | /** 42 | * Takes the required informations needed to start the server but doesn't actually start it. 43 | * 44 | * The starting of the server is done by {@link SynchronizeFxServer}. 45 | * 46 | * @param port The port to which to listen for new connections. 47 | * @param serializer The serializer that should be used to serialize SynchronizeFX messages. 48 | */ 49 | public NettyServer(final int port, final Serializer serializer) { 50 | super(port); 51 | this.serializer = serializer; 52 | } 53 | 54 | @Override 55 | protected BasicChannelInitializerServer createChannelInitializer() { 56 | return new BasicChannelInitializerServer(serializer, new LengthFieldBasedCodec(), false); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/AddToListSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.kryo.serializer; 21 | 22 | import java.util.UUID; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.commands.AddToList; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.ListCommand.ListVersionChange; 26 | import de.saxsys.synchronizefx.core.metamodel.commands.Value; 27 | 28 | import com.esotericsoftware.kryo.Kryo; 29 | import com.esotericsoftware.kryo.Serializer; 30 | import com.esotericsoftware.kryo.io.Input; 31 | import com.esotericsoftware.kryo.io.Output; 32 | 33 | /** 34 | * Serializes and deserializes {@link AddToList} commands. 35 | * 36 | * @author Raik Bieniek 37 | */ 38 | public class AddToListSerializer extends Serializer { 39 | 40 | @Override 41 | public void write(final Kryo kryo, final Output output, final AddToList object) { 42 | kryo.writeObject(output, object.getListId()); 43 | kryo.writeObject(output, object.getListVersionChange().getFromVersion()); 44 | kryo.writeObject(output, object.getListVersionChange().getToVersion()); 45 | kryo.writeObject(output, object.getValue()); 46 | output.writeInt(object.getPosition()); 47 | } 48 | 49 | @Override 50 | public AddToList read(final Kryo kryo, final Input input, final Class type) { 51 | return new AddToList(kryo.readObject(input, UUID.class), new ListVersionChange(kryo.readObject(input, 52 | UUID.class), kryo.readObject(input, UUID.class)), kryo.readObject(input, Value.class), input.readInt()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/ReplaceInListSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.kryo.serializer; 21 | 22 | import java.util.UUID; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.commands.ListCommand.ListVersionChange; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.ReplaceInList; 26 | import de.saxsys.synchronizefx.core.metamodel.commands.Value; 27 | 28 | import com.esotericsoftware.kryo.Kryo; 29 | import com.esotericsoftware.kryo.Serializer; 30 | import com.esotericsoftware.kryo.io.Input; 31 | import com.esotericsoftware.kryo.io.Output; 32 | 33 | /** 34 | * Serializes and deserializes {@link ReplaceInList} commands. 35 | * 36 | * @author Raik Bieniek 37 | */ 38 | public class ReplaceInListSerializer extends Serializer { 39 | 40 | @Override 41 | public void write(final Kryo kryo, final Output output, final ReplaceInList input) { 42 | kryo.writeObject(output, input.getListId()); 43 | kryo.writeObject(output, input.getListVersionChange().getFromVersion()); 44 | kryo.writeObject(output, input.getListVersionChange().getToVersion()); 45 | kryo.writeObject(output, input.getValue()); 46 | output.writeInt(input.getPosition()); 47 | } 48 | 49 | @Override 50 | public ReplaceInList read(final Kryo kryo, final Input input, final Class type) { 51 | return new ReplaceInList(kryo.readObject(input, UUID.class), new ListVersionChange(kryo.readObject(input, 52 | UUID.class), kryo.readObject(input, UUID.class)), kryo.readObject(input, Value.class), input.readInt()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /demos/sliderdemo/src/main/java/de/saxsys/synchronizefx/sliderdemo/client/ClientApp.java: -------------------------------------------------------------------------------- 1 | package de.saxsys.synchronizefx.sliderdemo.client; 2 | 3 | import javafx.application.Application; 4 | import javafx.scene.Scene; 5 | import javafx.stage.Stage; 6 | 7 | import de.saxsys.synchronizefx.SynchronizeFxBuilder; 8 | import de.saxsys.synchronizefx.core.clientserver.ClientCallback; 9 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxClient; 10 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 11 | import de.saxsys.synchronizefx.sliderdemo.server.Model; 12 | 13 | /** 14 | * Client application's entry point. 15 | * 16 | * @author manuel.mauky 17 | * 18 | */ 19 | public class ClientApp extends Application { 20 | 21 | private static final String SERVER = "localhost"; 22 | 23 | private Model model; 24 | 25 | private SynchronizeFxClient client; 26 | 27 | /** 28 | * Main entry point for the client application. 29 | * 30 | * @param args CLI arguments. 31 | */ 32 | public static void main(final String... args) { 33 | Application.launch(args); 34 | } 35 | 36 | @Override 37 | public void start(final Stage stage) throws Exception { 38 | stage.setTitle("SynchronizeFX Example Client"); 39 | final View view = new View(); 40 | stage.setScene(new Scene(view, 400, 200)); 41 | 42 | client = SynchronizeFxBuilder.create().client().address(SERVER).callback(new ClientCallback() { 43 | @Override 44 | public void modelReady(final Object object) { 45 | model = (Model) object; 46 | 47 | view.sliderValue().bindBidirectional(model.sliderValueProperty()); 48 | } 49 | 50 | @Override 51 | public void onError(final SynchronizeFXException exception) { 52 | System.out.println("Client Error: " + exception.getLocalizedMessage()); 53 | } 54 | 55 | @Override 56 | public void onServerDisconnect() { 57 | System.out.println("Server disconnected"); 58 | } 59 | }).build(); 60 | 61 | client.connect(); 62 | 63 | stage.show(); 64 | } 65 | 66 | /** 67 | * Disconnect the client when the application is closed. 68 | */ 69 | @Override 70 | public void stop() { 71 | System.out.print("Stopping the client..."); 72 | client.disconnect(); 73 | System.out.println("done"); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/PutToMap.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A command to set a value for some key in some map. 26 | * 27 | * @author raik.bieniek 28 | */ 29 | public class PutToMap implements Command { 30 | 31 | private UUID mapId; 32 | private Value key; 33 | private Value value; 34 | 35 | /** 36 | * @return the id of the map where a value for a key should be put. 37 | */ 38 | public UUID getMapId() { 39 | return mapId; 40 | } 41 | 42 | /** 43 | * @see PutToMap#getMapId() 44 | * @param mapId 45 | * the id 46 | */ 47 | public void setMapId(final UUID mapId) { 48 | this.mapId = mapId; 49 | } 50 | 51 | /** 52 | * @return The key of the mapping to add to the map. 53 | */ 54 | public Value getKey() { 55 | return key; 56 | } 57 | 58 | /** 59 | * @see #getKey() 60 | * @param key 61 | * The key 62 | */ 63 | public void setKey(final Value key) { 64 | this.key = key; 65 | } 66 | 67 | /** 68 | * @return The value of the mapping to add. 69 | */ 70 | public Value getValue() { 71 | return value; 72 | } 73 | 74 | /** 75 | * @see #getValue() 76 | * @param value 77 | * The value 78 | */ 79 | public void setValue(final Value value) { 80 | this.value = value; 81 | } 82 | 83 | @Override 84 | public String toString() { 85 | return "PutToMap [mapId=" + mapId + ", key=" + key + ", value=" + value + "]"; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /synchronizefx/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | de.saxsys.synchronizefx 6 | parent 7 | 0.8.0-SNAPSHOT 8 | .. 9 | 10 | 11 | synchronizefx 12 | Default Factory 13 | Factory classes for the default network layer and serializer implementations SynchronizeFX 14 | 15 | 16 | 17 | ${project.parent.groupId} 18 | synchronizefx-core 19 | 20 | 21 | ${project.parent.groupId} 22 | netty-transmitter 23 | 24 | 25 | ${project.parent.groupId} 26 | kryo-serializer 27 | 28 | 29 | ch.qos.logback 30 | logback-classic 31 | true 32 | 33 | 34 | junit 35 | junit 36 | test 37 | 38 | 39 | org.mockito 40 | mockito-all 41 | test 42 | 43 | 44 | org.assertj 45 | assertj-core 46 | test 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-failsafe-plugin 55 | 56 | false 57 | 58 | 59 | 60 | org.apache.maven.plugins 61 | maven-assembly-plugin 62 | 63 | 64 | distro-assembly 65 | package 66 | 67 | single 68 | 69 | 70 | false 71 | 72 | src/main/assemble/bin.xml 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/NetworkToTopologyCallbackClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.clientserver; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | 27 | /** 28 | * This is an callback interface for the network library to inform the upper layer of incomming commands. 29 | * 30 | * This is the interface for the client side. For the server side use {@link NetworkToTopologyCallbackServer}. 31 | * 32 | * @author raik.bieniek 33 | * 34 | */ 35 | public interface NetworkToTopologyCallbackClient { 36 | 37 | /** 38 | * Commands were received. 39 | * 40 | * @param commands The commands received. 41 | */ 42 | void recive(List commands); 43 | 44 | /** 45 | * An error occurred that made the Client disconnect from the server. 46 | * 47 | * When this method is called, the connection to the server has to be already closed. 48 | * 49 | * This method must only be called after the client successfully connected to a server. If an error occurred while 50 | * trying to connect to the server, throw an exception there. 51 | * 52 | * @param e an exception that describes the problem. 53 | */ 54 | void onError(SynchronizeFXException e); 55 | 56 | /** 57 | * This method is called when the server closed the connection to this client. 58 | * 59 | * This method is called when the server shut the connection down normally. When the connection just aborted 60 | * {@link NetworkToTopologyCallbackClient#onError(SynchronizeFXException)} is called instead. 61 | */ 62 | void onServerDisconnect(); 63 | } 64 | -------------------------------------------------------------------------------- /synchronizefx-core/src/test/java/de/saxsys/synchronizefx/core/testutils/EasyCommandsForDomainModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.testutils; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.CommandsForDomainModelCallback; 25 | import de.saxsys.synchronizefx.core.metamodel.MetaModel; 26 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 27 | 28 | /** 29 | * A tool to simplify 30 | * {@link MetaModel#commandsForDomainModel(de.saxsys.synchronizefx.core.metamodel.CommandsForDomainModelCallback)} for 31 | * test that can ensure thread safety in other ways. 32 | */ 33 | public final class EasyCommandsForDomainModel { 34 | private List commands; 35 | private MetaModel model; 36 | 37 | private EasyCommandsForDomainModel(final MetaModel model) { 38 | this.model = model; 39 | } 40 | 41 | private List commandsForDomainModel() { 42 | model.commandsForDomainModel(new CommandsForDomainModelCallback() { 43 | 44 | @Override 45 | public void commandsReady(final List initialCommands) { 46 | commands = initialCommands; 47 | } 48 | }); 49 | return commands; 50 | } 51 | 52 | /** 53 | * Creates the commands necessary to reproduce a domain model. 54 | * 55 | * Changes that are done to the domain model while this method has not returned can be lost. 56 | * 57 | * @param model the MetaModel for the domain model that the commands should be created. 58 | * @return The commands 59 | */ 60 | public static List commandsForDomainModel(final MetaModel model) { 61 | return new EasyCommandsForDomainModel(model).commandsForDomainModel(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /demos/pinboarddemo-server/src/main/java/de/saxsys/synchronizefx/pinboarddemo/domain/Note.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.pinboarddemo.domain; 21 | 22 | import javafx.beans.property.ObjectProperty; 23 | import javafx.beans.property.SimpleObjectProperty; 24 | import javafx.beans.property.SimpleStringProperty; 25 | import javafx.beans.property.StringProperty; 26 | 27 | /** 28 | * Represents a single note on the board. 29 | * 30 | * @author raik.bieniek 31 | */ 32 | public class Note { 33 | private StringProperty text = new SimpleStringProperty(); 34 | private ObjectProperty position = new SimpleObjectProperty<>(new Position2D(0, 0)); 35 | 36 | /** 37 | * 38 | * @return the text that is written on the note. 39 | */ 40 | public String getText() { 41 | return text.get(); 42 | } 43 | 44 | /** 45 | * @see Note#getText() 46 | * @param text the new text. 47 | */ 48 | public void setText(final String text) { 49 | this.text.set(text); 50 | } 51 | 52 | /** 53 | * @see Note#getText() 54 | * @return the property 55 | */ 56 | public StringProperty textProperty() { 57 | return text; 58 | } 59 | 60 | /** 61 | * 62 | * @return the relative position of the note on the board. 63 | */ 64 | public Position2D getPosition() { 65 | return position.get(); 66 | } 67 | 68 | /** 69 | * @see Note#getPosition() 70 | * @param position the new position. 71 | */ 72 | public void setPosition(final Position2D position) { 73 | this.position.set(position); 74 | } 75 | 76 | /** 77 | * @see Note#getPosition() 78 | * @return the property 79 | */ 80 | public ObjectProperty positionProperty() { 81 | return position; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /synchronizefx-core/src/test/java/de/saxsys/synchronizefx/core/testutils/SaveParameterCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.testutils; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 25 | import de.saxsys.synchronizefx.core.metamodel.TopologyLayerCallback; 26 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 27 | 28 | import static org.assertj.core.api.Assertions.fail; 29 | 30 | /** 31 | * An implementation that saves the parameters of the callback function so that they can be evaluated in tests. 32 | */ 33 | public class SaveParameterCallback implements TopologyLayerCallback { 34 | private Object root; 35 | private List commands; 36 | 37 | @Override 38 | public void sendCommands(final List commands) { 39 | this.commands = commands; 40 | } 41 | 42 | @Override 43 | public void onError(final SynchronizeFXException error) { 44 | fail("exception occured: ", error); 45 | } 46 | 47 | @Override 48 | public void domainModelChanged(final Object root) { 49 | this.root = root; 50 | } 51 | 52 | /** 53 | * The list with commands that was received last via {@link TopologyLayerCallback#sendCommands(List)}. 54 | * 55 | * @return The list or null if no commands where received yet. 56 | */ 57 | public List getCommands() { 58 | return commands; 59 | } 60 | 61 | /** 62 | * The last root object for a domain model that was received via 63 | * {@link TopologyLayerCallback#domainModelChanged(Object)}. 64 | * 65 | * @return The root object or null if {@link TopologyLayerCallback#domainModelChanged(Object)} was not called yet. 66 | */ 67 | public Object getRoot() { 68 | return root; 69 | } 70 | } -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/tcp/NettyClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.tcp; 21 | 22 | import java.net.InetSocketAddress; 23 | 24 | import de.saxsys.synchronizefx.core.clientserver.Serializer; 25 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxClient; 26 | import de.saxsys.synchronizefx.netty.base.client.BasicChannelInitializerClient; 27 | import de.saxsys.synchronizefx.netty.base.client.NettyBasicClient; 28 | 29 | /** 30 | * 31 | * A client side transmitter implementation for SynchronizeFX that uses Netty and transfers messages. 32 | * 33 | *

34 | * This class is intended to be used as input for {@link SynchronizeFxClient}. 35 | *

36 | * 37 | * @author Raik Bieniek 38 | */ 39 | public class NettyClient extends NettyBasicClient { 40 | 41 | private final Serializer serializer; 42 | 43 | /** 44 | * Takes the required informations to connect to a server but doesn't actually connect to it. 45 | * 46 | * The opening of the connection is done by {@link SynchronizeFxClient}. 47 | * 48 | * @param serverAdress The domain name or IP address of a server to connect to. 49 | * @param port The port of the server to connect to. 50 | * @param serializer The serializer that should be used to serialize SynchronizeFX messages. 51 | */ 52 | public NettyClient(final String serverAdress, final int port, final Serializer serializer) { 53 | super(new InetSocketAddress(serverAdress, port)); 54 | this.serializer = serializer; 55 | } 56 | 57 | @Override 58 | protected BasicChannelInitializerClient createChannelInitializer() { 59 | LengthFieldBasedCodec codec = new LengthFieldBasedCodec(); 60 | return new BasicChannelInitializerClient(serializer, codec, false); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/ValueSerializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.kryo.serializer; 21 | 22 | import java.util.UUID; 23 | 24 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Value; 26 | 27 | import com.esotericsoftware.kryo.Kryo; 28 | import com.esotericsoftware.kryo.Serializer; 29 | import com.esotericsoftware.kryo.io.Input; 30 | import com.esotericsoftware.kryo.io.Output; 31 | 32 | /** 33 | * Serializes and deserializes {@link Value} messages. 34 | * 35 | * @author Raik Bieniek 36 | */ 37 | public class ValueSerializer extends Serializer { 38 | 39 | @Override 40 | public void write(final Kryo kryo, final Output output, final Value object) { 41 | if (object.getObservableObjectId() == null) { 42 | if (object.getSimpleObjectValue() == null) { 43 | output.writeByte(0); 44 | } else { 45 | output.writeByte(1); 46 | kryo.writeClassAndObject(output, object.getSimpleObjectValue()); 47 | } 48 | } else { 49 | output.writeByte(2); 50 | kryo.writeObject(output, object.getObservableObjectId()); 51 | } 52 | } 53 | 54 | @Override 55 | public Value read(final Kryo kryo, final Input input, final Class type) { 56 | switch (input.readByte()) { 57 | case 0: 58 | return new Value(null); 59 | case 1: 60 | return new Value(kryo.readClassAndObject(input)); 61 | case 2: 62 | return new Value(kryo.readObject(input, UUID.class)); 63 | default: 64 | throw new SynchronizeFXException("Received a Value message of an unknown type."); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/Serializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.clientserver; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | 27 | /** 28 | * A thread safe serializer and deserializer that serializes {@link List}s of SynchronizeFX {@link Command}s. 29 | * 30 | * For a list with classes that this serializer must be able to serialize and deserializer see 31 | * {@link CommandTransferClient}. 32 | * 33 | * @author Raik Bieniek 34 | */ 35 | public interface Serializer { 36 | 37 | /** 38 | * Serializes a list with commands to byte arrays. 39 | * 40 | * This method must be implemented thread safe. 41 | * 42 | * @param objects The commands that should be serialized. 43 | * @return The serialized form of the objects. 44 | * @throws SynchronizeFXException When the serialisation failed. When this exception is thrown, the 45 | * serializer must still be able to serialize valid objects. 46 | */ 47 | byte[] serialize(List objects) throws SynchronizeFXException; 48 | 49 | /** 50 | * Deserializes a byte array to objects that was created with {@link Serializer#serialize(List)}. 51 | * 52 | * This method must be implemented thread safe. 53 | * 54 | * @param commands 55 | * The byte array that contains the serialized commands. 56 | * @return The objects that where encoded in the commands. 57 | * @throws SynchronizeFXException 58 | * When the deserialisation failed. When this exception is thrown, the serializer must still be able to 59 | * deserialize valid objects. 60 | */ 61 | List deserialize(byte[] commands) throws SynchronizeFXException; 62 | } 63 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/AddToList.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A command that states that an element should be added to a list. 26 | * 27 | * @author Raik Bieniek 28 | */ 29 | public class AddToList extends ListCommand { 30 | 31 | private final Value value; 32 | private final int position; 33 | 34 | /** 35 | * Initializes an instance. 36 | * 37 | * @param listId 38 | * see {@link #getListId()} 39 | * @param listVersionChange 40 | * see {@link #getListVersionChange()} 41 | * @param value 42 | * see {@link #getValue()} 43 | * @param position 44 | * see {@link #getPosition()} 45 | */ 46 | public AddToList(final UUID listId, final ListVersionChange listVersionChange, final Value value, // 47 | final int position) { 48 | super(listId, listVersionChange); 49 | this.value = value; 50 | this.position = position; 51 | } 52 | 53 | /** 54 | * The index the new element will have in the list when it's added. 55 | * 56 | *

57 | * The index of all items in the list thats index is greater or equal to the value returned here has to be 58 | * incremented by 1 to make this index available. 59 | *

60 | * 61 | * @return The index 62 | */ 63 | public int getPosition() { 64 | return position; 65 | } 66 | 67 | /** 68 | * @return The value to add to the list. 69 | */ 70 | public Value getValue() { 71 | return value; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "AddToList [listId=" + getListId() + ", versionChange=" + getListVersionChange() + ", value=" + value 77 | + ", position=" + position + "]"; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/RemoveFromList.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * Command to remove elements from a list. 26 | * 27 | * @author Raik Bieniek 28 | */ 29 | public class RemoveFromList extends ListCommand { 30 | 31 | private final int startPosition; 32 | private final int removeCount; 33 | 34 | /** 35 | * Initializes an instance. 36 | * 37 | * @param listId 38 | * see {@link #getListId()} 39 | * @param listVersionChange 40 | * see {@link #getListVersionChange()} 41 | * @param startPosition 42 | * see {@link #getStartPosition()} 43 | * @param removeCount 44 | * see {@link #getRemoveCount()} 45 | */ 46 | public RemoveFromList(final UUID listId, final ListVersionChange listVersionChange, final int startPosition, 47 | final int removeCount) { 48 | super(listId, listVersionChange); 49 | this.startPosition = startPosition; 50 | this.removeCount = removeCount; 51 | } 52 | 53 | /** 54 | * The index of the first element in the list that should be removed. 55 | * 56 | * @return The index 57 | */ 58 | public int getStartPosition() { 59 | return startPosition; 60 | } 61 | 62 | /** 63 | * The amount of elements starting from {@link #getStartPosition()} that should be removed. 64 | * 65 | * @return The element amount to delete. 66 | */ 67 | public int getRemoveCount() { 68 | return removeCount; 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return "RemoveFromList [listId=" + getListId() + ", versionChange=" + getListVersionChange() 74 | + ", startPosition=" + startPosition + ", removeCount=" + removeCount + "]"; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/base/CommandToBinaryByteBuf.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.base; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.clientserver.Serializer; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | 27 | import io.netty.buffer.ByteBuf; 28 | import io.netty.buffer.Unpooled; 29 | import io.netty.channel.ChannelHandlerContext; 30 | import io.netty.handler.codec.MessageToMessageCodec; 31 | 32 | /** 33 | * Translates Netty {@link ByteBuf}s to {@link List}s of SynchronizeFX {@link Command}s using a {@link Serializer}. 34 | * 35 | * @author Raik Bieniek 36 | */ 37 | public class CommandToBinaryByteBuf extends MessageToMessageCodec> { 38 | 39 | private final Serializer serializer; 40 | 41 | /** 42 | * Initializes the codec. 43 | * 44 | * @param serializer The implementation for serializing and deserializing byte[] to SynchronizeFX 45 | * commands. 46 | */ 47 | public CommandToBinaryByteBuf(final Serializer serializer) { 48 | this.serializer = serializer; 49 | } 50 | 51 | @Override 52 | protected void decode(final ChannelHandlerContext ctx, final ByteBuf msg, final List out) throws Exception { 53 | byte[] data; 54 | if (msg.hasArray()) { 55 | data = msg.array(); 56 | } else { 57 | data = new byte[msg.readableBytes()]; 58 | msg.readBytes(data); 59 | } 60 | 61 | out.add(serializer.deserialize(data)); 62 | } 63 | 64 | @Override 65 | protected void encode(final ChannelHandlerContext ctx, final List msg, final List out) 66 | throws Exception { 67 | final ByteBuf buffer = Unpooled.wrappedBuffer(serializer.serialize(msg)); 68 | buffer.retain(); 69 | out.add(buffer); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /transmitter/tomcat-transmitter/src/main/java/de/saxsys/synchronizefx/tomcat/SynchronizeFXTomcatConnection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.tomcat; 21 | 22 | import java.io.IOException; 23 | import java.nio.ByteBuffer; 24 | import java.nio.CharBuffer; 25 | 26 | import org.apache.catalina.websocket.MessageInbound; 27 | import org.apache.catalina.websocket.WsOutbound; 28 | import org.slf4j.Logger; 29 | import org.slf4j.LoggerFactory; 30 | 31 | /** 32 | * Objects of this class represent a single connection between the server and a client. 33 | * 34 | * @author Raik Bieniek 35 | */ 36 | class SynchronizeFXTomcatConnection extends MessageInbound { 37 | 38 | private static final Logger LOG = LoggerFactory.getLogger(SynchronizeFXTomcatChannel.class); 39 | 40 | private final SynchronizeFXTomcatChannel parent; 41 | 42 | /** 43 | * Initializes an instance with all its dependencies. 44 | * 45 | * @param synchronizeFXTomcatChannel the connection management instance that accepted this connection. This 46 | * instance get's informed when messages are received from the client or the client closed the 47 | * connection. 48 | */ 49 | SynchronizeFXTomcatConnection(final SynchronizeFXTomcatChannel synchronizeFXTomcatChannel) { 50 | this.parent = synchronizeFXTomcatChannel; 51 | } 52 | 53 | @Override 54 | protected void onOpen(final WsOutbound outbound) { 55 | parent.clientConnectionReady(this); 56 | } 57 | 58 | @Override 59 | protected void onClose(final int status) { 60 | parent.connectionCloses(this); 61 | } 62 | 63 | @Override 64 | protected void onBinaryMessage(final ByteBuffer message) throws IOException { 65 | parent.recivedMessage(message, this); 66 | } 67 | 68 | @Override 69 | protected void onTextMessage(final CharBuffer message) throws IOException { 70 | LOG.warn("Recived text. This was not expected."); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /synchronizefx/src/test/java/de/saxsys/synchronizefx/testapp/Message.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.testapp; 21 | 22 | import javafx.beans.property.SimpleStringProperty; 23 | import javafx.beans.property.StringProperty; 24 | 25 | /** 26 | * Represents a message with a simple text. 27 | * 28 | * @author ragna-diana.steglich 29 | * 30 | */ 31 | public class Message { 32 | 33 | private StringProperty text = new SimpleStringProperty(); 34 | 35 | /** 36 | * @return the text of a message 37 | */ 38 | public String getText() { 39 | return text.get(); 40 | } 41 | 42 | /** 43 | * Initializes the text of the message with the specified parameter. 44 | * 45 | * @param text 46 | * the new text of the message 47 | */ 48 | public void setText(final String text) { 49 | this.text.set(text); 50 | } 51 | 52 | /** 53 | * @see Message#getText() 54 | * @return the property 55 | */ 56 | public StringProperty textProperty() { 57 | return text; 58 | } 59 | 60 | @Override 61 | public int hashCode() { 62 | final int prime = 31; 63 | int result = 1; 64 | result = prime * result + ((text.get() == null) ? 0 : text.get().hashCode()); 65 | return result; 66 | } 67 | 68 | @Override 69 | public boolean equals(final Object obj) { 70 | if (this == obj) { 71 | return true; 72 | } 73 | if (obj == null) { 74 | return false; 75 | } 76 | if (getClass() != obj.getClass()) { 77 | return false; 78 | } 79 | Message other = (Message) obj; 80 | if (text.get() == null) { 81 | if (other.text.get() != null) { 82 | return false; 83 | } 84 | } else if (!text.get().equals(other.text.get())) { 85 | return false; 86 | } 87 | return true; 88 | } 89 | 90 | @Override 91 | public String toString() { 92 | return "Message [text=" + text.get() + "]"; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /synchronizefx-core/src/test/java/de/saxsys/synchronizefx/core/metamodel/SilentChangeExecutorTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | import org.junit.Before; 23 | import org.junit.Test; 24 | import org.mockito.InOrder; 25 | 26 | import static org.mockito.Mockito.inOrder; 27 | import static org.mockito.Mockito.mock; 28 | 29 | /** 30 | * Checks if {@link SilentChangeExecutor} works as expected. 31 | */ 32 | public class SilentChangeExecutorTest { 33 | 34 | private static final int NEW_VALUE = 42; 35 | 36 | private final Listeners listeners = mock(Listeners.class); 37 | private final SilentChangeExecutor cut = new SilentChangeExecutor(); 38 | 39 | private final DummyObservable dummyObservable = mock(DummyObservable.class); 40 | 41 | /** 42 | * Sets up the class under test. 43 | */ 44 | @Before 45 | public void setupCut() { 46 | cut.registerListenersToSilence(listeners); 47 | } 48 | 49 | /** 50 | * The change to the domain model should not be propagated to the synchronizeFX specific listeners that generate 51 | * change commands. 52 | */ 53 | @Test 54 | public void shouldDisableAndReanableChangeNotificationWhenChangingThePropertyValue() { 55 | cut.execute(dummyObservable, new Runnable() { 56 | @Override 57 | public void run() { 58 | dummyObservable.setValue(NEW_VALUE); 59 | } 60 | }); 61 | 62 | final InOrder inOrder = inOrder(listeners, dummyObservable); 63 | 64 | inOrder.verify(listeners).disableFor(dummyObservable); 65 | inOrder.verify(dummyObservable).setValue(NEW_VALUE); 66 | inOrder.verify(listeners).enableFor(dummyObservable); 67 | } 68 | 69 | /** 70 | * A dummy observable that simulates a wrapper for a single changeable value. 71 | */ 72 | private interface DummyObservable { 73 | /** 74 | * Sets the new value of the observable. 75 | * 76 | * @param newValue 77 | * The new value. 78 | */ 79 | void setValue(int newValue); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/CreateObservableObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | import java.util.UUID; 25 | 26 | /** 27 | * A command to create a new instance of an observable object. 28 | * 29 | * @author raik.bieniek 30 | */ 31 | public class CreateObservableObject implements Command { 32 | private UUID objectId; 33 | private String className; 34 | private Map propertyNameToId = new HashMap<>(); 35 | 36 | /** 37 | * @return The id this observable object gets. 38 | */ 39 | public UUID getObjectId() { 40 | return objectId; 41 | } 42 | 43 | /** 44 | * @see CreateObservableObject#getObjectId() 45 | * @param objectId the id 46 | */ 47 | public void setObjectId(final UUID objectId) { 48 | this.objectId = objectId; 49 | } 50 | 51 | /** 52 | * @return The class name of the type of this observable object. 53 | */ 54 | public String getClassName() { 55 | return className; 56 | } 57 | 58 | /** 59 | * @see CreateObservableObject#getClassName() 60 | * @param className the class name 61 | */ 62 | public void setClassName(final String className) { 63 | this.className = className; 64 | } 65 | 66 | /** 67 | * @return A mapping of the names of property fields to the id of the property object. 68 | */ 69 | public Map getPropertyNameToId() { 70 | return propertyNameToId; 71 | } 72 | 73 | /** 74 | * @see CreateObservableObject#getPropertyNameToId() 75 | * @param propertyNameToId the new name-object mapping 76 | */ 77 | public void setPropertyNameToId(final Map propertyNameToId) { 78 | this.propertyNameToId = propertyNameToId; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "CreateObservableObject [objectId=" + objectId + ", className=" + className + ", propertyNameToId=" 84 | + propertyNameToId + "]"; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/ServerBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import java.util.concurrent.Executor; 23 | 24 | import de.saxsys.synchronizefx.core.clientserver.ServerCallback; 25 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxServer; 26 | import de.saxsys.synchronizefx.kryo.KryoSerializer; 27 | import de.saxsys.synchronizefx.netty.tcp.NettyServer; 28 | 29 | import com.esotericsoftware.kryo.Serializer; 30 | 31 | /** 32 | * The Builder implementation for the Server. 33 | */ 34 | class ServerBuilder implements ServerModelStep, ServerCallbackStep, OptionalServerStep { 35 | private static final int DEFAULT_PORT = 54263; 36 | 37 | private int port = DEFAULT_PORT; 38 | private final KryoSerializer serializer = new KryoSerializer(); 39 | private ServerCallback callback; 40 | private Object model; 41 | 42 | private Executor changeExecutor; 43 | 44 | @Override 45 | public OptionalServerStep port(final int port) { 46 | this.port = port; 47 | return this; 48 | } 49 | 50 | @Override 51 | public OptionalServerStep customSerializer(final Class clazz, final Serializer serializer) { 52 | this.serializer.registerSerializableClass(clazz, serializer); 53 | return this; 54 | } 55 | 56 | @Override 57 | public OptionalServerStep callback(final ServerCallback callback) { 58 | this.callback = callback; 59 | return this; 60 | } 61 | 62 | @Override 63 | public ServerCallbackStep model(final Object model) { 64 | this.model = model; 65 | return this; 66 | } 67 | 68 | @Override 69 | public OptionalServerStep modelChangeExecutor(final Executor executor) { 70 | this.changeExecutor = executor; 71 | return this; 72 | } 73 | 74 | @Override 75 | public SynchronizeFxServer build() { 76 | final NettyServer netty = new NettyServer(port, serializer); 77 | 78 | if (changeExecutor == null) { 79 | return new SynchronizeFxServer(model, netty, callback); 80 | } else { 81 | return new SynchronizeFxServer(model, netty, changeExecutor, callback); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/ClientBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import java.util.concurrent.Executor; 23 | 24 | import de.saxsys.synchronizefx.core.clientserver.ClientCallback; 25 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxClient; 26 | import de.saxsys.synchronizefx.kryo.KryoSerializer; 27 | import de.saxsys.synchronizefx.netty.tcp.NettyClient; 28 | 29 | import com.esotericsoftware.kryo.Serializer; 30 | 31 | /** 32 | * The Builder implementation for the Client. 33 | */ 34 | class ClientBuilder implements ClientCallbackStep, OptionalClientStep, ClientAddressStep { 35 | private static final int DEFAULT_PORT = 54263; 36 | 37 | private int port = DEFAULT_PORT; 38 | private String address = "localhost"; 39 | private final KryoSerializer serializer = new KryoSerializer(); 40 | private ClientCallback callback; 41 | private Executor changeExecutor; 42 | 43 | 44 | @Override 45 | public ClientCallbackStep address(final String address) { 46 | this.address = address; 47 | return this; 48 | } 49 | @Override 50 | public OptionalClientStep callback(final ClientCallback callback) { 51 | this.callback = callback; 52 | return this; 53 | } 54 | 55 | @Override 56 | public OptionalClientStep port(final int port) { 57 | this.port = port; 58 | return this; 59 | } 60 | 61 | @Override 62 | public OptionalClientStep customSerializer(final Class clazz, final Serializer serializer) { 63 | this.serializer.registerSerializableClass(clazz, serializer); 64 | return this; 65 | } 66 | 67 | @Override 68 | public OptionalClientStep modelChangeExecutor(final Executor executor) { 69 | this.changeExecutor = executor; 70 | return this; 71 | } 72 | 73 | @Override 74 | public SynchronizeFxClient build() { 75 | final NettyClient netty = new NettyClient(address, port, serializer); 76 | if (changeExecutor == null) { 77 | return new SynchronizeFxClient(netty, callback); 78 | } else { 79 | return new SynchronizeFxClient(netty, callback, changeExecutor); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /synchronizefx-core/src/test/java/de/saxsys/synchronizefx/core/metamodel/TemporaryReferenceKeeperTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | import java.util.Date; 23 | 24 | import org.junit.Test; 25 | import org.junit.runner.RunWith; 26 | import org.mockito.InjectMocks; 27 | import org.mockito.Mock; 28 | import org.mockito.runners.MockitoJUnitRunner; 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | import static org.mockito.Mockito.when; 31 | 32 | /** 33 | * Checks if {@link TemporaryReferenceKeeper} works as expected. 34 | * 35 | * @author Raik Bieniek 36 | */ 37 | @RunWith(MockitoJUnitRunner.class) 38 | public class TemporaryReferenceKeeperTest { 39 | 40 | private static final Object SOME_OBJECT = "some object"; 41 | private static final Object OTHER_SOME_OBJECT = "other some object"; 42 | private static final Date SOME_TIME = new Date(100000); 43 | 44 | @Mock 45 | private Supplier currentTime; 46 | 47 | @InjectMocks 48 | private TemporaryReferenceKeeper cut; 49 | 50 | /** 51 | * As long as there is no time out for a kept reference, no reference is removed. 52 | */ 53 | @Test 54 | public void keepsReferencesToInstancesAsLongAsThereIsNoTimeout() { 55 | when(currentTime.get()).thenReturn(SOME_TIME); 56 | cut.keepReferenceTo(SOME_OBJECT); 57 | 58 | when(currentTime.get()).thenReturn(new Date(SOME_TIME.getTime() + 2000)); 59 | cut.keepReferenceTo(OTHER_SOME_OBJECT); 60 | 61 | when(currentTime.get()).thenReturn(new Date(SOME_TIME.getTime() + 50000)); 62 | cut.cleanReferenceCache(); 63 | 64 | assertThat(cut.getHardReferences()).containsOnly(SOME_OBJECT, OTHER_SOME_OBJECT); 65 | } 66 | 67 | /** 68 | * When the time references are held is over, references are removed. 69 | */ 70 | @Test 71 | public void removesReferencesThatHaveTimedOut() { 72 | when(currentTime.get()).thenReturn(SOME_TIME); 73 | cut.keepReferenceTo(SOME_OBJECT); 74 | 75 | when(currentTime.get()).thenReturn(new Date(SOME_TIME.getTime() + 20000)); 76 | cut.keepReferenceTo(OTHER_SOME_OBJECT); 77 | 78 | when(currentTime.get()).thenReturn(new Date(SOME_TIME.getTime() + 70000)); 79 | cut.cleanReferenceCache(); 80 | 81 | assertThat(cut.getHardReferences()).containsOnly(OTHER_SOME_OBJECT); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /demos/pinboarddemo-server/src/main/java/de/saxsys/synchronizefx/pinboarddemo/domain/Position2D.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.pinboarddemo.domain; 21 | 22 | import javafx.beans.property.DoubleProperty; 23 | import javafx.beans.property.SimpleDoubleProperty; 24 | 25 | /** 26 | * A relative 2 dimensional position. 27 | * 28 | * @author raik.bieniek 29 | * 30 | */ 31 | public class Position2D { 32 | private DoubleProperty x = new SimpleDoubleProperty(); 33 | private DoubleProperty y = new SimpleDoubleProperty(); 34 | 35 | /** 36 | * Initializes a relative position that points to the upper left corner. 37 | * 38 | * The coordinates will have the value 0. 39 | */ 40 | public Position2D() { 41 | } 42 | 43 | /** 44 | * Initializes a relative position with given coordinates. 45 | * 46 | * @param x the x coordinate, @see {@link Position2D#getX()} 47 | * @param y the y coordinate, @see {@link Position2D#getY()} 48 | */ 49 | public Position2D(final int x, final int y) { 50 | this.x.set(x); 51 | this.y.set(y); 52 | } 53 | 54 | /** 55 | * @see Position2D#getX() 56 | * @return the property 57 | */ 58 | public DoubleProperty xProperty() { 59 | return x; 60 | } 61 | 62 | /** 63 | * @see Position2D#getY() 64 | * @return the property 65 | */ 66 | public DoubleProperty yProperty() { 67 | return y; 68 | } 69 | 70 | /** 71 | * 72 | * @return the relative x value. This must be a value between 0 (as left as possible) and 1 (as right as possible). 73 | */ 74 | public double getX() { 75 | return x.get(); 76 | } 77 | 78 | /** 79 | * @see Position2D#getX() 80 | * @param x the new x coordinate 81 | */ 82 | public void setX(final double x) { 83 | this.x.set(x); 84 | } 85 | 86 | /** 87 | * 88 | * @return the relative y value. This must be a value between 0 (as up as possible) and 1 (as down as possible). 89 | */ 90 | public double getY() { 91 | return y.get(); 92 | } 93 | 94 | /** 95 | * @see Position2D#getY() 96 | * @param y the new y coordinate 97 | */ 98 | public void setY(final double y) { 99 | this.y.set(y); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/Value.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.commands; 21 | 22 | import java.util.UUID; 23 | 24 | /** 25 | * A value for properties and collections which is either an observable object or a simple object. 26 | */ 27 | public class Value { 28 | 29 | private final UUID observableObjectId; 30 | private final Object simpleObjectValue; 31 | 32 | /** 33 | * Initializes an instance that wrappes an observable object. 34 | * 35 | * @param observableObjectID 36 | * The id of the wrapped observable object. 37 | */ 38 | public Value(final UUID observableObjectID) { 39 | this.observableObjectId = observableObjectID; 40 | this.simpleObjectValue = null; 41 | } 42 | 43 | /** 44 | * Initializes an instance that wrapps a simple object. 45 | * 46 | * @param simpleObjectValue 47 | * The simple object that is wrapped. 48 | */ 49 | public Value(final Object simpleObjectValue) { 50 | this.observableObjectId = null; 51 | this.simpleObjectValue = simpleObjectValue; 52 | } 53 | 54 | /** 55 | * @return If this instance denotes an observable object this returns the id of this object. If this 56 | * instance denotes a simple object this method returns null. 57 | */ 58 | public UUID getObservableObjectId() { 59 | return observableObjectId; 60 | } 61 | 62 | /** 63 | * @return If this instance denotes a simple object this returns the value object. If this instance denotes 64 | * an observable object this method returns null. 65 | */ 66 | public Object getSimpleObjectValue() { 67 | return simpleObjectValue; 68 | } 69 | 70 | /** 71 | * Checks if this value wrapper stores a simple object. 72 | * 73 | * @return true if it wrapps a simple object and false if it wrapps an observable object. 74 | */ 75 | public boolean isSimpleObject() { 76 | return simpleObjectValue != null; 77 | } 78 | 79 | @Override 80 | public String toString() { 81 | return "Value [observableObjectId=" + observableObjectId + ", simpleObjectValue=" + simpleObjectValue + "]"; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/SimpleSingleValuePropertyCommandExecutor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.executors; 21 | 22 | import javafx.beans.property.Property; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.SilentChangeExecutor; 25 | import de.saxsys.synchronizefx.core.metamodel.ValueMapper; 26 | import de.saxsys.synchronizefx.core.metamodel.WeakObjectRegistry; 27 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 28 | import de.saxsys.synchronizefx.core.metamodel.commands.SetPropertyValue; 29 | import de.saxsys.synchronizefx.core.metamodel.commands.Value; 30 | 31 | /** 32 | * Executes all {@link Command}s that are passed to it on the users domain model without any filtering. 33 | * 34 | * @author Raik Bieniek 35 | */ 36 | public class SimpleSingleValuePropertyCommandExecutor implements SingleValuePropertyCommandExecutor { 37 | 38 | private final WeakObjectRegistry objectRegistry; 39 | private final SilentChangeExecutor changeExecutor; 40 | private final ValueMapper valueMapper; 41 | 42 | /** 43 | * Initializes the instance with all its dependencies. 44 | * 45 | * @param objectRegistry 46 | * the registry that stores all known observable objects. 47 | * @param valueMapper 48 | * Used to map {@link Value} massages to the actual value of a property. 49 | * @param changeExecutor 50 | * Used to prevent generation of change commands when doing changes to the users domain model. 51 | */ 52 | public SimpleSingleValuePropertyCommandExecutor(final WeakObjectRegistry objectRegistry, 53 | final SilentChangeExecutor changeExecutor, final ValueMapper valueMapper) { 54 | this.objectRegistry = objectRegistry; 55 | this.changeExecutor = changeExecutor; 56 | this.valueMapper = valueMapper; 57 | } 58 | 59 | @Override 60 | public void execute(final SetPropertyValue command) { 61 | @SuppressWarnings("unchecked") 62 | final Property property = (Property) objectRegistry.getByIdOrFail(command.getPropertyId()); 63 | 64 | changeExecutor.execute(property, new Runnable() { 65 | @Override 66 | public void run() { 67 | property.setValue(valueMapper.map(command.getValue())); 68 | } 69 | }); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/clientserver/NetworkToTopologyCallbackServer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.clientserver; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | 27 | /** 28 | * This is an callback interface for the network library to inform the upper layer of incoming events like commands 29 | * or new clients. 30 | * 31 | * This is the interface for the server side. For the client side use {@link NetworkToTopologyCallbackClient}. 32 | * 33 | * @author Raik Bieniek 34 | */ 35 | public interface NetworkToTopologyCallbackServer { 36 | 37 | /** 38 | * Commands were received. 39 | * 40 | * @param commands The commands received. 41 | * @param sender An object that represents the sender of the commands. 42 | */ 43 | void recive(List commands, Object sender); 44 | 45 | /** 46 | * A new client connected. 47 | * 48 | * @param newClient an object that represents the new client. 49 | */ 50 | void onConnect(Object newClient); 51 | 52 | /** 53 | * An error in the connection to some client occurred. 54 | * 55 | * When this method is called, the connection to the problematic client has to be already be terminated. The 56 | * server must still be working. If not use 57 | * {@link NetworkToTopologyCallbackServer#onFatalError(SynchronizeFXException)} instead. 58 | * 59 | * @param client An object that represents the client where the error occurred. 60 | * @param e an exception that describes the problem. 61 | */ 62 | void onClientConnectionError(Object client, SynchronizeFXException e); 63 | 64 | /** 65 | * A fatal error that made the server shut down. 66 | * 67 | * When this method is called, the server came across an error that made it impossible to continue the normal 68 | * operation. The connection to all remaining clients must already be closed and the server be shutdown. 69 | * 70 | * This method must only be called after the server successfully started. If an error occurred while trying to 71 | * start up, throw an exception there. 72 | * 73 | * @param e an exception that describes the problem. 74 | */ 75 | void onFatalError(SynchronizeFXException e); 76 | } 77 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/ValueMapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | import java.util.UUID; 23 | 24 | import de.saxsys.synchronizefx.core.exceptions.ObjectToIdMappingException; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | import de.saxsys.synchronizefx.core.metamodel.commands.Value; 27 | 28 | /** 29 | * Maps the {@link Value} parts of {@link Command}s to the values they describe. 30 | */ 31 | public class ValueMapper { 32 | 33 | private final WeakObjectRegistry objectRegistry; 34 | 35 | /** 36 | * Initializes an instance. 37 | * 38 | * @param objectRegistry 39 | * used to retrieve observable objects from the model registry. 40 | */ 41 | public ValueMapper(final WeakObjectRegistry objectRegistry) { 42 | this.objectRegistry = objectRegistry; 43 | } 44 | 45 | /** 46 | * Maps a {@link Value} message to the {@link Object} it describes. 47 | * 48 | * @param message 49 | * the message to map 50 | * @return The observed value 51 | * @throws ObjectToIdMappingException 52 | * When the value described it he message is unknown in the {@link MetaModel}. 53 | */ 54 | public Object map(final Value message) throws ObjectToIdMappingException { 55 | final UUID valueId = message.getObservableObjectId(); 56 | if (valueId != null) { 57 | return objectRegistry.getByIdOrFail(valueId); 58 | } else { 59 | return message.getSimpleObjectValue(); 60 | } 61 | } 62 | 63 | /** 64 | * Maps observable or simple objects to {@link Value} messages. 65 | * 66 | * @param value 67 | * The observed value to map. 68 | * @param isObservable 69 | * If the value is an observable object or a simple object 70 | * @return The message. 71 | * @throws ObjectToIdMappingException 72 | * When value wraps an observable object which has not been assigned an id yet. 73 | */ 74 | public Value map(final Object value, final boolean isObservable) throws ObjectToIdMappingException { 75 | if (isObservable) { 76 | return new Value(objectRegistry.getIdOrFail(value)); 77 | } else { 78 | return new Value(value); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/TopologyLayerCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 26 | 27 | /** 28 | * This is an callback interface for the meta model. 29 | * 30 | * The meta model uses it to inform the underlying layer on several events like new commands that have to be transfered 31 | * to other peers or that an error occurred in the meta model layer. 32 | * 33 | * @author Raik Bieniek 34 | */ 35 | public interface TopologyLayerCallback { 36 | 37 | /** 38 | * Called when the meta model layer has produced commands that need to be shared with other meta models. 39 | * 40 | *

41 | * This method should not block as this may could block the GUI thread. The order of the commands passed in 42 | * sequential calls to this methods however needs to be retained. 43 | *

44 | * 45 | *

46 | * When you've called {@link MetaModel#commandsForDomainModel(CommandsForDomainModelCallback)} to get the initial 47 | * domain model for a new peer, you don't need to send the commands from this method to this peer as long as your 48 | * callback {@link CommandsForDomainModelCallback#commandsReady(List)} has not been called. They are incorporated 49 | * automatically. 50 | *

51 | * 52 | * @param commands 53 | * The commands that need to be shared. 54 | */ 55 | void sendCommands(List commands); 56 | 57 | /** 58 | * Called when the domain model has changed. 59 | * 60 | * This method is most probably called only once. That is when the initial domain model has been transfered 61 | * completely to a peer. 62 | * 63 | * @param root 64 | * The root object of the new domain model. 65 | */ 66 | void domainModelChanged(Object root); 67 | 68 | /** 69 | * Called when an error occurred in the meta model layer. 70 | * 71 | * If an error occurred, synchronicity between clients can no longer be guaranteed. In some cases the meta model can 72 | * still be used and the error be ignored. 73 | * 74 | * @param error 75 | * The exception that caused the error. 76 | */ 77 | void onError(SynchronizeFXException error); 78 | } 79 | -------------------------------------------------------------------------------- /synchronizefx/src/test/java/de/saxsys/synchronizefx/testapp/ExampleServer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.testapp; 21 | 22 | import de.saxsys.synchronizefx.core.clientserver.ServerCallback; 23 | import de.saxsys.synchronizefx.core.clientserver.SynchronizeFxServer; 24 | import de.saxsys.synchronizefx.core.exceptions.SynchronizeFXException; 25 | import de.saxsys.synchronizefx.kryo.KryoSerializer; 26 | import de.saxsys.synchronizefx.netty.tcp.NettyServer; 27 | 28 | import org.slf4j.Logger; 29 | import org.slf4j.LoggerFactory; 30 | 31 | /** 32 | * 33 | * A server that provides messages, which contain a simple text. 34 | * 35 | * @author ragna-diana.steglich 36 | * 37 | */ 38 | public class ExampleServer implements ServerCallback { 39 | 40 | private static final Logger LOG = LoggerFactory.getLogger(ExampleServer.class); 41 | private static final int DEFAULT_PORT = 54263; 42 | 43 | private int port = DEFAULT_PORT; 44 | private KryoSerializer serializer = new KryoSerializer(); 45 | private SynchronizeFxServer server; 46 | private MessageContainer container; 47 | 48 | /** 49 | * Creates a new MessageContainer, adds several messages to this container and starts the server. 50 | */ 51 | public ExampleServer() { 52 | container = new MessageContainer(); 53 | addNewMessage("this is a message"); 54 | addNewMessage("it's a new message"); 55 | addNewMessage("can it be a message?"); 56 | 57 | startSynchronizeFX(); 58 | } 59 | 60 | /** 61 | * Shuts down the {@link SynchronizeFXServer}. 62 | */ 63 | public void shutdownServer() { 64 | server.shutdown(); 65 | } 66 | 67 | @Override 68 | public void onError(final SynchronizeFXException error) { 69 | LOG.error("A SynchronizeFX error occured. Terminating the server now.", error); 70 | System.exit(-1); 71 | } 72 | 73 | @Override 74 | public void onClientConnectionError(final Object client, final SynchronizeFXException error) { 75 | LOG.warn("A client connection error occured.", error); 76 | } 77 | 78 | private void addNewMessage(final String text) { 79 | Message message = new Message(); 80 | message.setText(text); 81 | 82 | this.container.getMessages().add(message); 83 | } 84 | 85 | private void startSynchronizeFX() { 86 | NettyServer netty = new NettyServer(port, serializer); 87 | server = new SynchronizeFxServer(container, netty, this); 88 | server.start(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/websockets/ByteBufToWebSocketFrameCodec.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.websockets; 21 | 22 | import java.util.LinkedList; 23 | import java.util.List; 24 | 25 | import io.netty.buffer.ByteBuf; 26 | import io.netty.buffer.Unpooled; 27 | import io.netty.channel.ChannelHandlerContext; 28 | import io.netty.handler.codec.MessageToMessageCodec; 29 | import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; 30 | import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; 31 | import io.netty.handler.codec.http.websocketx.WebSocketFrame; 32 | 33 | import org.slf4j.Logger; 34 | import org.slf4j.LoggerFactory; 35 | 36 | /** 37 | * A codec that collects coherent messages as {@link ByteBuf}s by using {@link BinaryWebSocketFrame}s. 38 | * 39 | * @author Raik Bieniek 40 | */ 41 | class ByteBufToWebSocketFrameCodec extends MessageToMessageCodec { 42 | 43 | private static final ByteBuf[] BYTE_BUF_TYPE = new ByteBuf[0]; 44 | private static final Logger LOG = LoggerFactory.getLogger(ByteBufToWebSocketFrameCodec.class); 45 | 46 | private final List fragments = new LinkedList<>(); 47 | 48 | /** 49 | * Initializes the codec. 50 | */ 51 | ByteBufToWebSocketFrameCodec() { 52 | } 53 | 54 | @Override 55 | protected void encode(final ChannelHandlerContext ctx, final ByteBuf msg, final List out) throws Exception { 56 | out.add(new BinaryWebSocketFrame(msg)); 57 | } 58 | 59 | @Override 60 | protected void decode(final ChannelHandlerContext ctx, final WebSocketFrame msg, final List out) 61 | throws Exception { 62 | if (msg instanceof BinaryWebSocketFrame) { 63 | ByteBuf content = msg.content(); 64 | // the content is passed to other handlers so they need to be retained. 65 | content.retain(); 66 | fragments.add(content); 67 | if (msg.isFinalFragment()) { 68 | if (fragments.size() == 1) { 69 | out.add(fragments.get(0)); 70 | } else { 71 | ByteBuf[] array = fragments.toArray(BYTE_BUF_TYPE); 72 | out.add(Unpooled.wrappedBuffer(array)); 73 | } 74 | fragments.clear(); 75 | } 76 | } else if (msg instanceof TextWebSocketFrame) { 77 | LOG.warn("Recieved a Websocket text frame. This was not expected. Ignoring it."); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/executors/CommandLogDispatcher.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel.executors; 21 | 22 | import java.util.List; 23 | 24 | import de.saxsys.synchronizefx.core.metamodel.commands.Command; 25 | import de.saxsys.synchronizefx.core.metamodel.commands.ListCommand; 26 | import de.saxsys.synchronizefx.core.metamodel.commands.SetPropertyValue; 27 | import de.saxsys.synchronizefx.core.metamodel.executors.lists.ReparingListPropertyCommandExecutor; 28 | 29 | /** 30 | * Logs commands that where generated and send from the local peer to the server to allow model repairing based on the 31 | * servers command stream. 32 | * 33 | *

34 | * This class dispatches the local commands to the different executors which are interested in them. 35 | *

36 | * 37 | * @author Raik Bieniek 38 | */ 39 | public class CommandLogDispatcher { 40 | 41 | private final RepairingSingleValuePropertyCommandExecutor singleValue; 42 | private final ReparingListPropertyCommandExecutor lists; 43 | 44 | /** 45 | * Initializes this dispatcher with all executers that are interested in commands. 46 | * 47 | * @param singleValue 48 | * The executor for single-value-property change commands. 49 | * @param lists 50 | * The executor for list property commands. 51 | */ 52 | public CommandLogDispatcher(final RepairingSingleValuePropertyCommandExecutor singleValue, 53 | final ReparingListPropertyCommandExecutor lists) { 54 | this.singleValue = singleValue; 55 | this.lists = lists; 56 | } 57 | 58 | /** 59 | * Creates an instance that dispatches no commands as no executors are interested in them. 60 | */ 61 | public CommandLogDispatcher() { 62 | this.singleValue = null; 63 | this.lists = null; 64 | } 65 | 66 | /** 67 | * Logs a list of locally generated commands that is sent to the server. 68 | * 69 | * @param commands 70 | * The commands that where send. 71 | */ 72 | public void logLocalCommands(final List commands) { 73 | if (singleValue == null) { 74 | return; 75 | } 76 | for (final Command command : commands) { 77 | if (command instanceof SetPropertyValue) { 78 | singleValue.logLocalCommand((SetPropertyValue) command); 79 | } else if (command instanceof ListCommand) { 80 | lists.logLocalCommand((ListCommand) command); 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /synchronizefx-core/src/test/java/de/saxsys/synchronizefx/core/metamodel/ChangesWhileConnectIT.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.core.metamodel; 21 | 22 | import org.junit.Ignore; 23 | import org.junit.Test; 24 | 25 | 26 | /** 27 | * These tests ensure that the tests in {@link ChangeWhileConnectTest} and the code it tests are reliable when they are 28 | * run often. 29 | * 30 | * @author Raik Bieniek 31 | */ 32 | @Ignore("Tests fail sporadically") 33 | public class ChangesWhileConnectIT { 34 | 35 | /** 36 | * How often every single test should be executed. 37 | */ 38 | private static final int EXECUTION_COUNT = 1000; 39 | 40 | /** 41 | * @see ChangeWhileConnectTest#testChangeWhileWalking(). 42 | */ 43 | @Test 44 | public void testChangeWhileWalking() { 45 | for (int i = 0; i < EXECUTION_COUNT; i++) { 46 | initializedChangeWhileConnectTest().testChangeWhileWalking(); 47 | } 48 | } 49 | 50 | /** 51 | * @see ChangeWhileConnectTest#testRemoveOfObjectThatWasntCreated(). 52 | */ 53 | @Test 54 | public void testRemoveOfObjectThatWasntCreated() { 55 | for (int i = 0; i < EXECUTION_COUNT; i++) { 56 | initializedChangeWhileConnectTest().testRemoveOfObjectThatWasntCreated(); 57 | } 58 | } 59 | 60 | /** 61 | * @see ChangeWhileConnectTest#testProvokeConcurentModificationExceptionByListIterateors(). 62 | */ 63 | @Test 64 | public void testProvokeConcurentModificationExceptionByListIterateors() { 65 | for (int i = 0; i < EXECUTION_COUNT; i++) { 66 | initializedChangeWhileConnectTest().testProvokeConcurentModificationExceptionByListIterateors(); 67 | } 68 | } 69 | 70 | /** 71 | * @see ChangeWhileConnectTest#testSynchronizeChangesAfterWalkingBeforeSending(). 72 | */ 73 | @Test 74 | public void testSynchronizeChangesAfterWalkingBeforeSending() { 75 | for (int i = 0; i < EXECUTION_COUNT; i++) { 76 | initializedChangeWhileConnectTest().testSynchronizeChangesAfterWalkingBeforeSending(); 77 | } 78 | } 79 | 80 | /** 81 | * @see ChangeWhileConnectTest#testIncommingChanges(). 82 | */ 83 | @Test 84 | public void testIncommingChanges() { 85 | for (int i = 0; i < EXECUTION_COUNT; i++) { 86 | initializedChangeWhileConnectTest().testIncommingChanges(); 87 | } 88 | } 89 | 90 | private ChangeWhileConnectTest initializedChangeWhileConnectTest() { 91 | ChangeWhileConnectTest test = new ChangeWhileConnectTest(); 92 | test.init(); 93 | return test; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /transmitter/netty-transmitter/src/main/java/de/saxsys/synchronizefx/netty/websockets/WhiteSpaceInPathWebSocketClientHandshaker13.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx.netty.websockets; 21 | 22 | import java.net.URI; 23 | 24 | import io.netty.handler.codec.http.FullHttpRequest; 25 | import io.netty.handler.codec.http.HttpHeaders; 26 | import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13; 27 | import io.netty.handler.codec.http.websocketx.WebSocketVersion; 28 | 29 | /** 30 | * A Websocket handshaker that handles encoded spaces in the URI path correctly. 31 | * 32 | *

33 | * This is a workaround for Netty issue 4505. 34 | *

35 | * 36 | * @author Raik Bieniek 37 | */ 38 | public class WhiteSpaceInPathWebSocketClientHandshaker13 extends WebSocketClientHandshaker13 { 39 | 40 | // CHECKSTYLE:OFF constructor is too long. 41 | /** 42 | * Initializes an instance with all is dependencies. 43 | * 44 | * @param webSocketURL see 45 | * {@link WebSocketClientHandshaker13#WebSocketClientHandshaker13(URI, WebSocketVersion, String, boolean, HttpHeaders, int)} 46 | * @param version see 47 | * {@link WebSocketClientHandshaker13#WebSocketClientHandshaker13(URI, WebSocketVersion, String, boolean, HttpHeaders, int)} 48 | * @param subprotocol see 49 | * {@link WebSocketClientHandshaker13#WebSocketClientHandshaker13(URI, WebSocketVersion, String, boolean, HttpHeaders, int)} 50 | * @param allowExtensions see 51 | * {@link WebSocketClientHandshaker13#WebSocketClientHandshaker13(URI, WebSocketVersion, String, boolean, HttpHeaders, int)} 52 | * @param customHeaders see 53 | * {@link WebSocketClientHandshaker13#WebSocketClientHandshaker13(URI, WebSocketVersion, String, boolean, HttpHeaders, int)} 54 | * @param maxFramePayloadLength see 55 | * {@link WebSocketClientHandshaker13#WebSocketClientHandshaker13(URI, WebSocketVersion, String, boolean, HttpHeaders, int)} 56 | */ 57 | // CHECKSTYLE:ON constructor is too long. 58 | public WhiteSpaceInPathWebSocketClientHandshaker13(final URI webSocketURL, final WebSocketVersion version, 59 | final String subprotocol, final boolean allowExtensions, final HttpHeaders customHeaders, 60 | final int maxFramePayloadLength) { 61 | super(webSocketURL, version, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength); 62 | } 63 | 64 | @Override 65 | protected FullHttpRequest newHandshakeRequest() { 66 | FullHttpRequest request = super.newHandshakeRequest(); 67 | request.setUri(super.uri().getRawPath()); 68 | return request; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /synchronizefx/src/main/java/de/saxsys/synchronizefx/OptionalStep.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of SynchronizeFX. 3 | * 4 | * Copyright (C) 2013-2014 Saxonia Systems AG 5 | * 6 | * SynchronizeFX is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * SynchronizeFX is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with SynchronizeFX. If not, see . 18 | */ 19 | 20 | package de.saxsys.synchronizefx; 21 | 22 | import java.util.concurrent.Executor; 23 | 24 | import com.esotericsoftware.kryo.Serializer; 25 | 26 | /** 27 | * Base interface for all steps that are optional and can be used for both the server and the client. 28 | * 29 | * @param The return type for the step methods. This has to be the extending interface itself. 30 | */ 31 | public interface OptionalStep { 32 | 33 | /** 34 | * Sets a custom port that differs from the default port 54263. 35 | * 36 | * @param port The port to connect if used for the client or the port on listen when used on server side. 37 | * @return The builder to provide a fluent API. 38 | */ 39 | K port(int port); 40 | 41 | /** 42 | * Sets a custom serializer for some {@link Class}. 43 | * 44 | *

45 | * Internally Kryo is used for the serialization and deserialization of objects. You do not need to register 46 | * serializers for every class you use in your domain model but in some cases this is desirable. Registering 47 | * custom serializers can be necessary when you use classes without a No-Arg constructor or to increase the 48 | * performance and decrease the network usage. 49 | *

50 | * 51 | *

52 | * An efficient serializer for {@link java.util.UUID} is already registered. 53 | *

54 | * 55 | * @param clazz The class for that the serializer should be registered. 56 | * @param same as clazz. 57 | * @param serializer The serializer to register. 58 | * @return The builder to provide a fluent API. 59 | */ 60 | K customSerializer(final Class clazz, final Serializer serializer); 61 | 62 | /** 63 | * Sets a custom executor for changes done on the domain model. 64 | * 65 | *

66 | * This method allows to set a custom executor that should be used by SynchronizeFX for all changes done to the 67 | * JavaFX properties in the domain model. 68 | *

69 | * 70 | *

71 | * If this method is not used, SynchronizeFX will uses an {@link Executor} for clients that executes all changes 72 | * in the JavaFX thread (see {@link javafx.application.Platform#runLater(Runnable)}. For servers an 73 | * {@link Executor} is used, that executes all changes in the network thread that received them. 74 | *

75 | * 76 | *

77 | * This functionality is useful for Non-GUI clients that do not have a JavaFX thread for example. 78 | *

79 | * 80 | * @param executor The executor to user for changes done on the domain model. 81 | * @return The builder to provide a fluent API. 82 | */ 83 | K modelChangeExecutor(final Executor executor); 84 | } 85 | --------------------------------------------------------------------------------