View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors. 
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   *
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.web.jcr.spi;
25  
26  import java.util.Set;
27  import javax.jcr.RepositoryException;
28  import javax.jcr.Session;
29  import javax.servlet.ServletContext;
30  import javax.servlet.http.HttpServletRequest;
31  
32  /**
33   * Interface for any class that provides access to one or more local JCR repositories.
34   * <p>
35   * Repository providers must provide a public, no-argument constructor and be thread-safe.
36   * </p>
37   */
38  public interface RepositoryProvider {
39  
40      /**
41       * Returns an active session for the given workspace name in the named repository.
42       * <p>
43       * JCR implementations that do not support multiple repositories on the same server can ignore the repositoryName parameter.
44       * </p>
45       * 
46       * @param request the servlet request; may not be null or unauthenticated
47       * @param repositoryName the name of the repository in which the session is created
48       * @param workspaceName the name of the workspace to which the session should be connected
49       * @return an active session with the given workspace in the named repository
50       * @throws RepositoryException if any other error occurs
51       */
52      public Session getSession( HttpServletRequest request,
53                                 String repositoryName,
54                                 String workspaceName ) throws RepositoryException;
55  
56      /**
57       * Returns the available repository names
58       * <p>
59       * JCR implementations that do not support multiple repositories on the same server should provide a singleton set containing
60       * some default repository name.
61       * </p>
62       * 
63       * @return the available repository names; may not be null or empty
64       */
65      Set<String> getJcrRepositoryNames();
66  
67      /**
68       * Signals the repository provider that it should initialize itself based on the provided {@link ServletContext servlet
69       * context} and begin accepting connections.
70       * 
71       * @param context the servlet context for the REST servlet
72       */
73      void startup( ServletContext context );
74  
75      /**
76       * Signals the repository provider that it should complete any pending transactions, shutdown, and release any external
77       * resource held.
78       */
79      void shutdown();
80  
81  }