Symmetric DS and Java

白昼怎懂夜的黑 提交于 2020-01-05 05:19:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!