Search in sources :

Example 6 with ServiceResources

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

the class PerThreadServiceLifecycle method createService.

@Override
public Object createService(ServiceResources resources, ObjectCreator creator) {
    ObjectCreator perThreadCreator = perthreadManager.createValue(creator);
    Class serviceInterface = resources.getServiceInterface();
    return proxyFactory.createProxy(serviceInterface, perThreadCreator, "<PerThread Proxy for " + resources.getServiceId() + "(" + serviceInterface.getName() + ")>");
}
Also used : ObjectCreator(org.apache.tapestry5.commons.ObjectCreator)

Example 7 with ServiceResources

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

the class DecorateByMarkerModule method doDecorate.

private static <T> T doDecorate(final String decoratorId, ServiceResources resources, T delegate, AspectDecorator aspectDecorator) {
    Class<T> serviceInterface = resources.getServiceInterface();
    AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, String.format("<Interceptor for %s(%s)>", resources.getServiceId(), serviceInterface.getName()));
    builder.adviseAllMethods(new MethodAdvice() {

        @Override
        public void advise(MethodInvocation invocation) {
            invocation.proceed();
            Object result = invocation.getReturnValue();
            invocation.setReturnValue(String.format("Decorated by %s[%s]", decoratorId, result));
        }
    });
    return builder.build();
}
Also used : MethodInvocation(org.apache.tapestry5.plastic.MethodInvocation) MethodAdvice(org.apache.tapestry5.plastic.MethodAdvice)

Example 8 with ServiceResources

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

the class DecorateByMarkerModule2 method doDecorate.

private static <T> T doDecorate(final String decoratorId, ServiceResources resources, T delegate, AspectDecorator aspectDecorator) {
    Class<T> serviceInterface = resources.getServiceInterface();
    AspectInterceptorBuilder<T> builder = aspectDecorator.createBuilder(serviceInterface, delegate, String.format("<Interceptor for %s(%s)>", resources.getServiceId(), serviceInterface.getName()));
    builder.adviseAllMethods(new MethodAdvice() {

        @Override
        public void advise(MethodInvocation invocation) {
            invocation.proceed();
            Object result = invocation.getReturnValue();
            invocation.setReturnValue(String.format("Decorated by %s[%s]", decoratorId, result));
        }
    });
    return builder.build();
}
Also used : MethodInvocation(org.apache.tapestry5.plastic.MethodInvocation) MethodAdvice(org.apache.tapestry5.plastic.MethodAdvice)

Example 9 with ServiceResources

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

the class IOCTestCase method mockServiceResources.

protected final ServiceResources mockServiceResources(OperationTracker tracker) {
    ServiceResources resources = mockServiceResources();
    train_getTracker(resources, tracker);
    return resources;
}
Also used : ServiceResources(org.apache.tapestry5.ioc.ServiceResources)

Example 10 with ServiceResources

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

the class RegistryImpl method addToUnorderedConfiguration.

private <T> void addToUnorderedConfiguration(Collection<T> collection, Class<T> valueType, ServiceDef3 serviceDef, final Module module) {
    String serviceId = serviceDef.getServiceId();
    Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef);
    if (contributions.isEmpty())
        return;
    Logger logger = getServiceLogger(serviceId);
    final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
    for (final ContributionDef def : contributions) {
        final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(valueType, resources, typeCoercerProxy, collection, serviceId);
        String description = "Invoking " + def;
        logger.debug(description);
        operationTracker.run(description, new Runnable() {

            @Override
            public void run() {
                def.contribute(module, resources, validating);
            }
        });
    }
}
Also used : ServiceResources(org.apache.tapestry5.ioc.ServiceResources) Logger(org.slf4j.Logger)

Aggregations

ServiceResources (org.apache.tapestry5.ioc.ServiceResources)7 Logger (org.slf4j.Logger)5 Orderer (org.apache.tapestry5.ioc.internal.util.Orderer)2 TapestryIOCModule (org.apache.tapestry5.ioc.modules.TapestryIOCModule)2 MethodAdvice (org.apache.tapestry5.plastic.MethodAdvice)2 MethodInvocation (org.apache.tapestry5.plastic.MethodInvocation)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Map (java.util.Map)1 ExceptionHandlerAssistant (org.apache.tapestry5.ExceptionHandlerAssistant)1 ObjectCreator (org.apache.tapestry5.commons.ObjectCreator)1 AbstractContributionDef (org.apache.tapestry5.http.internal.AbstractContributionDef)1 AdvisorDef (org.apache.tapestry5.ioc.AdvisorDef)1 ModuleBuilderSource (org.apache.tapestry5.ioc.ModuleBuilderSource)1 OperationTracker (org.apache.tapestry5.ioc.OperationTracker)1 ServiceAdvisor (org.apache.tapestry5.ioc.ServiceAdvisor)1 ServiceDecorator (org.apache.tapestry5.ioc.ServiceDecorator)1 ContributionDef (org.apache.tapestry5.ioc.def.ContributionDef)1 DelegatingInjectionResources (org.apache.tapestry5.ioc.internal.util.DelegatingInjectionResources)1 InjectionResources (org.apache.tapestry5.ioc.internal.util.InjectionResources)1