@Override protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) { ProxyFactory pf = new MapProxyFactory(); try { //TODO: design new lifecycle for ProxyFactory pf.postInstantiate( getEntityName(), null, null, null, null, null ); } catch ( HibernateException he ) { LOG.unableToCreateProxyFactory( getEntityName(), he ); pf = null; } return pf; }
@Override protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, Setter idSetter) { ProxyFactory pf = new MapProxyFactory(); try { //TODO: design new lifecycle for ProxyFactory pf.postInstantiate( getEntityName(), null, null, null, null, null ); } catch ( HibernateException he ) { LOG.unableToCreateProxyFactory(getEntityName(), he); pf = null; } return pf; }
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) { ProxyFactory pf = new MapProxyFactory(); try { //TODO: design new lifecycle for ProxyFactory pf.postInstantiate( getEntityName(), null, null, null, null, null ); } catch ( HibernateException he ) { log.warn( "could not create proxy factory for:" + getEntityName(), he ); pf = null; } return pf; }
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) { HashSet proxyInterfaces = new HashSet(); proxyInterfaces.add( HibernateProxy.class ); proxyInterfaces.add( Element.class ); ProxyFactory pf = new Dom4jProxyFactory(); try { pf.postInstantiate( getEntityName(), Element.class, proxyInterfaces, null, null, mappingInfo.hasEmbeddedIdentifier() ? (AbstractComponentType) mappingInfo.getIdentifier().getType() : null ); } catch ( HibernateException he ) { log.warn( "could not create proxy factory for:" + getEntityName(), he ); pf = null; } return pf; }
public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) { if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) { throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" ); } final javassist.util.proxy.ProxyFactory factory = new javassist.util.proxy.ProxyFactory(); factory.setFilter( FINALIZE_FILTER ); if ( superClass != null ) { factory.setSuperclass( superClass ); } if ( interfaces != null && interfaces.length > 0 ) { factory.setInterfaces( interfaces ); } proxyClass = factory.createClass(); }
@Override protected ProxyFactory buildProxyFactory(PersistentClass thePersistentClass, Getter idGetter, Setter idSetter) { ProxyFactory pf = new MapProxyFactory(); try { pf.postInstantiate(getEntityName(), null, null, null, null, null); } catch (final HibernateException he) { log.warn("could not create proxy factory for:" + getEntityName(), he); pf = null; } return pf; }
/** * Constructs a proxy factory instance * * @param persistentClass The persistent class * @return The factory */ public static ProxyFactory buildProxyFactory(PersistentClass persistentClass) { ProxyFactory proxyFactory = ProxyFactorySupport.createProxyFactory(); @SuppressWarnings("unchecked") Set<Class> proxyInterfaces = new HashSet<>(); proxyInterfaces.add(HibernateProxy.class); final Class<?> javaClass = persistentClass.getMappedClass(); final Property identifierProperty = persistentClass.getIdentifierProperty(); final Method idGetterMethod = identifierProperty!=null? identifierProperty.getGetter(javaClass).getMethod() : null; final Method idSetterMethod = identifierProperty!=null? identifierProperty.getSetter(javaClass).getMethod() : null; final Type identifierType = persistentClass.hasEmbeddedIdentifier() ? persistentClass.getIdentifier().getType() : null; try { proxyFactory.postInstantiate(persistentClass.getEntityName(), javaClass, proxyInterfaces, idGetterMethod, idSetterMethod, identifierType instanceof CompositeType ? (CompositeType) identifierType : null); } catch (HibernateException e) { LOG.warn("Cannot instantiate proxy factory: " + e.getMessage()); return null; } return proxyFactory; }
public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) { if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) { throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" ); } javassist.util.proxy.ProxyFactory factory = new javassist.util.proxy.ProxyFactory(); factory.setFilter( FINALIZE_FILTER ); if ( superClass != null ) { factory.setSuperclass( superClass ); } if ( interfaces != null && interfaces.length > 0 ) { factory.setInterfaces( interfaces ); } proxyClass = factory.createClass(); }
protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) { // allows defining a custom proxy factory, which is responsible for // generating lazy proxies for a given entity. // // Here we simply use the default... return super.buildProxyFactory( persistentClass, idGetter, idSetter ); }
@Override protected ProxyFactory buildProxyFactory(PersistentClass pc, Getter arg1,Setter arg2) { CFCHibernateProxyFactory pf = new CFCHibernateProxyFactory(); pf.postInstantiate(pc); return pf; }
/** * {@inheritDoc} */ @Override protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) { fixPropertyAccessors(persistentClass); return super.buildProxyFactory(persistentClass, idGetter, idSetter); }
protected final ProxyFactory getProxyFactory() { return proxyFactory; }
protected ProxyFactory buildProxyFactoryInternal(PersistentClass persistentClass, Getter idGetter, Setter idSetter) { // TODO : YUCK!!! fix after HHH-1907 is complete return Environment.getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); // return getFactory().getSettings().getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); }
@Override protected ProxyFactory buildProxyFactory(EntityBinding entityBinding, Getter idGetter, Setter idSetter) { // determine the id getter and setter methods from the proxy interface (if any) // determine all interfaces needed by the resulting proxy HashSet<Class> proxyInterfaces = new HashSet<Class>(); proxyInterfaces.add( HibernateProxy.class ); Class mappedClass = entityBinding.getEntity().getClassReference(); Class proxyInterface = entityBinding.getProxyInterfaceType().getValue(); if ( proxyInterface!=null && !mappedClass.equals( proxyInterface ) ) { if ( ! proxyInterface.isInterface() ) { throw new MappingException( "proxy must be either an interface, or the class itself: " + getEntityName() ); } proxyInterfaces.add( proxyInterface ); } if ( mappedClass.isInterface() ) { proxyInterfaces.add( mappedClass ); } for ( EntityBinding subEntityBinding : entityBinding.getPostOrderSubEntityBindingClosure() ) { final Class subclassProxy = subEntityBinding.getProxyInterfaceType().getValue(); final Class subclassClass = subEntityBinding.getClassReference(); if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) { if ( ! subclassProxy.isInterface() ) { throw new MappingException( "proxy must be either an interface, or the class itself: " + subEntityBinding.getEntity().getName() ); } proxyInterfaces.add( subclassProxy ); } } for ( AttributeBinding property : entityBinding.attributeBindings() ) { Method method = getGetter( property ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.gettersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName()); } method = getSetter( property ).getMethod(); if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { LOG.settersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName()); } } Method idGetterMethod = idGetter==null ? null : idGetter.getMethod(); Method idSetterMethod = idSetter==null ? null : idSetter.getMethod(); Method proxyGetIdentifierMethod = idGetterMethod==null || proxyInterface==null ? null : ReflectHelper.getMethod(proxyInterface, idGetterMethod); Method proxySetIdentifierMethod = idSetterMethod==null || proxyInterface==null ? null : ReflectHelper.getMethod(proxyInterface, idSetterMethod); ProxyFactory pf = buildProxyFactoryInternal( entityBinding, idGetter, idSetter ); try { pf.postInstantiate( getEntityName(), mappedClass, proxyInterfaces, proxyGetIdentifierMethod, proxySetIdentifierMethod, entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded() ? ( CompositeType ) entityBinding .getHierarchyDetails() .getEntityIdentifier() .getValueBinding() .getHibernateTypeDescriptor() .getResolvedTypeMapping() : null ); } catch ( HibernateException he ) { LOG.unableToCreateProxyFactory(getEntityName(), he); pf = null; } return pf; }
protected ProxyFactory buildProxyFactoryInternal(EntityBinding entityBinding, Getter idGetter, Setter idSetter) { // TODO : YUCK!!! fix after HHH-1907 is complete return Environment.getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); // return getFactory().getSettings().getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); }
@Override protected ProxyFactory buildProxyFactory(PersistentClass thePersistentClass, Getter idGetter, Setter idSetter) { final Class<?> mappedClass = thePersistentClass.getMappedClass(); Check.isNotNull(mappedClass, "Mapped class of entity " + thePersistentClass.getEntityName() + " is null"); // determine the id getter and setter methods from the proxy interface // (if // any) // determine all interfaces needed by the resulting proxy final HashSet<Object> proxyInterfaces = new HashSet<Object>(); proxyInterfaces.add(HibernateProxy.class); final Class<?> proxyInterface = thePersistentClass.getProxyInterface(); if (proxyInterface != null && !mappedClass.equals(proxyInterface)) { if (!proxyInterface.isInterface()) { throw new MappingException("proxy must be either an interface, or the class itself: " + getEntityName()); } proxyInterfaces.add(proxyInterface); } if (mappedClass.isInterface()) { proxyInterfaces.add(mappedClass); } final Iterator<?> iter = thePersistentClass.getSubclassIterator(); while (iter.hasNext()) { final Subclass subclass = (Subclass) iter.next(); final Class<?> subclassProxy = subclass.getProxyInterface(); final Class<?> subclassClass = subclass.getMappedClass(); if (subclassProxy != null && !subclassClass.equals(subclassProxy)) { if (proxyInterface == null || !proxyInterface.isInterface()) { throw new MappingException("proxy must be either an interface, or the class itself: " + subclass.getEntityName()); } proxyInterfaces.add(subclassProxy); } } final Method idGetterMethod = idGetter == null ? null : idGetter.getMethod(); final Method idSetterMethod = idSetter == null ? null : idSetter.getMethod(); final Method proxyGetIdentifierMethod = idGetterMethod == null || proxyInterface == null ? null : ReflectHelper.getMethod(proxyInterface, idGetterMethod); final Method proxySetIdentifierMethod = idSetterMethod == null || proxyInterface == null ? null : ReflectHelper.getMethod(proxyInterface, idSetterMethod); ProxyFactory pf = buildProxyFactoryInternal(thePersistentClass, idGetter, idSetter); try { pf.postInstantiate(getEntityName(), mappedClass, proxyInterfaces, proxyGetIdentifierMethod, proxySetIdentifierMethod, thePersistentClass.hasEmbeddedIdentifier() ? (CompositeType) thePersistentClass .getIdentifier().getType() : null); } catch (final HibernateException he) { log.warn("could not create proxy factory for:" + getEntityName(), he); pf = null; } return pf; }
@Override protected ProxyFactory buildProxyFactoryInternal(PersistentClass persistentClass, Getter idGetter, Setter idSetter) { return GrailsHibernateUtil.buildProxyFactory(persistentClass); }
@Override protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) { return GrailsHibernateUtil.buildProxyFactory(persistentClass); }
protected ProxyFactory buildProxyFactoryInternal(PersistentClass persistentClass, Getter idGetter, Setter idSetter) { // TODO : YUCK!!! finx after HHH-1907 is complete return Environment.getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); // return getFactory().getSettings().getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); }
/** * Build an appropriate ProxyFactory for the given mapped entity. * * @param mappingInfo The mapping information regarding the mapped entity. * @param idGetter The constructed Getter relating to the entity's id property. * @param idSetter The constructed Setter relating to the entity's id property. * @return An appropriate ProxyFactory instance. */ protected abstract ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter);
/** * Build an appropriate ProxyFactory for the given mapped entity. * * @param mappingInfo The mapping information regarding the mapped entity. * @param idGetter The constructed Getter relating to the entity's id property. * @param idSetter The constructed Setter relating to the entity's id property. * @return An appropriate ProxyFactory instance. */ protected abstract ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, Setter idSetter);
/** * Build a proxy factory specifically for handling runtime * lazy loading. * * @return The lazy-load proxy factory. */ public ProxyFactory buildProxyFactory();
/** * Builds a Javassist-based proxy factory. * * @return a new Javassist-based proxy factory. */ public ProxyFactory buildProxyFactory() { return new JavassistProxyFactory(); }
/** * Builds a CGLIB-based proxy factory. * * @return a new CGLIB-based proxy factory. */ public ProxyFactory buildProxyFactory() { return new CGLIBProxyFactory(); }