[Lazarus] WebDataProvider's Factory Support

Michael Van Canneyt michael at freepascal.org
Sun Oct 24 20:44:28 CEST 2010



On Sun, 24 Oct 2010, Leonardo M. Ramé wrote:

> I'm trying to understand how does factory support works for
> WebDataProvider.
>
> Is this feature useful when the programmer don't want to add too many
> WebDataProviders into the TFPWebProviderDataModule?.

yes.

>
> It is possible to define the WebDataProviders in their own unit (by
> code), then, in the TFPWebProviderDataModule register all providers with RegisterProvider,
> to let the module know about them?.

You can do this.

How we work at my job is: create N datamodules with WebDataProviders, 
and at program startup, register all the datamodules in the factory.

There is exactly 1 TFPWebProviderDataModule which has the option set 
to check the factory registry. It is registered with URL /Providers.

>
> If factory support's rationale is to avoid WebProviderDataModules full
> of WebDataProviders, why not just divide the app with many
> datamodules containing only some WebDataProviders?.

To have a single url. If you make many TFPWebProviderDataModules, they must all
be registered with their own URL. The factory system allows to have a single 
entry point.

All providers in my application are then accessible from
/Providers/ProviderName/Read
(and of course create/update/delete)

I created a Ext.data.Store descendent which has the URL and naming scheme
coded in so all I must do is
mystore = new WISA.ClientDataset ({
   ProviderName : 'MyData'
});
To access the data.

Michael.


More information about the Lazarus mailing list