[daisy] Get RepositoryManager from ServiceManager fails
Bruno Dumon
bruno at outerthought.org
Wed Aug 1 11:29:24 CDT 2007
On Wed, 2007-08-01 at 11:09 -0400, Kevin wrote:
> Hi,
>
> I am implementing a custom AuthenticationScheme, and I'm trying to get
> access to the UserManager in the check() method. To get this, I'm
> trying to get the Repository class, from which I can get the
> UserManager.
>
> There is plenty of code in daisy which does:
>
> RepositoryManager repositoryManager =
> (RepositoryManager)serviceManager.lookup("daisy-repository-manager");
>
> I have the ServiceManager from when my AuthenticationScheme gets
> registered, so I call the following code:
>
> RepositoryManager repositoryManager = null;
> Repository result = null;
> try {
> repositoryManager = (RepositoryManager)
> serviceManager.lookup("daisy-repository-manager");
> result = repositoryManager.getRepository(new Credentials("registrar",
> "defaultpwd"));
>
>
> However, this gives the following exception:
>
> org.apache.avalon.framework.service.ServiceException: Unknown key:
> daisy-repository-manager (Key='daisy-repository-manager')
> org.apache.avalon.activation.impl.DefaultServiceManager.lookup(DefaultServiceManager.java:150)
> org.apache.avalon.activation.impl.DefaultServiceManager.lookup(DefaultServiceManager.java:129)
>
> At first, this getting called at startup, since I was trying to get
> the repository earlier, but now I moved it to the check method which
> only finally gets called when a user tries to log in, and it still
> doesn't work.
>
> Does it have something to do with the fact that this is the
> "DefaultServiceManager?"
>
> All I need is the UserManager (I know I have it in the createUser
> method, but I don't need it then), so if there is another way, please
> let me know.
>
I'm wondering why you need access to the UserManager?
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"
(all this changed a lot with the new Daisy Runtime in 2.1).
--
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