01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.persistence.api;
25:
26: import javax.persistence.EntityManager;
27: import javax.persistence.EntityManagerFactory;
28: import javax.persistence.PersistenceContextType;
29:
30: /**
31: * Allows to get persistence units and allow to return EntityManager or
32: * EntityManagerFactory.
33: * @author Florent Benoit
34: */
35: public interface EZBPersistenceUnitManager {
36:
37: /**
38: * Gets an entity manager for the given unit name and the extra attributes.
39: * @param unitName the name of the persistence unit
40: * @param type the type of the persistence context
41: * @return entity manager corresponding to arguments
42: */
43: EntityManager getEntityManager(final String unitName,
44: final PersistenceContextType type);
45:
46: /**
47: * Gets an entity manager factory for the given unit name.
48: * @param unitName the name of the persistence unit
49: * @return entity manager factory.
50: */
51: EntityManagerFactory getEntityManagerFactory(final String unitName);
52:
53: /**
54: * Create a new EntityManager on each PersistenceContext. (Will be used for
55: * the method lifecycle)
56: */
57: void addCurrent();
58:
59: /**
60: * Sets back to the previous entity manager and close the current entity
61: * manager for each persistence context.
62: */
63: void closeCurrentAndReturnToPrevious();
64:
65: /**
66: * Merge the persistence context of a an other persistent unit manager in
67: * this one. Note that as specified in chapter 6.2.2 (persistence unit
68: * scope), an EAR level component level will only be seen by a subcomponent
69: * if it was not redefined. In our case : don't merge the given unit-name if
70: * the current manager defines this unit-name.
71: * @param otherPersistenceUnitManager the other persistence unit manager
72: * that will be merged into this one.
73: */
74: void merge(
75: final EZBPersistenceUnitManager otherPersistenceUnitManager);
76: }
|