Package org.apache.tapestry5.ioc

Examples of org.apache.tapestry5.ioc.AnnotationProvider


    @SuppressWarnings("unchecked")
    private static Object calculateParameterValue(Class parameterType, final Annotation[] parameterAnnotations,
                                                  ObjectLocator locator, Map<Class, Object> parameterDefaults)
    {
        AnnotationProvider provider = new AnnotationProvider()
        {
            public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
            {
                return findAnnotation(parameterAnnotations, annotationClass);
            }

        };

        // At some point, it would be nice to eliminate InjectService, and rely
        // entirely on service interface type and point-of-injection markers.

        InjectService is = provider.getAnnotation(InjectService.class);

        if (is != null)
        {
            String serviceId = is.value();

            return locator.getService(serviceId, parameterType);
        }

        // In the absence of @InjectService, try some autowiring. First, does the
        // parameter type match on of the resources (the parameter defaults)?

        if (provider.getAnnotation(Inject.class) == null)
        {
            Object result = parameterDefaults.get(parameterType);

            if (result != null) return result;
        }
View Full Code Here


    @SuppressWarnings("unchecked")
    @Test
    public void no_annotation()
    {
        Class objectType = Runnable.class;
        AnnotationProvider provider = mockAnnotationProvider();
        ObjectLocator locator = mockObjectLocator();

        train_getAnnotation(provider, Service.class, null);

        replay();
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void annotation_present()
    {
        Class objectType = Runnable.class;
        AnnotationProvider provider = mockAnnotationProvider();
        ObjectLocator locator = mockObjectLocator();
        Service service = newMock(Service.class);
        String serviceId = "JiffyPop";
        Runnable instance = mockRunnable();
View Full Code Here

        Field field = mockField();
        Messages messages = mockMessages();
        Locale locale = Locale.ENGLISH;
        Class propertyType = Map.class;
        TranslatorSource ts = mockTranslatorSource();
        AnnotationProvider ap = mockAnnotationProvider(null);

        train_findByType(ts, propertyType, null);

        replay();
View Full Code Here

    @Test
    public void create_default_translator_with_annotation()
    {
        TranslatorSource ts = mockTranslatorSource();
        AnnotationProvider ap = mockAnnotationProvider("fred");
        Translator t = mockTranslator();

        expect(ts.get("fred")).andReturn(t);

        replay();
View Full Code Here

        verify();
    }

    private AnnotationProvider mockAnnotationProvider(String translatorName)
    {
        AnnotationProvider ap = mockAnnotationProvider();

        if (translatorName == null)
        {
            train_getAnnotation(ap, Translate.class, null);
        }
View Full Code Here

        Messages globalMessages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        MarkupWriter writer = mockMarkupWriter();
        String label = "Field Label";
        String message = "Woops, did it again.";
        AnnotationProvider ap = mockAnnotationProvider(null);

        train_findByType(ts, propertyType, translator);

        train_getFormValidationId(fs, "myform");
View Full Code Here

        Translator translator = mockTranslator("maptrans", Map.class);
        MessageFormatter formatter = mockMessageFormatter();
        MarkupWriter writer = mockMarkupWriter();
        String label = "My Label";
        String message = "Formatted Message";
        AnnotationProvider ap = mockAnnotationProvider(null);

        train_findByType(ts, propertyType, translator);

        train_getFormValidationId(fs, "myform");
View Full Code Here

        Translator translator = mockTranslator("maptrans", Map.class);
        MessageFormatter formatter = mockMessageFormatter();
        MarkupWriter writer = mockMarkupWriter();
        String label = "My Label";
        String message = "Formatted Message";
        AnnotationProvider ap = mockAnnotationProvider(null);

        train_findByType(ts, propertyType, translator);

        train_getFormValidationId(fs, "myform");
View Full Code Here

    {
        String mode = "papyrus";

        AliasManager manager = newAliasManager();
        AliasManager overridesManager = newAliasManager();
        AnnotationProvider annotationProvider = mockAnnotationProvider();

        ObjectLocator locator = mockObjectLocator();
        Runnable r = mockRunnable();

        Map<Class, Object> configuration = newMap();
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.ioc.AnnotationProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.