001 // Copyright 2007, 2008 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.tynamo.jpa; 016 017 import javax.persistence.EntityManager; 018 import javax.persistence.EntityManagerFactory; 019 020 /** 021 * Responsible for creating an EntityManager as needed. Internally, is responsible for 022 * PersistenceUnit {@link Configuration}, resulting in a {@link EntityManagerFactory}. 023 * <p/> 024 * The service's configuration is a {@linkplain org.apache.tapestry5.ioc.services.ChainBuilder chain 025 * of command} of configurator objects. 026 */ 027 // @UsesOrderedConfiguration(org.apache.tapestry5.hibernate.HibernateConfigurer.class) 028 public interface JPAEntityManagerSource 029 { 030 /** 031 * Creates a new session using the {@link #getEntityManagerFactory() EntityManagerFactory} 032 * created at service startup. 033 */ 034 EntityManager create(); 035 036 /** 037 * Returns the EntityManagerFactory from which JPA entity managers are created. 038 */ 039 EntityManagerFactory getEntityManagerFactory(); 040 }