use of org.gradle.process.internal.worker.child.WorkerLogEventListener 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);
}
}
Aggregations