使用切面代理对象

@param <T> 切面对象类型
@param target 目标对象
@param aspectClass 切面对象类
@return 代理对象
423264
public static <T> T proxy(T target, Class<? extends Aspect> aspectClass){
		return ProxyFactory.createProxy(target, aspectClass);
	}
401278
@Override
    public StreamByteOutput<T> target(final T target) {
        return (StreamByteOutput<T>) super.target(target);
    }
397849
<T> Class<?> transform(Class<T> proxyInterface) {
    try {
      String packageName = proxyInterface.getPackage().getName();
      String genericProxyInterfaceName =
          packageName + "." + PROXY_PREFIX + proxyInterface.getSimpleName();
      try {
        return Class.forName(genericProxyInterfaceName);
      } catch (ClassNotFoundException e) {
        pool.insertClassPath(new ClassClassPath(proxyInterface));
        CtClass copy = pool.getAndRename(proxyInterface.getName(), genericProxyInterfaceName);
        replaceGenericResponseMethods(copy);

        return copy
            .toClass(this.getClass().getClassLoader(), this.getClass().getProtectionDomain());
      }
    } catch (NotFoundException e) {
      throw new RuntimeException(e);
    } catch (CannotCompileException e) {
      throw new RuntimeException(e);
    } catch (BadBytecode e) {
      throw new RuntimeException(e);
    }
  }
510002
@SuppressWarnings("unchecked")
	static <E, M extends BinderMapper<E>> M getMapper(Class<E> cls) {
		M mapper = (M) OBJECT_MAPPERS.get(cls);
		if (mapper == null) {
			// The only way the mapper wouldn't already be loaded into
			// OBJECT_MAPPERS is if it was compiled separately, but let's handle
			// it anyway
			String beanClassName = cls.getName();
			String mapperClassName = cls.getName() + KriptonBinder.MAPPER_CLASS_SUFFIX;
			try {
				Class<E> mapperClass = (Class<E>) Class.forName(mapperClassName);
				mapper = (M) mapperClass.newInstance();
				// mapper.
				OBJECT_MAPPERS.put(cls, mapper);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
				throw new KriptonRuntimeException(String.format("Class '%s' does not exist. Does '%s' have @BindType annotation?", mapperClassName, beanClassName));
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return mapper;
	}
474803
@AfterThrowing(pointcut = "execution( * org.eclipse.hawkbit.repository.jpa.*Management.*(..))", throwing = "ex")
    // Exception for squid:S00112, squid:S1162
    // It is a AspectJ proxy which deals with exceptions.
    @SuppressWarnings({ "squid:S00112", "squid:S1162" })
    public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable {

        // Workarround for EclipseLink merge where it does not throw
        // ConstraintViolationException directly in case of existing entity
        // update
        if (ex instanceof TransactionSystemException) {
            throw replaceWithCauseIfConstraintViolationException((TransactionSystemException) ex);
        }

        for (final Class<?> mappedEx : MAPPED_EXCEPTION_ORDER) {

            if (!mappedEx.isAssignableFrom(ex.getClass())) {
                continue;
            }

            if (EXCEPTION_MAPPING.containsKey(mappedEx.getName())) {
                throw (Exception) Class.forName(EXCEPTION_MAPPING.get(mappedEx.getName()))
                        .getConstructor(Throwable.class).newInstance(ex);
            }

            LOG.error("there is no mapping configured for exception class {}", mappedEx.getName());
            throw new GenericSpServerException(ex);
        }

        throw ex;
    }
585956
public boolean isAssignableTo(Class<?> target) {

        LettuceAssert.notNull(target, "Target type must not be null");

        return LettuceClassUtils.isAssignable(target, getParameterType());
    }
322854
public static <TARGET> Implementing<TARGET> implementing(Class<TARGET> targetType) {
        return new Implementing<>(TypeUtils.wrap(targetType));
    }
91504
public <T> JdbcMapperBuilder<T> newBuilder(final Type target) {
		ClassMeta<T> classMeta = getClassMeta(target);
		return newBuilder(classMeta);
	}
431446
public static Method getAccessibleMethodByName(final Object target, final String name) {
		for (Class<?> searchType = target.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
			Method[] methods = searchType.getDeclaredMethods();
			for (Method method : methods) {
				if (method.getName().equals(name)) {
					makeAccessible(method);
					return method;
				}
			}
		}
		return null;
	}
768191
public static Field getAccessibleField(final Object target, final String name) {
		for (Class<?> superClass = target.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
			try {
				Field field = superClass.getDeclaredField(name);
				makeAccessible(field);
				return field;
			} catch (NoSuchFieldException e) {
				// Field 不在当前类定义，继续向上转型
				LOG.trace("", e);
			}
		}
		return null;
	}
1352722
@GetMapping
  public String viewTagWizard(
      @RequestParam(required = false, value = "selectedTarget") String target, Model model) {
    List<String> entityTypeIds =
        dataService
            .findAll(ENTITY_TYPE_META_DATA, EntityType.class)
            .filter(entityType -> !EntityTypeUtils.isSystemEntity(entityType))
            .map(EntityType::getId)
            .collect(toList());

    if (StringUtils.isEmpty(target)) {
      Optional<String> findFirst = entityTypeIds.stream().findFirst();
      if (findFirst.isPresent()) {
        target = findFirst.get();
      }
    }

    if (StringUtils.isEmpty(target)) {
      throw new IllegalStateException("There are no entities available!");
    }

    List<Ontology> ontologies = ontologyService.getOntologies();
    EntityType emd = dataService.getEntityType(target);
    List<Attribute> attributes = newArrayList(emd.getAttributes());
    Map<String, Multimap<Relation, OntologyTerm>> taggedAttributes =
        attributes
            .stream()
            .collect(
                toMap((Attribute::getName), (x -> ontologyTagService.getTagsForAttribute(emd, x))));

    model.addAttribute("entity", emd);
    model.addAttribute("entityTypeIds", entityTypeIds);
    model.addAttribute("attributes", attributes);
    model.addAttribute("ontologies", ontologies);
    model.addAttribute("taggedAttributes", taggedAttributes);
    model.addAttribute("relations", Relation.values());

    return VIEW_TAG_WIZARD;
  }
1190586
@SuppressWarnings("unchecked")
    public static <T extends Annotation> T createAnnotation(final Class<T> clazz) {
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz, Annotation.class}, new SimpleAnnoInvocationHandler(clazz));
    }
