SC
- A subclass of AbstractSynchroContext
specialized for subclasses.public abstract class AbstractSynchroService<SC extends AbstractSynchroContext> extends Object
Constructor and Description |
---|
AbstractSynchroService() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
applyAction(SC context,
String path,
AbstractSynchroContext.SynchroAction action)
Apply the action required for the path.
|
protected void |
applyActions(SC context)
Call
#applyAction(AbstractSynchroContext, String, SynchroAction) for each path with a required action. |
protected AbstractSynchroContext.SynchroAction |
defineAction(SC context,
String path)
Called to define the required action for the specified path.
|
protected void |
defineActions(SC context)
Called in the synchro process.
|
abstract String |
getDistantName()
Get the name of the distant side.
|
abstract String |
getLocalName()
Get the name of the local side.
|
protected void |
initializeContext(SC context,
Object previousState)
Initialize the context.
|
protected abstract SC |
newSynchroContext()
Instanciate a context for ONE synchro run.
|
protected void |
onActionsApplied(SC context)
Called when all actions are applied.
|
protected void |
onActionsDefined(SC context)
Called when all paths are analysed and required actions defined.
|
protected void |
onFatalException(SC context,
SynchroFatalException ex)
Called when an
SynchroFatalException is thrown during the synchro process. |
protected void |
onNonFatalException(SC context,
SynchroNonFatalException ex,
String currentFilePath)
Called when an
SynchroNonFatalException is thrown during the synchro process. |
protected void |
onShutdown(SC context)
Called every time a synchro run is finished even if a
SynchroFatalException is thrown. |
protected void |
onUncaughtException(SC context,
Throwable ex)
Called when an exception is thrown during the synchro process.
|
boolean |
synchronize()
The synchronisation process main method.
|
public static Logger logger
public abstract String getLocalName()
public abstract String getDistantName()
public boolean synchronize()
true
if the synchronisation ended without error.protected void initializeContext(SC context, Object previousState) throws SynchroFatalException
context
- previousState
- SynchroFatalException
protected abstract SC newSynchroContext()
AbstractSynchroContext
specialized for the current AbstractSynchroService
implementation.protected void defineActions(SC context) throws SynchroFatalException
defineAction(AbstractSynchroContext, String)
for each path and AbstractSynchroContext.setAction(String, SynchroAction)
with the result.context
- the current AbstractSynchroContext
SynchroFatalException
protected AbstractSynchroContext.SynchroAction defineAction(SC context, String path) throws SynchroNonFatalException, SynchroFatalException
context
- the current AbstractSynchroContext
path
- SynchroNonFatalException
SynchroFatalException
protected void onActionsDefined(SC context)
context
- the current AbstractSynchroContext
protected void applyActions(SC context)
#applyAction(AbstractSynchroContext, String, SynchroAction)
for each path with a required action.context
- the current AbstractSynchroContext
protected abstract void applyAction(SC context, String path, AbstractSynchroContext.SynchroAction action) throws SynchroNonFatalException
context
- the current AbstractSynchroContext
path
- action
- SynchroNonFatalException
protected void onActionsApplied(SC context)
context
- the current AbstractSynchroContext
protected void onNonFatalException(SC context, SynchroNonFatalException ex, String currentFilePath)
SynchroNonFatalException
is thrown during the synchro process. Only the current file will be skipped.context
- the current AbstractSynchroContext
ex
- currentFilePath
- protected void onFatalException(SC context, SynchroFatalException ex)
SynchroFatalException
is thrown during the synchro process. This is fatal for ONE run.context
- the current AbstractSynchroContext
ex
- protected void onUncaughtException(SC context, Throwable ex)
context
- the current AbstractSynchroContext
. Can be null
if the exception is thrown during the call of newSynchroContext()
.ex
- protected void onShutdown(SC context)
SynchroFatalException
is thrown. See AbstractSynchroContext.isErrorOccured()
.
newSynchroContext()
failed.context
- the current AbstractSynchroContext
Copyright © 2012-2018. All Rights Reserved.