org.springframework.cglib.proxy.Factory类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中org.springframework.cglib.proxy.Factory类的一些代码示例,展示了Factory类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory类的具体详情如下:
包路径:org.springframework.cglib.proxy.Factory
类名称:Factory

Factory介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

factory.setCallbacks(new Callback[] {NoOp.INSTANCE,
    new LookupOverrideMethodInterceptor(this.beanDefinition, this.owner),
    new ReplaceOverrideMethodInterceptor(this.beanDefinition, this.owner)});

代码示例来源:origin: spring-projects/spring-framework

@Override
  public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
    Object other = args[0];
    if (proxy == other) {
      return true;
    }
    if (other instanceof Factory) {
      Callback callback = ((Factory) other).getCallback(INVOKE_EQUALS);
      if (!(callback instanceof EqualsInterceptor)) {
        return false;
      }
      AdvisedSupport otherAdvised = ((EqualsInterceptor) callback).advised;
      return AopProxyUtils.equalsInProxy(this.advised, otherAdvised);
    }
    else {
      return false;
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

((Factory) fbProxy).setCallback(0, (MethodInterceptor) (obj, method, args, proxy) -> {
  if (method.getName().equals("getObject") && args.length == 0) {
    return beanFactory.getBean(beanName);

代码示例来源:origin: spring-projects/spring-framework

((Factory) proxyInstance).setCallbacks(callbacks);
return proxyInstance;

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-mapper

public static MethodInterceptorRdf getMethodInterceptor(Object o) {
  MethodInterceptorRdf result = null;
  if(o != null && Enhancer.isEnhanced(o.getClass())) {
    Factory factory = (Factory)o;
    Callback callback = factory.getCallback(0);
    result = callback != null && callback instanceof MethodInterceptorRdf
        ? (MethodInterceptorRdf)callback : null;
  }
  return result;
}

代码示例来源:origin: org.springframework/spring-context

((Factory) fbProxy).setCallback(0, (MethodInterceptor) (obj, method, args, proxy) -> {
  if (method.getName().equals("getObject") && args.length == 0) {
    return beanFactory.getBean(beanName);

代码示例来源:origin: org.springframework/spring-beans

factory.setCallbacks(new Callback[] {NoOp.INSTANCE,
    new LookupOverrideMethodInterceptor(this.beanDefinition, this.owner),
    new ReplaceOverrideMethodInterceptor(this.beanDefinition, this.owner)});

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

public static MethodInterceptorRdf getMethodInterceptor(Object o) {
  MethodInterceptorRdf result = null;
  if(o != null && Enhancer.isEnhanced(o.getClass())) {
    Factory factory = (Factory)o;
    Callback callback = factory.getCallback(0);
    result = callback != null && callback instanceof MethodInterceptorRdf
        ? (MethodInterceptorRdf)callback : null;
  }
  return result;
}

代码示例来源:origin: apache/servicemix-bundles

((Factory) fbProxy).setCallback(0, (MethodInterceptor) (obj, method, args, proxy) -> {
  if (method.getName().equals("getObject") && args.length == 0) {
    return beanFactory.getBean(beanName);

代码示例来源:origin: spring-projects/spring-framework

((Factory) proxy).setCallbacks(new Callback[] {interceptor});
return (T) proxy;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-aop

@Override
  public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
    Object other = args[0];
    if (proxy == other) {
      return true;
    }
    if (other instanceof Factory) {
      Callback callback = ((Factory) other).getCallback(INVOKE_EQUALS);
      if (!(callback instanceof EqualsInterceptor)) {
        return false;
      }
      AdvisedSupport otherAdvised = ((EqualsInterceptor) callback).advised;
      return AopProxyUtils.equalsInProxy(this.advised, otherAdvised);
    }
    else {
      return false;
    }
  }
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Creates a proxy for the given {@link MongoPersistentProperty} using the given {@link DbRefResolverCallback} to
 * eventually resolve the value of the property.
 *
 * @param property must not be {@literal null}.
 * @param dbref can be {@literal null}.
 * @param callback must not be {@literal null}.
 * @return
 */
private Object createLazyLoadingProxy(MongoPersistentProperty property, @Nullable DBRef dbref,
    DbRefResolverCallback callback, DbRefProxyHandler handler) {
  Class<?> propertyType = property.getType();
  LazyLoadingInterceptor interceptor = new LazyLoadingInterceptor(property, dbref, exceptionTranslator, callback);
  if (!propertyType.isInterface()) {
    Factory factory = (Factory) objenesis.newInstance(getEnhancedTypeFor(propertyType));
    factory.setCallbacks(new Callback[] { interceptor });
    return handler.populateId(property, dbref, factory);
  }
  ProxyFactory proxyFactory = new ProxyFactory();
  for (Class<?> type : propertyType.getInterfaces()) {
    proxyFactory.addInterface(type);
  }
  proxyFactory.addInterface(LazyLoadingProxy.class);
  proxyFactory.addInterface(propertyType);
  proxyFactory.addAdvice(interceptor);
  return handler.populateId(property, dbref, proxyFactory.getProxy());
}

代码示例来源:origin: fang-yan-peng/eagle

@Override
  public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
    Object other = args[0];
    if (proxy == other) {
      return true;
    }
    if (other instanceof Factory) {
      Callback callback = ((Factory) other).getCallback(INVOKE_EQUALS);
      if (!(callback instanceof EagleTraceCglibProxy.EqualsInterceptor)) {
        return false;
      }
      AdvisedSupport otherAdvised = ((EagleTraceCglibProxy.EqualsInterceptor) callback).advised;
      return AopProxyUtils.equalsInProxy(this.advised, otherAdvised);
    } else {
      return false;
    }
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

((Factory) proxy).setCallbacks(new Callback[] {interceptor});
return (T) proxy;

代码示例来源:origin: apache/servicemix-bundles

@Override
  public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
    Object other = args[0];
    if (proxy == other) {
      return true;
    }
    if (other instanceof Factory) {
      Callback callback = ((Factory) other).getCallback(INVOKE_EQUALS);
      if (!(callback instanceof EqualsInterceptor)) {
        return false;
      }
      AdvisedSupport otherAdvised = ((EqualsInterceptor) callback).advised;
      return AopProxyUtils.equalsInProxy(this.advised, otherAdvised);
    }
    else {
      return false;
    }
  }
}

代码示例来源:origin: org.springframework/spring-webmvc

((Factory) proxy).setCallbacks(new Callback[] {interceptor});
return (T) proxy;

代码示例来源:origin: spring-projects/spring-framework

((Factory) proxy).setCallbacks(new Callback[] {interceptor});
return (T) proxy;

代码示例来源:origin: spring-projects/spring-framework

((Factory) proxy).setCallbacks(new Callback[] {interceptor});
return (T) proxy;

代码示例来源:origin: spring-projects/spring-hateoas

@SuppressWarnings("unchecked")
private static <T> T getProxyWithInterceptor(Class<?> type, InvocationRecordingMethodInterceptor interceptor,
    ClassLoader classLoader) {
  if (type.isInterface()) {
    ProxyFactory factory = new ProxyFactory(EmptyTargetSource.INSTANCE);
    factory.addInterface(type);
    factory.addInterface(LastInvocationAware.class);
    factory.addAdvice(interceptor);
    return (T) factory.getProxy();
  }
  Factory factory = (Factory) OBJENESIS.newInstance(getOrCreateEnhancedClass(type, classLoader));
  factory.setCallbacks(new Callback[] { interceptor });
  return (T) factory;
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

/**
 * Creates a proxy for the given {@link MongoPersistentProperty} using the given {@link DbRefResolverCallback} to
 * eventually resolve the value of the property.
 *
 * @param property must not be {@literal null}.
 * @param dbref can be {@literal null}.
 * @param callback must not be {@literal null}.
 * @return
 */
private Object createLazyLoadingProxy(MongoPersistentProperty property, @Nullable DBRef dbref,
    DbRefResolverCallback callback, DbRefProxyHandler handler) {
  Class<?> propertyType = property.getType();
  LazyLoadingInterceptor interceptor = new LazyLoadingInterceptor(property, dbref, exceptionTranslator, callback);
  if (!propertyType.isInterface()) {
    Factory factory = (Factory) objenesis.newInstance(getEnhancedTypeFor(propertyType));
    factory.setCallbacks(new Callback[] { interceptor });
    return handler.populateId(property, dbref, factory);
  }
  ProxyFactory proxyFactory = new ProxyFactory();
  for (Class<?> type : propertyType.getInterfaces()) {
    proxyFactory.addInterface(type);
  }
  proxyFactory.addInterface(LazyLoadingProxy.class);
  proxyFactory.addInterface(propertyType);
  proxyFactory.addAdvice(interceptor);
  return handler.populateId(property, dbref, proxyFactory.getProxy());
}

相关文章