<delegate> elements and related data object types
The <delegate> XML root element defines delegate data object types. A
delegate data object type is a collection of properties and
behaviors. Moreover, a delegate contains an interface and a
default implementation of that interface. A delegate can also add
its own columns to the tables of data object types that
implement the delegate. This type of delegation enables a data
object type to implement an interface while delegating the
implementation to the delegate.
You often use a delegate so that objects can share code. The delegate implements the shared code rather than each class implementing copies of common code. Thus, a delegate is an entity associated with an implemented interface that multiple parent entities can reuse.
Guidewire defines delegates in data model metadata files. You can extend existing delegates that are marked as extendible. You can also create your own custom delegates.
PolicyCenter stores all database columns on the delegate entity in the implementing entity.
Attributes of <delegate>
The <delegate>
element contains the following attributes.
|
Description |
Default |
|---|---|---|
|
Internal. |
|
|
Required. |
None |
|
Internal. Do not use. The only real effect is to change the location in which the table appears in a data distribution report. |
|
|
Specifies that the
delegate must be implemented by an entity of a general type, such as
Possible values for the |
|
|
See Data objects and scriptability for information. |
None |
Subelements of <delegate>
The <delegate>
element contains the following subelements.
|
Description |
|---|---|
|
See <column>. |
|
Internal. |
|
Internal. |
|
See <foreignkey>. |
|
See <fulldescription>. |
|
See <implementsEntity>. |
|
|
|
See <index>. |
|
Handles monetary amounts. The |
|
See <typekey>. |
Implementing delegate data object types
To implement most delegate data object types, you add the following to an entity definition or extension.
<implementsEntity name="SomeDelegate"/>For example, in the base configuration,
the Group entity implements
the Validatable delegate
by using the following:
<entity entity="Group" ... >
<implementsEntity name="Validatable"/>
...
</entity>
It is possible for an entity to implement multiple delegates, just as a Gosu or Java class can implement multiple interfaces.
See also
- <implementsEntity>
- Creating a new delegate object.
- For a discussion of working with delegates in Gosu classes, see Delegation syntax.
Delegate object types that you cannot implement directly
There are some delegates that you cannot implement
directly through the use of the <implementsEntity>
element. They are:
VersionableKeyableBeanEditableRetireableEffDatedEffDatedBranchEffDatedContainer
These are special delegates that PolicyCenter implicitly adds to an
entity if you set the type
attribute on the entity to one of these values. Therefore, do not use
the <implementsEntity>
element to specify one of these delegates. Instead, use the type attribute on the entity declaration.
The basic syntax looks similar to the following:
<entity name="SomeEntity" ... type="SomeDelegate">For example, in the base configuration,
the Group entity also
implements the Retireable
delegate by setting the entity type
attribute to retireable.
<entity entity="Group" ... type="retireable">
<implementsEntity name="Validatable"/>
...
</entity>
Also, it is not possible to explicitly implement the
EventAware delegate. PolicyCenter automatically adds this
delegate to any entity that contains an <events> element.
Archiving delegates in the base configuration must not be changed
To support the archive process, certain Guidewire entities in the base configuration implement one or more of the following delegates:
RootInfoExtractableOverlapTable
Recommendations for using delegates
Guidewire recommends that you use delegates in three scenarios.
Implementing a common interface
Guidewire recommends that you use a delegate if you want both of the following:
- If you want to have multiple entities implement the same interface
- If you want most of the implementations of the interface to be common
PolicyCenter defines a number of delegates in the base configuration. For example:
AssignableEditableValidatable- ...
To determine the list of base configuration delegate entities, search the folder for files that contain the following text:
<delegateSubtyping without single-table inheritance
Guidewire recommends that you create a delegate entity rather than define a supertype entity if you do not want to store subtype data in a single table. PolicyCenter stores information on all subtypes of a supertype entity in a single table. This can create a table that is extremely large and extremely wide. This is true especially if you have an entity hierarchy with a number of different subtypes that each have their own columns. Using a delegate avoids this single-table inheritance while preserving the ability to define the fields and behavior common to all the subtypes in one place.
Guidewire recommends that you consider carefully before making a decision on how to model your entity hierarchy.
Using entity polymorphism
Guidewire recommends that you create a
delegate entity if you want to use polymorphism on class methods. For
core PolicyCenter classes defined
in Java, you cannot override these class methods on its Gosu subtypes.
You can, however, push all methods and behaviors that can possibly be
polymorphic into an interface, rather than the Java superclass. You can
then require that all implementers of the delegate implement that interface
(the <implementsEntity>)
through the use of the delegate requires
attribute. This delegate usage permits the use of polymorphism and enables
delegate implementations to share common implementations on a common
superclass.
