Package org.apache.tapestry.ioc

Examples of org.apache.tapestry.ioc.AnnotationProvider


        String description = String.format("PropertyConduit[%s %s]", rootClass.getName(), expression);

        Class conduitClass = classFab.createClass();

        AnnotationProvider provider = new AnnotationProvider()
        {
            public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
            {
                T result = readInfo == null ? null : readInfo.getAnnotation(annotationClass);
View Full Code Here


    @Test
    public void no_path_annotation()
    {
        AssetSource source = mockAssetSource();
        ObjectLocator locator = mockObjectLocator();
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        TypeCoercer typeCoercer = mockTypeCoercer();
        SymbolSource symbolSource = mockSymbolSource();

        train_getAnnotation(annotationProvider, Path.class, null);
View Full Code Here

        AssetSource source = mockAssetSource();
        ObjectLocator locator = mockObjectLocator();
        Asset asset = mockAsset();
        String path = "${foo}";
        String expanded = "foo/bar/baz.gif";
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        TypeCoercer typeCoercer = mockTypeCoercer();
        Path pathAnnotation = mockPath();
        SymbolSource symbolSource = mockSymbolSource();

        train_getAnnotation(annotationProvider, Path.class, pathAnnotation);
View Full Code Here

    @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

    @Test
    public void no_annotation()
    {
        SymbolSource source = mockSymbolSource();
        TypeCoercer coercer = mockTypeCoercer();
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        ObjectLocator locator = mockObjectLocator();

        train_getAnnotation(annotationProvider, Symbol.class, null);

        replay();
View Full Code Here

    @Test
    public void annotation_present()
    {
        SymbolSource source = mockSymbolSource();
        TypeCoercer coercer = mockTypeCoercer();
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        ObjectLocator locator = mockObjectLocator();
        String symbolName = "example-symbol";
        String symbolValue = "symbol-value";
        Long coercedValue = 123l;
        Symbol annotation = newSymbol(symbolName);
View Full Code Here

    @Test
    public void intermediate_type()
    {
        SymbolSource source = mockSymbolSource();
        TypeCoercer coercer = mockTypeCoercer();
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        ObjectLocator locator = mockObjectLocator();
        String symbolName = "example-symbol";
        String symbolValue = "symbol-value";
        Long coercedValue = 123l;
        Symbol annotation = newSymbol(symbolName);
View Full Code Here

    public void found_match_first()
    {
        ObjectProvider prov1 = mockObjectProvider();
        ObjectProvider prov2 = mockObjectProvider();
        Class type = Runnable.class;
        AnnotationProvider ap = mockAnnotationProvider();
        ObjectLocator locator = mockObjectLocator();
        Object expected = mockRunnable();

        train_provide(prov1, type, ap, locator, expected);
View Full Code Here

TOP

Related Classes of org.apache.tapestry.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.