Search in sources :

Example 1 with Target

use of jodd.madvoc.injector.Target in project jodd by oblac.

the class ResultsManager method initializeResult.

// ---------------------------------------------------------------- init
/**
	 * Initializes action result.
	 */
protected void initializeResult(ActionResult result) {
    contextInjectorComponent.injectContext(new Target(result));
    result.init();
}
Also used : Target(jodd.madvoc.injector.Target)

Example 2 with Target

use of jodd.madvoc.injector.Target in project jodd by oblac.

the class ActionMethodParser method parseActionDef.

/**
	 * Parses action class and method and creates {@link jodd.madvoc.ActionDef parsed action definition}.
	 */
public ActionDef parseActionDef(final Class<?> actionClass, final Method actionMethod) {
    ActionAnnotationData annotationData = detectActionAnnotationData(actionMethod);
    // collector for all action names
    final ActionNames actionNames = new ActionNames();
    readPackageActionPath(actionNames, actionClass);
    readClassActionPath(actionNames, actionClass);
    readMethodActionPath(actionNames, actionMethod.getName(), annotationData);
    readMethodExtension(actionNames, annotationData);
    readMethodHttpMethod(actionNames, annotationData);
    final Class<? extends ActionNamingStrategy> actionPathNamingStrategy = parseMethodNamingStrategy(annotationData);
    ActionNamingStrategy namingStrategy;
    try {
        namingStrategy = actionPathNamingStrategy.newInstance();
        contextInjectorComponent.injectContext(new Target(namingStrategy));
    } catch (Exception ex) {
        throw new MadvocException(ex);
    }
    return namingStrategy.buildActionDef(actionClass, actionMethod, actionNames);
}
Also used : ActionNamingStrategy(jodd.madvoc.path.ActionNamingStrategy) Target(jodd.madvoc.injector.Target) ActionNames(jodd.madvoc.ActionNames) ActionAnnotationData(jodd.madvoc.meta.ActionAnnotationData) MadvocException(jodd.madvoc.MadvocException) MadvocException(jodd.madvoc.MadvocException)

Example 3 with Target

use of jodd.madvoc.injector.Target in project jodd by oblac.

the class WrapperManager method initializeWrapper.

// ---------------------------------------------------------------- init
/**
	 * Initializes action wrapper.
	 */
protected void initializeWrapper(T wrapper) {
    contextInjectorComponent.injectContext(new Target(wrapper));
    wrapper.init();
}
Also used : Target(jodd.madvoc.injector.Target)

Example 4 with Target

use of jodd.madvoc.injector.Target in project jodd by oblac.

the class ActionRequest method makeTargets.

/**
	 * Joins action and parameters into one array of Targets.
	 */
protected Target[] makeTargets() {
    if (!actionConfig.hasArguments) {
        return new Target[] { new Target(action) };
    }
    ActionConfig.MethodParam[] methodParams = actionConfig.getMethodParams();
    Target[] target = new Target[methodParams.length + 1];
    target[0] = new Target(action);
    for (int i = 0; i < methodParams.length; i++) {
        ActionConfig.MethodParam mp = methodParams[i];
        Class type = mp.getType();
        Target t;
        if (mp.getAnnotationType() == null) {
            // parameter is NOT annotated
            t = new Target(createActionMethodArgument(type));
        } else if (mp.getAnnotationType() == Out.class) {
            // parameter is annotated with *only* OUT annotation
            // we need to create the output AND to save the type
            t = new Target(createActionMethodArgument(type), type);
        } else {
            // parameter is annotated with any IN annotation
            t = new Target(type) {

                @Override
                protected void createValueInstance() {
                    value = createActionMethodArgument(type);
                }
            };
        }
        target[i + 1] = t;
    }
    return target;
}
Also used : Target(jodd.madvoc.injector.Target) Out(jodd.madvoc.meta.Out)

Aggregations

Target (jodd.madvoc.injector.Target)4 ActionNames (jodd.madvoc.ActionNames)1 MadvocException (jodd.madvoc.MadvocException)1 ActionAnnotationData (jodd.madvoc.meta.ActionAnnotationData)1 Out (jodd.madvoc.meta.Out)1 ActionNamingStrategy (jodd.madvoc.path.ActionNamingStrategy)1