| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.sling.jcr.base.AbstractSlingRepository
public abstract class AbstractSlingRepository
The AbstractSlingRepository is an abstract implementation of
 the SlingRepository interface which provides core support for session
 pooling. Implementations of the SlingRepository interface may
 wish to extend this class to benefit from a default implementation.
 
 Extensions of this class will have to declare the following
 scr.property tags to have them declared automatically in the
 respective component and metatype definitions by the maven-sling-plugin:
| Field Summary | |
|---|---|
| static java.lang.String | DEFAULT_ADMIN_PASS | 
| static java.lang.String | DEFAULT_ADMIN_USER | 
| static java.lang.String | DEFAULT_ANONYMOUS_PASS | 
| static java.lang.String | DEFAULT_ANONYMOUS_USER | 
| static int | DEFAULT_POLL_ACTIVEThe default value for the number of seconds to wait between two consecutive checks while the repository is active (value is 10). | 
| static int | DEFAULT_POLL_INACTIVEThe default value for the number of seconds to wait between two consecutive checks while the repository is not active (value is 10). | 
| static int | MIN_POLLThe minimum number of seconds allowed for any of the two poll times | 
| static java.lang.String | PROPERTY_ADMIN_PASS | 
| static java.lang.String | PROPERTY_ADMIN_USER | 
| static java.lang.String | PROPERTY_ANONYMOUS_PASS | 
| static java.lang.String | PROPERTY_ANONYMOUS_USER | 
| static java.lang.String | PROPERTY_DEFAULT_WORKSPACE | 
| static java.lang.String | PROPERTY_MAX_ACTIVE_SESSIONSThe name of the configuration parameter containing the upper limit of the simultaneously active sessions (value is "pool.maxActive"). | 
| static java.lang.String | PROPERTY_MAX_ACTIVE_SESSIONS_WAITThe name of the configuration parameter containing the maximum number of seconds to wait for the number of currently active sessions to drop be low the upper limit before giving up (value is "pool.maxActiveWait"). | 
| static java.lang.String | PROPERTY_MAX_IDLE_SESSIONSThe name of the configuration parameter containing the upper limit of the currently idle sessions to keep in the pool (value is "pool.maxIdle"). | 
| static java.lang.String | PROPERTY_POLL_ACTIVE | 
| static java.lang.String | PROPERTY_POLL_INACTIVE | 
| Fields inherited from interface javax.jcr.Repository | 
|---|
| LEVEL_1_SUPPORTED, LEVEL_2_SUPPORTED, OPTION_LOCKING_SUPPORTED, OPTION_OBSERVATION_SUPPORTED, OPTION_QUERY_SQL_SUPPORTED, OPTION_TRANSACTIONS_SUPPORTED, OPTION_VERSIONING_SUPPORTED, QUERY_XPATH_DOC_ORDER, QUERY_XPATH_POS_INDEX, REP_NAME_DESC, REP_VENDOR_DESC, REP_VENDOR_URL_DESC, REP_VERSION_DESC, SPEC_NAME_DESC, SPEC_VERSION_DESC | 
| Constructor Summary | |
|---|---|
| protected  | AbstractSlingRepository() | 
| Method Summary | |
|---|---|
| protected  javax.jcr.Repository | acquireRepository()Acquires the repository by calling the RepositoryAccessor.getRepositoryFromURL(String)with the value of theRepositoryAccessor.REPOSITORY_URL_OVERRIDE_PROPERTYframework or configuration property. | 
| protected  void | activate(org.osgi.service.component.ComponentContext componentContext)This method must be called if overwritten by implementations !! | 
| protected  void | bindLog(org.osgi.service.log.LogService log) | 
|  void | bundleChanged(org.osgi.framework.BundleEvent event)Loads and unloads any components provided by the bundle whose state changed. | 
| protected  org.apache.sling.jcr.base.internal.SessionPool | createSessionPool(org.apache.sling.jcr.base.internal.SessionPoolManager mgr,
                  javax.jcr.SimpleCredentials credentials) | 
| protected  void | deactivate(org.osgi.service.component.ComponentContext componentContext)This method must be called if overwritten by implementations !! | 
| protected  void | disposeRepository(javax.jcr.Repository repository)Disposes off the given repository. | 
| protected  org.osgi.service.component.ComponentContext | getComponentContext() | 
|  java.lang.String | getDefaultWorkspace()Returns the default workspace, which may be nullmeaning
 to use the repository provided default workspace. | 
