Use SpaceService.find(Expansion...) or SpaceManagerInternal

Hi,

I’m working on a plugin for Confluence and it uses this function to get a space :
Space space = aSpaceManager.getSpace(((PageContext) renderContext).getSpaceKey());

But as I saw in the documentation : SpaceManager (Atlassian Confluence 7.4.7 API)

It’s deprecated and I don’t understand how SpaceService or SpaceManagerInternal work…

Could you help me please ? Do you have some example ?

Thanks a lot

SpaceService can be injected, just like SpaceManager.

https://developer.atlassian.com/server/confluence/how-do-i-get-a-reference-to-a-component/

There is an example in the javadoc of the find(Expansion…) method that finds by keys

See the articles I wrote. There are 2 parts:
Get spaces by keys with the Confluence API
Get spaces by keys with the Confluence API Part 2