Search in sources :

Example 1 with ContributionDef3

use of org.apache.tapestry5.ioc.def.ContributionDef3 in project tapestry-5 by apache.

the class DefaultModuleDefImpl method addContributionDef.

private void addContributionDef(Method method) {
    Contribute annotation = method.getAnnotation(Contribute.class);
    Class serviceInterface = annotation == null ? null : annotation.value();
    String serviceId = annotation != null ? null : stripMethodPrefix(method, CONTRIBUTE_METHOD_NAME_PREFIX);
    Class returnType = method.getReturnType();
    if (!returnType.equals(void.class))
        logger.warn(IOCMessages.contributionWrongReturnType(method));
    ConfigurationType type = null;
    for (Class parameterType : method.getParameterTypes()) {
        ConfigurationType thisParameter = PARAMETER_TYPE_TO_CONFIGURATION_TYPE.get(parameterType);
        if (thisParameter != null) {
            if (type != null)
                throw new RuntimeException(IOCMessages.tooManyContributionParameters(method));
            type = thisParameter;
        }
    }
    if (type == null)
        throw new RuntimeException(IOCMessages.noContributionParameter(method));
    Set<Class> markers = extractMarkers(method, Contribute.class, Optional.class);
    boolean optional = method.getAnnotation(Optional.class) != null;
    ContributionDef3 def = new ContributionDefImpl(serviceId, method, optional, proxyFactory, serviceInterface, markers);
    contributionDefs.add(def);
}
Also used : Optional(org.apache.tapestry5.ioc.annotations.Optional) ContributionDef3(org.apache.tapestry5.ioc.def.ContributionDef3) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Aggregations

Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1 Optional (org.apache.tapestry5.ioc.annotations.Optional)1 ContributionDef3 (org.apache.tapestry5.ioc.def.ContributionDef3)1