1296367
public Expression checkedCast(final Type target) {
    checkArgument(
        target.getSort() == Type.OBJECT,
        "cast targets must be reference types. (%s)",
        target.getClassName());
    checkArgument(
        resultType().getSort() == Type.OBJECT,
        "you may only cast from reference types. (%s)",
        resultType().getClassName());
    if (BytecodeUtils.isDefinitelyAssignableFrom(target, resultType())) {
      return this;
    }
    return new Expression(target, features()) {
      @Override
      protected void doGen(CodeBuilder adapter) {
        Expression.this.gen(adapter);
        // TODO(b/191662001) Remove this once we have fully switched the type
        // system over. Normally, we should just cast this result over, but in
        // the case of SoyString, there are temporarily two states (SanitizedContent == SoyString)
        // and (SanitizedContent != SoyString). This branch bails out to a runtime function that
        // effectively does the below but also optionally logs a warning.
        if (resultType().equals(BytecodeUtils.SOY_STRING_TYPE)) {
          MethodRef.RUNTIME_CHECK_SOY_STRING.invokeUnchecked(adapter);
        } else {
          adapter.checkCast(resultType());
        }
      }
    };
  }
798929
public static <T extends Annotation> T getAnnotation( Class<?> target, Class<T> annotationClass) {
        Class<?> clazz = target;
        T annotation = clazz.getAnnotation(annotationClass);
        if(annotation != null) {
            return annotation;
        }
        while((clazz = clazz.getSuperclass()) != null) {
            annotation = clazz.getAnnotation(annotationClass);
            if(annotation != null) {
                return annotation;
            }
        }
        return null;
    }
686114
public static Object getTarget(Object proxy) throws Exception {  
          
        if(!AopUtils.isAopProxy(proxy)) {  
            return proxy;//不是代理对象  
        }  
          
        if(AopUtils.isJdkDynamicProxy(proxy)) {  
            Object object = getJdkDynamicProxyTargetObject(proxy);  
            return getTarget(object);
        } else { //cglib  
        	Object object =  getCglibProxyTargetObject(proxy);  
        	return getTarget(object);
        }  
          
          
          
    }
830461
@Override
    public  <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
        return AnnotationUtils.getAnnotation(target, annotationClass);
    }
135702
public static <TARGET> CopyingConverter<Object, TARGET> forTargetType(final Class<TARGET> target) {
        final Typed<TARGET> targetType = TypeUtils.wrap(target);

        return new Fluent<TARGET>(requireDefaultConstructor(target)) {
            @Override
            public Typed<TARGET> getTargetType() {
                return targetType;
            }
        };
    }