Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345835

Summary: Provide a user manager that knows about its repository
Product: [Modeling] EMF Reporter: Eike Stepper <stepper>
Component: cdo.coreAssignee: Eike Stepper <stepper>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: enhancement    
Priority: P3 CC: mtaal
Version: 4.0Keywords: noteworthy
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Eike Stepper CLA 2011-05-15 05:23:00 EDT
The default implementations of IUserManager currently shipped do not know about their context. In other words, they're like singletons in their IManagedContainer.

An IElementProcessor can be used to inject an IRepository into the user manager...
Comment 1 Eike Stepper CLA 2011-05-15 06:51:14 EDT
You'll need to create your custom RepositoryUserManager and a respective custom RepositoryUserManagerFactory, e.g.:

    public class TestRepositoryUserManager extends RepositoryUserManager
    {
      @Override
      protected char[] getPassword(IRepository repository, String userID)
      {
        System.out.println(userID + " --> " + repository.getName());
        return "12345".toCharArray(); // TODO Retrieve the password from the repository
      }
    
      public static class Factory extends RepositoryUserManagerFactory
      {
        public Factory()
        {
          super("TestRepository"); // Must match the type attribute in plugin.xml
        }
    
        @Override
        protected RepositoryUserManager doCreate(String description) throws ProductCreationException
        {
          return new TestRepositoryUserManager();
        }
      }
    }

Then you register this factory in your plugin.xml:

		<extension point="org.eclipse.net4j.util.factories">
      	<factory
            productGroup="org.eclipse.net4j.userManagers"
            type="TestRepository"
            class="com.foo.bar.TestRepositoryUserManager$Factory"/>
   	</extension>

Then you can use this markup in your cdo-server.xml:

  	<repository name="repo1">
				<userManager type="TestRepository" description="repo1"/>
				...
Comment 2 Eike Stepper CLA 2011-05-15 06:54:09 EDT
Committed revision 7722
Comment 3 Eike Stepper CLA 2011-06-23 03:40:50 EDT
Available in R20110608-1407