Class CredentialsStrategySessionFactory

  • All Implemented Interfaces:
    org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.extensions.jcr.SessionFactory

    public class CredentialsStrategySessionFactory
    extends Object
    implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.extensions.jcr.SessionFactory
    Copy-and-paste of JcrSessionFactory except that this implementation delegates to a CredentialsStrategy implementation for getting a Credentials instance. Also has fixes from SEJCR-18. Also getBareSession changed to getAdminSession and runs as Jackrabbit admin.
    Author:
    mlowery
    • Constructor Detail

      • CredentialsStrategySessionFactory

        public CredentialsStrategySessionFactory​(javax.jcr.Repository repository,
                                                 CredentialsStrategy credentialsStrategy)
        Constructor with all the required fields.
        Parameters:
        repository -
        workspaceName -
        credentials -
      • CredentialsStrategySessionFactory

        public CredentialsStrategySessionFactory​(javax.jcr.Repository repository,
                                                 CredentialsStrategy credentialsStrategy,
                                                 CredentialsStrategy adminCredentialsStrategy)
        Constructor with all the required fields.
        Parameters:
        repository -
        workspaceName -
        credentials -
      • CredentialsStrategySessionFactory

        public CredentialsStrategySessionFactory​(javax.jcr.Repository repository,
                                                 String workspaceName,
                                                 CredentialsStrategy credentialsStrategy,
                                                 CredentialsStrategy adminCredentialsStrategy)
        Constructor with all the required fields.
        Parameters:
        repository -
        workspaceName -
        credentials -
      • CredentialsStrategySessionFactory

        public CredentialsStrategySessionFactory​(javax.jcr.Repository repository,
                                                 String workspaceName,
                                                 CredentialsStrategy credentialsStrategy,
                                                 CredentialsStrategy adminCredentialsStrategy,
                                                 org.springframework.extensions.jcr.SessionHolderProviderManager sessionHolderProviderManager)
        Constructor containing all the fields available.
        Parameters:
        repository -
        workspaceName -
        credentials -
        sessionHolderProviderManager -
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • registerNodeTypes

        protected void registerNodeTypes()
                                  throws Exception
        Throws:
        Exception
      • unregisterNodeTypes

        protected void unregisterNodeTypes()
                                    throws Exception
        Hook for un-registering node types on the underlying repository. Since this process is not covered by the spec, each implementation requires its own subclass. By default, this method doesn't do anything.
        Throws:
        Exception
      • registerNamespaces

        protected void registerNamespaces()
                                   throws Exception
        Register the namespaces.
        Throws:
        javax.jcr.RepositoryException
        Exception
      • destroy

        public void destroy()
                     throws Exception
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
        Throws:
        Exception
        See Also:
        DisposableBean.destroy()
      • unregisterNamespaces

        protected void unregisterNamespaces()
                                     throws Exception
        Removes the namespaces.
        Throws:
        Exception
      • getAdminSession

        public javax.jcr.Session getAdminSession()
                                          throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getSession

        public javax.jcr.Session getSession()
                                     throws javax.jcr.RepositoryException
        Specified by:
        getSession in interface org.springframework.extensions.jcr.SessionFactory
        Throws:
        javax.jcr.RepositoryException
        See Also:
        SessionFactory.getSession()
      • createSessionProxy

        public javax.jcr.Session createSessionProxy​(javax.jcr.Session session)
        We create a proxy wraper around the actualy session to prevent it from being closed. This allows it to be re-used for subsequent requests.
        Parameters:
        session -
        Returns:
      • getSessionHolder

        public org.springframework.extensions.jcr.SessionHolder getSessionHolder​(javax.jcr.Session session)
        Specified by:
        getSessionHolder in interface org.springframework.extensions.jcr.SessionFactory
        See Also:
        SessionFactory.getSessionHolder(javax.jcr.Session)
      • addListeners

        protected javax.jcr.Session addListeners​(javax.jcr.Session session)
                                          throws javax.jcr.RepositoryException
        Hook for adding listeners to the newly returned session. We have to treat exceptions manually and can't rely on the template.
        Parameters:
        session - JCR session
        Returns:
        the listened session
        Throws:
        javax.jcr.RepositoryException
      • getRepository

        public javax.jcr.Repository getRepository()
        Returns:
        Returns the repository.
      • setRepository

        public void setRepository​(javax.jcr.Repository repository)
        Parameters:
        repository - The repository to set.
      • setWorkspaceName

        public void setWorkspaceName​(String workspaceName)
        Parameters:
        workspaceName - The workspaceName to set.
      • getEventListeners

        public org.springframework.extensions.jcr.EventListenerDefinition[] getEventListeners()
        Returns:
        Returns the eventListenerDefinitions.
      • setEventListeners

        public void setEventListeners​(org.springframework.extensions.jcr.EventListenerDefinition[] eventListenerDefinitions)
        Parameters:
        eventListenerDefinitions - The eventListenerDefinitions to set.
      • getNamespaces

        public Properties getNamespaces()
        Returns:
        Returns the namespaces.
      • setNamespaces

        public void setNamespaces​(Properties namespaces)
        Parameters:
        namespaces - The namespaces to set.
      • getSessionHolderProvider

        protected org.springframework.extensions.jcr.SessionHolderProvider getSessionHolderProvider()
        Used internally.
        Returns:
        Returns the sessionHolderProvider.
      • setSessionHolderProvider

        protected void setSessionHolderProvider​(org.springframework.extensions.jcr.SessionHolderProvider sessionHolderProvider)
        Used internally.
        Parameters:
        sessionHolderProvider - The sessionHolderProvider to set.
      • getSessionHolderProviderManager

        public org.springframework.extensions.jcr.SessionHolderProviderManager getSessionHolderProviderManager()
        Returns:
        Returns the sessionHolderProviderManager.
      • setSessionHolderProviderManager

        public void setSessionHolderProviderManager​(org.springframework.extensions.jcr.SessionHolderProviderManager sessionHolderProviderManager)
        Parameters:
        sessionHolderProviderManager - The sessionHolderProviderManager to set.
      • setKeepNewNamespaces

        public void setKeepNewNamespaces​(boolean keepNamespaces)
        Indicate if the given namespace registrations will be kept (the default) when the application context closes down or if they will be unregistered. If unregistered, the namespace mappings that were overriden are registered back to the repository.
        Parameters:
        keepNamespaces - The keepNamespaces to set.
        See Also:
        forceNamespacesRegistration
      • setForceNamespacesRegistration

        public void setForceNamespacesRegistration​(boolean forceNamespacesRegistration)
        Indicate if the given namespace registrations will override the namespace already registered in the repository under the same prefix. This will cause unregistration for the namespaces that will be modified.

        However, depending on the setKeepNewNamespaces(boolean) setting, the old namespaces can be registered back once the application context is destroyed. False by default.

        Parameters:
        forceNamespacesRegistration - The forceNamespacesRegistration to set.
      • setSkipExistingNamespaces

        public void setSkipExistingNamespaces​(boolean skipRegisteredNamespace)
        Indicate if the given namespace registrations will skip already registered namespaces or not. If true (default), the new namespace will not be registered and the old namespace kept in place. If not skipped, registration of new namespaces will fail if there are already namespace registered under the same prefix.

        This flag is required for JCR implementations which do not support namespace unregistration which render the setForceNamespacesRegistration(boolean) method useless (as namespace registration cannot be forced).

        Parameters:
        skipRegisteredNamespace - The skipRegisteredNamespace to set.
      • isForceNamespacesRegistration

        public boolean isForceNamespacesRegistration()
        Returns:
        Returns the forceNamespacesRegistration.
      • isKeepNewNamespaces

        public boolean isKeepNewNamespaces()
        Returns:
        Returns the keepNewNamespaces.
      • isSkipExistingNamespaces

        public boolean isSkipExistingNamespaces()
        Returns:
        Returns the skipExistingNamespaces.
      • getWorkspaceName

        public String getWorkspaceName()
        Returns:
        Returns the workspaceName.