use of org.gradle.internal.service.ServiceLookup in project gradle by gradle.
the class DefaultTransformer method newTransformAction.
private TransformAction<?> newTransformAction(Provider<FileSystemLocation> inputArtifactProvider, ArtifactTransformDependencies artifactTransformDependencies, @Nullable InputChanges inputChanges) {
TransformParameters parameters = isolatedParameters.get().getIsolatedParameterObject().isolate();
ServiceLookup services = new IsolationScheme<>(TransformAction.class, TransformParameters.class, TransformParameters.None.class).servicesForImplementation(parameters, internalServices);
services = new TransformServiceLookup(inputArtifactProvider, requiresDependencies ? artifactTransformDependencies : null, inputChanges, services);
return instanceFactory.newInstance(services);
}
use of org.gradle.internal.service.ServiceLookup in project gradle by gradle.
the class DefaultWorkerServer method execute.
@Override
public DefaultWorkResult execute(SimpleActionExecutionSpec<?> spec) {
try {
Class<? extends WorkAction<?>> implementationClass = Cast.uncheckedCast(spec.getImplementationClass());
// Exceptions to services available for injection
Spec<Class<?>> whiteListPolicy;
if (spec.isInternalServicesRequired()) {
whiteListPolicy = element -> true;
} else {
whiteListPolicy = element -> false;
}
ServiceLookup instantiationServices = isolationScheme.servicesForImplementation(spec.getParameters(), internalServices, additionalWhitelistedServices, whiteListPolicy);
Instantiator instantiator = instantiatorFactory.inject(instantiationServices);
WorkAction<?> execution;
if (ProvidesWorkResult.class.isAssignableFrom(implementationClass)) {
execution = instantiator.newInstance(implementationClass, spec.getParameters(), instantiator);
} else {
execution = instantiator.newInstance(implementationClass);
}
execution.execute();
if (execution instanceof ProvidesWorkResult) {
return ((ProvidesWorkResult) execution).getWorkResult();
} else {
return DefaultWorkResult.SUCCESS;
}
} catch (Throwable t) {
return new DefaultWorkResult(true, t);
}
}
use of org.gradle.internal.service.ServiceLookup in project gradle by gradle.
the class BuildServiceProvider method instantiate.
private Try<T> instantiate() {
// TODO - extract some shared infrastructure to take care of instantiation (eg which services are visible, strict vs lenient, decorated or not?)
// TODO - should hold the project lock to do the isolation. Should work the same way as artifact transforms (a work node does the isolation, etc)
P isolatedParameters = isolatableFactory.isolate(parameters).isolate();
// TODO - reuse this in other places
ServiceLookup instantiationServices = instantiationServicesFor(isolatedParameters);
try {
return Try.successful(instantiate(instantiationServices));
} catch (Exception e) {
return Try.failure(instantiationException(e));
}
}
Aggregations