How to override default binding in a custom plugin

Issue #283 resolved
Former user created an issue


I search to override the DefaultGroupManager to MyCustomGroupManager but I have an exception :

1) A binding to was already configured at sonia.scm.ScmServletModule.bind

My code is :

@Extension public class MyServletModule extends ServletModule {

protected void configureServlets() {





Comments (10)

  1. yop190

    Thanks that's work fine ;)

    But, have you plan to move DefaultGroupManager and DefaultUserManager to the core ? (For now I have duplicate file and I don't like this ...)

    In fact I want to extend the search feature when you use Crowd (merge the result search with local group and with crowd remote group) .

  2. Sebastian Sdorra repo owner

    Ok, i've now created a decorator api for the UserManager, GroupManager and RepositoryManager. The new api is available in the latest snapshot of version 1.23 of scm-manager. So be sure your pom uses the 1.23-SNAPSHOT version as parent.

    Here a short example to override the search method of the GroupManager:

    public class ExampleGroupManagerDecorator extends GroupManagerDecorator {
      public ExampleGroupManagerDecorator(GroupManager groupManager){
      public Collection<Group> search(SearchRequest searchRequest){
        Collection<Group> groups =;
        groups.add(new Group("example", "example-group"));
        return groups;

    To register your group manager decorator you have to create a GroupManagerDecoratorFactory with a Extension annotation. E.g.:

    public class ExampleGroupManagerDecoratorFactory implements GroupManagerDecoratorFactory {
      public GroupManager createDecorator(GroupManager groupManager)
        return new ExampleGroupManagerDecorator(groupManager);

    Could you please test this new api?

  3. yop190

    Thanks, Sebastian,

    Your code is very clean, I have written my code in few time. I'm going to propose my code to Stephan github repo.

    Let me know if you move these classes to the core, I'll update my code in this case.

  4. Log in to comment