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() + ")>");
}
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();
}
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();
}
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;
}
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);
}
});
}
}
Aggregations