@Documented @Target(value=METHOD) @Retention(value=RUNTIME) public @interface Sharable
Marker interface used to mark the setter methods of JavaBean
properties that are sharable. When a resource is
duplicated using Factory.duplicate(gate.Resource)
the values of any sharable properties from the original
resource will be copied by reference into the duplicate.
In particular, and sharable properties that are themselves
resources will not be recursively duplicated, even
if the properties are also marked as CreoleParameter
s.
The Sharable marker is typically used for cases where a resource creates at initialization time a data structure which it subsequently accesses in a read-only fashion. Duplicates of this resource can share a reference to the original's copy of this data structure rather than having to build their own identical copy.
The default Factory.duplicate(gate.Resource)
implementation sets sharable properties at the same time as
init parameters (i.e. after the constructor call but before
init() is called). So resources that make use of sharable
properties need to check in their init() methods whether
the sharable properties have been set, and only do the
necessary initialization logic if the property values are
null
.
Modifier and Type | Optional Element and Description |
---|---|
boolean |
value
Defaults to true but can be set to false to explicitly mark a property as
not sharable when a superclass has marked it as sharable.
|
Copyright © 2024 GATE. All rights reserved.