View Javadoc
1   package org.apache.onami.persist;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * This is the main control to the entire persistence engine. Before calling any other method
24   * of either {@link UnitOfWork}, {@link EntityManagerProvider}, or any method annotated with
25   * {@link Transactional @Transactional} the persistence service must be started.
26   */
27  public interface PersistenceService
28  {
29  
30      /**
31       * Starts the underlying persistence engine and makes onami-persist ready for use.
32       * This method must be called by your code prior to using any other onami-persist artifacts.
33       * If you are using onami-persist in a web container {@link PersistenceFilter} will call this
34       * method upon initialization of the web application.
35       *
36       * @throws IllegalStateException if the service is already running.
37       */
38      void start();
39  
40      /**
41       * @return {@code true} if the underlying persistence engine is running.
42       *         {@code false} otherwise.
43       */
44      boolean isRunning();
45  
46      /**
47       * Stops the underlying persistence engine.
48       * <ul>
49       * <li>If already stopped, calling this method does nothing.</li>
50       * <li>If not yet started, it also does nothing.</li>
51       * </ul>
52       */
53      void stop();
54  
55  }