Skip to content

Commit

Permalink
Added documentation and an INFO level log statement to list the regis…
Browse files Browse the repository at this point in the history
…tered extensions.
  • Loading branch information
chenson42 committed Jul 19, 2009
1 parent 78fbf12 commit 6f76dc0
Showing 1 changed file with 18 additions and 6 deletions.
Expand Up @@ -52,7 +52,16 @@
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

import org.springframework.context.ApplicationContext;

/**
* This {@link BeanFactoryPostProcessor} runs after all the Spring configuration files have been read to give the
* application a chance to do a bit of configuration. This is where the application will register
* {@link IExtensionPoint}s defined both by SymmetricDS and others found in the {@link ApplicationContext}.
* <P>
* SymmetricDS reads in any Spring XML file found in the classpath of the application that matches the following
* pattern: /META-INF/services/symmetric-*-ext.xml
*/
public class ExtensionProcessor implements BeanFactoryPostProcessor {

static final Log logger = LogFactory.getLog(ExtensionProcessor.class);
Expand All @@ -74,7 +83,7 @@ public class ExtensionProcessor implements BeanFactoryPostProcessor {
IRegistrationService registrationService;

ITransportManager transportManager;

IRoutingService routingService;

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -115,6 +124,9 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)

private void registerExtension(String beanName, IExtensionPoint ext) {

logger.info(String.format("Registering an extension point named '%s' of type '%s' with SymmetricDS", beanName,
ext.getClass().getSimpleName()));

if (ext instanceof ISyncUrlExtension) {
transportManager.addExtensionSyncUrlHandler(beanName, (ISyncUrlExtension) ext);
}
Expand Down Expand Up @@ -171,13 +183,13 @@ private void registerExtension(String beanName, IExtensionPoint ext) {
if (ext instanceof INodeIdGenerator) {
nodeService.setNodeIdGenerator((INodeIdGenerator) ext);
}

if (ext instanceof IDataRouter) {
routingService.addDataRouter(beanName, (IDataRouter)ext);
routingService.addDataRouter(beanName, (IDataRouter) ext);
}

if (ext instanceof IBatchAlgorithm) {
routingService.addBatchAlgorithm(beanName, (IBatchAlgorithm)ext);
routingService.addBatchAlgorithm(beanName, (IBatchAlgorithm) ext);
}
}

Expand Down

0 comments on commit 6f76dc0

Please sign in to comment.