├── .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 | # 
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 |
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