Klasse AbstractRegistrationSupport

java.lang.Object
org.apache.sling.jcr.registration.AbstractRegistrationSupport

public abstract class AbstractRegistrationSupport extends Object
The 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
    Modifizierer und Typ
    Feld
    Beschreibung
    protected org.osgi.service.log.Logger
    The Logger for logging.
    protected final Object
    A lock to serialize access to the registry management in this class.
    static final String
    The JCR Repository service registration property used to create the registration name.
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
     
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    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.
    protected void
    bindLogger(org.osgi.service.log.Logger logger)
    Binds the Logger
    protected abstract Object
    bindRepository(String name, javax.jcr.Repository repository)
    Called to actually register a repository with the registry.
    protected void
    bindRepository(org.osgi.framework.ServiceReference reference)
    Registers the repository identified by the OSGi service reference under the name set as service property.
    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.
    protected abstract boolean
    Performs additional activation tasks.
    protected abstract void
    Performs additional deactivation tasks.
    protected org.osgi.service.component.ComponentContext
    Returns the OSGi ComponentContext of this component.
    protected String
    getName(org.osgi.framework.ServiceReference reference)
    Returns the name property from the service properties or null if no such property exists or the property is an empty string.
    protected void
    unbindLogger(org.osgi.service.log.Logger logger)
    Unbinds the Logger
    protected abstract void
    Called to actually unregister a repository with the registry.
    protected void
    unbindRepository(org.osgi.framework.ServiceReference reference)
    Unregisters the repository identified by the OSGi service reference under the name set as service property.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • REPOSITORY_REGISTRATION_NAME

      public static final String 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 logger
      The Logger for logging. Extensions of this class must declare the log service as a reference or call the bindLogger(Logger) to enable logging correctly.
    • registryLock

      protected final Object 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 the activate(ComponentContext) method and is intended for internal setup, such as acquiring the registry.
      Gibt zurück:
      Whether the activation succeeded or not. If true is returned, activation succeeded and any repositories which have been bound before the component was activated are now actually registered. If false is 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 the deactivate(ComponentContext) method and is intended for internal cleanup of setup done by the doActivate() method.

      This method is always called, regardless of whether doActivate() succeeded or not.

    • bindRepository

      protected abstract Object bindRepository(String name, javax.jcr.Repository repository)
      Called to actually register a repository with the registry. This method is called by activate(ComponentContext) for any repositories bound before the component was activated and by bindRepository(ServiceReference) for any repositories bound after the component was activated.

      If actual registration fails, this method is expected to return null to indicate this fact. In this case, the unbindRepository(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 - The javax.jcr.Repository to register.
      Gibt zurück:
      Returns an object which is later given as the data parameter to the unbindRepository(String, Object) method to unregister the repository of the given name. This may be null if actual registration failed.
    • unbindRepository

      protected abstract void unbindRepository(String name, Object data)
      Called to actually unregister a repository with the registry. This method is called by unbindRepository(ServiceReference) for any repositories unbound before the component is deactivated and by deactivate(ComponentContext) for any repositories not unbound before the component is deactivated.

      If the bindRepository(String, Repository) returned null for 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 the bindRepositoryInternal(String, ServiceReference) method.
    • getComponentContext

      protected org.osgi.service.component.ComponentContext getComponentContext()
      Returns the OSGi ComponentContext of this component. This method returns null before the doActivate() method is called and after the doDeactivate() method has been called. That is, this method does not return null if it is fully operational.
    • getName

      protected String getName(org.osgi.framework.ServiceReference reference)
      Returns the name property from the service properties or null if no such property exists or the property is an empty string.
      Parameter:
      reference - The ServiceReference whose name property 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:
      1. Set the OSGi ComponentContext field
      2. Call doActivate()
      3. Register repositores bound before activation calling bindRepository(String, Repository) for each such repository.

      If doActivate() returns false, the repositories already bound are not actually registered, but this component is disabled.

      Parameter:
      componentContext - The OSGi ComponentContext of this component.
    • deactivate

      protected void deactivate(org.osgi.service.component.ComponentContext context)
      Deactivates this component thread-safely as follows:
      1. Unregister repositores still bound calling unbindRepository(String, Object) for each such repository.
      2. Call doDeactivate()
      3. Clear the OSGi ComponentContext field
      Parameter:
      context - The OSGi ComponentContext of this component.
    • 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 - The ServiceReference representing 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 - The ServiceReference representing 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