KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ssh2 > CVSSSH2Plugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation.
10  * IBM Corporation - ongoing maintenance
11  *******************************************************************************/

12 package org.eclipse.team.internal.ccvs.ssh2;
13
14 import org.eclipse.core.runtime.Platform;
15 import org.eclipse.jsch.core.IJSchService;
16 import org.eclipse.ui.plugin.AbstractUIPlugin;
17 import org.osgi.framework.BundleContext;
18 import org.osgi.util.tracker.ServiceTracker;
19
20 public class CVSSSH2Plugin extends AbstractUIPlugin {
21
22     public static String JavaDoc ID = "org.eclipse.team.cvs.ssh2"; //$NON-NLS-1$
23
private static CVSSSH2Plugin plugin;
24
25     static String JavaDoc SSH_HOME_DEFAULT = null;
26     static {
27         String JavaDoc ssh_dir_name = ".ssh"; //$NON-NLS-1$
28

29         // Windows doesn't like files or directories starting with a dot.
30
if (Platform.getOS().equals(Platform.OS_WIN32)) {
31             ssh_dir_name = "ssh"; //$NON-NLS-1$
32
}
33         SSH_HOME_DEFAULT = System.getProperty("user.home"); //$NON-NLS-1$
34
if (SSH_HOME_DEFAULT != null) {
35             SSH_HOME_DEFAULT = SSH_HOME_DEFAULT + java.io.File.separator + ssh_dir_name;
36         } else {
37             
38         }
39     }
40
41     private ServiceTracker tracker;
42     
43     public CVSSSH2Plugin() {
44         super();
45         plugin = this;
46     }
47
48     public void stop(BundleContext context) throws Exception JavaDoc {
49         try {
50             JSchSession.shutdown();
51             tracker.close();
52         } finally {
53             super.stop(context);
54         }
55     }
56
57     public static CVSSSH2Plugin getDefault() {
58         return plugin;
59     }
60     
61     public void start(BundleContext context) throws Exception JavaDoc {
62         super.start(context);
63         tracker = new ServiceTracker(getBundle().getBundleContext(), IJSchService.class.getName(), null);
64         tracker.open();
65     }
66     
67     public IJSchService getJSchService() {
68         return (IJSchService)tracker.getService();
69     }
70 }
71
Popular Tags