ThingWorx Edge Java SDK > Application Details > VirtualThing Component > Defining Properties > Using Aspects
  
Using Aspects
Aspects further define a property. They define what happens when the value of a property changes, what threshold generates a change event, and whether a property is persisted or and can be changed at the ThingWorx platform. Further, the cacheTime and pushType aspects define how The platform behaves when it needs to read the value of a property.
The following aspects are frequently used as part of a property definition. The aspect names are found in the file, com.thingworx.types.constants.Aspects. You can use them either in an annotation or in methods.
Here are definitions of the available aspects for properties:
dataChangeType — This field acts as the default value for the data change type field of the property when it is added to the remote thing on the ThingWorx platform. The data change type describes how the platform responds when the value in the remote thing on the server changes.
Subscriptions to these value changes can be created on the server. For details about implementing subscriptions, refer to the Help Center for the ThingWorx platform. For now, what you need to remember is that the setting you choose for the dataChangeType field affects what the platform does when the value of the property changes.
If nothing needs to react to the property change, it is recommended that this value be set to NEVER. The possible values are listed and briefly described here:
Value
Description
ALWAYS
Always notify subscribers that the value has changed, even if the same value comes in multiple times in a row.
VALUE
Notify subscribers only if the value changes.
ON
For BOOLEAN properties, notify subscribers only if the value is true..
OFF
For BOOLEAN properties, notify subscribers only if the value is false..
NEVER
The server should do nothing when the value of the property changes.
dataChangeThreshold — This field acts as the default value for the data change threshold field of the property when it is bound to the remote thing on the ThingWorx platform. It defines how much the value must change to trigger a change event. For example 0 (zero) indicates that any change triggers an event. A value of 10, for example, means that an update is not triggered unless the value changes by an amount greater than or equal to 10.
isPersistent — Set to true for the platform to persist the value even if the platform restarts. It is extremely expensive to have persistent values, so it is recommended to set this value to false unless persistence is absolutely necessary.
isReadOnly — Set to true to inform the platform that this value is only readable and cannot be written.
cacheTime — Tells the ThingWorx platform how to behave when reading a remote property. This parameter works in conjunction with the pushType aspect and can take the following values:
-1 — Indicates that the VirtualThing always sends its value. Use this value for properties that are configured to always be pushed to the platform. Set this parameter to -1 if the VirtualThing should set the value every time it changes.
0 — Indicates that every time that the platform needs the value, it should request it from the cache.
Any other positive value — Indicates that the platform should cache the value for that many seconds and then only after that time expires request it from the VirtualThing.
* 
Setting a cache time that is greater than 0 is important if you want to read the value from your edge devices, especially for properties that are accessed frequently by many users. Even a cache time of one second could eliminate duplicate traffic if more than one user is accessing the same value at the same time. For example, if 100 users attempt to access a property value within a 10 second period, you could set this value to 30 seconds. That setting would ensure that only a single request for the property is sent to the edge device every 30 seconds. However, the value returned by the platform could be out of date by up to 30 seconds.
pushType — Informs the platform how the VirtualThing pushes its values to it. This aspect works in conjunction with cacheTime. The possible values are as follows:
Push Type
Description
ALWAYS
The VirtualThing sends updates even if the value has not changed. It is common to use a cacheTime setting of 0 in this case, so that the platform always reads from the cache.
NEVER
The VirtualThing never sends the value. It is common to use a cacheTime setting that is greater than zero, so that the server requests the value from the device, but only if the cached value is older than the number of seconds that is specified for cacheTime.
VALUE
The VirtualThing sends updates only when the value changes. It is common to use a cacheTime setting of 0 in this case, so that the server always reads from the cache.
You could also use a value greater than 0 for cacheTime with a pushType of VALUE. Then, the platform would read the value from the cache, as long as the value is not too old. The device would keep the cache on the platform up to date with the latest change. That would allow dataChange events to fire on the platform, but also give users the latest value if they requested it.
These evaluations are performed whenever the updateSubscribedProperties() method of the VirtualThing is called to determine which properties to push to the platform.
defaultValue — The default value is the value that the platform uses when the remote thing that is bound to the VirtualThing first starts up and has not had an update from the VirtualThing. The value is different based on the type for each parameter.
isFolded — Determines how property values are stored and pushed to the platform. If a property uses isFolded, only the last value set is pushed to the platform when updateSubscribedProperties is called. If isFolded is FALSE, all property updates, along with a timestamp, are queued and sent to the platform. The default value is TRUE.
Aspects can also be set as part of an annotation. The section, Annotations, shows how.