I have simple service, lets use resourceResolver and session for some logic:
@Component(immediate = true)
@Service(value = ServiceInterface.class)
public class S
The session will be automatically closed, when you close the ResourceResolver, so resourceResolver.close() is enough. You can dig into the code to find the place where this happens. If you get a session repo.loginAdministrative(), you should logout the session at the end, but this is not the recommended way to obtain a jcr session.