public class LazyEnvManagerDetector extends Object implements IEnvManager
IEnvManager
which avoids connecting to the remote machine until it is actually
necessary, then displays a progress dialog while the connection is established and subsequently forwards all
method calls to the IEnvManager
returned by EnvManagerRegistry.getEnvManager(IProgressMonitor, IRemoteConnection)
.
When it becomes necessary to connect to the remote machine, a modal progress dialog is displayed while the connection is
established. Then, EnvManagerRegistry.getEnvManager(IProgressMonitor, IRemoteConnection)
is invoked to detects the
environment management system on the remote machine, if any, and acquire an IEnvManager
capable of interfacing with that
system.
All of the IEnvManager
methods delegate to the IEnvManager
returned by
EnvManagerRegistry.getEnvManager(IProgressMonitor, IRemoteConnection)
.
ENV_MANAGER_EXTENSION_POINT_ID
Constructor and Description |
---|
LazyEnvManagerDetector(IRemoteConnection remoteConnection)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkForCompatibleInstallation(IProgressMonitor pm)
Returns true iff the remote machine is running an environment management system supported by this
IEnvManager . |
void |
configure(IRemoteConnection remoteConnection)
Sets the
IRemoteConnection which will be used to run commands on a remote machine. |
String |
createBashScript(IProgressMonitor pm,
boolean echo,
IEnvManagerConfig config,
String commandToExecuteAfterward)
Creates a temporary file on the remote machine and writes a Bash shell script into that file which will configure the remote
environment with the given elements, execute the given command, and then delete the temporary file (shell script).
|
List<String> |
determineAvailableElements(IProgressMonitor pm)
Returns the set of all environment configuration elements available on the remote machine (e.g., the result of
module -t avail).
|
List<String> |
determineDefaultElements(IProgressMonitor pm)
Returns the set of all environment configuration elements loaded by default upon login (e.g., the result of
module -t list in a login shell).
|
String |
getBashConcatenation(String separator,
boolean echo,
IEnvManagerConfig config,
String commandToExecuteAfterward)
Returns a single Bash shell command which will configure the remote environment with the given elements and then execute the
given command.
|
Comparator<String> |
getComparator()
Returns a
Comparator used to sort the strings returned by IEnvManager.determineAvailableElements(IProgressMonitor) and
IEnvManager.determineDefaultElements(IProgressMonitor) when displaying them to the user. |
String |
getDescription(IProgressMonitor pm)
If the remote machine is running an environment management system supported by this
IEnvManager , returns a short
description of the environment management system (e.g., "Modules 3.2.7"); otherwise, returns null . |
String |
getInstructions()
Returns a short sentence that will be displayed to the user to request that items be selected from a checklist.
|
String |
getName()
Returns a human-readable name for this environment management system.
|
void |
setProgressMonitor(IProgressMonitor monitor)
Set a progress monitor to use for long running operations.
|
public LazyEnvManagerDetector(IRemoteConnection remoteConnection)
remoteConnection
- IRemoteConnection
used to access files and execute shell commands on the remote machine (non-
null
)public boolean checkForCompatibleInstallation(IProgressMonitor pm) throws RemoteConnectionException, IOException
IEnvManager
IEnvManager
.checkForCompatibleInstallation
in interface IEnvManager
pm
- progress monitor used to report the status of potentially long-running operations to the user (non-
null
)IEnvManager
RemoteConnectionException
- if an remote connection error occursIOException
- if an input/output error occurspublic void configure(IRemoteConnection remoteConnection)
IEnvManager
IRemoteConnection
which will be used to run commands on a remote machine.
This method must be invoked before IEnvManager.checkForCompatibleInstallation(IProgressMonitor)
,
IEnvManager.getDescription(IProgressMonitor)
, IEnvManager.determineAvailableElements(IProgressMonitor)
,
IEnvManager.determineDefaultElements(IProgressMonitor)
, or
IEnvManager.createBashScript(IProgressMonitor, boolean, IEnvManagerConfig, String)
.
configure
in interface IEnvManager
remoteConnection
- IRemoteConnection
(non-null
)public String createBashScript(IProgressMonitor pm, boolean echo, IEnvManagerConfig config, String commandToExecuteAfterward) throws RemoteConnectionException, IOException
IEnvManager
createBashScript
in interface IEnvManager
pm
- progress monitor used to report the status of potentially long-running operations to the user (non-
null
)echo
- true iff the script should "echo" each command prior to executionconfig
- environment manager configuration (non-null
)commandToExecuteAfterward
- a Bash shell command to execute after the environment has been configurednull
)RemoteConnectionException
- if an remote connection error occursIOException
- if an input/output error occurspublic List<String> determineAvailableElements(IProgressMonitor pm) throws RemoteConnectionException, IOException
IEnvManager
determineAvailableElements
in interface IEnvManager
pm
- progress monitor used to report the status of potentially long-running operations to the user (non-
null
)null
)RemoteConnectionException
- if an remote connection error occursIOException
- if an input/output error occurspublic List<String> determineDefaultElements(IProgressMonitor pm) throws RemoteConnectionException, IOException
IEnvManager
determineDefaultElements
in interface IEnvManager
pm
- progress monitor used to report the status of potentially long-running operations to the user (non-
null
)null
)RemoteConnectionException
- if an remote connection error occursIOException
- if an input/output error occurspublic String getBashConcatenation(String separator, boolean echo, IEnvManagerConfig config, String commandToExecuteAfterward)
IEnvManager
The returned command may include sequencing, piping, I/O redirection, etc.; however, it must be possible to concatenate additional Bash commands by appending a semicolon.
getBashConcatenation
in interface IEnvManager
separator
- string that will be inserted between consecutive Bash commands: typically, either a semicolon or a newlineecho
- true iff the script should "echo" each command prior to executionconfig
- environment manager configuration (non-null
)commandToExecuteAfterward
- a Bash shell command to execute after the environment has been configurednull
)public Comparator<String> getComparator()
IEnvManager
Comparator
used to sort the strings returned by IEnvManager.determineAvailableElements(IProgressMonitor)
and
IEnvManager.determineDefaultElements(IProgressMonitor)
when displaying them to the user.getComparator
in interface IEnvManager
Comparator
(non-null
)public String getDescription(IProgressMonitor pm) throws RemoteConnectionException, IOException
IEnvManager
IEnvManager
, returns a short
description of the environment management system (e.g., "Modules 3.2.7"); otherwise, returns null
.getDescription
in interface IEnvManager
pm
- progress monitor used to report the status of potentially long-running operations to the user (non-
null
)null
if a compatible environment configuration system is not present on the remote machineRemoteConnectionException
- if an remote connection error occursIOException
- if an input/output error occurspublic String getInstructions()
IEnvManager
For example, "Select modules to be loaded."
getInstructions
in interface IEnvManager
null
)public String getName()
IEnvManager
getName
in interface IEnvManager
null
)public void setProgressMonitor(IProgressMonitor monitor)
monitor
- progress monitorCopyright (c) 2011 IBM Corporation and others. All Rights Reserved.