Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 



org.eclipse.wst.server.core.model
Class ServerBehaviourDelegate

java.lang.Object
  extended by 
org.eclipse.wst.server.core.model.ServerBehaviourDelegate

public abstract class ServerBehaviourDelegate
extends java.lang.Object

A server delegate provides the implementation for various generic and server-type-specific operations for a specific type of server. A server delegate is specified by the class attribute of a serverTypes extension.

When the server instance needs to be given a delegate, the delegate class specified for the server type is instantiated with a 0-argument constructor and primed with delegate.initialize(((IServerState)server), which it is expected to hang on to. Later, when delegate.dispose() is called as the server instance is being discarded, the delegate is expected to let go of the server instance.

Server delegates may keep state in instance fields, but that state is transient and will not be persisted across workbench sessions.

This abstract class is intended to be extended only by clients to extend the serverTypes extension point.

Since:
1.0
See Also:
IServer, IServerWorkingCopy

Field Summary
static int ADDED
          Publish kind constant (value 1) for added resources.
static int CHANGED
          Publish kind constant (value 2) for changed resources.
static int NO_CHANGE
          Publish kind constant (value 0) for no change.
static int REMOVED
          Publish kind constant (value 3) for removed resources.
 
Constructor Summary
ServerBehaviourDelegate ()
          Delegates must have a public 0-arg constructor.
 
Method Summary
 boolean canControlModule ( IModule[] module)
          Returns whether the given module can be restarted.
 IStatus canPublish ()
          Returns whether this server is in a state that it can be published to.
 IStatus canRestart (java.lang.String mode)
          Returns whether this server is in a state that it can be restarted in the given mode.
 IStatus canStart (java.lang.String launchMode)
          Returns whether this server is in a state that it can be started in the given mode.
 IStatus canStop ()
          Returns whether this server is in a state that it can be stopped.
 void dispose ()
          Disposes of this server delegate.
  IServer getServer ()
          Returns the server that this server delegate corresponds to.
 void handleResourceChange ()
          Called when resources change within the workspace.
 IStatus publish (int kind, IProgressMonitor monitor)
          Publish to the server.
 void publish (int kind, java.util.List< IModule[]> modules, IProgressMonitor monitor, IAdaptable info)
          Publish to the server.
 void restart (java.lang.String launchMode)
          Restart this server.
 void restartModule ( IModule[] module, IProgressMonitor monitor)
          Restarts the given module on the server.
 void setupLaunchConfiguration (ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor)
          Configure the given launch configuration to start this server.
 void startModule ( IModule[] module, IProgressMonitor monitor)
          Starts the given module on the server.
abstract  void stop (boolean force)
          Shuts down and stops this server.
 void stopModule ( IModule[] module, IProgressMonitor monitor)
          Stops the given module on the server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_CHANGE

public static final int NO_CHANGE
Publish kind constant (value 0) for no change.

See Also:
publishModule(int, int, IModule[], IProgressMonitor), Constant Field Values

ADDED

public static final int ADDED
Publish kind constant (value 1) for added resources.

See Also:
publishModule(int, int, IModule[], IProgressMonitor), Constant Field Values

CHANGED

public static final int CHANGED
Publish kind constant (value 2) for changed resources.

See Also:
publishModule(int, int, IModule[], IProgressMonitor), Constant Field Values

REMOVED

public static final int REMOVED
Publish kind constant (value 3) for removed resources.

See Also:
publishModule(int, int, IModule[], IProgressMonitor), Constant Field Values
Constructor Detail

ServerBehaviourDelegate

public ServerBehaviourDelegate()
Delegates must have a public 0-arg constructor.

Method Detail

getServer

public final 
IServer getServer()
Returns the server that this server delegate corresponds to.

Returns:
the server

dispose

public void dispose()
Disposes of this server delegate.

This method is called by the server core framework. Clients should never call this method.

Implementations are expected to let go of the delegate's reference to the server, deregister listeners, etc.


setupLaunchConfiguration

public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy,
                                     IProgressMonitor monitor)
                              throws CoreException
Configure the given launch configuration to start this server. This method is called whenever the server is started to ensure that the launch configuration is accurate and up to date. This method should not blindly update the launch configuration in cases where the user has access to change the launch configuration by hand.

Parameters:
workingCopy - a launch configuration working copy
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if there is an error setting up the configuration

restart

public void restart(java.lang.String launchMode)
             throws CoreException
Restart this server. The server should use the server listener to notify progress. It must use the same debug flags as was originally passed into the start() method. This method is used if there is a quick/better way to restart the server. If it throws a CoreException, the normal stop/start actions will be used.

Parameters:
launchMode - the mode to restart in, one of the mode constants defined by ILaunchManager
Throws:
CoreException - if there was a problem restarting

canControlModule

public boolean canControlModule(
IModule[] module)
Returns whether the given module can be restarted.

This call should complete reasonably fast and not require communication with the (potentially remote) server. If communication is required it should be done asynchronously and this method should either fail until that is complete or succeed and handle failure in the xxModule methods.

