public class LazyEnvManagerDetector extends java.lang.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(org.eclipse.core.runtime.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. |
java.lang.String |
createBashScript(org.eclipse.core.runtime.IProgressMonitor pm,
boolean echo,
IEnvManagerConfig config,
java.lang.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).
|
java.util.List<java.lang.String> |
determineAvailableElements(org.eclipse.core.runtime.IProgressMonitor pm)
Returns the set of all environment configuration elements available on the remote machine (e.g., the result of
module -t avail).
|
java.util.List<java.lang.String> |
determineDefaultElements(org.eclipse.core.runtime.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).
|
java.lang.String |
getBashConcatenation(java.lang.String separator,
boolean echo,
IEnvManagerConfig config,
java.lang.String commandToExecuteAfterward)
Returns a single Bash shell command which will configure the remote environment with the given elements and then execute the
given command.
|
java.util.Comparator<java.lang.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. |
java.lang.String |
getDescription(org.eclipse.core.runtime.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. |
java.lang.String |
getInstructions()
Returns a short sentence that will be displayed to the user to request that items be selected from a checklist.
|
java.lang.String |
getName()
Returns a human-readable name for this environment management system.
|
void |
setProgressMonitor(org.eclipse.core.runtime.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(org.eclipse.core.runtime.IProgressMonitor pm)
throws RemoteConnectionException,
java.io.IOException
IEnvManagerIEnvManager.checkForCompatibleInstallation in interface IEnvManagerpm - progress monitor used to report the status of potentially long-running operations to the user (non-
null)IEnvManagerRemoteConnectionException - if an remote connection error occursjava.io.IOException - if an input/output error occurspublic void configure(IRemoteConnection remoteConnection)
IEnvManagerIRemoteConnection 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 IEnvManagerremoteConnection - IRemoteConnection (non-null)public java.lang.String createBashScript(org.eclipse.core.runtime.IProgressMonitor pm,
boolean echo,
IEnvManagerConfig config,
java.lang.String commandToExecuteAfterward)
throws RemoteConnectionException,
java.io.IOException
IEnvManagercreateBashScript in interface IEnvManagerpm - 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 occursjava.io.IOException - if an input/output error occurspublic java.util.List<java.lang.String> determineAvailableElements(org.eclipse.core.runtime.IProgressMonitor pm)
throws RemoteConnectionException,
java.io.IOException
IEnvManagerdetermineAvailableElements in interface IEnvManagerpm - progress monitor used to report the status of potentially long-running operations to the user (non-
null)null)RemoteConnectionException - if an remote connection error occursjava.io.IOException - if an input/output error occurspublic java.util.List<java.lang.String> determineDefaultElements(org.eclipse.core.runtime.IProgressMonitor pm)
throws RemoteConnectionException,
java.io.IOException
IEnvManagerdetermineDefaultElements in interface IEnvManagerpm - progress monitor used to report the status of potentially long-running operations to the user (non-
null)null)RemoteConnectionException - if an remote connection error occursjava.io.IOException - if an input/output error occurspublic java.lang.String getBashConcatenation(java.lang.String separator,
boolean echo,
IEnvManagerConfig config,
java.lang.String commandToExecuteAfterward)
IEnvManagerThe 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 IEnvManagerseparator - 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 java.util.Comparator<java.lang.String> getComparator()
IEnvManagerComparator used to sort the strings returned by IEnvManager.determineAvailableElements(IProgressMonitor) and
IEnvManager.determineDefaultElements(IProgressMonitor) when displaying them to the user.getComparator in interface IEnvManagerComparator (non-null)public java.lang.String getDescription(org.eclipse.core.runtime.IProgressMonitor pm)
throws RemoteConnectionException,
java.io.IOException
IEnvManagerIEnvManager, returns a short
description of the environment management system (e.g., "Modules 3.2.7"); otherwise, returns null.getDescription in interface IEnvManagerpm - 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 occursjava.io.IOException - if an input/output error occurspublic java.lang.String getInstructions()
IEnvManagerFor example, "Select modules to be loaded."
getInstructions in interface IEnvManagernull)public java.lang.String getName()
IEnvManagergetName in interface IEnvManagernull)public void setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor monitor)
monitor - progress monitorCopyright (c) 2011 IBM Corporation and others. All Rights Reserved.