improve changeset preprocessor api

This commit is contained in:
Sebastian Sdorra
2011-08-15 15:07:35 +02:00
parent c3b8fc8e72
commit 12299bacae
4 changed files with 31 additions and 41 deletions

View File

@@ -40,9 +40,7 @@ import sonia.scm.plugin.ExtensionPoint;
/**
*
* @author Sebastian Sdorra
* @deprecated use {@link ExtendedChangesetPreProcessor} instead.
*/
@Deprecated
@ExtensionPoint
public interface ChangesetPreProcessor
{

View File

@@ -1,10 +1,10 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
@@ -13,7 +13,7 @@
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -24,17 +24,12 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* http://bitbucket.org/sdorra/scm-manager
*
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.plugin.ExtensionPoint;
/**
@@ -43,15 +38,9 @@ import sonia.scm.plugin.ExtensionPoint;
* @since 1.7
*/
@ExtensionPoint
public interface ExtendedChangesetPreProcessor
public interface ChangesetPreProcessorFactory
{
/**
* Method description
*
*
* @param repository
* @param changeset
*/
public void process(Repository repository, Changeset changeset);
public ChangesetPreProcessor createPreProcessor(Repository repository);
}

View File

@@ -47,7 +47,7 @@ import sonia.scm.io.FileSystem;
import sonia.scm.plugin.ext.Extension;
import sonia.scm.plugin.ext.ExtensionProcessor;
import sonia.scm.repository.ChangesetPreProcessor;
import sonia.scm.repository.ExtendedChangesetPreProcessor;
import sonia.scm.repository.ChangesetPreProcessorFactory;
import sonia.scm.repository.RepositoryHandler;
import sonia.scm.repository.RepositoryHook;
import sonia.scm.repository.RepositoryListener;
@@ -106,8 +106,8 @@ public class BindingExtensionProcessor implements ExtensionProcessor
Multibinder.newSetBinder(binder, ResourceHandler.class);
Multibinder<ChangesetPreProcessor> changesetPreProcessorBinder =
Multibinder.newSetBinder(binder, ChangesetPreProcessor.class);
Multibinder<ExtendedChangesetPreProcessor> extChangesetPreProcessorBinder =
Multibinder.newSetBinder(binder, ExtendedChangesetPreProcessor.class);
Multibinder<ChangesetPreProcessorFactory> changesetPreProcessorFactoryBinder =
Multibinder.newSetBinder(binder, ChangesetPreProcessorFactory.class);
authenticators.addBinding().to(XmlAuthenticationHandler.class);
@@ -215,16 +215,16 @@ public class BindingExtensionProcessor implements ExtensionProcessor
changesetPreProcessorBinder.addBinding().to(extensionClass);
}
else if (ExtendedChangesetPreProcessor.class.isAssignableFrom(
else if (ChangesetPreProcessorFactory.class.isAssignableFrom(
extensionClass))
{
if (logger.isInfoEnabled())
{
logger.info("bind ExtendedChangesetPreProcessor {}",
logger.info("bind ChangesetPreProcessorFactory {}",
extensionClass.getName());
}
extChangesetPreProcessorBinder.addBinding().to(extensionClass);
changesetPreProcessorFactoryBinder.addBinding().to(extensionClass);
}
else if (RepositoryHook.class.isAssignableFrom(extensionClass))
{

View File

@@ -48,8 +48,8 @@ import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.ChangesetPreProcessor;
import sonia.scm.repository.ChangesetPreProcessorFactory;
import sonia.scm.repository.ChangesetViewerUtil;
import sonia.scm.repository.ExtendedChangesetPreProcessor;
import sonia.scm.repository.PathNotFoundException;
import sonia.scm.repository.Permission;
import sonia.scm.repository.PermissionType;
@@ -114,7 +114,7 @@ public class RepositoryResource
* @param repositoryManager
* @param securityContextProvider
* @param changesetPreProcessorSet
* @param extChangesetPreProcessorSet
* @param changesetPreProcessorFactorySet
* @param changesetViewerUtil
* @param repositoryBrowserUtil
*/
@@ -123,7 +123,7 @@ public class RepositoryResource
ScmConfiguration configuration, RepositoryManager repositoryManager,
Provider<WebSecurityContext> securityContextProvider,
Set<ChangesetPreProcessor> changesetPreProcessorSet,
Set<ExtendedChangesetPreProcessor> extChangesetPreProcessorSet,
Set<ChangesetPreProcessorFactory> changesetPreProcessorFactorySet,
ChangesetViewerUtil changesetViewerUtil,
RepositoryBrowserUtil repositoryBrowserUtil)
{
@@ -132,7 +132,7 @@ public class RepositoryResource
this.repositoryManager = repositoryManager;
this.securityContextProvider = securityContextProvider;
this.changesetPreProcessorSet = changesetPreProcessorSet;
this.extChangesetPreProcessorSet = extChangesetPreProcessorSet;
this.changesetPreProcessorFactorySet = changesetPreProcessorFactorySet;
this.changesetViewerUtil = changesetViewerUtil;
this.repositoryBrowserUtil = repositoryBrowserUtil;
setDisableCache(false);
@@ -220,7 +220,7 @@ public class RepositoryResource
if (Util.isNotEmpty(changesets.getChangesets()))
{
callPreProcessors(changesets);
callExtendedPreProcessors(id, changesets);
callPreProcessorFactories(id, changesets);
}
response = Response.ok(changesets).build();
@@ -401,20 +401,23 @@ public class RepositoryResource
* @param id
* @param changesets
*/
private void callExtendedPreProcessors(String id,
private void callPreProcessorFactories(String id,
ChangesetPagingResult changesets)
{
if (Util.isNotEmpty(extChangesetPreProcessorSet))
if (Util.isNotEmpty(changesetPreProcessorFactorySet))
{
Repository repository = repositoryManager.get(id);
if (repository != null)
{
for (Changeset c : changesets.getChangesets())
for (ChangesetPreProcessorFactory factory :
changesetPreProcessorFactorySet)
{
for (ExtendedChangesetPreProcessor ecpp : extChangesetPreProcessorSet)
ChangesetPreProcessor cpp = factory.createPreProcessor(repository);
for (Changeset c : changesets.getChangesets())
{
ecpp.process(repository, c);
cpp.process(c);
}
}
}
@@ -571,6 +574,9 @@ public class RepositoryResource
//~--- fields ---------------------------------------------------------------
/** Field description */
private Set<ChangesetPreProcessorFactory> changesetPreProcessorFactorySet;
/** Field description */
private Set<ChangesetPreProcessor> changesetPreProcessorSet;
@@ -580,9 +586,6 @@ public class RepositoryResource
/** Field description */
private ScmConfiguration configuration;
/** Field description */
private Set<ExtendedChangesetPreProcessor> extChangesetPreProcessorSet;
/** Field description */
private RepositoryBrowserUtil repositoryBrowserUtil;