use of org.gradle.internal.service.DefaultServiceRegistry in project gradle by gradle.
the class WorkerAction method execute.
@Override
public void execute(WorkerProcessContext workerProcessContext) {
completed = new CountDownLatch(1);
RequestArgumentSerializers argumentSerializers = new RequestArgumentSerializers();
try {
ServiceRegistry parentServices = workerProcessContext.getServiceRegistry();
if (instantiatorFactory == null) {
instantiatorFactory = new DefaultInstantiatorFactory(new DefaultCrossBuildInMemoryCacheFactory(new DefaultListenerManager(Global.class)), Collections.emptyList(), new OutputPropertyRoleAnnotationHandler(Collections.emptyList()));
}
DefaultServiceRegistry serviceRegistry = new DefaultServiceRegistry("worker-action-services", parentServices);
// Make the argument serializers available so work implementations can register their own serializers
serviceRegistry.add(RequestArgumentSerializers.class, argumentSerializers);
serviceRegistry.add(InstantiatorFactory.class, instantiatorFactory);
Class<?> workerImplementation = Class.forName(workerImplementationName);
implementation = Cast.uncheckedNonnullCast(instantiatorFactory.inject(serviceRegistry).newInstance(workerImplementation));
} catch (Exception e) {
failure = e;
}
ObjectConnection connection = workerProcessContext.getServerConnection();
connection.addIncoming(RequestProtocol.class, this);
responder = connection.addOutgoing(ResponseProtocol.class);
workerLogEventListener = workerProcessContext.getServiceRegistry().get(WorkerLogEventListener.class);
if (failure == null) {
connection.useParameterSerializers(RequestSerializerRegistry.create(this.getClass().getClassLoader(), argumentSerializers));
} else {
// Discard incoming requests, as the serializers may not have been configured
connection.useParameterSerializers(RequestSerializerRegistry.createDiscardRequestArg());
// Notify the client
responder.infrastructureFailed(failure);
}
connection.connect();
try {
completed.await();
} catch (InterruptedException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
use of org.gradle.internal.service.DefaultServiceRegistry in project gradle by gradle.
the class DefaultIvyArtifactRepository method createInjectorForMetadataSupplier.
/**
* Creates a service registry giving access to the services we want to expose to rules and returns an instantiator that uses this service registry.
*
* @param transport the transport used to create the repository accessor
* @return a dependency injecting instantiator, aware of services we want to expose
*/
private Instantiator createInjectorForMetadataSupplier(final RepositoryTransport transport) {
DefaultServiceRegistry registry = new DefaultServiceRegistry();
registry.addProvider(new Object() {
RepositoryResourceAccessor createResourceAccessor() {
return createRepositoryAccessor(transport);
}
});
return instantiatorFactory.inject(registry);
}
use of org.gradle.internal.service.DefaultServiceRegistry in project gradle by gradle.
the class DaemonClientFactory method createStopDaemonServices.
/**
* Creates the services for a {@link DaemonStopClient} that can be used to stop builds.
*/
public ServiceRegistry createStopDaemonServices(OutputEventListener loggingReceiver, DaemonParameters daemonParameters) {
DefaultServiceRegistry loggingServices = new DefaultServiceRegistry(sharedServices);
loggingServices.add(OutputEventListener.class, loggingReceiver);
return new DaemonClientServices(loggingServices, daemonParameters, new ByteArrayInputStream(new byte[0]));
}
use of org.gradle.internal.service.DefaultServiceRegistry in project gradle by gradle.
the class DefaultValueSourceProviderFactory method instantiateValueSource.
@NotNull
public <T, P extends ValueSourceParameters> ValueSource<T, P> instantiateValueSource(Class<? extends ValueSource<T, P>> valueSourceType, @Nullable Class<P> parametersType, @Nullable P isolatedParameters) {
DefaultServiceRegistry services = new DefaultServiceRegistry();
services.add(GradleProperties.class, gradleProperties);
services.add(ExecOperations.class, execOperations);
if (isolatedParameters != null) {
services.add(parametersType, isolatedParameters);
}
return instantiatorFactory.injectScheme().withServices(services).instantiator().newInstance(valueSourceType);
}
use of org.gradle.internal.service.DefaultServiceRegistry in project gradle by gradle.
the class AsmBackedClassGeneratorTest method newInstance.
private <T> T newInstance(Class<T> clazz, Object... args) throws Exception {
DefaultServiceRegistry services = new DefaultServiceRegistry();
services.add(InstantiatorFactory.class, TestUtil.instantiatorFactory());
return newInstance(clazz, services, args);
}
Aggregations