Class Oak


  • public class Oak
    extends java.lang.Object
    Builder class for constructing ContentRepository instances with a set of specified plugin components. This class acts as a public facade that hides the internal implementation classes and the details of how they get instantiated and wired together.
    Since:
    Oak 0.6
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_WORKSPACE_NAME
      Constant for the default workspace name
    • Constructor Summary

      Constructors 
      Constructor Description
      Oak()  
      Oak​(org.apache.jackrabbit.oak.spi.state.NodeStore store)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      org.apache.jackrabbit.oak.api.ContentRepository createContentRepository()
      Returns the content repository instance created with the given configuration.
      org.apache.jackrabbit.oak.api.ContentSession createContentSession()
      Creates a content repository with the given configuration and logs in to the default workspace with no credentials, returning the resulting content session.
      org.apache.jackrabbit.oak.api.Root createRoot()
      Creates a content repository with the given configuration and returns a Root instance after logging in to the default workspace with no credentials.
      static java.util.concurrent.ExecutorService defaultExecutorService()
      Default ExecutorService used for scheduling concurrent tasks.
      static java.util.concurrent.ScheduledExecutorService defaultScheduledExecutor()
      Default ScheduledExecutorService used for scheduling background tasks.
      @NotNull org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard getWhiteboard()  
      @NotNull Oak with​(@NotNull java.lang.String defaultWorkspaceName)
      Sets the default workspace name that should be used in case of login with null workspace name.
      @NotNull Oak with​(@NotNull java.util.concurrent.Executor executor)  
      @NotNull Oak with​(@NotNull java.util.concurrent.ScheduledExecutorService scheduledExecutor)  
      @NotNull Oak with​(@NotNull javax.management.MBeanServer mbeanServer)  
      @NotNull Oak with​(@NotNull IndexEditorProvider provider)
      Associates the given index hook provider with the repository to be created.
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.commit.CommitHook hook)
      Associates the given commit hook with the repository to be created.
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.commit.ConflictHandler conflictHandler)
      Deprecated.
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.commit.Editor editor)
      Associates the given editor with the repository to be created.
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.commit.EditorProvider provider)
      Associates the given editor provider with the repository to be created.
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.commit.Observer observer)  
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler conflictHandler)  
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer initializer)  
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.query.QueryIndexProvider provider)
      Associates the given query index provider with the repository to be created.
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.query.QueryLimits settings)  
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.security.SecurityProvider securityProvider)  
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.state.Clusterable c)
      Define the current repository as being a Clusterable one.
      @NotNull Oak with​(@NotNull org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard whiteboard)  
      Oak withAsyncIndexing()
      Deprecated.
      Oak withAsyncIndexing​(@NotNull java.lang.String name, long delayInSeconds)
      Enable the asynchronous (background) indexing behavior for the provided task name.
      Oak withAtomicCounter()  
      Oak withFailOnMissingIndexProvider()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_WORKSPACE_NAME

        public static final java.lang.String DEFAULT_WORKSPACE_NAME
        Constant for the default workspace name
        See Also:
        Constant Field Values
    • Constructor Detail

      • Oak

        public Oak​(org.apache.jackrabbit.oak.spi.state.NodeStore store)
      • Oak

        public Oak()
    • Method Detail

      • defaultScheduledExecutor

        public static java.util.concurrent.ScheduledExecutorService defaultScheduledExecutor()
        Default ScheduledExecutorService used for scheduling background tasks. This default spawns up to 32 background thread on an as need basis. Idle threads are pruned after one minute.
        Returns:
        fresh ScheduledExecutorService
      • defaultExecutorService

        public static java.util.concurrent.ExecutorService defaultExecutorService()
        Default ExecutorService used for scheduling concurrent tasks. This default spawns as many threads as required with a priority of Thread.MIN_PRIORITY. Idle threads are pruned after one minute.
        Returns:
        fresh ExecutorService
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.state.Clusterable c)
        Define the current repository as being a Clusterable one.
        Parameters:
        c -
        Returns:
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull java.lang.String defaultWorkspaceName)
        Sets the default workspace name that should be used in case of login with null workspace name. If this method has not been called some internal default value will be used.
        Parameters:
        defaultWorkspaceName - The name of the default workspace.
        Returns:
        this builder.
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer initializer)
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.query.QueryLimits settings)
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.query.QueryIndexProvider provider)
        Associates the given query index provider with the repository to be created.
        Parameters:
        provider - query index provider
        Returns:
        this builder
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull IndexEditorProvider provider)
        Associates the given index hook provider with the repository to be created.
        Parameters:
        provider - index hook provider
        Returns:
        this builder
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.commit.CommitHook hook)
        Associates the given commit hook with the repository to be created.
        Parameters:
        hook - commit hook
        Returns:
        this builder
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.commit.EditorProvider provider)
        Associates the given editor provider with the repository to be created.
        Parameters:
        provider - editor provider
        Returns:
        this builder
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.commit.Editor editor)
        Associates the given editor with the repository to be created.
        Parameters:
        editor - editor
        Returns:
        this builder
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.security.SecurityProvider securityProvider)
      • with

        @Deprecated
        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.commit.ConflictHandler conflictHandler)
        Deprecated.
        Associates the given conflict handler with the repository to be created.
        Parameters:
        conflictHandler - conflict handler
        Returns:
        this builder
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler conflictHandler)
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull java.util.concurrent.ScheduledExecutorService scheduledExecutor)
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull java.util.concurrent.Executor executor)
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull javax.management.MBeanServer mbeanServer)
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard whiteboard)
      • with

        @NotNull
        public @NotNull Oak with​(@NotNull
                                 @NotNull org.apache.jackrabbit.oak.spi.commit.Observer observer)
      • withAsyncIndexing

        @Deprecated
        public Oak withAsyncIndexing()
        Deprecated.

        Enable the asynchronous (background) indexing behavior.

        Please note that when enabling the background indexer, you need to take care of calling #shutdown on the executor provided for this Oak instance.

      • withFailOnMissingIndexProvider

        public Oak withFailOnMissingIndexProvider()
      • withAtomicCounter

        public Oak withAtomicCounter()
      • withAsyncIndexing

        public Oak withAsyncIndexing​(@NotNull
                                     @NotNull java.lang.String name,
                                     long delayInSeconds)

        Enable the asynchronous (background) indexing behavior for the provided task name.

        Please note that when enabling the background indexer, you need to take care of calling #shutdown on the executor provided for this Oak instance.

      • getWhiteboard

        @NotNull
        public @NotNull org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard getWhiteboard()
      • createContentRepository

        public org.apache.jackrabbit.oak.api.ContentRepository createContentRepository()
        Returns the content repository instance created with the given configuration. If the repository doesn't exist yet, a new instance will be created and returned for each subsequent call of this method.
        Returns:
        content repository
      • createContentSession

        public org.apache.jackrabbit.oak.api.ContentSession createContentSession()
        Creates a content repository with the given configuration and logs in to the default workspace with no credentials, returning the resulting content session.

        This method exists mostly as a convenience for one-off tests, as there's no way to create other sessions for accessing the same repository.

        There is typically no need to explicitly close the returned session unless the repository has explicitly been configured to reserve some resources until all sessions have been closed. The repository will be garbage collected once the session is no longer used.

        Returns:
        content session
      • createRoot

        public org.apache.jackrabbit.oak.api.Root createRoot()
        Creates a content repository with the given configuration and returns a Root instance after logging in to the default workspace with no credentials.

        This method exists mostly as a convenience for one-off tests, as the returned root is the only way to access the session or the repository.

        Note that since there is no way to close the underlying content session, this method should only be used when no components that require sessions to be closed have been configured. The repository and the session will be garbage collected once the root is no longer used.

        Returns:
        root instance