AbstractSlingRepositoryManager
and
AbstractSlingRepository2
instead.@Deprecated @ProviderType public abstract class AbstractSlingRepository extends AbstractNamespaceMappingRepository implements SlingRepository, Runnable
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.
As of version 2.2 (bundle version 2.2.0) the registration of repository
services based on this abstract base class works differently. To be able to
know the calling bundle to implement the
loginService(String, String)
method the service is registered as a
service factory. Yet this component is registered as a non-service component
with Declarative Services handling its registration itself so the the
ServiceFactory
cannot simply create instances of this class. The
solution is for the service factory to create a proxy to the actual component
object. All method calls are just routed through with the exception of the
loginService(String, String)
method which is routed to a new
internal method taking the calling bundle as an additional argument.
The changes to support this new registration mechanism are as follows:
registerService()
method is now final.getServiceRegistrationInterfaces()
and
getServiceRegistrationProperties()
methods have been added and can
be overwritten by implementations of this class. The
registerService()
method calls these new methods to get the
interfaces and properties for the service registration.registerService()
method must replace this overwritten method with overwriting the new
getServiceRegistrationInterfaces()
and/or
getServiceRegistrationProperties()
methods.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ADMIN_PASS
Deprecated.
|
static String |
DEFAULT_ADMIN_USER
Deprecated.
|
static String |
DEFAULT_ANONYMOUS_PASS
Deprecated.
|
static String |
DEFAULT_ANONYMOUS_USER
Deprecated.
|
static boolean |
DEFAULT_LOGIN_ADMIN_ENABLED
Deprecated.
|
static int |
DEFAULT_POLL_ACTIVE
Deprecated.
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
Deprecated.
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
Deprecated.
The minimum number of seconds allowed for any of the two poll times
|
static String |
PROPERTY_ADMIN_PASS
Deprecated.
|
static String |
PROPERTY_ADMIN_USER
Deprecated.
|
static String |
PROPERTY_ANONYMOUS_PASS
Deprecated.
|
static String |
PROPERTY_ANONYMOUS_USER
Deprecated.
|
static String |
PROPERTY_DEFAULT_WORKSPACE
Deprecated.
|
static String |
PROPERTY_LOGIN_ADMIN_ENABLED
Deprecated.
|
static String |
PROPERTY_POLL_ACTIVE
Deprecated.
|
static String |
PROPERTY_POLL_INACTIVE
Deprecated.
|
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
Modifier | Constructor and Description |
---|---|
protected |
AbstractSlingRepository()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected javax.jcr.Repository |
acquireRepository()
Deprecated.
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)
Deprecated.
This method must be called if overwritten by implementations !!
|
protected void |
bindLog(org.osgi.service.log.LogService log)
Deprecated.
|
protected void |
deactivate(org.osgi.service.component.ComponentContext componentContext)
Deprecated.
This method must be called if overwritten by implementations !!
|
protected void |
disposeRepository(javax.jcr.Repository repository)
Deprecated.
Disposes off the given
repository . |
protected javax.jcr.Credentials |
getAdministrativeCredentials(String adminUser)
Deprecated.
|
protected javax.jcr.Credentials |
getAnonCredentials(String anonUser)
Deprecated.
|
protected org.osgi.service.component.ComponentContext |
getComponentContext()
Deprecated.
|
String |
getDefaultWorkspace()
Deprecated.
Returns the default workspace, which may be
null meaning
to use the repository provided default workspace. |
String |
getDescriptor(String name)
Deprecated.
|
String[] |
getDescriptorKeys()
Deprecated.
|
javax.jcr.Value |
getDescriptorValue(String key)
Deprecated.
|
javax.jcr.Value[] |
getDescriptorValues(String key)
Deprecated.
|
protected javax.jcr.Repository |
getRepository()
Deprecated.
Returns the repository underlying this instance or
null if
no repository is currently being available. |
protected RepositoryAccessor |
getRepositoryAccessor()
Deprecated.
Returns a new instance of the
RepositoryAccessor class to access
a repository over RMI or through JNDI. |
protected String[] |
getServiceRegistrationInterfaces()
Deprecated.
Returns the service types to be used to register the repository service
in
registerService() . |
protected Dictionary<String,Object> |
getServiceRegistrationProperties()
Deprecated.
Return the service registration properties to be used to register the
repository service in
registerService() . |
boolean |
isSingleValueDescriptor(String key)
Deprecated.
|
boolean |
isStandardDescriptor(String key)
Deprecated.
|
protected void |
log(int level,
String message)
Deprecated.
|
protected void |
log(int level,
String message,
Throwable t)
Deprecated.
|
javax.jcr.Session |
login()
Deprecated.
Logs in as an anonymous user.
|
javax.jcr.Session |
login(javax.jcr.Credentials credentials)
Deprecated.
|
javax.jcr.Session |
login(javax.jcr.Credentials credentials,
String workspace)
Deprecated.
|
javax.jcr.Session |
login(String workspace)
Deprecated.
|
javax.jcr.Session |
loginAdministrative(String workspace)
Deprecated.
Returns a session to the given workspace which has administrative powers.
|
protected javax.jcr.Session |
loginAdministrativeInternal(String workspace)
Deprecated.
Actual (unprotected) implementation of administrative login.
|
javax.jcr.Session |
loginService(String subServiceName,
String workspace)
Deprecated.
This method always throws
LoginException because it does
not directly have the calling bundle at its disposition to decide
on the required service name. |
protected boolean |
pingAndCheck()
Deprecated.
Ping our current repository and check that admin login (required by Sling) works.
|
protected boolean |
pingRepository(javax.jcr.Repository repository)
Deprecated.
Checks that the given
repository is still available. |
protected org.osgi.framework.ServiceRegistration |
registerService()
Deprecated.
Registers this component as an OSGi service with the types provided by
the
getServiceRegistrationInterfaces() method and properties
provided by the getServiceRegistrationProperties() method. |
void |
run()
Deprecated.
|
protected void |
setupRepository(javax.jcr.Repository repository)
Deprecated.
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)
Deprecated.
Performs any cleanups before the repository is actually disposed off by
the
disposeRepository(Repository) method. |
protected void |
unbindLog(org.osgi.service.log.LogService log)
Deprecated.
|
protected void |
unregisterService(org.osgi.framework.ServiceRegistration serviceRegistration)
Deprecated.
Unregisters the service represented by the
serviceRegistration . |
getNamespaceMapperServices, setup, tearDown
getNamespaceAwareSession, setup
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 boolean DEFAULT_LOGIN_ADMIN_ENABLED
@Property public static final String PROPERTY_DEFAULT_WORKSPACE
@Property(value="anonymous") public static final String PROPERTY_ANONYMOUS_USER
@Property(value="anonymous") public static final String PROPERTY_ANONYMOUS_PASS
@Property(value="admin") public static final String PROPERTY_ADMIN_USER
@Property(value="admin") public static final String PROPERTY_ADMIN_PASS
@Property(boolValue=true) public static final String PROPERTY_LOGIN_ADMIN_ENABLED
public static final int DEFAULT_POLL_ACTIVE
public static final int DEFAULT_POLL_INACTIVE
@Property(intValue=10) public static final String PROPERTY_POLL_ACTIVE
@Property(intValue=10) public static final String PROPERTY_POLL_INACTIVE
public static final int MIN_POLL
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.Repository
javax.jcr.LoginException
javax.jcr.RepositoryException
public final 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.
This method is deprecated. Services running in the Sling system should
use the SlingRepository.loginService(String serviceInfo, String workspace)
method instead. Implementations of this method must throw
javax.jcr.LoginException
if they don't support it.
loginAdministrative
in interface SlingRepository
workspace
- The name of the workspace to which to get an
administrative session. If null
the
SlingRepository.getDefaultWorkspace()
default workspace is assumed.javax.jcr.LoginException
- If this method is not supported or is disabled by
the implementation.javax.jcr.RepositoryException
- If an error occurrs creating the
administrative sessionpublic final javax.jcr.Session loginService(String subServiceName, String workspace) throws javax.jcr.LoginException, javax.jcr.RepositoryException
LoginException
because it does
not directly have the calling bundle at its disposition to decide
on the required service name.
This method is final and cannot be overwritten by extensions. See the class comments for full details on how this works.
loginService
in interface SlingRepository
subServiceName
- Optional Subservice Name to specialize account
selection for the service. This may be null
.workspace
- The name of the workspace to which to get an
administrative session. If null
the
SlingRepository.getDefaultWorkspace()
default workspace is assumed.javax.jcr.LoginException
- If there is no service account defined for the
calling bundle or the defined service account does not exist.javax.jcr.RepositoryException
- if an error occurrs.public javax.jcr.Session login(javax.jcr.Credentials credentials) throws javax.jcr.LoginException, javax.jcr.RepositoryException
login
in interface javax.jcr.Repository
javax.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.Repository
javax.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.Repository
javax.jcr.LoginException
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryException
protected javax.jcr.Session loginAdministrativeInternal(String workspace) throws javax.jcr.RepositoryException
This methods is internally used to administratively login.
workspace
- The workspace to login to (or null
to use the
default workspace
.javax.jcr.RepositoryException
- if an error occurrs.protected 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.Repository
public String[] getDescriptorKeys()
getDescriptorKeys
in interface javax.jcr.Repository
public javax.jcr.Value getDescriptorValue(String key)
getDescriptorValue
in interface javax.jcr.Repository
public javax.jcr.Value[] getDescriptorValues(String key)
getDescriptorValues
in interface javax.jcr.Repository
public boolean isSingleValueDescriptor(String key)
isSingleValueDescriptor
in interface javax.jcr.Repository
public boolean isStandardDescriptor(String key)
isStandardDescriptor
in interface javax.jcr.Repository
protected void log(int level, String message)
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 final org.osgi.framework.ServiceRegistration registerService()
getServiceRegistrationInterfaces()
method and properties
provided by the getServiceRegistrationProperties()
method.
As of version 2.2 (bundle version 2.2.0) this method is final and cannot
be overwritten because the mechanism of service registration using a
service factory is required to fully implement the
loginService(String, String)
method. See the class comments for
full details on how this works.
ServiceRegistration
object representing the
registered service.protected Dictionary<String,Object> getServiceRegistrationProperties()
registerService()
.
This method may be overwritten to return additional service registration properties. But it is strongly recommended to always include the properties returned from this method.
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 must always be included.
registerService()
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 ExceptionException
protected 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)
Copyright © 2014 The Apache Software Foundation. All rights reserved.