@ProviderType public abstract class AbstractSlingRepositoryManager extends NamespaceMappingSupport
AbstractSlingRepositoryManager
is the basis for controlling
the JCR repository instances used by Sling. As a manager it starts and stops
the actual repository instance, manages service registration and hands out
SlingRepository
instances to be used by the consumers.
This base class controls the livecycle of repository instance whereas implementations of this class provide actual integration into the runtime context. The livecycle of the repository instance is defined as follows:
To start the repository instance, the implemetation calls the
start(BundleContext, String, boolean)
method which goes through the
steps of instantiating the repository, setting things up, and registering the
repository as an OSGi service:
acquireRepository()
create(Bundle)
NamespaceMappingSupport.setup(BundleContext, SlingRepository)
registerService()
To stop the repository instance, the implementation calls the stop()
method which goes through the setps of unregistering the OSGi service,
tearing all special settings down and finally shutting down the repository:
unregisterService(ServiceRegistration)
NamespaceMappingSupport.tearDown()
destroy(AbstractSlingRepository2)
disposeRepository(Repository)
Instances of this class manage a single repository instance backing the OSGi service instances. Each consuming bundle, though, gets its own service instance backed by the single actual repository instance managed by this class.
AbstractSlingRepository2
Constructor and Description |
---|
AbstractSlingRepositoryManager() |
Modifier and Type | Method and Description |
---|---|
protected abstract javax.jcr.Repository |
acquireRepository()
Creates the backing JCR repository instances.
|
protected abstract AbstractSlingRepository2 |
create(org.osgi.framework.Bundle usingBundle)
Creates an instance of the
AbstractSlingRepository2
implementation for use by the given usingBundle . |
protected abstract void |
destroy(AbstractSlingRepository2 repositoryServiceInstance)
Cleans up the given
AbstractSlingRepository2 instance previously
created by the create(Bundle) method. |
protected abstract void |
disposeRepository(javax.jcr.Repository repository)
Disposes off the given
repository . |
String |
getDefaultWorkspace()
Returns the default workspace, which may be
null meaning to
use the repository provided default workspace. |
protected javax.jcr.Repository |
getRepository()
Returns the repository underlying this instance or
null if
no repository is currently being available. |
protected String[] |
getServiceRegistrationInterfaces()
Returns the service types to be used to register the repository service
in
registerService() . |
protected abstract Dictionary<String,Object> |
getServiceRegistrationProperties()
Return the service registration properties to be used to register the
repository service in
registerService() . |
protected abstract ServiceUserMapper |
getServiceUserMapper()
Returns the
ServiceUserMapper service to map the service name to
a service user name. |
boolean |
isDisableLoginAdministrative()
Returns whether to disable the
SlingRepository.loginAdministrative method or not. |
protected org.osgi.framework.ServiceRegistration |
registerService()
Registers this component as an OSGi service with the types provided by
the
getServiceRegistrationInterfaces() method and properties
provided by the getServiceRegistrationProperties() method. |
protected boolean |
start(org.osgi.framework.BundleContext bundleContext,
String defaultWorkspace,
boolean disableLoginAdministrative)
This method actually starts the backing repository instannce and
registeres the repository service.
|
protected void |
stop()
This method must be called if overwritten by implementations !!
|
protected void |
unregisterService(org.osgi.framework.ServiceRegistration serviceRegistration)
Unregisters the service represented by the
serviceRegistration . |
getNamespaceAwareSession, getNamespaceMapperServices, setup, tearDown
public final String getDefaultWorkspace()
null
meaning to
use the repository provided default workspace.null
indicating the repository's
default workspace is actually used.public final boolean isDisableLoginAdministrative()
SlingRepository.loginAdministrative
method or not.true
if SlingRepository.loginAdministrative
is
disabled.protected abstract ServiceUserMapper getServiceUserMapper()
ServiceUserMapper
service to map the service name to
a service user name.
The ServiceUserMapper
is used to implement the
AbstractSlingRepository2.loginService(String, String)
method used
to replace the
AbstractSlingRepository2.loginAdministrative(String)
method. If
this method returns null
and hence the
ServiceUserMapperService
is not available, the
loginService
method is not able to login.
ServiceUserMapper
service or null
if not
available.AbstractSlingRepository2.loginService(String, String)
protected abstract javax.jcr.Repository acquireRepository()
This method does not throw any Throwable
but instead just
returns null
if not repository is available. Any problems
trying to acquire the repository must be caught and logged as
appropriate.
Repository
or null
if
not repository can be acquired.start(BundleContext, String, boolean)
protected final org.osgi.framework.ServiceRegistration registerService()
getServiceRegistrationInterfaces()
method and properties
provided by the getServiceRegistrationProperties()
method.
The repository is actually registered as an OSGi ServiceFactory
where the create(Bundle)
method is called to create an actual
AbstractSlingRepository2
repository instance for a calling
(using) bundle. When the bundle is done using the repository instance,
the destroy(AbstractSlingRepository2)
method is called to clean
up.
ServiceRegistration
object representing the
registered service.start(BundleContext, String, boolean)
,
getServiceRegistrationInterfaces()
,
getServiceRegistrationProperties()
,
create(Bundle)
,
destroy(AbstractSlingRepository2)
protected abstract Dictionary<String,Object> getServiceRegistrationProperties()
registerService()
.registerService()
registerService()
protected String[] getServiceRegistrationInterfaces()
registerService()
. All interfaces returned must be accessible
to the class loader of the class of this instance.
This method may be overwritten to return additional types but the types
returned from this base implementation, SlingRepository
and
Repository
, must always be included.
registerService()
registerService()
protected abstract AbstractSlingRepository2 create(org.osgi.framework.Bundle usingBundle)
AbstractSlingRepository2
implementation for use by the given usingBundle
.
This method is called when the repository service is requested from within the using bundle for the first time.
This method is expected to return a new instance on every call.
usingBundle
- The bundle providing from which the repository is
requested.AbstractSlingRepository2
implementation instance to
be used by the usingBundle
.registerService()
protected abstract void destroy(AbstractSlingRepository2 repositoryServiceInstance)
AbstractSlingRepository2
instance previously
created by the create(Bundle)
method.repositoryServiceInstance
- The AbstractSlingRepository2
istance to cleanup.registerService()
protected final javax.jcr.Repository getRepository()
null
if
no repository is currently being available.protected final void unregisterService(org.osgi.framework.ServiceRegistration serviceRegistration)
serviceRegistration
.serviceRegistration
- The service to unregisterprotected abstract void disposeRepository(javax.jcr.Repository repository)
repository
.repository
- The repository to be disposed off which is the same as
the one returned from acquireRepository()
.protected final boolean start(org.osgi.framework.BundleContext bundleContext, String defaultWorkspace, boolean disableLoginAdministrative)
Multiple subsequent calls to this method without calling stop()
first have no effect.
bundleContext
- The BundleContext
to register the repository
service (and optionally more services required to operate the
repository)defaultWorkspace
- The name of the default workspace to use to
login. This may be null
to have the actual repository
instance define its own defaultdisableLoginAdministrative
- Whether to disable the
SlingRepository.loginAdministrative
method or not.true
if the repository has been started and the service
is registered.protected final void stop()
Copyright © 2015 The Apache Software Foundation. All rights reserved.