org.systinet.wasp.policy
Class PolicyElement

java.lang.Object
  extended byorg.systinet.wasp.policy.PolicyElement
Direct Known Subclasses:
PolicyAssertion, PolicyCompositor

public abstract class PolicyElement
extends java.lang.Object

This class represents the base class for the WSO2 SOA Enablement Server policy framework. A policy element defines a PolicyUsage and preference. It provides methods for reading readStandardAttributes(javax.xml.transform.dom.DOMSource) and writing writeStandardAttributes(javax.xml.transform.dom.DOMSource) of these attributes from a DOMSource.

Since:
5.0
Component:
Core

Constructor Summary
protected PolicyElement()
          This only sets the preference to 100.
 
Method Summary
abstract  javax.xml.transform.Source getContent()
          Gets the content of this object as Source
 PolicyElement getParentElement()
          Gets the parent policy element of this element or null, if any parent if not specified.
 int getPreference()
          Gets the preference of the policy element.
 PolicyUsage getUsage()
          Gets the usage of the policy element.
protected  void readStandardAttributes(javax.xml.transform.dom.DOMSource domSource)
          Reads the usage and preference from given XML source.
 void setParentElement(PolicyElement parentElement)
          Sets the parent policy element of this element.
 void setPreference(int preference)
          Sets the preference of the policy element.
 void setUsage(PolicyUsage usage)
          Sets the usage of the policy element.
protected  void writeStandardAttributes(javax.xml.transform.dom.DOMSource domSource)
          Writes the usage and preference to given XML source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolicyElement

protected PolicyElement()
This only sets the preference to 100. Any subclass must call this to ensure that a policy element or an assertion created at runtime has enough big preference to override a persistent policy assertions. When the policy element is loaded from XML source, the preference is set to 0 if it's not present.

Method Detail

getUsage

public PolicyUsage getUsage()
Gets the usage of the policy element. If the usage is not specified for this element, gets the usage of parent element of this element if a parent is specifed; PolicyUsage.OBSERVED otherwise.

Returns:
the usage of the policy element

setUsage

public void setUsage(PolicyUsage usage)
Sets the usage of the policy element.

Parameters:
usage - usage to set

getPreference

public int getPreference()
Gets the preference of the policy element.

Returns:
the preference of the policy element

setPreference

public void setPreference(int preference)
Sets the preference of the policy element.

Parameters:
preference - preference to set

getParentElement

public PolicyElement getParentElement()
Gets the parent policy element of this element or null, if any parent if not specified.

Returns:
the parent policy element of this element or null

setParentElement

public void setParentElement(PolicyElement parentElement)
                      throws PolicyException
Sets the parent policy element of this element. The parent element is automatically set when the element is added to a PolicyCompositor. The parent can be set only once, that means there is no possible to add one instance of a policy element to more than one compositor.

Parameters:
parentElement - parent policy element
Throws:
PolicyException - when the parent element was already set

readStandardAttributes

protected void readStandardAttributes(javax.xml.transform.dom.DOMSource domSource)
Reads the usage and preference from given XML source.

Parameters:
domSource - source to read

writeStandardAttributes

protected void writeStandardAttributes(javax.xml.transform.dom.DOMSource domSource)
Writes the usage and preference to given XML source.

Parameters:
domSource - source where the attributes will be written

getContent

public abstract javax.xml.transform.Source getContent()
                                               throws PolicyException
Gets the content of this object as Source

Returns:
the content of this object as Source
Throws:
PolicyException - when an error occurs