blob: 4b5eba9c958ba1a443100f2b170a026b81fffaf8 (
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
|
/*******************************************************************************
* Copyright (c) 2015 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.tcf.te.core.terminals;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.tcf.te.core.terminals.activator.CoreBundleActivator;
import org.eclipse.tcf.te.core.terminals.interfaces.ITerminalService;
import org.eclipse.tcf.te.core.terminals.nls.Messages;
import org.osgi.framework.Bundle;
/**
* Terminal service factory implementation.
* <p>
* Provides access to the terminal service instance.
*/
public final class TerminalServiceFactory {
private static ITerminalService instance = null;
static {
// Tries to instantiate the terminal service implementation
// from the o.e.tcf.te.ui.terminals bundle
Bundle bundle = Platform.getBundle("org.eclipse.tcf.te.ui.terminals"); //$NON-NLS-1$
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
try {
Class<?> clazz = bundle.loadClass("org.eclipse.tcf.te.ui.terminals.services.TerminalService"); //$NON-NLS-1$
instance = (ITerminalService) clazz.newInstance();
}
catch (Exception e) {
if (Platform.inDebugMode()) {
Platform.getLog(bundle).log(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), Messages.TerminalServiceFactory_error_serviceImplLoadFailed, e));
}
}
}
}
/**
* Returns the terminal service instance.
*/
public static ITerminalService getService() {
return instance;
}
}
|