[ 
https://issues.apache.org/jira/browse/SLING-11849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17718858#comment-17718858
 ] 

Stefan Seifert commented on SLING-11849:
----------------------------------------

you're right - it's more complex than just calling 
context.bundleContext().registerService - all the static methods in 
MockOsgi.register* also do not return the service registration, so it's really 
not that easy to get hold of the service registration. i will think about a 
long-term solution as part of a bigger refactoring how components/services are 
handled in OSGi mocks, that, along with other improvements, should make it 
possible to easier get the service registrations.

> Create osgiContext#unregisterService() for easy unregistering of services
> -------------------------------------------------------------------------
>
>                 Key: SLING-11849
>                 URL: https://issues.apache.org/jira/browse/SLING-11849
>             Project: Sling
>          Issue Type: Improvement
>          Components: Testing
>    Affects Versions: Testing OSGi Mock 3.3.6
>            Reporter: Henry Kuijpers
>            Priority: Major
>
> Since we can do:
> {code:java}
> this.underTest = context.registerInjectActivateService(Test.class);
> {code}
> it would be very useful if we can also do:
> {code:java}
> context.unregisterService(this.underTest);
> {code}
> for example.
> It would be very convenient to do this, since the OSGi Mock API is easy and 
> simple to write and to be able to unregister services, it would be needed to 
> have a ServiceRegistration<Test> and also a ServiceReference<Test> to be able 
> to call .unregister() on it
> If we add this method, then all this logic can be put in this method.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to