[daisy] Get RepositoryManager from ServiceManager fails
Bruno Dumon
bruno at outerthought.org
Thu Aug 2 03:54:04 CDT 2007
On Wed, 2007-08-01 at 12:55 -0400, Kevin wrote:
> Hi,
>
> On 8/1/07, Bruno Dumon <bruno at outerthought.org> wrote:
> >
> > I'm wondering why you need access to the UserManager?
>
> I want to (potentially) update roles if certain conditions have
> changed since last login (in the check(Credentials) method).
>
> >
> > As for getting access to the repository manager, you can only get access
> > to components for which you declared a dependency, e.g. like this:
> >
> > @avalon.dependency key="repository-manager" type="org.outerj.daisy.repository.RepositoryManager"
> >
>
> Where do I declare this? I decorated my AuthenticationSchemeFactory
> service method, but it threw the same exception:
>
> /**
> * @avalon.dependency key="auth-scheme-registrar"
> *
> type="org.outerj.daisy.authentication.AuthenticationSchemeRegistrar"
> * @avalon.dependency key="repository-manager"
> * type="org.outerj.daisy.repository.RepositoryManager"
> */
> public void service(ServiceManager serviceManager) throws ServiceException {
> super.service(serviceManager);
>
> this.serviceManager = serviceManager;
>
> Repository result = getRepository(serviceManager);
> RepositoryManager repositoryManager = null;
> try {
> repositoryManager = (RepositoryManager) serviceManager
> .lookup("repository-manager");
> result = repositoryManager.getRepository(new Credentials(
> "registrar", "defaultpwd"));
> } catch (RepositoryException e) {
> e.printStackTrace();
> } finally {
> if (repositoryManager != null)
> serviceManager.release(repositoryManager);
> }
> System.out.println("DEBUG: " + result);
> }
>
> I also tried adding
>
> <dependency key="repository-manager"
> type="org.outerj.daisy.repository.RepositoryManager"/>
>
> To my .xinfo file in my JAR that contains the AuthenticationScheme,
This is a good way to do this. This .xinfo file can be generated from
the javadoc annotations, but that depends on your build setup.
> and the repository startup froze (I did a Ctrl-Break to get the thread
> dump in case you want to check to see why an invalid .xinfo file
> freezes the startup).
Ah yes, I didn't think of this: by introducing this dependency there's a
circular dependency between the repository manager and the
authenticator. So it's impossible to do it this way, so I see no
solution without modifying Daisy sources.
Your use case seems valid to me, though I would keep the check() method
free from side-effects. Maybe we can add an updateUser() method to the
AuthenticationScheme interface to support this need.
Feel free to create a jira issue for this (and a patch against trunk is
welcome too of course).
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno at outerthought.org bruno at apache.org
More information about the daisy
mailing list