Java 类org.hibernate.proxy.ProxyFactory 实例源码

项目:lams    文件:DynamicMapEntityTuplizer.java   
@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;
}
项目:lams    文件:DynamicMapEntityTuplizer.java   
@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;
}
项目:cacheonix-core    文件:DynamicMapEntityTuplizer.java   
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;
    }
项目:cacheonix-core    文件:Dom4jEntityTuplizer.java   
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;
}
项目:lams    文件:ProxyFactoryFactoryImpl.java   
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();
}
项目:openbravo-brazil    文件:OBDynamicTuplizer.java   
@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;
}
项目:gorm-hibernate5    文件:GrailsHibernateUtil.java   
/**
 * 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;
}
项目:cacheonix-core    文件:ProxyFactoryFactoryImpl.java   
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();
}
项目:cacheonix-core    文件:MyEntityTuplizer.java   
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 );
}
项目:Lucee4    文件:AbstractEntityTuplizerImpl.java   
@Override
protected ProxyFactory buildProxyFactory(PersistentClass pc, Getter arg1,Setter arg2) {
    CFCHibernateProxyFactory pf = new CFCHibernateProxyFactory();
    pf.postInstantiate(pc);

    return pf;
}
项目:jspresso-ce    文件:DynamicPojoEntityTuplizer.java   
/**
 * {@inheritDoc}
 */
@Override
protected ProxyFactory buildProxyFactory(PersistentClass persistentClass,
    Getter idGetter, Setter idSetter) {
  fixPropertyAccessors(persistentClass);
  return super.buildProxyFactory(persistentClass, idGetter, idSetter);
}
项目:lams    文件:AbstractEntityTuplizer.java   
protected final ProxyFactory getProxyFactory() {
    return proxyFactory;
}
项目:lams    文件:PojoEntityTuplizer.java   
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();
    }
项目:lams    文件:PojoEntityTuplizer.java   
@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;
}
项目:lams    文件:PojoEntityTuplizer.java   
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();
    }
项目:openbravo-brazil    文件:OBTuplizer.java   
@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;
}
项目:gorm-hibernate5    文件:GroovyAwarePojoEntityTuplizer.java   
@Override
protected ProxyFactory buildProxyFactoryInternal(PersistentClass persistentClass, Getter idGetter, Setter idSetter) {
    return GrailsHibernateUtil.buildProxyFactory(persistentClass);
}
项目:gorm-hibernate5    文件:GroovyAwarePojoEntityTuplizer.java   
@Override
protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) {
    return GrailsHibernateUtil.buildProxyFactory(persistentClass);
}
项目:cacheonix-core    文件:AbstractEntityTuplizer.java   
protected final ProxyFactory getProxyFactory() {
    return proxyFactory;
}
项目:cacheonix-core    文件:PojoEntityTuplizer.java   
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();
    }
项目:lams    文件:AbstractEntityTuplizer.java   
/**
 * 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);
项目:lams    文件:AbstractEntityTuplizer.java   
/**
 * 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);
项目:lams    文件:ProxyFactoryFactory.java   
/**
 * Build a proxy factory specifically for handling runtime
 * lazy loading.
 *
 * @return The lazy-load proxy factory.
 */
public ProxyFactory buildProxyFactory();
项目:lams    文件:ProxyFactoryFactoryImpl.java   
/**
 * Builds a Javassist-based proxy factory.
 *
 * @return a new Javassist-based proxy factory.
 */
public ProxyFactory buildProxyFactory() {
    return new JavassistProxyFactory();
}
项目:cacheonix-core    文件:AbstractEntityTuplizer.java   
/**
 * 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);
项目:cacheonix-core    文件:ProxyFactoryFactoryImpl.java   
/**
 * Builds a Javassist-based proxy factory.
 *
 * @return a new Javassist-based proxy factory.
 */
public ProxyFactory buildProxyFactory() {
    return new JavassistProxyFactory();
}
项目:cacheonix-core    文件:ProxyFactoryFactoryImpl.java   
/**
 * Builds a CGLIB-based proxy factory.
 *
 * @return a new CGLIB-based proxy factory.
 */
public ProxyFactory buildProxyFactory() {
    return new CGLIBProxyFactory();
}
项目:cacheonix-core    文件:ProxyFactoryFactory.java   
/**
 * Build a proxy factory specifically for handling runtime
 * lazy loading.
 *
 * @return The lazy-load proxy factory.
 */
public ProxyFactory buildProxyFactory();