001package com.avaje.ebean.bean; 002 003import java.beans.PropertyChangeListener; 004import java.io.Serializable; 005 006/** 007 * Bean that is aware of EntityBeanIntercept. 008 * <p> 009 * This interface and implementation of these methods is added to Entity Beans 010 * via instrumentation. These methods have a funny _ebean_ prefix to avoid any 011 * clash with normal methods these beans would have. These methods are not for 012 * general application consumption. 013 * </p> 014 */ 015public interface EntityBean extends Serializable { 016 017 String[] _ebean_getPropertyNames(); 018 019 String _ebean_getPropertyName(int pos); 020 021 /** 022 * Return the enhancement marker value. 023 * <p> 024 * This is the class name of the enhanced class and used to check that all 025 * entity classes are enhanced (specifically not just a super class). 026 * </p> 027 */ 028 String _ebean_getMarker(); 029 030 /** 031 * Create and return a new entity bean instance. 032 */ 033 Object _ebean_newInstance(); 034 035 /** 036 * Add a PropertyChangeListener to this bean. 037 */ 038 void addPropertyChangeListener(PropertyChangeListener listener); 039 040 /** 041 * Remove a PropertyChangeListener from this bean. 042 */ 043 void removePropertyChangeListener(PropertyChangeListener listener); 044 045 /** 046 * Generated method that sets the loaded state on all the embedded beans on 047 * this entity bean by using EntityBeanIntercept.setEmbeddedLoaded(Object o); 048 */ 049 void _ebean_setEmbeddedLoaded(); 050 051 /** 052 * Return true if any embedded beans are new or dirty. 053 */ 054 boolean _ebean_isEmbeddedNewOrDirty(); 055 056 /** 057 * Return the intercept for this object. 058 */ 059 EntityBeanIntercept _ebean_getIntercept(); 060 061 /** 062 * Similar to _ebean_getIntercept() except it checks to see if the intercept 063 * field is null and will create it if required. 064 * <p> 065 * This is really only required when transientInternalFields=true as an 066 * enhancement option. In this case the intercept field is transient and will 067 * be null after a bean has been deserialised. 068 * </p> 069 * <p> 070 * This transientInternalFields=true option was to support some serialization 071 * frameworks that can't take into account our ebean fields. 072 * </p> 073 */ 074 EntityBeanIntercept _ebean_intercept(); 075 076 /** 077 * Set the value of a field of an entity bean of this type. 078 * <p> 079 * Note that using this method bypasses any interception that otherwise occurs 080 * on entity beans. That means lazy loading and oldValues creation. 081 * </p> 082 */ 083 void _ebean_setField(int fieldIndex, Object value); 084 085 /** 086 * Set the field value with interception. 087 */ 088 void _ebean_setFieldIntercept(int fieldIndex, Object value); 089 090 /** 091 * Return the value of a field from an entity bean of this type. 092 * <p> 093 * Note that using this method bypasses any interception that otherwise occurs 094 * on entity beans. That means lazy loading. 095 * </p> 096 */ 097 Object _ebean_getField(int fieldIndex); 098 099 /** 100 * Return the field value with interception. 101 */ 102 Object _ebean_getFieldIntercept(int fieldIndex); 103 104}