Search in sources :

Example 1 with BaseActionWrapperStack

use of jodd.madvoc.BaseActionWrapperStack in project jodd by oblac.

the class WrapperManager method expand.

/**
	 * Replaces all {@link #getDefaultWebAppWrapper()} with {@link #getDefaultWebAppWrapper()}
	 * and {@link BaseActionWrapperStack} with stack values.
	 */
protected Class<? extends T>[] expand(Class<? extends T>[] actionWrappers) {
    if (actionWrappers == null) {
        return null;
    }
    List<Class<? extends T>> list = new ArrayList<>(actionWrappers.length);
    list.addAll(Arrays.asList(actionWrappers));
    int i = 0;
    while (i < list.size()) {
        Class<? extends T> wrapperClass = list.get(i);
        if (wrapperClass == null) {
            continue;
        }
        if (wrapperClass.equals(getDefaultWebAppWrapper())) {
            list.remove(i);
            // add default wrappers list
            Class<? extends T>[] defaultWrappers = getDefaultWrappers();
            if (defaultWrappers != null) {
                int ndx = i;
                for (Class<? extends T> defaultWrapper : defaultWrappers) {
                    // can't add default list stack to default list
                    if (defaultWrapper.equals(getDefaultWebAppWrapper())) {
                        throw new MadvocException("Default wrapper list is self-contained (cyclic dependency)!");
                    }
                    list.add(ndx, defaultWrapper);
                    ndx++;
                }
            }
            continue;
        }
        if (ReflectUtil.isTypeOf(wrapperClass, BaseActionWrapperStack.class)) {
            BaseActionWrapperStack stack = (BaseActionWrapperStack) resolve(wrapperClass);
            list.remove(i);
            Class<? extends T>[] stackWrappers = stack.getWrappers();
            if (stackWrappers != null) {
                list.addAll(i, Arrays.asList(stackWrappers));
            }
            i--;
        //continue;
        }
        i++;
    }
    return list.toArray(new Class[list.size()]);
}
Also used : BaseActionWrapperStack(jodd.madvoc.BaseActionWrapperStack) ArrayList(java.util.ArrayList) MadvocException(jodd.madvoc.MadvocException)

Aggregations

ArrayList (java.util.ArrayList)1 BaseActionWrapperStack (jodd.madvoc.BaseActionWrapperStack)1 MadvocException (jodd.madvoc.MadvocException)1