Search in sources :

Example 1 with AutobuildObjectProvider

use of org.apache.tapestry5.ioc.internal.services.AutobuildObjectProvider in project tapestry-5 by apache.

the class TapestryIOCModule method setupObjectProviders.

/**
 * <dl>
 * <dt>AnnotationBasedContributions</dt>
 * <dd>Empty placeholder used to separate annotation-based ObjectProvider contributions (which come before) from
 * non-annotation based (such as ServiceOverride) which come after.</dd>
 * <dt>Value</dt>
 * <dd>Supports the {@link org.apache.tapestry5.ioc.annotations.Value} annotation</dd>
 * <dt>Symbol</dt>
 * <dd>Supports the {@link org.apache.tapestry5.ioc.annotations.Symbol} annotations</dd>
 * <dt>Autobuild</dt>
 * <dd>Supports the {@link org.apache.tapestry5.ioc.annotations.Autobuild} annotation</dd>
 * <dt>ServiceOverride</dt>
 * <dd>Allows simple service overrides via the {@link org.apache.tapestry5.ioc.services.ServiceOverride} service
 * (and its configuration)
 * </dl>
 */
@Contribute(MasterObjectProvider.class)
public static void setupObjectProviders(OrderedConfiguration<ObjectProvider> configuration, @Local final ServiceOverride serviceOverride) {
    configuration.add("AnnotationBasedContributions", null);
    configuration.addInstance("Value", ValueObjectProvider.class, before("AnnotationBasedContributions").build());
    configuration.addInstance("Symbol", SymbolObjectProvider.class, before("AnnotationBasedContributions").build());
    configuration.add("Autobuild", new AutobuildObjectProvider(), before("AnnotationBasedContributions").build());
    ObjectProvider wrapper = new ObjectProvider() {

        @Override
        public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) {
            return serviceOverride.getServiceOverrideProvider().provide(objectType, annotationProvider, locator);
        }
    };
    configuration.add("ServiceOverride", wrapper, after("AnnotationBasedContributions").build());
}
Also used : AutobuildObjectProvider(org.apache.tapestry5.ioc.internal.services.AutobuildObjectProvider) ValueObjectProvider(org.apache.tapestry5.ioc.internal.services.ValueObjectProvider) MasterObjectProvider(org.apache.tapestry5.ioc.services.MasterObjectProvider) SymbolObjectProvider(org.apache.tapestry5.ioc.internal.services.SymbolObjectProvider) AutobuildObjectProvider(org.apache.tapestry5.ioc.internal.services.AutobuildObjectProvider)

Aggregations

AutobuildObjectProvider (org.apache.tapestry5.ioc.internal.services.AutobuildObjectProvider)1 SymbolObjectProvider (org.apache.tapestry5.ioc.internal.services.SymbolObjectProvider)1 ValueObjectProvider (org.apache.tapestry5.ioc.internal.services.ValueObjectProvider)1 MasterObjectProvider (org.apache.tapestry5.ioc.services.MasterObjectProvider)1