1 22 23 24 package com.mchange.v2.c3p0.impl; 25 26 import java.lang.reflect.Constructor ; 27 import java.util.Map ; 28 import java.util.Set ; 29 import com.mchange.v2.c3p0.C3P0Registry; 30 import com.mchange.v2.naming.JavaBeanObjectFactory; 31 32 public class C3P0JavaBeanObjectFactory extends JavaBeanObjectFactory 33 { 34 private final static Class [] CTOR_ARG_TYPES = new Class [] { boolean.class }; 35 private final static Object [] CTOR_ARGS = new Object [] { Boolean.FALSE }; 36 37 protected Object createBlankInstance(Class beanClass) throws Exception 38 { 39 if ( IdentityTokenized.class.isAssignableFrom( beanClass ) ) 40 { 41 Constructor ctor = beanClass.getConstructor( CTOR_ARG_TYPES ); 42 return ctor.newInstance( CTOR_ARGS ); 43 } 44 else 45 return super.createBlankInstance( beanClass ); 46 } 47 48 protected Object findBean(Class beanClass, Map propertyMap, Set refProps ) throws Exception 49 { 50 Object out = super.findBean( beanClass, propertyMap, refProps ); 51 if (out instanceof IdentityTokenized) 52 out = C3P0Registry.reregister( (IdentityTokenized) out ); 53 return out; 56 } 57 } 58 | Popular Tags |