コード例 #1
0
  /**
   * Enhances the object on load.
   *
   * @param <T> Type of the object to enhance.
   * @param obj Object to augment/enhance.
   * @return Enhanced object.
   */
  @SuppressWarnings({"unchecked"})
  public static <T> T enhance(T obj) {
    ProxyFactory proxyFac = new ProxyFactory(obj);

    proxyFac.addAdvice(dfltAsp);
    proxyFac.addAdvice(setToValAsp);
    proxyFac.addAdvice(setToSetAsp);

    while (proxyFac.getAdvisors().length > 0) {
      proxyFac.removeAdvisor(0);
    }

    proxyFac.addAdvisor(
        new DefaultPointcutAdvisor(
            new GridifySpringPointcut(GridifySpringPointcutType.DFLT), dfltAsp));
    proxyFac.addAdvisor(
        new DefaultPointcutAdvisor(
            new GridifySpringPointcut(GridifySpringPointcutType.SET_TO_VALUE), setToValAsp));
    proxyFac.addAdvisor(
        new DefaultPointcutAdvisor(
            new GridifySpringPointcut(GridifySpringPointcutType.SET_TO_SET), setToSetAsp));

    return (T) proxyFac.getProxy();
  }