1/**
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.google.inject.persist;
17
18/**
19 * Persistence provider service. Use this to manage the overall
20 * startup and stop of the persistence module(s).
21 *
22 * TODO(dhanji): Integrate with Service API when appropriate.
23 *
24 * @author dhanji@gmail.com (Dhanji R. Prasanna)
25 */
26public interface PersistService {
27
28  /**
29   * Starts the underlying persistence engine and makes guice-persist ready for
30   * use. For instance, with JPA, it creates an EntityManagerFactory and may
31   * open connection pools. This method must be called by your code prior to
32   * using any guice-persist or JPA artifacts. If already started,
33   * calling this method does nothing, if already stopped, it also does
34   * nothing.
35   */
36  void start();
37
38  /**
39   * Stops the underlying persistence engine. For instance, with JPA, it
40   * closes the {@code EntityManagerFactory}. If already stopped, calling this
41   * method does nothing. If not yet started, it also does nothing.
42   */
43  void stop();
44}
45