public final class Session extends Object implements ContextProvider
Description | |
Functionality |
Properties:
Session has two standard read only properties - name (Session.getName() ) and
location name (Session.getLocationName() ).
Management of languages and engines: Debugger Core supports debugging in different languages. It means that each session can be debugged using different languages and DebuggerEngine s. Session manages list
of supported languages (Session.getSupportedLanguages() ) and current
language (Session.getCurrentLanguage() ). Current language can be changed
(Session.setCurrentLanguage(java.lang.String) ).
Each language corresponds to one
DebuggerEngine
(Session.getEngineForLanguage(java.lang.String) ). So, the current language
defines current debugger engine (Session.getCurrentEngine() )
A support for a new debugger language can be added during a start of
debugging only. See
DebuggerManager.startDebugging(org.netbeans.api.debugger.DebuggerInfo) and
DebuggerEngineProvider
Support for additional services: Session is final class. The standard method how to extend its functionality is using lookup methods ( Session.lookup and
Session.lookupFirst(java.lang.String, java.lang.Class<T>) ).
There are two ways how to register some service provider for some
type of Session:
Support for listening: Session propagates all changes to PropertyChangeListener .
|
Clients / Providers |
This class is final, so it does not have any external provider.
Debugger Core and UI modules are clients of this class.
|
Life-cycle |
A new instance of Session class can be created and registered to
DebuggerManager during the process
of starting of debugging (see
DebuggerManager.startDebugging(org.netbeans.api.debugger.DebuggerInfo) ).
Session is removed automatically from
DebuggerManager when the
number of "supported languages" (Session.getSupportedLanguages() ) is zero.
|
Evolution | No method should be removed from this class, but some functionality can be added in future. |
Modifier and Type | Field and Description |
---|---|
static String |
PROP_CURRENT_LANGUAGE
Name of property for current language.
|
static String |
PROP_SUPPORTED_LANGUAGES
Name of property for the set of supported languages.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds a property change listener.
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener l)
Adds a property change listener.
|
DebuggerEngine |
getCurrentEngine()
Returns current debugger engine for this session.
|
String |
getCurrentLanguage()
Returns current language for this session.
|
DebuggerEngine |
getEngineForLanguage(String language)
Return DebuggerEngine registered for given language or null.
|
String |
getLocationName()
Returns name of location this session is running on.
|
String |
getName()
Returns display name of this session.
|
String[] |
getSupportedLanguages()
Returns set of all languages supported by this session.
|
void |
kill()
Kills all registered engines / languages.
|
<T> List<? extends T> |
lookup(String folder,
Class<T> service)
Returns list of services of given type from given folder.
|
<T> T |
lookupFirst(String folder,
Class<T> service)
Returns one service of given type from given folder.
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes a property change listener.
|
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener l)
Removes a property change listener.
|
void |
setCurrentLanguage(String language)
Sets current language for this session.
|
String |
toString()
Returns string representation of this session.
|
public static final String PROP_CURRENT_LANGUAGE
public static final String PROP_SUPPORTED_LANGUAGES
public String getName()
public String getLocationName()
public DebuggerEngine getCurrentEngine()
public String getCurrentLanguage()
public String[] getSupportedLanguages()
DebuggerEngineProvider
public <T> List<? extends T> lookup(String folder, Class<T> service)
lookup
in interface ContextProvider
service
- a type of service to look forfolder
- a folder name or nullpublic <T> T lookupFirst(String folder, Class<T> service)
lookupFirst
in interface ContextProvider
service
- a type of service to look forfolder
- a folder name or nullpublic void kill()
postAction (DebuggerEngine.ACTION_KILL)method on all registered DebuggerEngines.
public DebuggerEngine getEngineForLanguage(String language)
public void setCurrentLanguage(String language)
language
- current languageDebuggerEngineProvider
public String toString()
public void addPropertyChangeListener(PropertyChangeListener l)
l
- the listener to addpublic void removePropertyChangeListener(PropertyChangeListener l)
l
- the listener to removepublic void addPropertyChangeListener(String propertyName, PropertyChangeListener l)
propertyName
- a name of property to listen onl
- the listener to addpublic void removePropertyChangeListener(String propertyName, PropertyChangeListener l)
propertyName
- a name of property to stop listening onl
- the listener to remove