KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > persistence > api > EZBPersistenceUnitManager


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: EZBPersistenceUnitManager.java 589 2006-06-05 14:00:37Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.persistence.api;
27
28
29 import javax.persistence.EntityManager;
30 import javax.persistence.EntityManagerFactory;
31 import javax.persistence.PersistenceContextType;
32
33 /**
34  * Allows to get persistence units and allow to return EntityManager or
35  * EntityManagerFactory.
36  * @author Florent Benoit
37  */

38 public interface EZBPersistenceUnitManager {
39
40     /**
41      * Gets an entity manager for the given unit name and the extra attributes.
42      * @param unitName the name of the persistence unit
43      * @param type the type of the persistence context
44      * @return entity manager corresponding to arguments
45      */

46     EntityManager getEntityManager(final String JavaDoc unitName, final PersistenceContextType type);
47
48     /**
49      * Gets an entity manager factory for the given unit name.
50      * @param unitName the name of the persistence unit
51      * @return entity manager factory.
52      */

53     EntityManagerFactory getEntityManagerFactory(final String JavaDoc unitName);
54
55     /**
56      * Create a new EntityManager on each PersistenceContext. (Will be used for
57      * the method lifecycle)
58      */

59     void addCurrent();
60
61     /**
62      * Sets back to the previous entity manager and close the current entity
63      * manager for each persistence context.
64      */

65     void closeCurrentAndReturnToPrevious();
66
67     /**
68      * Merge the persistence context of a an other persistent unit manager in
69      * this one. Note that as specified in chapter 6.2.2 (persistence unit
70      * scope), an EAR level component level will only be seen by a subcomponent
71      * if it was not redefined. In our case : don't merge the given unit-name if
72      * the current manager defines this unit-name.
73      * @param otherPersistenceUnitManager the other persistence unit manager
74      * that will be merged into this one.
75      */

76     void merge(final EZBPersistenceUnitManager otherPersistenceUnitManager);
77 }
78
Popular Tags