You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by David Leangen <os...@leangen.net> on 2018/03/12 02:20:21 UTC
Re: Felix Useradmin as service factory
Thanks, Neil,
I think the subsystem approach is a bit too heavy, as you pointed out.
Is there a means (which I could eventually submit via a pull request) that would allow the Useradmin to be configured as either a factory or a singleton?
Or is it one or the other, period.
The start() method of the Activator code looks like this:
public void start(BundleContext context) throws Exception {
m_context = createServiceContext(context);
// The actual service itself...
UserAdminImpl service = new UserAdminImpl(m_context.m_roleRepository, m_context.m_eventDispatcher);
// Register the actual service...
context.registerService(UserAdmin.class.getName(), service, null);
// Start/open all helper classes...
m_context.start();
}
Perhaps packaging as a separate bundle is the answer? So a singleton Useradmin bundle, and a factory Useradmin bundle?
Cheers,
=David
> On Feb 13, 2018, at 20:29, Neil Bartlett <nj...@gmail.com> wrote:
>
> I can't think of a way. If a bundle does not provide a service as a
> bundle-scope or prototype-scope service, you cannot force it to provide
> multiple implementations.
>
> You could go down the subsystems route in order to get multiple copies of
> the UserAdmin bundle installed into the framework. Maybe you should
> consider that as a high-level solution for what sounds like a multi-tenant
> application... but it's very heavyweight if all you want is multiple copies
> of a single service.
>
> Neil
>
> On Tue, Feb 13, 2018 at 11:13 AM, David Leangen <os...@leangen.net> wrote:
>
>>
>> Hi!
>>
>> Although my question is probably a more general OSGi question, I thought I
>> would try here first, as it is related to the Felix Useradmin…
>>
>> I intend to use multiple instances of the Useradmin. The reason is because
>> I want to host multiple (small) enterprise customers in one installation,
>> but I want to ensure safe segregation of user data. The spec seems to imply
>> that there is only one Useradmin, yet I do not see anything in the spec
>> that prohibits multiple instances of the service.
>>
>> In the Felix implementation, it is provided as a service singleton. In
>> order to do what I want, I ended up embedding the felix implementation in
>> my own bundle and wrapped it with a DS service factory component.
>>
>>
>> I don’t like depending on the implementation code.
>>
>>
>> Is there a better way?
>>
>>
>> Cheers,
>> =David
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>