KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > jpda > AttachingSessionProvider


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.debugger.jpda;
21
22 import java.util.Map JavaDoc;
23 import org.netbeans.api.debugger.jpda.AttachingDICookie;
24 import org.netbeans.api.debugger.jpda.JPDADebugger;
25 import org.netbeans.spi.debugger.SessionProvider;
26 import org.netbeans.spi.debugger.ContextProvider;
27 import org.openide.util.NbBundle;
28
29
30 /**
31  *
32  * @author Jan Jancura
33  */

34 public class AttachingSessionProvider extends SessionProvider {
35
36     private ContextProvider contextProvider;
37     private AttachingDICookie sadic;
38
39     public AttachingSessionProvider (ContextProvider contextProvider) {
40         this.contextProvider = contextProvider;
41         sadic = (AttachingDICookie) contextProvider.lookupFirst
42             (null, AttachingDICookie.class);
43     };
44     
45     public String JavaDoc getSessionName () {
46         Map JavaDoc arguments = (Map JavaDoc) contextProvider.lookupFirst
47             (null, Map JavaDoc.class);
48         if (arguments != null) {
49             String JavaDoc processName = (String JavaDoc) arguments.get ("name");
50             if (processName != null)
51                 return LaunchingSessionProvider.findUnique (processName);
52         }
53         if (sadic.getHostName () != null)
54             return sadic.getHostName () + ":" + sadic.getPortNumber ();
55         return LaunchingSessionProvider.findUnique
56             (sadic.getSharedMemoryName ());
57     };
58     
59     public String JavaDoc getLocationName () {
60         if (sadic.getHostName () != null)
61             return sadic.getHostName ();
62         return NbBundle.getMessage
63             (AttachingSessionProvider.class, "CTL_Localhost");
64     }
65     
66     public String JavaDoc getTypeID () {
67         return JPDADebugger.SESSION_ID;
68     }
69     
70     public Object JavaDoc[] getServices () {
71         return new Object JavaDoc [0];
72     }
73 }
74
75
Popular Tags