|
||||||||||
| 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 default support for
attached repositories as well as ensuring live repository connection,
reconnecting if needed. Implementations of the SlingRepository
interface may wish to extend this class to benefit from a default
implementation.
| Field Summary | |
|---|---|
static String |
DEFAULT_ADMIN_PASS
|
static String |
DEFAULT_ADMIN_USER
|
static String |
DEFAULT_ANONYMOUS_PASS
|
static String |
DEFAULT_ANONYMOUS_USER
|
static int |
DEFAULT_POLL_ACTIVE
The 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_INACTIVE
The 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_POLL
The minimum number of seconds allowed for any of the two poll times |
static String |
PROPERTY_ADMIN_PASS
|
static String |
PROPERTY_ADMIN_USER
|
static String |
PROPERTY_ANONYMOUS_PASS
|
static String |
PROPERTY_ANONYMOUS_USER
|
static String |
PROPERTY_DEFAULT_WORKSPACE
|
static String |
PROPERTY_POLL_ACTIVE
|
static String |
PROPERTY_POLL_INACTIVE
|
| Fields inherited from interface javax.jcr.Repository |
|---|
IDENTIFIER_STABILITY, IDENTIFIER_STABILITY_INDEFINITE_DURATION, IDENTIFIER_STABILITY_METHOD_DURATION, IDENTIFIER_STABILITY_SAVE_DURATION, IDENTIFIER_STABILITY_SESSION_DURATION, LEVEL_1_SUPPORTED, LEVEL_2_SUPPORTED, NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED, NODE_TYPE_MANAGEMENT_INHERITANCE, NODE_TYPE_MANAGEMENT_INHERITANCE_MINIMAL, NODE_TYPE_MANAGEMENT_INHERITANCE_MULTIPLE, NODE_TYPE_MANAGEMENT_INHERITANCE_SINGLE, NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED, NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED, NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED, NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED, NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED, NODE_TYPE_MANAGEMENT_PROPERTY_TYPES, NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED, NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED, NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED, NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED, OPTION_ACCESS_CONTROL_SUPPORTED, OPTION_ACTIVITIES_SUPPORTED, OPTION_BASELINES_SUPPORTED, OPTION_JOURNALED_OBSERVATION_SUPPORTED, OPTION_LIFECYCLE_SUPPORTED, OPTION_LOCKING_SUPPORTED, OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED, OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED, OPTION_OBSERVATION_SUPPORTED, OPTION_QUERY_SQL_SUPPORTED, OPTION_RETENTION_SUPPORTED, OPTION_SHAREABLE_NODES_SUPPORTED, OPTION_SIMPLE_VERSIONING_SUPPORTED, OPTION_TRANSACTIONS_SUPPORTED, OPTION_UNFILED_CONTENT_SUPPORTED, OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED, OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED, OPTION_VERSIONING_SUPPORTED, OPTION_WORKSPACE_MANAGEMENT_SUPPORTED, OPTION_XML_EXPORT_SUPPORTED, OPTION_XML_IMPORT_SUPPORTED, QUERY_FULL_TEXT_SEARCH_SUPPORTED, QUERY_JOINS, QUERY_JOINS_INNER, QUERY_JOINS_INNER_OUTER, QUERY_JOINS_NONE, QUERY_LANGUAGES, QUERY_STORED_QUERIES_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, WRITE_SUPPORTED |
| Constructor Summary | |
|---|---|
protected |
AbstractSlingRepository()
|
| Method Summary | |
|---|---|
protected javax.jcr.Repository |
acquireRepository()
Acquires the repository by calling the RepositoryAccessor.getRepositoryFromURL(String)
with the value of the
RepositoryAccessor.REPOSITORY_URL_OVERRIDE_PROPERTY
framework 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)
|
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 javax.jcr.Credentials |
getAdministrativeCredentials(String adminUser)
|
protected javax.jcr.Credentials |
getAnonCredentials(String anonUser)
|
protected org.osgi.service.component.ComponentContext |
getComponentContext()
|
String |
getDefaultWorkspace()
Returns the default workspace, which may be null meaning
to use the repository provided default workspace. |
String |
getDescriptor(String name)
|
String[] |
getDescriptorKeys()
|
javax.jcr.Value |
getDescriptorValue(String key)
|
javax.jcr.Value[] |
getDescriptorValues(String key)
|
protected javax.jcr.Repository |
getRepository()
Returns the repository underlying this instance or null if
no repository is currently being available. |
protected RepositoryAccessor |
getRepositoryAccessor()
Returns a new instance of the RepositoryAccessor class to access
a repository over RMI or through JNDI. |
boolean |
isSingleValueDescriptor(String key)
|
boolean |
isStandardDescriptor(String key)
|
protected void |
log(int level,
String message)
|
protected void |
log(int level,
String message,
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,
String workspace)
|
javax.jcr.Session |
login(String workspace)
|
javax.jcr.Session |
loginAdministrative(String workspace)
Returns a session to the default workspace which has administrative powers. |
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 repository is still available. |
protected org.osgi.framework.ServiceRegistration |
registerService()
Registers this component as an OSGi service with type javax.jcr.Repository and
org.apache.sling.jcr.api.SlingRepository using 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 String PROPERTY_DEFAULT_WORKSPACE
public static final String PROPERTY_ANONYMOUS_USER
public static final String PROPERTY_ANONYMOUS_PASS
public static final String PROPERTY_ADMIN_USER
public static final String PROPERTY_ADMIN_PASS
public static final String PROPERTY_POLL_ACTIVE
public static final String PROPERTY_POLL_INACTIVE
public static final String DEFAULT_ANONYMOUS_USER
public static final String DEFAULT_ANONYMOUS_PASS
public static final String DEFAULT_ADMIN_USER
public static final 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 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 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(String workspace)
throws javax.jcr.RepositoryException
SlingRepository
NOTE: This method is intended for use by infrastructure bundles to
access the repository and provide general services. This method MUST not
be used to handle client requests of whatever kinds. To handle client
requests a regular authenticated session retrieved
through Repository.login(javax.jcr.Credentials, String) or
Session.impersonate(javax.jcr.Credentials) must be used.
loginAdministrative in interface SlingRepositoryworkspace - The name of the workspace to which to get an
administrative session. If null the
SlingRepository.getDefaultWorkspace() default workspace is assumed.
javax.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(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,
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.RepositoryExceptionprotected javax.jcr.Credentials getAnonCredentials(String anonUser)
anonUser - the user name of the anon user.
protected javax.jcr.Credentials getAdministrativeCredentials(String adminUser)
adminUser - the name of the administrative user.
public String getDescriptor(String name)
getDescriptor in interface javax.jcr.Repositorypublic String[] getDescriptorKeys()
getDescriptorKeys in interface javax.jcr.Repositorypublic javax.jcr.Value getDescriptorValue(String key)
getDescriptorValue in interface javax.jcr.Repositorypublic javax.jcr.Value[] getDescriptorValues(String key)
getDescriptorValues in interface javax.jcr.Repositorypublic boolean isSingleValueDescriptor(String key)
isSingleValueDescriptor in interface javax.jcr.Repositorypublic boolean isStandardDescriptor(String key)
isStandardDescriptor in interface javax.jcr.Repository
protected void log(int level,
String message)
protected void log(int level,
String message,
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 - protected org.osgi.service.component.ComponentContext getComponentContext()
protected void activate(org.osgi.service.component.ComponentContext componentContext)
throws Exception
nothing, - but allow derived classes to throw any Exception
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 Runnable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||