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

java.lang.Object
  extended byorg.eclipse.wst.server.core.model.RuntimeDelegate

public abstract class RuntimeDelegate
extends java.lang.Object

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

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

RuntimeDelegate supports an open-ended set of attribute-value pairs. All state stored in this manner will be saved when the runtime working copy is saved, and persisted across workbench sessions. Runtime delegates may keep state in instance fields, but that state is transient and will not be persisted across workbench sessions. To save state across workbench sessions, it must be persisted using the attributes.

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

Caveat: The server core API is still in an early form, and is likely to change significantly before the initial release.

Since:
1.0
See Also:
IRuntime, IRuntimeWorkingCopy

Constructor Summary
RuntimeDelegate()
          Delegates must have a public 0-arg constructor.
 
Method Summary
 void dispose()
          Disposes of this runtime delegate.
 boolean getAttribute(java.lang.String id, boolean defaultValue)
          Returns the value of the specified boolean-valued attribute.
 int getAttribute(java.lang.String id, int defaultValue)
          Returns the value of the specified int-valued attribute.
 java.util.List getAttribute(java.lang.String id, java.util.List defaultValue)
          Returns the value of the specified List-valued attribute.
 java.util.Map getAttribute(java.lang.String id, java.util.Map defaultValue)
          Returns the value of the specified Map-valued attribute.
 java.lang.String getAttribute(java.lang.String id, java.lang.String defaultValue)
          Returns the value of the specified String-valued attribute.
 IRuntime getRuntime()
          Returns the runtime that this runtime delegate corresponds to.
 IRuntimeWorkingCopy getRuntimeWorkingCopy()
          Returns the runtime working copy that this runtime delegate corresponds to.
 void initialize()
          Initializes this runtime delegate.
 void initialize(org.eclipse.wst.server.core.internal.Runtime newRuntime)
          Initializes this runtime delegate with its life-long runtime instance.
 void setAttribute(java.lang.String id, boolean value)
          Sets the value of the specified boolean-valued attribute of this element.
 void setAttribute(java.lang.String id, int value)
          Sets the value of the specified integer-valued attribute of this element.
 void setAttribute(java.lang.String id, java.util.List value)
          Sets the value of the specified list-valued attribute of this element.
 void setAttribute(java.lang.String id, java.util.Map value)
          Sets the value of the specified map-valued attribute of this element.
 void setAttribute(java.lang.String id, java.lang.String value)
          Sets the value of the specified string-valued attribute of this element.
 void setDefaults()
          Initializes this runtime with default values.
 IStatus validate()
          Validates this runtime instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuntimeDelegate

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

Method Detail

initialize

public final void initialize(org.eclipse.wst.server.core.internal.Runtime newRuntime)
Initializes this runtime delegate with its life-long runtime instance.

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

Parameters:
newRuntime - the runtime instance

initialize

public void initialize()
Initializes this runtime delegate. This method gives delegates a chance to do their own initialization.

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


getRuntime

public IRuntime getRuntime()
Returns the runtime that this runtime delegate corresponds to.

Returns:
the runtime

getRuntimeWorkingCopy

public IRuntimeWorkingCopy getRuntimeWorkingCopy()
Returns the runtime working copy that this runtime delegate corresponds to.

Returns:
the runtime

validate

public IStatus validate()
Validates this runtime instance. Subclasses should override and call super.validate() for basic validation.

This method is called by the web server core framework, in response to a call to IRuntime.validate(IProgressMonitor). Clients should never call this method.

Returns:
a status object with code IStatus.OK if this runtime is valid, otherwise a status object indicating what is wrong with it

getAttribute

public int getAttribute(java.lang.String id,
                        int defaultValue)
Returns the value of the specified int-valued attribute.

Parameters:
id - the attribute id
defaultValue - the default value of the specified attribute
Returns:
the attribute value
See Also:
setAttribute(String, int)

getAttribute

public boolean getAttribute(java.lang.String id,
                            boolean defaultValue)
Returns the value of the specified boolean-valued attribute.

Parameters:
id - the attribute id
defaultValue - the default value of the specified attribute
Returns:
the attribute value
See Also:
setAttribute(String, boolean)

getAttribute

public java.lang.String getAttribute(java.lang.String id,
                                     java.lang.String defaultValue)
Returns the value of the specified String-valued attribute.

Parameters:
id - the attribute id
defaultValue - the default value of the specified attribute
Returns:
the attribute value
See Also:
setAttribute(String, String)

getAttribute

public java.util.List getAttribute(java.lang.String id,
                                   java.util.List defaultValue)
Returns the value of the specified List-valued attribute.

Parameters:
id - the attribute id
defaultValue - the default value of the specified attribute
Returns:
the attribute value
See Also:
setAttribute(String, List)

getAttribute

public java.util.Map getAttribute(java.lang.String id,
                                  java.util.Map defaultValue)
Returns the value of the specified Map-valued attribute.

Parameters:
id - the attribute id
defaultValue - the default value of the specified attribute
Returns:
the attribute value
See Also:
setAttribute(String, Map)

dispose

public void dispose()
Disposes of this runtime delegate.

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

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


setDefaults

public void setDefaults()
Initializes this runtime with default values. This method is called when a new runtime is created so that the runtime can be initialized with meaningful values.


setAttribute

public void setAttribute(java.lang.String id,
                         int value)
Sets the value of the specified integer-valued attribute of this element.

Parameters:
id - the attribute id
value - the value of the specified attribute
See Also:
getAttribute(String, int)

setAttribute

public void setAttribute(java.lang.String id,
                         boolean value)
Sets the value of the specified boolean-valued attribute of this element.

Parameters:
id - the attribute id
value - the value of the specified attribute
See Also:
getAttribute(String, boolean)

setAttribute

public void setAttribute(java.lang.String id,
                         java.lang.String value)
Sets the value of the specified string-valued attribute of this element.

Parameters:
id - the attribute id
value - the value of the specified attribute
See Also:
getAttribute(String, String)

setAttribute

public void setAttribute(java.lang.String id,
                         java.util.List value)
Sets the value of the specified list-valued attribute of this element. The list may only contain String values.

Parameters:
id - the attribute id
value - the value of the specified attribute
See Also:
getAttribute(String, List)

setAttribute

public void setAttribute(java.lang.String id,
                         java.util.Map value)
Sets the value of the specified map-valued attribute of this element. The map may only contain String values.

Parameters:
id - the attribute id
value - the value of the specified attribute
See Also:
getAttribute(String, Map)