Parameters:
module - the module
Returns:
true if the given module can be restarted, and false otherwise

canStart

public IStatus canStart(java.lang.String launchMode)
Returns whether this server is in a state that it can be started in the given mode.

This call should complete reasonably fast and not require communication with the (potentially remote) server. If communication is required it should be done asynchronously and this method should either fail until that is complete or succeed and handle failure during start.

This method is called by the server core framework, in response to a call to IServer.canStart(). The framework has already filtered out obviously invalid situations, such as starting a server that is already running. Clients should never call this method directly.

Parameters:
launchMode - a mode in which a server can be launched, one of the mode constants defined by org.eclipse.debug.core.ILaunchManager
Returns:
a status object with code IStatus.OK if the server can be started, otherwise a status object indicating why it can't
Since:
3.0

canRestart

public IStatus canRestart(java.lang.String mode)
Returns whether this server is in a state that it can be restarted in the given mode. Note that only servers that are currently running can be restarted.

This call should complete reasonably fast and not require communication with the (potentially remote) server. If communication is required it should be done asynchronously and this method should either fail until that is complete or succeed and handle failure during restart.

This method is called by the server core framework, in response to a call to IServer.canRestart(). The framework has already filtered out obviously invalid situations, such as restarting a stopped server. Clients should never call this method directly.

Parameters:
mode - a mode in which a server can be launched, one of the mode constants defined by org.eclipse.debug.core.ILaunchManager
Returns:
a status object with code IStatus.OK if the server can be restarted, otherwise a status object indicating why it can't
Since:
3.0

canStop

public IStatus canStop()
Returns whether this server is in a state that it can be stopped. Servers can be stopped if they are not already stopped and if they belong to a state-set that can be stopped.

This call should complete reasonably fast and not require communication with the (potentially remote) server. If communication is required it should be done asynchronously and this method should either fail until that is complete or succeed and handle failure during stop.

This method is called by the server core framework, in response to a call to IServer.canStop(). The framework has already filtered out obviously invalid situations, such as stopping a server that is already stopped. Clients should never call this method directly.

Returns:
a status object with code IStatus.OK if the server can be stopped, otherwise a status object indicating why it can't
Since:
3.0

canPublish

public IStatus canPublish()
Returns whether this server is in a state that it can be published to.

This call should complete reasonably fast and not require communication with the (potentially remote) server. If communication is required it should be done asynchronously and this method should either fail until that is complete or succeed and handle failure during publish.

This method is called by the server core framework, in response to a call to IServer.canPublish(). The framework has already filtered out obviously invalid situations, such as publishing to a server in the wrong mode. Clients should never call this method directly.

Returns:
a status object with code IStatus.OK if the server can be published to, otherwise a status object indicating what is wrong
Since:
3.0

startModule

public void startModule(
IModule[] module,
                        IProgressMonitor monitor)
                 throws CoreException
Starts the given module on the server. See the specification of IServer.startModule(IModule[], IServer.IOperationListener) for further details.

The implementation should update the module sync state and fire an event for the module.

This method will throw an exception if the module does not exist on the server.

[issue: Since this method is asynchronous, is there any need for the progress monitor?]

Parameters:
module - the module to be started
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if an error occurs while trying to restart the module

stopModule

public void stopModule(
IModule[] module,
                       IProgressMonitor monitor)
                throws CoreException
Stops the given module on the server. See the specification of IServer.stopModule(IModule[], IServer.IOperationListener) for further details.

The implementation should update the module sync state and fire an event for the module.

This method will throw an exception if the module does not exist on the server.

[issue: Since this method is asynchronous, is there any need for the progress monitor?]

Parameters:
module - the module to be stopped
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if an error occurs while trying to restart the module

restartModule

public void restartModule(
IModule[] module,
                          IProgressMonitor monitor)
                   throws CoreException
Restarts the given module on the server. See the specification of IServer.restartModule(IModule[], IServer.IOperationListener) for further details.

The implementation should update the module sync state and fire an event for the module.

This method will throw an exception if the module does not exist on the server.

[issue: Since this method is asynchronous, is there any need for the progress monitor?]

Parameters:
module - the module to be stopped
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Throws:
CoreException - if an error occurs while trying to restart the module

stop

public abstract void stop(boolean force)
Shuts down and stops this server. The server should return from this method quickly and use the server listener to notify shutdown progress.

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.

[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 async operations to be diagnosed.]

Parameters:
force - true to kill the server, or false to stop normally

publish

public void publish(int kind,
                    java.util.List<
IModule[]> modules,
                    IProgressMonitor monitor,
                    IAdaptable info)
             throws CoreException
Publish to the server.

Parameters:
kind - the publish kind
modules -
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
info -
Throws:
CoreException

publish

public IStatus publish(int kind,
                       IProgressMonitor monitor)
Publish to the server.

Parameters:
kind - the publish kind
monitor - a progress monitor, or null if progress reporting and cancellation are not desired
Returns:
the publish status

handleResourceChange

public void handleResourceChange()
Called when resources change within the workspace. This gives the server an opportunity to update the server or module restart state.




 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire