org.mockejb
Class EntityBeanSubclass

java.lang.Object
  extended byorg.mockejb.EntityBeanSubclass
All Implemented Interfaces:
net.sf.cglib.proxy.Callback, net.sf.cglib.proxy.MethodInterceptor

public class EntityBeanSubclass
extends java.lang.Object
implements net.sf.cglib.proxy.MethodInterceptor

Provides mock subclass of the CMP entity abstract class. The subclass gets created dynamically using CGLIB. The behavior is the following: CMP field getters return null if the corresponding set was not called, otherwise it returns the previously set value. Attempt to call ejbFind and ejbSelect will trigger exception. You need to intercept the appropriate methods of the Home interface and provide your own implementation. Intercept "create" method if you want to change the behavior.

Author:
Alexander Ananiev

Method Summary
 java.lang.Object create()
          Creates the subclass of the abstract entity class using CGLIB enhancer.
 java.lang.Object intercept(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] paramVals, net.sf.cglib.proxy.MethodProxy cglibMethodProxy)
           
protected  java.lang.Object invokeEjbSelect(java.lang.Object subclassObj, java.lang.reflect.Method ejbSelectMethod, java.lang.Object[] paramVals)
           
static EntityBeanSubclass newInstance(java.lang.Class abstractEntityClass)
          Creates an instance of EntityBeanSubclass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static EntityBeanSubclass newInstance(java.lang.Class abstractEntityClass)
Creates an instance of EntityBeanSubclass. Current implementation creates a new instance evry time. This method does not create the actual sublcass, for that you need to call "create".

Returns:
an instance of EntityBeanSubclass

create

public java.lang.Object create()
Creates the subclass of the abstract entity class using CGLIB enhancer.

Returns:
an instance of the subclass implementing abstract methods of the provided entity bean class

intercept

public java.lang.Object intercept(java.lang.Object obj,
                                  java.lang.reflect.Method method,
                                  java.lang.Object[] paramVals,
                                  net.sf.cglib.proxy.MethodProxy cglibMethodProxy)
                           throws java.lang.Throwable
Specified by:
intercept in interface net.sf.cglib.proxy.MethodInterceptor
Throws:
java.lang.Throwable

invokeEjbSelect

protected java.lang.Object invokeEjbSelect(java.lang.Object subclassObj,
                                           java.lang.reflect.Method ejbSelectMethod,
                                           java.lang.Object[] paramVals)
                                    throws java.lang.Exception
Throws:
java.lang.Exception