Package org.gradle.messaging.remote

Examples of org.gradle.messaging.remote.ObjectConnection


    }

    private void expectWorkerProcessStarted() {
        context.checking(new Expectations() {{
            WorkerProcessBuilder builder = context.mock(WorkerProcessBuilder.class);
            ObjectConnection connection = context.mock(ObjectConnection.class);
            JavaExecHandleBuilder javaCommandBuilder = context.mock(JavaExecHandleBuilder.class);

            one(workerFactory).create();
            will(returnValue(builder));
View Full Code Here


        }
    };

    @Test
    public void createsConnectionAndExecutesAction() throws Exception {
        final ObjectConnection connection = context.mock(ObjectConnection.class);
        final Collector<WorkerProcessContext> collector = collector();

        context.checking(new Expectations() {{
            one(action).execute(with(notNullValue(WorkerProcessContext.class)));
            will(collectTo(collector));
View Full Code Here

        completed = new CountDownLatch(1);

        System.setProperty(WORKER_ID_SYS_PROPERTY, workerProcessContext.getWorkerId().toString());
       
        ObjectConnection serverConnection = workerProcessContext.getServerConnection();

        IdGenerator<Object> idGenerator = new CompositeIdGenerator(workerProcessContext.getWorkerId(),
                new LongIdGenerator());

        DefaultServiceRegistry testServices = new DefaultServiceRegistry();
        testServices.add(IdGenerator.class, idGenerator);
        TestClassProcessor targetProcessor = factory.create(testServices);

        targetProcessor = new WorkerTestClassProcessor(targetProcessor, idGenerator.generateId(),
                workerProcessContext.getDisplayName(), new TrueTimeProvider());
        ContextClassLoaderProxy<TestClassProcessor> proxy = new ContextClassLoaderProxy<TestClassProcessor>(
                TestClassProcessor.class, targetProcessor, workerProcessContext.getApplicationClassLoader());
        processor = proxy.getSource();

        this.resultProcessor = serverConnection.addOutgoing(TestResultProcessor.class);

        serverConnection.addIncoming(RemoteTestClassProcessor.class, this);

        try {
            completed.await();
        } catch (InterruptedException e) {
            throw new UncheckedException(e);
View Full Code Here

        }
    }

    public ExecResult waitForStop() {
        ExecResult result = execHandle.waitForFinish();
        ObjectConnection connection;
        lock.lock();
        try {
            connection = this.connection;
        } finally {
            lock.unlock();
        }
        if (connection != null) {
            connection.stop();
        }
        return result.assertNormalExitValue();
    }
View Full Code Here

    public void execute(final WorkerContext workerContext) {
        MessagingServices messagingServices = createClient();
        try {
            final MessagingClient client = messagingServices.get(MessagingClient.class);
            final ObjectConnection clientConnection = client.getConnection(serverAddress);
            try {
                LOGGER.debug("Starting {}.", displayName);
                WorkerProcessContext context = new WorkerProcessContext() {
                    public ObjectConnection getServerConnection() {
                        return clientConnection;
                    }

                    public ClassLoader getApplicationClassLoader() {
                        return workerContext.getApplicationClassLoader();
                    }

                    public Object getWorkerId() {
                        return workerId;
                    }

                    public String getDisplayName() {
                        return displayName;
                    }
                };

                ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(action.getClass().getClassLoader());
                try {
                    action.execute(context);
                } finally {
                    Thread.currentThread().setContextClassLoader(contextClassLoader);
                }
                LOGGER.debug("Completed {}.", displayName);
            } finally {
                clientConnection.stop();
            }
        } finally {
            LOGGER.debug("Stopping client connection.");
            messagingServices.stop();
        }
View Full Code Here

                workerProcessContext.getDisplayName(), new TrueTimeProvider());
        ContextClassLoaderProxy<TestClassProcessor> proxy = new ContextClassLoaderProxy<TestClassProcessor>(
                TestClassProcessor.class, targetProcessor, workerProcessContext.getApplicationClassLoader());
        processor = proxy.getSource();

        ObjectConnection serverConnection = workerProcessContext.getServerConnection();
        serverConnection.useParameterSerializer(new TestEventSerializer());
        this.resultProcessor = serverConnection.addOutgoing(TestResultProcessor.class);
        serverConnection.addIncoming(RemoteTestClassProcessor.class, this);
        serverConnection.connect();
    }
View Full Code Here

        buildConfigAction.execute(builder);

        workerProcess = builder.build();
        workerProcess.start();

        ObjectConnection connection = workerProcess.getConnection();
        connection.useParameterSerializer(new TestEventSerializer());
        connection.addIncoming(TestResultProcessor.class, resultProcessor);
        RemoteTestClassProcessor remoteProcessor = connection.addOutgoing(RemoteTestClassProcessor.class);
        connection.connect();
        remoteProcessor.startProcessing();
        return remoteProcessor;
    }
View Full Code Here

TOP

Related Classes of org.gradle.messaging.remote.ObjectConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.