Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UserManager to support construction of IUserServices with IRuntimeManager as a constructor parameter #1171

Merged
merged 3 commits into from
Jan 6, 2017
Merged

Update UserManager to support construction of IUserServices with IRuntimeManager as a constructor parameter #1171

merged 3 commits into from
Jan 6, 2017

Conversation

martinspielmann
Copy link
Contributor

In gitblit-crowd-plugin I make use of my own subclass of ConfigUserService.
Unfortunatelly i'm not able to get the data directory from the settings during construction, which is quite bad.

A very simple approach of supporting customized IUserServices is implemented in this PR:
Behavior at the moment:

  • Try to instantiate an IUserService with default constructor.
  • If class not found ->create ConfigUserService from conf file
  • If instantiation fails -> log error (and die... this will cause NullPointerExceptions afterwards

Newly implemented behavior:

  • Try to instantiate an IUserService with default constructor.
  • If class not found -> create ConfigUserService from conf file
  • If instantiation with default constructor fails -> Try again with constructor having IRuntimeManager as a parameter
  • If this instantiation fails also -> log error (and die... this will cause NullPointerExceptions afterwards

This way no further changes in existing UserServices are needed. New implementations will have the possibility to access all application settings by implementing a constructor like the following:

public class MyCoolUserService implements IUserService {
  public MyCoolUserService(IRuntimeManager manager){
    //do whatever you like. you know the runtimeManager now
  }
}

@gitblit
Copy link
Collaborator

gitblit commented Jan 5, 2017

I like this idea. Would you please make instantiation of a user service a new method? i.e. extract realmClass.newInstance() and your catch block into a new method.

@gitblit gitblit merged commit 5541f37 into gitblit-org:master Jan 6, 2017
@flaix flaix modified the milestone: 1.9.0 Mar 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants