Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 90fadb4eab68214aa5cf07d030535a7e4ce3b7ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*******************************************************************************
 * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tm.internal.tcf.dsf.launch;

import org.eclipse.dd.dsf.concurrent.DsfExecutor;
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.tm.internal.tcf.debug.model.ITCFConstants;
import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch;
import org.eclipse.tm.tcf.protocol.IChannel;


public class TCFDSFLaunch extends TCFLaunch {

    private final TCFDSFExecuter executor;
    private final DsfSession session;

    public TCFDSFLaunch(ILaunchConfiguration launchConfiguration, String mode) {
        super(launchConfiguration, mode);
        executor = new TCFDSFExecuter();
        session = DsfSession.startSession(executor, ITCFConstants.ID_TCF_DEBUG_MODEL);
    }

    @Override
    protected void runLaunchSequence(final Runnable done) {
        super.runLaunchSequence(new Runnable() {
            public void run() {
                IChannel channel = getChannel();
                if (channel != null) {
                    RequestMonitor monitor = new RequestMonitor(executor, null) {
                        @Override
                        protected void handleSuccess() {
                            done.run();
                        }
                    };
                    executor.execute(new TCFDSFLaunchSequence(session, TCFDSFLaunch.this, monitor));
                }
                else {
                    done.run();
                }
            }
        });
    }

    @Override
    protected void runShutdownSequence(final Runnable done) {
        RequestMonitor monitor = new RequestMonitor(executor, null) {
            @Override
            protected void handleSuccess() {
                TCFDSFLaunch.super.runShutdownSequence(done);
            }
        };
        executor.execute(new TCFDSFShutdownSequence(session, TCFDSFLaunch.this, monitor));
    }

    public DsfExecutor getDsfExecutor() {
        return executor;
    }

    public DsfSession getSession() {
        return session;
    }
}

Back to the top