|  java.lang.String | getDescriptor(java.lang.String name) | 
|  java.lang.String[] | getDescriptorKeys() | 
| protected  org.apache.sling.jcr.base.internal.SessionPoolManager | getPoolManager() | 
| protected  javax.jcr.Repository | getRepository()Returns the repository underlying this instance or nullif
 no repository is currently being available. | 
| protected  RepositoryAccessor | getRepositoryAccessor()Returns a new instance of the RepositoryAccessorclass to access
 a repository over RMI or through JNDI. | 
| protected  org.apache.sling.jcr.base.internal.SessionPoolFactory | getSessionPoolFactory() | 
| protected  void | log(int level,
    java.lang.String message) | 
| protected  void | log(int level,
    java.lang.String message,
    java.lang.Throwable t) | 
|  javax.jcr.Session | login()Logs in as an anonymous user. | 
|  javax.jcr.Session | login(javax.jcr.Credentials credentials) | 
|  javax.jcr.Session | login(javax.jcr.Credentials credentials,
      java.lang.String workspace) | 
|  javax.jcr.Session | login(java.lang.String workspace) | 
|  javax.jcr.Session | loginAdministrative(java.lang.String workspace) | 
| protected  boolean | pingAndCheck()Ping our current repository and check that admin login (required by Sling) works. | 
| protected  boolean | pingRepository(javax.jcr.Repository repository)Checks that the given repositoryis still available. | 
| protected  org.osgi.framework.ServiceRegistration | registerService()Registers this component as an OSGi service with type javax.jcr.Repositoryandorg.apache.sling.jcr.api.SlingRepositoryusing the
 component properties as service registration properties. | 
|  void | run() | 
| protected  void | setupRepository(javax.jcr.Repository repository)This method is called after a repository has been acquired by acquireRepository()but before the repository is registered as a
 service. | 
| protected  void | tearDown(javax.jcr.Repository repository)Performs any cleanups before the repository is actually disposed off by the disposeRepository(Repository)method. | 
| protected  void | unbindLog(org.osgi.service.log.LogService log) | 
| protected  void | unregisterService(org.osgi.framework.ServiceRegistration serviceRegistration)Unregisters the service represented by the serviceRegistration. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final java.lang.String PROPERTY_DEFAULT_WORKSPACE
public static final java.lang.String PROPERTY_ANONYMOUS_USER
public static final java.lang.String PROPERTY_ANONYMOUS_PASS
public static final java.lang.String PROPERTY_ADMIN_USER
public static final java.lang.String PROPERTY_ADMIN_PASS
public static final java.lang.String PROPERTY_POLL_ACTIVE
public static final java.lang.String PROPERTY_POLL_INACTIVE
public static final java.lang.String PROPERTY_MAX_ACTIVE_SESSIONS_WAIT
public static final java.lang.String PROPERTY_MAX_ACTIVE_SESSIONS
public static final java.lang.String PROPERTY_MAX_IDLE_SESSIONS
public static final java.lang.String DEFAULT_ANONYMOUS_USER
public static final java.lang.String DEFAULT_ANONYMOUS_PASS
public static final java.lang.String DEFAULT_ADMIN_USER
public static final java.lang.String DEFAULT_ADMIN_PASS
public static final int DEFAULT_POLL_ACTIVE
public static final int DEFAULT_POLL_INACTIVE
public static final int MIN_POLL
| Constructor Detail | 
|---|
protected AbstractSlingRepository()
| Method Detail | 
|---|
public final java.lang.String getDefaultWorkspace()
null meaning
 to use the repository provided default workspace. Declared final to make
 sure the SLING-256 rule is enforced.
getDefaultWorkspace in interface org.apache.sling.jcr.api.SlingRepository
public javax.jcr.Session login()
                        throws javax.jcr.LoginException,
                               javax.jcr.RepositoryException
login(Credentials, String)
login in interface javax.jcr.Repositoryjavax.jcr.LoginException
javax.jcr.RepositoryException
public javax.jcr.Session loginAdministrative(java.lang.String workspace)
                                      throws javax.jcr.RepositoryException
loginAdministrative in interface org.apache.sling.jcr.api.SlingRepositoryjavax.jcr.RepositoryException
public javax.jcr.Session login(javax.jcr.Credentials credentials)
                        throws javax.jcr.LoginException,
                               javax.jcr.RepositoryException
