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 */ 16 package com.google.inject.persist; 17 18 /** 19 * Persistence provider service. Use this to manage the overall startup and stop of the persistence 20 * module(s). 21 * 22 * <p>TODO(dhanji): Integrate with Service API when appropriate. 23 * 24 * @author dhanji@gmail.com (Dhanji R. Prasanna) 25 */ 26 public interface PersistService { 27 28 /** 29 * Starts the underlying persistence engine and makes guice-persist ready for use. For instance, 30 * with JPA, it creates an EntityManagerFactory and may open connection pools. This method must be 31 * called by your code prior to using any guice-persist or JPA artifacts. If already started, 32 * calling this method does nothing, if already stopped, it also does nothing. 33 */ start()34 void start(); 35 36 /** 37 * Stops the underlying persistence engine. For instance, with JPA, it closes the {@code 38 * EntityManagerFactory}. If already stopped, calling this method does nothing. If not yet 39 * started, it also does nothing. 40 */ stop()41 void stop(); 42 } 43