예제 #1
0
  /**
   * Wraps given object using proxy created by {@link ProxyInstanceFactory}.
   *
   * @param obj
   * @return
   * @throws InstantiationException
   * @throws IllegalAccessException
   */
  @SuppressWarnings("unchecked")
  private <T> T proxyImpl(T obj) throws InstantiationException, IllegalAccessException {
    ChainStateHolder.setChain(new ArrayList<String>());
    retrievePossibleChains();

    Integer chainIndex = ChainStateHolder.getCurrentChainIndex();
    if (chainIndex == null) {
      chainIndex = 0;
    } else {
      ++chainIndex;
    }
    ChainStateHolder.setCurrentChainIndex(chainIndex);

    return (T) proxyInstanceFactory.proxy(obj, (Class<T>) obj.getClass());
  }