PreparedStatement createPreparedStatementProxy(
     PreparedStatement targetStatement, String sqlQuery) {
   return ProxyHelper.proxy(
       targetStatement,
       new PreparedStatementProxy(
           targetStatement, sqlQuery, metric, new TimeableMethodPredicate()));
 }
Exemple #2
0
  @SuppressWarnings("ConstantConditions")
  static <T, V> Collection<V> genericCollect(
      Collection<T> from, Class<? extends Collection> collectionClass, int initialCapacity) {
    checkPrepositions(J7GroupPrepositions.Preposition.FIELD);
    Collection<V> collected = createCollectionInstance(collectionClass, initialCapacity);

    for (T entity : from) {
      collected.add(ProxyHelper.<V>extractFirstArgument(entity));
    }

    return collected;
  }
  @Override
  public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Exception {
    final String mname = method.getName();
    Class<?> declaringClass = method.getDeclaringClass();
    if (declaringClass.equals(FormFieldCleaner.class)) {
      return super.invoke(self, method, proceed, args);
    } else {
      if ("setFormOwner".equals(mname) || "getFormStatus".equals(mname)) {
        return super.invoke(self, method, proceed, args);
      }

      try {
        if (!method.getDeclaringClass().isAssignableFrom(FormProxyObject.class)) {
          if (mname.startsWith("get")) {
            if (_origin == null) return null;

            final String attr = toAttrName(method);
            if (_cache != null) {
              if (_cache.containsKey(attr)) {
                return _cache.get(attr);
              }
            }

            Object value = method.invoke(_origin, args);
            if (value != null) {

              // ZK-2736 Form proxy with Immutable values
              value = ProxyHelper.createProxyIfAny(value, method.getAnnotations());

              addCache(attr, value);
              if (value instanceof FormProxyObject) {
                addDirtyField(attr); // it may be changed.
              }
            }
            return value;
          }
        }
      } catch (Exception e) {
        throw UiException.Aide.wrap(e);
      }
    }

    return super.invoke(self, method, proceed, args);
  }
Exemple #4
0
 private static boolean extractDesiredValue() {
   J7GroupPrepositions.Preposition calledPreposition =
       ProxyHelper.getCalledPreposition(FIRST_PREPOSITION_INDEX);
   try {
     switch (calledPreposition) {
       case WHEN_TRUE:
         return true;
       case WHEN_FALSE:
         return false;
       default:
         throw new IllegalPrepositionException(
             "Not allowed preposition was used. "
                 + "Expected prepositions: WHEN_TRUE, WHEN_FALSE. Actual preposition: "
                 + calledPreposition);
     }
   } finally {
     clearCalledPrepositions();
   }
 }
Exemple #5
0
 public List<E> subList(int fromIndex, int toIndex) {
   return ProxyHelper.createProxyIfAny(
       ((List<E>) getCache()).subList(fromIndex, toIndex), _callerAnnots);
 }
 public void rollback() throws IllegalStateException {
   proxyHelper.doOp(ClusterOperation.TRANSACTION_ROLLBACK, null, null);
   ClientThreadContext threadContext = ClientThreadContext.get();
   threadContext.removeTransaction();
 }
 public void commit() throws IllegalStateException {
   proxyHelper.doOp(ClusterOperation.TRANSACTION_COMMIT, null, null);
   ClientThreadContext threadContext = ClientThreadContext.get();
   threadContext.removeTransaction();
 }
 public void begin() throws IllegalStateException {
   proxyHelper.doOp(ClusterOperation.TRANSACTION_BEGIN, null, null);
 }