login in interface javax.jcr.Repositoryjavax.jcr.LoginException
javax.jcr.RepositoryException
public javax.jcr.Session login(java.lang.String workspace)
                        throws javax.jcr.LoginException,
                               javax.jcr.NoSuchWorkspaceException,
                               javax.jcr.RepositoryException
login in interface javax.jcr.Repositoryjavax.jcr.LoginException
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryException
public javax.jcr.Session login(javax.jcr.Credentials credentials,
                               java.lang.String workspace)
                        throws javax.jcr.LoginException,
                               javax.jcr.NoSuchWorkspaceException,
                               javax.jcr.RepositoryException
login in interface javax.jcr.Repositoryjavax.jcr.LoginException
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryExceptionpublic java.lang.String getDescriptor(java.lang.String name)
getDescriptor in interface javax.jcr.Repositorypublic java.lang.String[] getDescriptorKeys()
getDescriptorKeys in interface javax.jcr.Repositoryprotected final org.apache.sling.jcr.base.internal.SessionPoolManager getPoolManager()
protected org.apache.sling.jcr.base.internal.SessionPoolFactory getSessionPoolFactory()
protected org.apache.sling.jcr.base.internal.SessionPool createSessionPool(org.apache.sling.jcr.base.internal.SessionPoolManager mgr,
                                                                           javax.jcr.SimpleCredentials credentials)
protected void log(int level,
                   java.lang.String message)
protected void log(int level,
                   java.lang.String message,
                   java.lang.Throwable t)
protected RepositoryAccessor getRepositoryAccessor()
RepositoryAccessor class to access
 a repository over RMI or through JNDI.
 
 Extensions of this method may return an extension of the
 RepositoryAccessor class if the provide extended functionality.
protected javax.jcr.Repository acquireRepository()
RepositoryAccessor.getRepositoryFromURL(String)
 with the value of the
 RepositoryAccessor.REPOSITORY_URL_OVERRIDE_PROPERTY
 framework or configuration property. If the property exists and a
 repository can be accessed using this property, that repository is
 returned. Otherwise null is returned.
 Extensions of this class may overwrite this method with implementation specific acquisition semantics and may call this base class method or not as the implementation sees fit.
 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.protected void setupRepository(javax.jcr.Repository repository)
acquireRepository() but before the repository is registered as a
 service.
 Implementations may overwrite this method but MUST call this base class implementation first.
repository - The JCR Repository to setup.protected org.osgi.framework.ServiceRegistration registerService()
javax.jcr.Repository and
 org.apache.sling.jcr.api.SlingRepository using the
 component properties as service registration properties.
 This method may be overwritten to register the component with different types.
ServiceRegistration object representing
         the registered service.protected javax.jcr.Repository getRepository()
null if
 no repository is currently being available.
protected boolean pingRepository(javax.jcr.Repository repository)
repository is still available. This
 implementation tries to get the Repository.SPEC_NAME_DESC
 descriptor from the repository and returns true if the
 returned value is not null.
 
 Extensions of this class may overwrite this method to implement different
 access checks. The contract of this method must be obeyed, though in a
 sense, the true must only be returned if
 repository is actually usable.
repository - The JCR Repository to check for
            availability.
true if repository is not
         null and accessible.protected boolean pingAndCheck()
protected void unregisterService(org.osgi.framework.ServiceRegistration serviceRegistration)
serviceRegistration.
 This method may be overwritten by extensions of this class as long as it is made sure, the given service registration is unregistered.
protected void tearDown(javax.jcr.Repository repository)
disposeRepository(Repository) method.
 This method is meant for cleanup tasks before the repository is actually disposed off. Extensions of this class may overwrite but must call this base class implementation.
repository - protected void disposeRepository(javax.jcr.Repository repository)
repository. This base class
 implementation does nothing. Extensions should overwrite if any special
 disposal operation is required.
repository - public void bundleChanged(org.osgi.framework.BundleEvent event)
bundleChanged in interface org.osgi.framework.BundleListenerevent - The BundleEvent representing the bundle state
            change.protected org.osgi.service.component.ComponentContext getComponentContext()
protected void activate(org.osgi.service.component.ComponentContext componentContext)
                 throws java.lang.Exception
nothing, - but allow derived classes to throw any Exception
java.lang.Exceptionprotected void deactivate(org.osgi.service.component.ComponentContext componentContext)
componentContext - protected void bindLog(org.osgi.service.log.LogService log)
protected void unbindLog(org.osgi.service.log.LogService log)
public void run()
run in interface java.lang.Runnable| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||