|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IServer
Represents a server instance. Every server is an instance of a particular, fixed server type.
Not surprisingly, the notion of server is central in the web tools server infrastructure. In this context, understand that a server is a web server of some ilk. It could be a simple web server lacking Java support, or an J2EE based server, or perhaps even some kind of database server. A more exact definition is not required for the purposes of this API. From a tool-centric point of view, a server is something that the developer is writing "content" for. The unit of content is termed a module. In a sense, the server exists, but lacks useful content. The development task is to provide that content. The content can include anything from simple, static HTML web pages to complex, highly dynamic web applications. In the course of writing and debugging this content, the developer will want to test their content on a web server, to see how it gets served up. For this they will need to launch a server process running on some host machine (often the local host on which the IDE is running), or attach to a server that's already running on a remote (or local) host. The newly developed content sitting in the developer's workspace needs to end up in a location and format that the running server can use for its serving purposes.
In this picture, an IServer
object is a proxy for the real web
server. Through this proxy, a client can configure the server, and start,
stop, and restart it.
The server framework maintains a global list of all known server instances
(ServerCore.getServers()
).
[rough notes: Server has a state. Server can be started, stopped, and restarted. To modify server attributes, get a working copy, modify it, and then save it to commit the changes. Server attributes. Serialization. Chained working copies for runtime, server configuration. Server has a set of root modules. Modules have state wrt a server. Restarting modules. ]
Two servers are identical if and only if they have the same id.
This interface is not intended to be implemented by clients.
Nested Class Summary | |
---|---|
static interface |
IServer.IOperationListener
An operation listener is used to receive notification back about a specific server operation, such as starting or stopping a server. |
Field Summary | |
---|---|
static int |
PUBLISH_AUTO
Publish kind constant (value 3) indicating an automatic publish request. |
static int |
PUBLISH_CLEAN
Publish kind constant (value 4) indicating a publish clean request |
static int |
PUBLISH_FULL
Publish kind constant (value 2) indicating a full publish request. |
static int |
PUBLISH_INCREMENTAL
Publish kind constant (value 1) indicating an incremental publish request. |
static int |
PUBLISH_STATE_FULL
Publish state constant (value 3) indicating that a full publish is required. |
static int |
PUBLISH_STATE_INCREMENTAL
Publish state constant (value 2) indicating that an incremental publish is required. |
static int |
PUBLISH_STATE_NONE
Publish state constant (value 1) indicating that there is no publish required. |
static int |
PUBLISH_STATE_UNKNOWN
Publish state constant (value 0) indicating that it's in an unknown state. |
static int |
STATE_STARTED
Server state constant (value 2) indicating that the server is ready to serve content. |
static int |
STATE_STARTING
Server state constant (value 1) indicating that the server is starting, but not yet ready to serve content. |
static int |
STATE_STOPPED
Server state constant (value 4) indicating that the server is stopped. |
static int |
STATE_STOPPING
Server state constant (value 3) indicating that the server is shutting down. |
static int |
STATE_UNKNOWN
Server state constant (value 0) indicating that the server is in an unknown state. |
Method Summary | |
---|---|
void |
addPublishListener(IPublishListener listener)
Adds a publish listener to this server. |
void |
addServerListener(IServerListener listener)
Adds the given server state listener to this server. |
void |
addServerListener(IServerListener listener,
int eventMask)
Adds the given server state listener to this server. |
org.eclipse.core.runtime.IStatus |
canControlModule(IModule[] module,
org.eclipse.core.runtime.IProgressMonitor monitor)
Returns whether the given module can be restarted. |
org.eclipse.core.runtime.IStatus |
canPublish()
Returns whether this server is in a state that it can be published to. |
org.eclipse.core.runtime.IStatus |
canRestart(java.lang.String mode)
Returns whether this server is in a state that it can be restarted in the given mode. |
org.eclipse.core.runtime.IStatus |
canStart(java.lang.String launchMode)
Returns whether this server is in a state that it can be started in the given mode. |
org.eclipse.core.runtime.IStatus |
canStop()
Returns whether this server is in a state that it can be stopped. |
org.eclipse.debug.core.ILaunchConfiguration |
getLaunchConfiguration(boolean create,
org.eclipse.core.runtime.IProgressMonitor monitor)
Return the launch configuration for this server. |
java.lang.String |
getMode()
Returns the ILaunchManager mode that the server is in. |
int |
getModulePublishState(IModule[] module)
Returns the module's sync state. |
boolean |
getModuleRestartState(IModule[] module)
Check if the given module is in sync on the server. |
int |
getModuleState(IModule[] module)
Returns the current state of the given module on this server. |
int |
getServerPublishState()
Returns the server's sync state. |
boolean |
getServerRestartState()
Returns whether this server is out of sync and needs to be restarted. |
int |
getServerState()
Returns the current state of this server. |
org.eclipse.core.runtime.IStatus |
publish(int kind,
org.eclipse.core.runtime.IProgressMonitor monitor)
Publish to the server using the progress monitor. |
void |
removePublishListener(IPublishListener listener)
Removes a publish listener from this server. |
void |
removeServerListener(IServerListener listener)
Removes the given server state listener from this server. |
void |
restart(java.lang.String launchMode,
org.eclipse.core.runtime.IProgressMonitor monitor)
Asynchronously restarts this server. |
void |
restart(java.lang.String launchMode,
IServer.IOperationListener listener)
Asynchronously restarts this server. |
void |
restartModule(IModule[] module,
IServer.IOperationListener listener)
Asynchronously restarts the given module on the server. |
boolean |
shouldPublish()
Returns true if the server should be published to. |
boolean |
shouldRestart()
Returns true if the server should be restarted. |
void |
start(java.lang.String launchMode,
org.eclipse.core.runtime.IProgressMonitor monitor)
Asynchronously starts this server in the given launch mode. |
void |
start(java.lang.String launchMode,
IServer.IOperationListener listener)
Asynchronously starts this server in the given launch mode. |
void |
startModule(IModule[] module,
IServer.IOperationListener listener)
Asynchronously starts this server in the given launch mode. |
void |
stop(boolean force)
Asynchronously stops this server. |
void |
stop(boolean force,
IServer.IOperationListener listener)
Asynchronously stops this server. |
void |
stopModule(IModule[] module,
IServer.IOperationListener listener)
Asynchronously stops the given module. |
void |
synchronousRestart(java.lang.String launchMode,
org.eclipse.core.runtime.IProgressMonitor monitor)
Deprecated. this method is deprecated. use restart(String, IProgressMonitor, IOperationListener) instead |
void |
synchronousStart(java.lang.String launchMode,
org.eclipse.core.runtime.IProgressMonitor monitor)
Deprecated. this method is deprecated. use start(String, IProgressMonitor, IOperationListener) instead |
void |
synchronousStop(boolean force)
Deprecated. this method is deprecated. use stop(boolean, IOperationListener) instead |
Methods inherited from interface org.eclipse.wst.server.core.IServerAttributes |
---|
canModifyModules, createWorkingCopy, delete, getAdapter, getChildModules, getHost, getId, getModules, getName, getRootModules, getRuntime, getServerConfiguration, getServerPorts, getServerType, isReadOnly, isWorkingCopy, loadAdapter |
Field Detail |
---|
static final int STATE_UNKNOWN
getServerState()
,
getModuleState(IModule[])
,
Constant Field Valuesstatic final int STATE_STARTING
getServerState()
,
getModuleState(IModule[])
,
Constant Field Valuesstatic final int STATE_STARTED
getServerState()
,
getModuleState(IModule[])
,
Constant Field Valuesstatic final int STATE_STOPPING
getServerState()
,
getModuleState(IModule[])
,
Constant Field Valuesstatic final int STATE_STOPPED
getServerState()
,
getModuleState(IModule[])
,
Constant Field Valuesstatic final int PUBLISH_STATE_UNKNOWN
getServerPublishState()
,
getModulePublishState(IModule[])
,
Constant Field Valuesstatic final int PUBLISH_STATE_NONE
getServerPublishState()
,
getModulePublishState(IModule[])
,
Constant Field Valuesstatic final int PUBLISH_STATE_INCREMENTAL
getServerPublishState()
,
getModulePublishState(IModule[])
,
Constant Field Valuesstatic final int PUBLISH_STATE_FULL
getServerPublishState()
,
getModulePublishState(IModule[])
,
Constant Field Valuesstatic final int PUBLISH_INCREMENTAL
publish(int, IProgressMonitor)
,
Constant Field Valuesstatic final int PUBLISH_FULL
publish(int, IProgressMonitor)
,
Constant Field Valuesstatic final int PUBLISH_AUTO
publish(int, IProgressMonitor)
,
Constant Field Valuesstatic final int PUBLISH_CLEAN
publish(int, IProgressMonitor)
,
Constant Field ValuesMethod Detail |
---|
int getServerState()
Note that this operation is guaranteed to be fast (it does not actually communicate with any actual server).
STATE_XXX
)
constants declared on IServer
java.lang.String getMode()
ILaunchManager
, or
null
if the server is stopped.int getServerPublishState()
void addServerListener(IServerListener listener)
listener
- the server listenerremoveServerListener(IServerListener)
void addServerListener(IServerListener listener, int eventMask)
listener
- the server listenereventMask
- the bit-wise OR of all event types of interest to the
listenerremoveServerListener(IServerListener)
void removeServerListener(IServerListener listener)
listener
- the listeneraddServerListener(IServerListener)
void addPublishListener(IPublishListener listener)
listener
- the publish listenerremovePublishListener(IPublishListener)
void removePublishListener(IPublishListener listener)
listener
- the publish listeneraddPublishListener(IPublishListener)
org.eclipse.core.runtime.IStatus canPublish()
IStatus.OK
if the server can
be published to, otherwise a status object indicating what is wrongboolean shouldPublish()
true
when the server
can be published to and the server's publish state or any module's publish state is not
PUBLISH_STATE_NONE.
org.eclipse.core.runtime.IStatus publish(int kind, org.eclipse.core.runtime.IProgressMonitor monitor)
This method should not be called from the UI thread. Publishing is long- running and may trigger resource change events or builds. Although this framework is safe, there is no guarantee that other bundles are UI-safe and the risk of UI deadlock is high.
kind
- the kind of publish being requested. Valid values are
PUBLSIH_FULL
- indicates a full publish.PUBLISH_INCREMENTAL
- indicates a incremental publish.
PUBLISH_CLEAN
- indicates a clean request. Clean throws
out all state and cleans up the module on the server before doing a
full publish.
monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
org.eclipse.core.runtime.IStatus canStart(java.lang.String launchMode)
launchMode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
IStatus.OK
if the server can
be started, otherwise a status object indicating why it can'tvoid start(java.lang.String launchMode, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
If canStart(launchMode) is false, this method will throw an exception.
If the caller wants to listen for failure or success of the server starting, it can add a server listener or use the version of this method that takes a status listener as a parameter.
launchMode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
org.eclipse.core.runtime.CoreException
- if an error occurs while trying to start the servervoid start(java.lang.String launchMode, IServer.IOperationListener listener)
If canStart(launchMode) is false, this method will throw an exception.
The operation listener can be used to add a listener for notification of this specific server launch. The listener will be called with a single successful status (severity OK) when the server has finished starting, or a single failure (severity ERROR) if there was an error starting the server.
launchMode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
listener
- an operation listener to receive notification when this
operation is done, or null
if notification is not
requiredvoid synchronousStart(java.lang.String launchMode, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
This convenience method uses start(String, IProgressMonitor)
to start the server, and an internal thread and listener to detect
when the server has finished starting.
launchMode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
org.eclipse.core.runtime.CoreException
- if an error occurs while trying to start the serverorg.eclipse.core.runtime.IStatus canRestart(java.lang.String mode)
mode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
IStatus.OK
if the server can
be restarted, otherwise a status object indicating why it can'tboolean shouldRestart()
true
when the server
can be restarted and the server's restart state or any module's restart states is not
false.
boolean getServerRestartState()
[issue: Need to explain what is it that can get out of "out of sync" here, and how this can happen.]
true
if this server is out of sync and needs to be
restarted, and false
otherwise (e.g., if the contents have
not been modified and the server process is still in sync); the
result is unspecified if the server is not currently runningvoid restart(java.lang.String launchMode, org.eclipse.core.runtime.IProgressMonitor monitor)
canRestart(String)
returns false
.
This method cannot be used to start the server from a stopped state.
If the caller wants to listen for failure or success of the server restarting, it can add a server listener or use the version of this method that takes a status listener as a parameter.
launchMode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desiredvoid restart(java.lang.String launchMode, IServer.IOperationListener listener)
canRestart(String)
returns false
.
This method cannot be used to start the server from a stopped state.
The operation listener can be used to add a listener for notification of this specific server restart. The listener will be called with a single successful status (severity OK) when the server has finished restarting, or a single failure (severity ERROR) if there was an error restarting the server.
launchMode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
listener
- an operation listener to receive notification when this
operation is done, or null
if notification is not
requiredvoid synchronousRestart(java.lang.String launchMode, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
canRestart(String)
returns false
.
[issue: There is no way to communicate failure to the client. Given that this operation can go awry, there probably should be a mechanism that allows failing asynch operations to be diagnosed.]
launchMode
- a mode in which a server can be launched,
one of the mode constants defined by
ILaunchManager
monitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
org.eclipse.core.runtime.CoreException
- if there was an errororg.eclipse.core.runtime.IStatus canStop()
IStatus.OK
if the server can
be stopped, otherwise a status object indicating why it can'tvoid stop(boolean force)
canStop()
returns false
.
If force is false
, it will attempt to stop the server
normally/gracefully. If force is true
, then the server
process will be terminated any way that it can.
If the caller wants to listen for success or failure of the server stopping, it can add a server listener or use the version of this method that takes a status listener as a parameter.
force
- true
to kill the server, or false
to stop normallyvoid stop(boolean force, IServer.IOperationListener listener)
canStop()
returns false
.
If force is false
, it will attempt to stop the server
normally/gracefully. If force is true
, then the server
process will be terminated any way that it can.
The operation listener can be used to add a listener for notification of this specific server stop. The listener will be called with a single successful status (severity OK) when the server has finished stopping, or a single failure (severity ERROR) if there was an error stopping the server.
force
- true
to kill the server, or false
to stop normallylistener
- an operation listener to receive notification when this
operation is done, or null
if notification is not
requiredvoid synchronousStop(boolean force)
This convenience method uses stop(boolean)
to stop the server, and an internal thread and listener to detect
when the server has complied.
force
- true
to kill the server, or false
to stop normallyint getModuleState(IModule[] module)
STATE_UNKNOWN
if the module
is not among the ones associated with this server.
module
- the module
STATE_XXX
) constants declared
on IServer
int getModulePublishState(IModule[] module)
module
- the module
boolean getModuleRestartState(IModule[] module)
module
- the module
org.eclipse.core.runtime.IStatus canControlModule(IModule[] module, org.eclipse.core.runtime.IProgressMonitor monitor)
This method has a progress monitor because it may involve plugin and class loading. No communication to the server will occur.
module
- the modulemonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
IStatus.OK
if the module can
be restarted, otherwise a status object indicating why it can'tvoid startModule(IModule[] module, IServer.IOperationListener listener)
If canStart(launchMode) is false, this method will throw an exception.
The operation listener can be used to add a listener for notification of this specific module start. The listener will be called with a single successful status (severity OK) when the module has finished starting, or a single failure (severity ERROR) if there was an error starting the module.
module
- the module to be startedlistener
- an operation listener to receive notification when this
operation is done, or null
if notification is not
requiredvoid stopModule(IModule[] module, IServer.IOperationListener listener)
The operation listener can be used to add a listener for notification of this specific module stop. The listener will be called with a single successful status (severity OK) when the module has finished stopping, or a single failure (severity ERROR) if there was an error stopping the module.
module
- the module to be stoppedlistener
- an operation listener to receive notification when this
operation is done, or null
if notification is not
requiredvoid restartModule(IModule[] module, IServer.IOperationListener listener)
The implementation should update the module sync state and fire an event for the module. If the module does not exist on the server, an exception will be thrown.
[issue: Since this method is ascynchronous, is there any need for the progress monitor?]
[issue: IServer.synchronousModuleRestart throws CoreException if anything goes wrong.]
[issue: If the module was just published to the server and had never been started, would is be ok to "start" the module using this method?]
module
- the module to be startedlistener
- an operation listener to receive notification when this
operation is done, or null
if notification is not
requiredorg.eclipse.debug.core.ILaunchConfiguration getLaunchConfiguration(boolean create, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException
null
.
Will return null
if this server type is invalid or has no associated
launch configuration type (i.e. this server type cannot be started).
create
- true
if a new launch configuration should be
created if there are none alreadymonitor
- a progress monitor, or null
if progress
reporting and cancellation are not desired
null
if there was no
existing launch configuration and create
was false
org.eclipse.core.runtime.CoreException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |