Example: WorkArea SimpleSample application
In this example, the client creates a work area and inserts two properties into the work area: a site identifier and a priority. The site-identifier is set as a read-only property; the client does not allow recipients of the work area to override the site identifier. This property consists of the key company and a static instance of a SimpleSampleCompany object. The priority property consists of the key priority and a static instance of a SimpleSamplePriority object. The object types are defined as shown in the following code example
public static final class SimpleSampleCompany { public static final SimpleSampleCompany Main; public static final SimpleSampleCompany NewYork_Sales; public static final SimpleSampleCompany NewYork_Development; public static final SimpleSampleCompany London_Sales; public static final SimpleSampleCompany London_Development; } public static final class SimpleSamplePriority { public static final SimpleSamplePriority Platinum; public static final SimpleSamplePriority Gold; public static final SimpleSamplePriority Silver; public static final SimpleSamplePriority Bronze; public static final SimpleSamplePriority Tin; }The client then makes an invocation on a remote object. The work area is automatically propagated; none of the methods on the remote object take a work area argument. On the remote side, the request is first handled by the SimpleSampleBean; the bean first reads the site identifier and priority properties from the work area. The bean then intentionally attempts, and fails, both to write directly into the imported work area and to override the read-only site-identifier property.
The SimpleSampleBean successfully begins a nested work area, in which it overrides the client's priority, then calls another bean, the SimpleSampleBackendBean. The SimpleSampleBackendBean reads the properties from the work area, which contains the site identifier set in the client and priority set in the SimpleSampleBean. Finally, the SimpleSampleBean completes its nested work area, writes out a message based on the site-identifier property, and returns.
The implementation of this application is discussed in the topic, Developing applications that use work areas.