1 package org.controlhaus.hibernate; 2 3 import net.sf.hibernate.HibernateException; 4 import net.sf.hibernate.Session; 5 import net.sf.hibernate.SessionFactory; 6 7 import org.apache.beehive.controls.api.bean.ControlInterface; 8 import org.apache.beehive.controls.api.properties.PropertySet; 9 10 import java.lang.annotation.Retention; 11 import java.lang.annotation.RetentionPolicy; 12 import java.lang.annotation.Target; 13 import java.lang.annotation.ElementType; 14 15 /*** 16 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 17 * @since Oct 29, 2004 18 */ 19 @ControlInterface 20 public interface HibernateControl 21 { 22 /*** 23 * Get the Hibernate <code>SessionFactory</code>. 24 * @return 25 */ 26 SessionFactory getSessionFactory(); 27 28 /*** 29 * Return the session that is currently associated with this Thread. 30 * 31 * @return 32 * @throws HibernateException 33 */ 34 Session getSession() throws HibernateException; 35 36 /*** 37 * Close the session for the current Thread. 38 * @throws HibernateException 39 */ 40 void closeSession() throws HibernateException; 41 42 /*** 43 * Override this method to provide logic on how to get the 44 * Hibernate configuration file. This can be a file or a resource 45 * on the classpath. 46 * 47 * @return 48 */ 49 String getConfigurationLocation(); 50 51 /*** 52 * The instance of hibernate that you want this control to use. 53 * This will be "default" unless you use the HibernateInstance annotation 54 * to override it. 55 * 56 * @return 57 */ 58 String getHibernateInstance(); 59 60 @PropertySet(prefix="HibernateInstance") 61 @Target( {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD} ) 62 @Retention(RetentionPolicy.RUNTIME) 63 public @interface HibernateInstance 64 { 65 String value() default "default"; 66 } 67 }