Search in sources :

Example 1 with Type

use of net.sf.cglib.asm.Type in project simplejpa by appoxy.

the class LazyInterceptor method handleSetMethod.

private void handleSetMethod(Object obj, Method method, Object[] args) throws Throwable {
    // we basically want to mark this object as dirty if this is called and to only delete attributes if it's dirty
    dirty = true;
    String attributeName = NamingHelper.attributeName(method);
    if (args != null && args.length == 1) {
        Object valueToSet = args[0];
        if (valueToSet == null) {
            // FIXME support direct field accessors better here
            PersistentMethod persistentMethod = (PersistentMethod) (PersistentMethod) em.getFactory().getAnnotationManager().getAnnotationInfo(obj).getPersistentProperty(attributeName);
            Method getter = persistentMethod.getGetter();
            MethodProxy getterProxy = MethodProxy.find(obj.getClass(), new Signature(persistentMethod.getGetter().getName(), Type.getType(getter.getReturnType()), new Type[] {}));
            Object ret = getterProxy.invokeSuper(obj, null);
            if (ret != null) {
                nulledFields.put(attributeName, ret);
                logger.fine("field " + attributeName + " is being nulled. Old value = " + ret);
            }
        }
    }
}
Also used : Type(net.sf.cglib.asm.Type) Signature(net.sf.cglib.core.Signature) MethodProxy(net.sf.cglib.proxy.MethodProxy) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 Type (net.sf.cglib.asm.Type)1 Signature (net.sf.cglib.core.Signature)1 MethodProxy (net.sf.cglib.proxy.MethodProxy)1