|
|
|
|
org.eclipse.wst.server.core
Class ServerUtil
java.lang.Object
org.eclipse.wst.server.core.ServerUtil
-
public class ServerUtil
- extends java.lang.Object
Server utility methods. These static methods can be used to perform
common operations on server artifacts.
This class provides all its functionality through static members.
It is not intended to be sub-classed or instantiated.
-
Since:
- 1.0
Field Summary
|
static java.lang.Object
|
SERVER_JOB_FAMILY
Constant identifying the job family identifier for server operations. |
Method Summary
|
static boolean
|
containsModule
(
IServer server,
IModule module,
IProgressMonitor monitor)
Returns true if the given server currently contains the given module. |
static
IServer[]
|
getAvailableServersForModule
(
IModule module,
boolean includeErrors,
IProgressMonitor monitor)
Returns a list of all servers that this module is not currently
configured on, but could be added to. |
static
IModule
|
getModule
(IProject project)
Returns the module contained within the given project. |
static
IModule[]
|
getModules
(IProject project)
Returns the modules contained within the given project. |
static int
|
getMonitoredPort
(
IServer server,
int port,
java.lang.String contentType)
Returns the port that is being used to monitor the given port on the server. |
static
IRuntime[]
|
getRuntimes
(java.lang.String type,
java.lang.String version)
Return a list of all runtime targets that match the given type and version. |
static
IRuntimeType[]
|
getRuntimeTypes
(java.lang.String type,
java.lang.String version)
Return a list of all runtime types that match the given type and version. |
static
IRuntimeType[]
|
getRuntimeTypes
(java.lang.String type,
java.lang.String version,
java.lang.String runtimeTypeId)
Return a list of all runtime types that match the given type, version,
and partial runtime type id. |
static
IServer
|
getServer
(ILaunchConfiguration configuration)
Returns the server associated with the given launch configuration. |
static
IServer[]
|
getServersByModule
(
IModule module,
IProgressMonitor monitor)
Returns a list of all servers that this module is configured on. |
static ISchedulingRule
|
getServerSchedulingRule
(
IServer server)
Deprecated. the server instance is now a scheduling rule directly
|
static IFile
|
getUnusedServerFile
(IProject project,
IServer server)
Returns an unused file in the given project. |
static boolean
|
isSupportedModule
(
IModuleType[] moduleTypes,
IModuleType mt)
Returns true if any of the given moduleTypes match the given
module type. |
static boolean
|
isSupportedModule
(
IModuleType[] moduleTypes,
java.lang.String typeId,
java.lang.String versionId)
Returns true if any of the given moduleTypes have the given
module type id and version id. |
static boolean
|
isSupportedModule
(
IModuleType moduleType,
IModuleType mt)
Returns true if the two given module types are compatible. |
static void
|
modifyModules
(
IServerWorkingCopy server,
IModule[] add,
IModule[] remove,
IProgressMonitor monitor)
Adds or removes modules from a server. |
static void
|
setRuntimeDefaultName
(
IRuntimeWorkingCopy runtime)
Sets a default name on the given runtime. |
static void
|
setServerDefaultName
(
IServerWorkingCopy server)
Sets a default name on the given server. |
static IStatus
|
validateEdit
(java.lang.Object context,
IServer server)
Validates whether this server can be editted. |
Methods inherited from class java.lang.Object
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
SERVER_JOB_FAMILY
public static final java.lang.Object SERVER_JOB_FAMILY
- Constant identifying the job family identifier for server operations.
-
Since:
- 2.0
-
See Also:
-
org.eclipse.core.runtime.jobs.IJobManager#join(Object, IProgressMonitor)
getModule
public static
IModule getModule(IProject project)
- Returns the module contained within the given project. If more than one module
is contained with the project, this method will return an arbitrary module
unless the module factory defines an ordering. If there might be multiple
modules in a project, users should typically use getModules(IProject) instead.
This method may trigger bundle loading and is not suitable for
short/UI operations.
-
-
Parameters:
-
project - a project
-
Returns:
- a module that is contained with the project, or null if no
modules are contained in the given project
-
See Also:
-
getModules(IProject)
getModules
public static
IModule[] getModules(IProject project)
- Returns the modules contained within the given project.
This method may trigger bundle loading and is not suitable for
short/UI operations.
-
-
Parameters:
-
project - a project
-
Returns:
- a possibly-empty array of modules
-
See Also:
-
getModule(IProject)
isSupportedModule
public static boolean isSupportedModule(
IModuleType[] moduleTypes,
java.lang.String typeId,
java.lang.String versionId)
- Returns
true if any of the given moduleTypes have the given
module type id and version id.
-
-
Parameters:
-
moduleTypes - an array of module types, may not be null -
typeId - a module type id, or null for any module type -
versionId - a module version, or null for any version
-
Returns:
-
true if the module type is supported, and
false otherwise
isSupportedModule
public static boolean isSupportedModule(
IModuleType[] moduleTypes,
IModuleType mt)
- Returns
true if any of the given moduleTypes match the given
module type.
-
-
Parameters:
-
moduleTypes - an array of modules types, may not be null -
mt - a module type, may not be null
-
Returns:
-
true if the module type is supported, and
false otherwise
isSupportedModule
public static boolean isSupportedModule(
IModuleType moduleType,
IModuleType mt)
- Returns true if the two given module types are compatible.
-
-
Parameters:
-
moduleType - a module type, may not be null -
mt - a module type, may not be null
-
Returns:
-
true if the module type is supported, and
false otherwise
modifyModules
public static void modifyModules(
IServerWorkingCopy server,
IModule[] add,
IModule[] remove,
IProgressMonitor monitor)
throws CoreException
- Adds or removes modules from a server. Will search for the first parent module
of each module and add it to the server instead. This method will handle multiple
modules having the same parent (the parent will only be added once), but may not
handle the case where the same module or parent is being both added and removed.
Entries in the add or remove arrays may not be null.
-
-
Parameters:
-
server - a server -
add - an array of modules to add, or null to not add any -
remove - an array of modules to remove, or null to not remove any -
monitor - a progress monitor, or null if progress
reporting and cancellation are not desired
-
Throws:
-
CoreException - if anything goes wrong
setRuntimeDefaultName
public static void setRuntimeDefaultName(
IRuntimeWorkingCopy runtime)
- Sets a default name on the given runtime.
-
-
Parameters:
-
runtime - a runtime
setServerDefaultName
public static void setServerDefaultName(
IServerWorkingCopy server)
- Sets a default name on the given server.
-
-
Parameters:
-
server - a server
getUnusedServerFile
public static IFile getUnusedServerFile(IProject project,
IServer server)
- Returns an unused file in the given project.
-
-
Parameters:
-
project - a project -
server - a server
-
Returns:
- an unused file within the given project
getRuntimes
public static
IRuntime[] getRuntimes(java.lang.String type,
java.lang.String version)
- Return a list of all runtime targets that match the given type and version.
If type or version is null, it matches all of that type or version.
-
-
Parameters:
-
type - a module type -
version - a module version
-
Returns:
- a possibly-empty array of runtime instances
IRuntime
getRuntimeTypes
public static
IRuntimeType[] getRuntimeTypes(java.lang.String type,
java.lang.String version)
- Return a list of all runtime types that match the given type and version.
If type or version is null, it matches all of that type or version.
-
-
Parameters:
-
type - a module type -
version - a module version
-
Returns:
- a possibly-empty array of runtime type instances
IRuntimeType
getRuntimeTypes
public static
IRuntimeType[] getRuntimeTypes(java.lang.String type,
java.lang.String version,
java.lang.String runtimeTypeId)
- Return a list of all runtime types that match the given type, version,
and partial runtime type id. If type, version, or runtimeTypeId is null,
it matches all of that type or version.
-
-
Parameters:
-
type - a module type -
version - a module version -
runtimeTypeId - the id of a runtime type
-
Returns:
- a possibly-empty array of runtime type instances
IRuntimeType
getAvailableServersForModule
public static
IServer[] getAvailableServersForModule(
IModule module,
boolean includeErrors,
IProgressMonitor monitor)
- Returns a list of all servers that this module is not currently
configured on, but could be added to. If includeErrors is true, this
method return servers where the parent module may throw errors. For
instance, this module may be the wrong spec level.
-
-
Parameters:
-
module - a module -
includeErrors - true to include servers that returned
errors when trying to add the module, and false otherwise -
monitor - a progress monitor, or null if progress
reporting and cancellation are not desired
-
Returns:
- a possibly empty array of servers
getServersByModule
public static
IServer[] getServersByModule(
IModule module,
IProgressMonitor monitor)
- Returns a list of all servers that this module is configured on.
-
-
Parameters:
-
module - a module -
monitor - a progress monitor, or null if progress
reporting and cancellation are not desired
-
Returns:
- a possibly-empty array of server instances
IServer
containsModule
public static boolean containsModule(
IServer server,
IModule module,
IProgressMonitor monitor)
- Returns true if the given server currently contains the given module.
-
-
Parameters:
-
server - a server -
module - a module -
monitor - a progress monitor, or null if progress
reporting and cancellation are not desired
-
Returns:
- boolean
true if the module is contained on the server,
or false otherwise
getServer
public static
IServer getServer(ILaunchConfiguration configuration)
throws CoreException
- Returns the server associated with the given launch configuration.
-
-
Parameters:
-
configuration - a launch configuration
-
Returns:
- the server associated with the launch configuration, or
null if no server could be found
-
Throws:
-
CoreException - if there is a problem getting the attribute from
the launch configuration
validateEdit
public static IStatus validateEdit(java.lang.Object context,
IServer server)
- Validates whether this server can be editted.
-
-
Parameters:
-
context - the context (Shell) -
server - the server
-
Returns:
- a status object with code
IStatus.OK if the server
can be edited, otherwise a status object indicating what when wrong
with the checkout
getMonitoredPort
public static int getMonitoredPort(
IServer server,
int port,
java.lang.String contentType)
- Returns the port that is being used to monitor the given port on the server.
This method can be used whenever creating a 'client' for the server, and allows
the client to seamlessly use a monitored port instead of going directly to the
server.
Provisional API: This class/interface is part of an interim API that is still under development and expected to
change significantly before reaching stability. It is being made available at this early stage to solicit feedback
from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
(repeatedly) as the API evolves.
-
-
Parameters:
-
server - a server -
port - a port on the server -
contentType - the content type, e.g. "web"
-
Returns:
- the monitored port, or the original port number if the port is not
currently being monitored
getServerSchedulingRule
public static ISchedulingRule getServerSchedulingRule(
IServer server)
-
Deprecated. the server instance is now a scheduling rule directly
- Returns a scheduling rule to prevent jobs from simultaneously starting,
publishing, or stopping the same server.
-
-
Parameters:
-
server - a server
-
Returns:
- a scheduling rule for this server
-
Since:
- 2.0
|
|
|