问题
I need to extend Symmetric DS functionality by extending the interfaces it provides. Does anyone has any idea what the development process should be? In the documentation it only explains where to put the JAR file (containing the classes extending the interfaces) and how to add them to spring context but doesnt explain how to develop them. i.e. what libraries are needed to get the interfaces and what process should be followed to develop/test. It seems very cumbersome to each time modify and build the jar file then copy it to the symmetricds server folder to test.
Does anyone has any experience with this please? thanks
回答1:
Extend the class DatabaseWriterFilterAdapter
in a default package, i.e. no package ...;
at the top of the implementation. If you need to access the db implement the interface ISymmetricEngineAware
and override its setter void setSymmetricEngine(ISymmetricEngine)
that will be called by Spring upon initialization. Name your writer filter implementation for example MyWriterFilter
.
Override either one or both methods boolean beforeWrite(DataContext, Table, CsvData)
or boolean afterWrite(DataContext, Table, CsvData)
implementing whatever transformation necessary.
Find the file ftp-extensions.xml
and in the same directory add a subdirectory conf
. Add a file symmetric-extensions.xml
to that conf
subdirectory with content:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">
<bean id="myWriterFilter" class="MyWriterFilter" />
</beans>
Test the class MyWriterFilter
as any other class with jUnit tests and with some functional tests as part of symmetricDs performing syncing for your distributed system.
来源:https://stackoverflow.com/questions/39374565/symmetric-ds-and-java