Processor ExampleProcessorExample demonstrates how to use a processor to modify a set of data in the cache. In the code sample that follows, all Contacts who live in MA will have their work address updated. Java Processor Example
Apply the OfficeUpdater on all contacts who live in MA. The OfficeUpdater is a class that implements the InvocableMap.EntryProcessor interface by extending AbstractProcessor. cache.invokeAll(new EqualsFilter("getHomeAddress.getState", "MA"), new OfficeUpdater(addrWork)); .NET Processor Example
Apply the OfficeUpdater on all contacts who live in MA. The OfficeUpdater is a class that implements the IEntryProcessor interface by extending AbstractProcessor. cache.InvokeAll(new EqualsFilter("getHomeAddress.getState", "MA"), new OfficeUpdater(addrWork)); C++ Processor Example
The OfficeUpdater is a class that extends the UpdaterProcessor type. class OfficeUpdater : public class_spec<OfficeUpdater, extends<UpdaterProcessor>, implements<PortableObject> > Apply the OfficeUpdater on all contacts who live in MA. Filter::View vEqualsFilter = EqualsFilter::create( ChainedExtractor::create(ChainedExtractor::createExtractors( "getHomeAddress.getState")), String::create("MA")); InvocableMap::EntryProcessor::Handle hOffice = OfficeUpdater::create(addrWork); Map::View vMap = hCache->invokeAll(vEqualsFilter, hOffice); Example OutputThe example Output (due to Observer Example) is large due to the number of contacts. A sample of output: entry updated old value: John Keau Addresses Home: 443 Beacon St. Ophvowvw, MA 06539 US Work: Yoyodyne Propulsion Systems 330 Lectroid Rd. Grover's Mill, FL 86812 US Phone Numbers work: +11 8 919 9456102 home: +11 25 759 588823 Birth Date: 1968-12-31 new value: John Keau Addresses Home: 443 Beacon St. Ophvowvw, MA 06539 US Work: 200 Newbury St. Yoyodyne, Ltd. Boston, MA 02116 US Phone Numbers work: +11 8 919 9456102 home: +11 25 759 588823 entry updated old value: John Lbggblkd Addresses Home: 929 Beacon St. Trwylbmf, MA 50358 US Work: Yoyodyne Propulsion Systems 330 Lectroid Rd. Grover's Mill, AZ 19164 US Phone Numbers work: +11 60 699 203810 home: +11 34 149 5018157 Birth Date: 1964-01-02 new value: John Lbggblkd Addresses Home: 929 Beacon St. Trwylbmf, MA 50358 US Work: 200 Newbury St. Yoyodyne, Ltd. Boston, MA 02116 US Phone Numbers work: +11 60 699 203810 home: +11 34 149 5018157 Birth Date: 1964-01-02 Birth Date: 1968-12-31 |