01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.springframework.orm.jpa.persistenceunit;
18:
19: import javax.persistence.spi.PersistenceUnitInfo;
20:
21: /**
22: * Interface that defines an abstraction for finding and managing
23: * JPA PersistenceUnitInfos. Used by
24: * {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean}
25: * in order to obtain a {@link javax.persistence.spi.PersistenceUnitInfo}
26: * for building a concrete {@link javax.persistence.EntityManagerFactory}.
27: *
28: * <p>Obtaining a PersistenceUnitInfo instance is an exclusive process.
29: * A PersistenceUnitInfo instance is not available for further calls
30: * anymore once it has been obtained.
31: *
32: * @author Juergen Hoeller
33: * @since 2.0
34: * @see DefaultPersistenceUnitManager
35: * @see org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#setPersistenceUnitManager
36: */
37: public interface PersistenceUnitManager {
38:
39: /**
40: * Obtain the default PersistenceUnitInfo from this manager.
41: * @return the PersistenceUnitInfo (never <code>null</code>)
42: * @throws IllegalStateException if there is no default PersistenceUnitInfo defined
43: * or it has already been obtained
44: */
45: PersistenceUnitInfo obtainDefaultPersistenceUnitInfo()
46: throws IllegalStateException;
47:
48: /**
49: * Obtain the specified PersistenceUnitInfo from this manager.
50: * @param persistenceUnitName the name of the desired persistence unit
51: * @return the PersistenceUnitInfo (never <code>null</code>)
52: * @throws IllegalArgumentException if no PersistenceUnitInfo with the given
53: * name is defined
54: * @throws IllegalStateException if the PersistenceUnitInfo with the given
55: * name has already been obtained
56: */
57: PersistenceUnitInfo obtainPersistenceUnitInfo(
58: String persistenceUnitName)
59: throws IllegalArgumentException, IllegalStateException;
60:
61: }
|