Klasse AbstractRegistrationSupport
AbstractRegistrationSupport class is the base class for
registration purposes of embedded repositories.
This base class cares for synchronization issues of the
activate(ComponentContext), deactivate(ComponentContext),
bindRepository(ServiceReference) and
unbindRepository(ServiceReference) methods. Implementations of the
abstract API may safely assume to run thread-safe.
To ensure this thread-safeness, said methods should not be overwritten.
-
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected voidactivate(org.osgi.service.component.ComponentContext componentContext) Activates this component thread-safely as follows: Set the OSGi ComponentContext field CalldoActivate()Register repositores bound before activation callingbindRepository(String, Repository)for each such repository.protected voidbindLogger(org.osgi.service.log.Logger logger) Binds the Loggerprotected abstract ObjectbindRepository(String name, javax.jcr.Repository repository) Called to actually register a repository with the registry.protected voidbindRepository(org.osgi.framework.ServiceReference reference) Registers the repository identified by the OSGi service reference under the name set as service property.protected voiddeactivate(org.osgi.service.component.ComponentContext context) Deactivates this component thread-safely as follows: Unregister repositores still bound callingunbindRepository(String, Object)for each such repository.protected abstract booleanPerforms additional activation tasks.protected abstract voidPerforms additional deactivation tasks.protected org.osgi.service.component.ComponentContextReturns the OSGiComponentContextof this component.protected StringgetName(org.osgi.framework.ServiceReference reference) Returns thenameproperty from the service properties ornullif no such property exists or the property is an empty string.protected voidunbindLogger(org.osgi.service.log.Logger logger) Unbinds the Loggerprotected abstract voidunbindRepository(String name, Object data) Called to actually unregister a repository with the registry.protected voidunbindRepository(org.osgi.framework.ServiceReference reference) Unregisters the repository identified by the OSGi service reference under the name set as service property.
-
Felddetails
-
REPOSITORY_REGISTRATION_NAME
The JCR Repository service registration property used to create the registration name. If this service registration property (assumed to be a single string) does not exist, the repository is not registered.- Siehe auch:
-
logger
protected org.osgi.service.log.Logger loggerThe Logger for logging. Extensions of this class must declare the log service as a reference or call thebindLogger(Logger)to enable logging correctly. -
registryLock
A lock to serialize access to the registry management in this class.
-
-
Konstruktordetails
-
AbstractRegistrationSupport
public AbstractRegistrationSupport()
-
-
Methodendetails
-
doActivate
protected abstract boolean doActivate()Performs additional activation tasks. This method is called by theactivate(ComponentContext)method and is intended for internal setup, such as acquiring the registry.- Gibt zurück:
- Whether the activation succeeded or not. If
trueis returned, activation succeeded and any repositories which have been bound before the component was activated are now actually registered. Iffalseis returned, activation failed and this component is disabled and receives no further repository bind and unbound events (apart for unbind events for repositories which have already been bound).
-
doDeactivate
protected abstract void doDeactivate()Performs additional deactivation tasks. This method is called by thedeactivate(ComponentContext)method and is intended for internal cleanup of setup done by thedoActivate()method.This method is always called, regardless of whether
doActivate()succeeded or not. -
bindRepository
Called to actually register a repository with the registry. This method is called byactivate(ComponentContext)for any repositories bound before the component was activated and bybindRepository(ServiceReference)for any repositories bound after the component was activated.If actual registration fails, this method is expected to return
nullto indicate this fact. In this case, theunbindRepository(String, Object)will NOT be called for the named repository.This method may safely assume that it is only called on or after activation of this component on or before the component deactivation.
- Parameter:
name- The name under which the repository is to be registered.repository- Thejavax.jcr.Repositoryto register.- Gibt zurück:
- Returns an object which is later given as the
dataparameter to theunbindRepository(String, Object)method to unregister the repository of the given name. This may benullif actual registration failed.
-
unbindRepository
Called to actually unregister a repository with the registry. This method is called byunbindRepository(ServiceReference)for any repositories unbound before the component is deactivated and bydeactivate(ComponentContext)for any repositories not unbound before the component is deactivated.If the
bindRepository(String, Repository)returnednullfor when the named repository was registered, this method is not called.This method may safely assume that it is only called on or after activation of this component on or before the component deactivation.
- Parameter:
name- The name under which the repository is to be registered.data- The data object returned by thebindRepositoryInternal(String, ServiceReference)method.
-
getComponentContext
protected org.osgi.service.component.ComponentContext getComponentContext()Returns the OSGiComponentContextof this component. This method returnsnullbefore thedoActivate()method is called and after thedoDeactivate()method has been called. That is, this method does not returnnullif it is fully operational. -
getName
Returns thenameproperty from the service properties ornullif no such property exists or the property is an empty string.- Parameter:
reference- TheServiceReferencewhosenameproperty is to be returned.- Gibt zurück:
- The non-empty name property or
null.
-
activate
protected void activate(org.osgi.service.component.ComponentContext componentContext) Activates this component thread-safely as follows:- Set the OSGi ComponentContext field
- Call
doActivate() - Register repositores bound before activation calling
bindRepository(String, Repository)for each such repository.
If
doActivate()returnsfalse, the repositories already bound are not actually registered, but this component is disabled.- Parameter:
componentContext- The OSGiComponentContextof this component.
-
deactivate
protected void deactivate(org.osgi.service.component.ComponentContext context) Deactivates this component thread-safely as follows:- Unregister repositores still bound calling
unbindRepository(String, Object)for each such repository. - Call
doDeactivate() - Clear the OSGi ComponentContext field
- Parameter:
context- The OSGiComponentContextof this component.
- Unregister repositores still bound calling
-
bindRepository
protected void bindRepository(org.osgi.framework.ServiceReference reference) Registers the repository identified by the OSGi service reference under the name set as service property. If the repository service has not name property, the repository is not registered.- Parameter:
reference- TheServiceReferencerepresenting the repository to register.
-
unbindRepository
protected void unbindRepository(org.osgi.framework.ServiceReference reference) Unregisters the repository identified by the OSGi service reference under the name set as service property. If the repository service has no name property, the repository is assumed not be registered and nothing needs to be done.- Parameter:
reference- TheServiceReferencerepresenting the repository to unregister.
-
bindLogger
protected void bindLogger(org.osgi.service.log.Logger logger) Binds the Logger -
unbindLogger
protected void unbindLogger(org.osgi.service.log.Logger logger) Unbinds the Logger
-